Advertisement
Sunnas

main

Mar 24th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.78 KB | None | 0 0
  1. package cz.sunnas.school.LS.hour05_swing;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Dimension;
  5. import java.awt.FlowLayout;
  6. import java.awt.GridLayout;
  7. import java.awt.event.ActionEvent;
  8. import java.awt.event.ActionListener;
  9. import javax.swing.JComponent;
  10. import javax.swing.JFrame;
  11. import javax.swing.JPanel;
  12. import javax.swing.KeyStroke;
  13.  
  14. public class NumericPanel extends JFrame{
  15.    
  16.     private final JPanel numbs;
  17.     private final JPanel display;
  18.    
  19.     public static void main( String[] args ) throws Exception {
  20.         NumericPanel numPan = new NumericPanel();
  21.     }
  22.    
  23.     public NumericPanel() {
  24.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  25.         setTitle("Numeric Panel");
  26.         setMinimumSize(new Dimension(250, 300));
  27.         setResizable(true);
  28.         setLocationRelativeTo(null);
  29.         setLayout(new BorderLayout());
  30.        
  31.         numbs = new JPanel(new GridLayout(4, 3, 25, 25));
  32.         display = new JPanel(new FlowLayout(FlowLayout.CENTER));
  33.         display.add(new Display(0, 50));
  34.        
  35.         numbs.add(new Button("0", 0, 60, 20));
  36.         numbs.add(new Button("1", 1, 60, 20));
  37.         numbs.add(new Button("2", 2, 60, 20));
  38.         numbs.add(new Button("3", 3, 60, 20));
  39.         numbs.add(new Button("4", 4, 60, 20));
  40.         numbs.add(new Button("5", 5, 60, 20));
  41.         numbs.add(new Button("6", 6, 60, 20));
  42.         numbs.add(new Button("7", 7, 60, 20));
  43.         numbs.add(new Button("8", 8, 60, 20));
  44.         numbs.add(new Button("9", 9, 60, 20));
  45.         numbs.add(new Button("E", 10, 60, 20));
  46.         numbs.add(new Button("C", 11, 60, 20));
  47.        
  48.        
  49.         add(display, BorderLayout.NORTH);
  50.         add(numbs, BorderLayout.CENTER);
  51.        
  52.         setVisible(true);
  53.         pack();
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement