Advertisement
Guest User

Untitled

a guest
Jun 24th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. public class Application extends JFrame {
  2. private static final long serialVersionUID = 1L;
  3.  
  4. private static final String TITLE = "Average Machine - 'Iyyel'";
  5.  
  6. private static final int WIDTH = 900;
  7. private static final int HEIGHT = 550;
  8.  
  9. private JPanel contentPane;
  10. private JTextArea txtrInput, txtrOutput;
  11. private JButton btnAdd, btnAvg, btnClear;
  12. private JScrollPane scrollOut, scrollIn;
  13.  
  14. public Application() {
  15. initComponents();
  16. initLayout();
  17. }
  18.  
  19. private void initComponents() {
  20. getContentPane().setBackground(Color.black);
  21. setSize(WIDTH, HEIGHT);
  22. contentPane = new JPanel();
  23. contentPane.setBorder(new EmptyBorder(0, 0, 0, 0));
  24.  
  25. setContentPane(contentPane);
  26. GridBagLayout gbl_contentPane = new GridBagLayout();
  27. gbl_contentPane.columnWidths = new int[] { 700, 0, 20, 20, 20 };
  28. gbl_contentPane.rowHeights = new int[] { 280, 270, };
  29. gbl_contentPane.columnWeights = new double[] { 1.0, 0.0, 0.0, 1.0, Double.MIN_VALUE };
  30. gbl_contentPane.rowWeights = new double[] { 1.0, Double.MIN_VALUE };
  31. contentPane.setLayout(gbl_contentPane);
  32.  
  33. txtrInput = new JTextArea();
  34. GridBagConstraints gbc_txtrConsole = new GridBagConstraints();
  35. gbc_txtrConsole.insets = new Insets(0, 0, 0, 0);
  36. gbc_txtrConsole.fill = GridBagConstraints.BOTH;
  37. gbc_txtrConsole.gridx = 0;
  38. gbc_txtrConsole.gridy = 0;
  39. txtrInput.setBorder(BorderFactory.createTitledBorder("Input"));
  40. contentPane.add(txtrInput, gbc_txtrConsole);
  41.  
  42. /*
  43. * This makes the Input text area disappear.
  44. *
  45. * scrollIn = new JScrollPane(txtrInput);
  46. * getContentPane().add(scrollIn);
  47. */
  48.  
  49. txtrOutput = new JTextArea();
  50. txtrOutput.setEditable(false);
  51. GridBagConstraints gbc_txtrOutput = new GridBagConstraints();
  52. gbc_txtrOutput.insets = new Insets(0, 0, 0, 0);
  53. gbc_txtrOutput.fill = GridBagConstraints.BOTH;
  54. gbc_txtrOutput.gridx = 0;
  55. gbc_txtrOutput.gridy = 1;
  56. txtrOutput.setBorder(BorderFactory.createTitledBorder("Output"));
  57. contentPane.add(txtrOutput, gbc_txtrOutput);
  58.  
  59. btnAdd = new JButton("Add");
  60. GridBagConstraints gbc_btnAdd = new GridBagConstraints();
  61. gbc_btnAdd.insets = new Insets(0, 0, 0, 0);
  62. gbc_btnAdd.anchor = GridBagConstraints.SOUTH;
  63. gbc_btnAdd.gridx = 2;
  64. gbc_btnAdd.gridy = 1;
  65. contentPane.add(btnAdd, gbc_btnAdd);
  66.  
  67. btnAvg = new JButton("Average");
  68. GridBagConstraints gbc_btnAvg = new GridBagConstraints();
  69. gbc_btnAvg.insets = new Insets(0, 0, 0, 0);
  70. gbc_btnAvg.anchor = GridBagConstraints.SOUTH;
  71. gbc_btnAvg.gridx = 3;
  72. gbc_btnAvg.gridy = 1;
  73. contentPane.add(btnAvg, gbc_btnAvg);
  74.  
  75. btnClear = new JButton("Clear");
  76. GridBagConstraints gbc_btnClear = new GridBagConstraints();
  77. gbc_btnClear.insets = new Insets(0, 0, 0, 0);
  78. gbc_btnClear.anchor = GridBagConstraints.SOUTH;
  79. gbc_btnClear.gridx = 4;
  80. gbc_btnClear.gridy = 1;
  81. contentPane.add(btnClear, gbc_btnClear);
  82. }
  83.  
  84. private void initLayout() {
  85. setTitle(Application.TITLE);
  86. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  87. setResizable(false);
  88. setSize(WIDTH, HEIGHT);
  89. setLocationRelativeTo(null);
  90. setVisible(true);
  91. }
  92.  
  93. public static void main(String[] args) {
  94. try {
  95. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  96. new Application();
  97. } catch (Exception e) {
  98. e.printStackTrace();
  99. }
  100.  
  101. }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement