Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I adjust Button size in Keyboard application?
    text
    copied!<p>I'm writing a java application for my class. It's a telephone keypad. I'm almost finished with it. I just have to get the numbers to show I just don't have a clue of how to change the size of the number buttons. Everything I've tried so far has resulted in ERRORS when compiling.</p> <pre><code>import java.awt.*; import java.applet.*; import java.awt.event.*; import java.awt.Graphics; import javax.swing.JOptionPane; import javax.swing.JApplet; import javax.swing.JFrame; import java.awt.event.*; public class TelephoneKeypad extends javax.swing.JFrame { public TelephoneKeypad() { Panel pnlKeyPad = new Panel(); GridLayout gridLayout1 = new GridLayout(); Button btnZero = new Button(); Button btnOne = new Button(); Button btnTwo = new Button(); Button btnThree = new Button(); Button btnFour = new Button(); Button btnFive = new Button(); Button btnSix = new Button(); Button btnSeven = new Button(); Button btnEight = new Button(); Button btnNine = new Button(); Button btnStar = new Button(); Button btnHash = new Button(); TextField tfNumber = new TextField(15); Button btnDial = new Button(); BorderLayout borderLayout1 = new BorderLayout(); Panel pnlNumberEntry = new Panel(); FlowLayout flowLayout1 = new FlowLayout(); btnOne.setLabel("1"); btnTwo.setLabel("2"); btnThree.setLabel("3"); btnFour.setLabel("4"); btnFive.setLabel("5"); btnSix.setLabel("6"); btnSeven.setLabel("7"); btnEight.setLabel("8"); btnNine.setLabel("9"); btnStar.setLabel("*"); btnZero.setLabel("0"); btnHash.setLabel("#"); btnDial.setLabel("Dial"); pnlNumberEntry.setLayout(flowLayout1); pnlKeyPad.setLayout(gridLayout1); this.setLayout(borderLayout1); this.add(pnlNumberEntry, BorderLayout.NORTH); pnlNumberEntry.add(tfNumber, null); pnlNumberEntry.add(btnDial, null); this.add(pnlKeyPad, BorderLayout.CENTER); pnlKeyPad.add(btnOne, null); pnlKeyPad.add(btnTwo, null); pnlKeyPad.add(btnThree, null); pnlKeyPad.add(btnFour, null); pnlKeyPad.add(btnFive, null); pnlKeyPad.add(btnSix, null); pnlKeyPad.add(btnSeven, null); pnlKeyPad.add(btnEight, null); pnlKeyPad.add(btnNine, null); pnlKeyPad.add(btnStar, null); pnlKeyPad.add(btnZero, null); pnlKeyPad.add(btnHash, null); } public static void main(String args[]) { TelephoneKeypad kpad = new TelephoneKeypad(); kpad.setBounds(500, 500, 500, 500); kpad.setVisible(true); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload