Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public PGM_1_3_Panel() {
- // Set BorderLayout for this panel
- setLayout(new BorderLayout());
- // Instantiate Dimensions of border layout areas
- Dimension north = new Dimension(110, 50);
- Dimension south = new Dimension(110, 50);
- Dimension east = new Dimension(50, 50);
- Dimension west = new Dimension(50, 50);
- Dimension center = new Dimension(150, 200);
- // north and south: 110 x 50; east and west: 50 x 50; center: 150, 200
- // Instantiate JLabels for north, south, east and west border areas
- JLabel JNorth = new JLabel("My Keypad");
- JLabel JSouth = new JLabel("Press Any Button...");
- JLabel JEast = new JLabel("");
- JLabel JWest = new JLabel("");
- // Add and center text to north and south JLabels
- JLabel text1 = new JLabel("My Keypad");
- JLabel text2 = new JLabel("Press Any Button...");
- JNorth.add(text1);
- JSouth.add(text2);
- // Set the preferred size of the north, south, east, and west JLabels
- JNorth.setPreferredSize(north);
- JSouth.setPreferredSize(south);
- JEast.setPreferredSize(east);
- JWest.setPreferredSize(west);
- // Instantiate and set north JLabel font to Lucida Console, bold, 20 point
- JNorth.setFont(new Font("Lucida Console", Font.BOLD, 20));
- // Instantiate and set south JLabel font to Lucida Console, bold, 12 point
- JSouth.setFont(new Font("Lucida Console", Font.BOLD, 12));
- // Instantiate the keypad JPanel and set the panel layout to a GridLayout of 4 rows by 3 columns
- JPanel keypad = new JPanel();
- keypad.setLayout(new GridLayout(4, 3));
- one = new KeypadButton("1");
- two = new KeypadButton("2");
- three = new KeypadButton("3");
- four = new KeypadButton("4");
- five = new KeypadButton("5");
- six = new KeypadButton("6");
- seven = new KeypadButton("7");
- eight = new KeypadButton("8");
- nine = new KeypadButton("9");
- zero = new KeypadButton("0");
- star = new KeypadButton("*");
- hash = new KeypadButton("#");
- // Add keypad JButtons to the keypad JPanel
- keypad.add(one);
- keypad.add(two);
- keypad.add(three);
- keypad.add(four);
- keypad.add(five);
- keypad.add(six);
- keypad.add(seven);
- keypad.add(eight);
- keypad.add(nine);
- keypad.add(star);
- keypad.add(zero);
- keypad.add(hash);
- add(keypad, BorderLayout.CENTER);
- add(JNorth, BorderLayout.NORTH);
- add(JSouth, BorderLayout.SOUTH);
- add(JWest, BorderLayout.WEST);
- add(JEast, BorderLayout.EAST);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement