Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Dimension;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.KeyEvent;
- import java.io.FileNotFoundException;
- import javax.swing.*;
- public class JavaAssignmentPanel {
- public static JMenuBar setupMenu() { // method modifiers where mising here
- JMenuBar menuBar = new JMenuBar(); // menubar
- JMenu menu1 = new JMenu("Menu"); // menu
- menuBar.add(menu1); // add menu to gui
- JMenuItem menuItem1 = new JMenuItem("Item 1", KeyEvent.VK_1); // create
- // drop
- // down
- // menu
- menu1.add(menuItem1); // adds drop down menu to gui
- // execute code when selected
- menuItem1.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- // panel.showText("Example1 text - normally read from file");
- }
- });
- return menuBar;
- }
- public static void main(String[] args) throws FileNotFoundException {
- window window = new window();
- }
- private static class window extends JFrame {
- public window() throws FileNotFoundException {
- JPanel leftScrollPane = new JPanel();
- JPanel rightPane = new JPanel();
- JSplitPane splitPane;
- this.setVisible(true);
- this.setSize(400, 400);
- this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- splitPane = new JSplitPane();
- splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
- splitPane.setDividerSize(10);
- splitPane.setDividerLocation(100);
- splitPane.setLeftComponent(leftScrollPane);
- splitPane.setRightComponent(rightPane);
- splitPane.setOneTouchExpandable(true);
- splitPane.setDividerLocation(200);
- Dimension minimumSize = new Dimension(100, 50);
- leftScrollPane.setSize(400, 400);
- this.setJMenuBar(setupMenu());
- splitPane.setPreferredSize(new Dimension(400, 200));
- splitPane.setLeftComponent(leftScrollPane);
- splitPane.setRightComponent(rightPane);
- this.add(splitPane);
- this.setSize(1280, 720);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement