-
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???
Similar Threads
-
By dave.potter@hol in forum .NET
Replies: 2
Last Post: 01-30-2006, 11:54 AM
-
By dave.potter@hol in forum ASP.NET
Replies: 0
Last Post: 10-07-2005, 06:10 PM
-
By jobartley515 in forum VB Classic
Replies: 2
Last Post: 10-03-2005, 12:01 AM
-
By spudmasher in forum ASP.NET
Replies: 3
Last Post: 07-03-2005, 11:59 PM
-
By Daniel Noack in forum VB Classic
Replies: 3
Last Post: 02-22-2002, 12:24 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks