Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.*;
  3.  
  4. public class gui {
  5. static void launchgui() {
  6. //Creating the Frame
  7. JFrame frame = new JFrame("SIM CREATE");
  8. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  9. frame.setSize(600, 400);
  10. //GridLayout coolLayout = new GridLayout(1,2,1,1);
  11. //frame.setLayout(coolLayout);
  12.  
  13. //Creating the MenuBar and adding components
  14. JMenuBar mb = new JMenuBar();
  15. JMenu m1 = new JMenu("FILE");
  16. JMenu m2 = new JMenu("Help");
  17. mb.add(m1);
  18. mb.add(m2);
  19. JMenuItem m11 = new JMenuItem("Open");
  20. JMenuItem m22 = new JMenuItem("Save as");
  21. m1.add(m11);
  22. m1.add(m22);
  23.  
  24. //Creating the panel at bottom and adding components
  25. JPanel rightpanel = new JPanel(); // the panel is not visible in output
  26. JLabel label = new JLabel("Enter Text");
  27. JTextField tf = new JTextField(10); // accepts upto 10 characters
  28. JButton send = new JButton("Send");
  29. JButton reset = new JButton("Reset");
  30.  
  31.  
  32.  
  33. //Right panel
  34. rightpanel.add(label); // Components Added using Flow Layout
  35. rightpanel.add(tf);
  36. rightpanel.add(send);
  37. rightpanel.add(reset);
  38.  
  39.  
  40. //Left Panel
  41. JPanel leftpanel = new JPanel();
  42. JLabel label2 = new JLabel("Timeline");
  43. JLabel updatelabel = new JLabel("empty");
  44. JTextArea ta = new JTextArea();
  45.  
  46. Dimension size = updatelabel.getPreferredSize();
  47. updatelabel.setBounds(150, 100, size.width, size.height);
  48.  
  49. leftpanel.add(label2);
  50. leftpanel.add(updatelabel);
  51. leftpanel.add(ta);
  52. leftpanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  53.  
  54.  
  55.  
  56.  
  57. //Adding Components to the frame.
  58. frame.getContentPane().add(BorderLayout.WEST, leftpanel);
  59. //frame.getContentPane().add(BorderLayout.EAST, rightpanel);
  60. //frame.getContentPane().add(BorderLayout.SOUTH, mb);
  61. //frame.getContentPane().add(BorderLayout.CENTER, ta);
  62. frame.setVisible(true);
  63.  
  64. //Update the information shown on updatelabel
  65. updatelabel.setText("data data data");
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement