Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- public class gui {
- static void launchgui() {
- //Creating the Frame
- JFrame frame = new JFrame("SIM CREATE");
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setSize(600, 400);
- //GridLayout coolLayout = new GridLayout(1,2,1,1);
- //frame.setLayout(coolLayout);
- //Creating the MenuBar and adding components
- JMenuBar mb = new JMenuBar();
- JMenu m1 = new JMenu("FILE");
- JMenu m2 = new JMenu("Help");
- mb.add(m1);
- mb.add(m2);
- JMenuItem m11 = new JMenuItem("Open");
- JMenuItem m22 = new JMenuItem("Save as");
- m1.add(m11);
- m1.add(m22);
- //Creating the panel at bottom and adding components
- JPanel rightpanel = new JPanel(); // the panel is not visible in output
- JLabel label = new JLabel("Enter Text");
- JTextField tf = new JTextField(10); // accepts upto 10 characters
- JButton send = new JButton("Send");
- JButton reset = new JButton("Reset");
- //Right panel
- rightpanel.add(label); // Components Added using Flow Layout
- rightpanel.add(tf);
- rightpanel.add(send);
- rightpanel.add(reset);
- //Left Panel
- JPanel leftpanel = new JPanel();
- JLabel label2 = new JLabel("Timeline");
- JLabel updatelabel = new JLabel("empty");
- JTextArea ta = new JTextArea();
- Dimension size = updatelabel.getPreferredSize();
- updatelabel.setBounds(150, 100, size.width, size.height);
- leftpanel.add(label2);
- leftpanel.add(updatelabel);
- leftpanel.add(ta);
- leftpanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
- //Adding Components to the frame.
- frame.getContentPane().add(BorderLayout.WEST, leftpanel);
- //frame.getContentPane().add(BorderLayout.EAST, rightpanel);
- //frame.getContentPane().add(BorderLayout.SOUTH, mb);
- //frame.getContentPane().add(BorderLayout.CENTER, ta);
- frame.setVisible(true);
- //Update the information shown on updatelabel
- updatelabel.setText("data data data");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement