Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Resizing buttons

I'm having real issues getting some buttons to resize. the app is to be on touch screen, so they need to be big enough to be prodded with fat fingers...

//The constructor...
public TotalDialog(float total) {
topPanel = new JPanel();
topPanel.setLayout(new BoxLayout(topPanel,BoxLayout.Y_AXIS));
bottomPanel = new JPanel(new GridLayout(1,4));
ftotal = total;
addWidgets();
mainPanel = new JPanel();
mainPanel.add(topPanel);
topPanel.add(bottomPanel);
System.out.print("Total: "+total+"\n");
JDialog.setDefaultLookAndFeelDecorated(true);
JDialog tdFrame = new JDialog(ownerFrame,true);
tdFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
tdFrame.setContentPane(mainPanel);
tdFrame.setSize(400,300);
tdFrame.setVisible(true);
}

private void addWidgets() {
java.text.DecimalFormat formatter = new java.text.DecimalFormat("#.00");
JLabel lMessage = new JLabel("Please enter the amount tendered:");
lMessage.setAlignmentX(Component.CENTER_ALIGNMENT);
lMessage.setFont(lMessage.getFont().deriveFont(Font.BOLD, 18));
topPanel.add(lMessage);
JLabel lOwing = new JLabel(""+formatter.format(ftotal)+" Owing");
lOwing.setAlignmentX(Component.CENTER_ALIGNMENT);
topPanel.add(lOwing);
lOwing.setFont(lOwing.getFont().deriveFont(Font.BOLD, 18));
JTextArea tInput = new JTextArea(formatter.format(ftotal));
Font myFont = new Font(tInput.getFont().getFontName(),tInput.getFont().getStyle(),tInput.getFont().getSize() );
myFont = myFont.deriveFont((float)72);
tInput.setFont(myFont);
topPanel.add(tInput);
JButton bCash = new JButton("Cash");
JButton bCard = new JButton("Card");
JButton bCheque = new JButton("Cheque");
JButton bVoucher = new JButton("Voucher");
bCash.setSize(200,200);
bCard.setSize(100,100);
bCheque.setSize(100,100);
bVoucher.setSize(100,100);
bottomPanel.add(bCash);
bottomPanel.add(bCard);
bottomPanel.add(bCheque);
bottomPanel.add(bVoucher);
}

So, bCash JButton should be twice the h & w as the rest, but it's not. What's going on?
[2280 byte] By [ohowson] at [2007-11-11 8:04:04]