I created a simple menu in Java, but I can't figure out how to change the size of a button. My menu looks like this:
I want the last button to have same size like other buttons.
tlacTisk.setSize(10,10);
tlacTisk.setPreferredSize(10,10);
doesn't work.
Code, where I created buttons and box:
JButton tlacSVG = new JButton();
tlacSVG.setText("Export do SVG");
tlacSVG.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
exportujSVG();
}
});
JButton tlacPNG = new JButton();
tlacPNG.setText("Export do PNG");
tlacPNG.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
exportujPNG();
}
});
JButton tlacTisk = new JButton();
tlacTisk.setText("Tisk...");
tlacTisk.setPreferredSize(new Dimension(50, 25));
tlacTisk.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
tiskni();
}
});
Box boxTlacitek = Box.createVerticalBox();
boxTlacitek.add(Box.createVerticalStrut(5));
boxTlacitek.add(tlacSVG);
boxTlacitek.add(Box.createVerticalStrut(10));
boxTlacitek.add(tlacPNG);
boxTlacitek.add(Box.createVerticalStrut(10));
boxTlacitek.add(tlacTisk);
boxTlacitek.setBorder(BorderFactory.createTitledBorder("Menu"));
okno.add(boxTlacitek, BorderLayout.EAST);
Can you give me advice how I can change size? Thanks.