/** * Init JWhiteBoard interface * * @throws Exception */ public void go() throws Exception { if (!noChannel && !useState) channel.connect(groupName); mainFrame = new JFrame(); mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); drawPanel = new DrawPanel(useState); drawPanel.setBackground(backgroundColor); subPanel = new JPanel(); mainFrame.getContentPane().add("Center", drawPanel); clearButton = new JButton("Clean"); clearButton.setFont(defaultFont); clearButton.addActionListener(this); leaveButton = new JButton("Exit"); leaveButton.setFont(defaultFont); leaveButton.addActionListener(this); subPanel.add("South", clearButton); subPanel.add("South", leaveButton); mainFrame.getContentPane().add("South", subPanel); mainFrame.setBackground(backgroundColor); clearButton.setForeground(Color.blue); leaveButton.setForeground(Color.blue); mainFrame.pack(); mainFrame.setLocation(15, 25); mainFrame.setBounds(new Rectangle(250, 250)); if (!noChannel && useState) { channel.connect(groupName, null, stateTimeout); } mainFrame.setVisible(true); }
/** Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.setBounds(100, 100, 450, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame .getContentPane() .setLayout( new FormLayout( new ColumnSpec[] { FormFactory.LABEL_COMPONENT_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.LINE_GAP_ROWSPEC, })); JPanel panel = new JPanel(); frame.getContentPane().add(panel, "2, 2, fill, fill"); openDialog = new FileDialog(this, "Open File", FileDialog.LOAD); JButton btnCharger = new JButton("Charger une partie"); btnCharger.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { openDialog.setVisible(true); try { String dir = openDialog.getDirectory() + openDialog.getFile(); Utilitaire.writeln(dir, textArea); jeu = new Kakuro(frame, dir); jeu.setVisible(true); } catch (NullPointerException point) { } } }); panel.add(btnCharger); JButton btnNvlPartie = new JButton("Nouvelle Partie"); panel.add(btnNvlPartie); btnNvlPartie.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { Random list = new Random(); int seed = list.nextInt(); new Utilitaire(Utilitaire.x, Utilitaire.y, seed); jeu = new Kakuro(frame); jeu.setVisible(true); } }); textArea = new JTextArea(); JScrollPane scrollPane = new JScrollPane(textArea); frame.getContentPane().add(scrollPane, "2, 4, fill, fill"); }
public TabSpawnable spawn() { JFrame f = new JFrame(); f.getContentPane().setLayout(new BorderLayout()); f.setTitle(_title); TabSpawnable newPanel = (TabSpawnable) clone(); if (newPanel == null) return null; // failed to clone newPanel.setTitle(_title); if (newPanel instanceof TabToDoTarget) { TabToDoTarget me = (TabToDoTarget) this; TabToDoTarget it = (TabToDoTarget) newPanel; it.setTarget(me.getTarget()); } else if (newPanel instanceof TabModelTarget) { TabModelTarget me = (TabModelTarget) this; TabModelTarget it = (TabModelTarget) newPanel; it.setTarget(me.getTarget()); } f.getContentPane().add(newPanel, BorderLayout.CENTER); Rectangle bounds = getBounds(); bounds.height += OVERLAPP * 2; f.setBounds(bounds); Point loc = new Point(0, 0); SwingUtilities.convertPointToScreen(loc, this); loc.y -= OVERLAPP; f.setLocation(loc); f.setVisible(true); if (_tear && (getParent() instanceof JTabbedPane)) ((JTabbedPane) getParent()).remove(this); return newPanel; }
private void setLayout() { GroupLayout layout = new GroupLayout(dialog.getContentPane()); dialog.getContentPane().setLayout(layout); dialog.setResizable(true); layout.setAutoCreateContainerGaps(true); layout.setHorizontalGroup(layout.createParallelGroup().addComponent(tabbedPane)); layout.setVerticalGroup(layout.createParallelGroup().addComponent(tabbedPane)); layout.setHonorsVisibility(tabbedPane, true); // TODO set color here dialog.getContentPane().setBackground(new Color(0x132638)); dialog.validate(); dialog.repaint(); }
/** Create the entire GUI from scratch */ private void createGUI() { clientFrame = new JFrame("LeetFTP"); // Allow program to exit gracefully clientFrame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); createTabs(); createMenu(); // Top Options Bar connectButton = new JButton("Connect"); connectButton.addMouseListener(mouseHandler); optionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); optionPanel.add(connectButton); optionPanel.add(new JLabel("Name Server Hostname")); optionPanel.add(serverTextField); optionPanel.add(new JLabel("Port #")); optionPanel.add(portTextField); optionPanel.add(new JLabel("UserName")); optionPanel.add(nameTextField); // Bottom Transfer Table transferTable = new JTable(); transferPanel = new JPanel(new BorderLayout()); transferPanel.add(new JLabel("Current Transfers:"), BorderLayout.NORTH); transferPanel.add(transferTable); // Make the tab pane the GUI pane clientFrame.getContentPane().setLayout(new BorderLayout()); clientFrame.getContentPane().add(mainPanel); clientFrame.getContentPane().add(optionPanel, BorderLayout.NORTH); clientFrame.getContentPane().add(transferPanel, BorderLayout.SOUTH); // Set Client Window Properties clientFrame.setSize(800, 600); // clientFrame.setResizable(false); clientFrame.setLocationRelativeTo(null); clientFrame.setVisible(true); }
public static void main(String[] args) { final JPopupMenu menu = new JPopupMenu(); menu.setLayout(new GridLayout(0, 3, 5, 5)); final MenuedButton button = new MenuedButton("Icons", menu); for (int i = 0; i < 9; i++) { // replace "print.gif" with your own image final JLabel label = new JLabel("" + i); // new ImageIcon("resources/images/print.gif") ); label.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { button.getMainButton().setIcon(label.getIcon()); menu.setVisible(false); } }); menu.add(label); } JFrame frame = new JFrame("Button Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new JLabel("Click Arrow Button To Show Popup"), BorderLayout.NORTH); frame.getContentPane().add(button, BorderLayout.CENTER); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
public static void main(String[] args) { ArrayList<Pattern> patterns = new ArrayList<Pattern>(); ArrayList<Cut> cuts; ArrayList<Garment> garments; patterns.add(new Pattern(2, 2, 1, "Tie")); patterns.add(new Pattern(2, 6, 4, "Skirt")); patterns.add(new Pattern(4, 2, 3, "Blouse")); patterns.add(new Pattern(5, 3, 5, "Dress")); int width = 30; int height = 15; ClothCutter cutter = new ClothCutter(width, height, patterns); System.out.println("Optimized value: " + cutter.optimize()); cuts = cutter.getCuts(); garments = cutter.getGarments(); ClothPanel panel = new ClothPanel(width, height); JFrame frame = new JFrame("A luxurious bolt of fabric"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(panel); frame.pack(); frame.setVisible(true); sleep(1000); for (int i = 0; i < cuts.size(); i++) { panel.drawCut(cuts.get(i)); sleep(100); } for (int i = 0; i < garments.size(); i++) { System.out.println(garments.get(i)); panel.drawGarment(garments.get(i)); sleep(100); } }
private void initGUI() { JPanel pCommand = new JPanel(); pResult = new JPanel(); nsSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pCommand, pResult); pCommand.setLayout(new BorderLayout()); pResult.setLayout(new BorderLayout()); Font fFont = new Font("Dialog", Font.PLAIN, 12); txtCommand = new JTextArea(5, 40); txtCommand.setMargin(new Insets(5, 5, 5, 5)); txtCommand.addKeyListener(this); txtCommandScroll = new JScrollPane(txtCommand); txtResult = new JTextArea(20, 40); txtResult.setMargin(new Insets(5, 5, 5, 5)); txtResultScroll = new JScrollPane(txtResult); txtCommand.setFont(fFont); txtResult.setFont(new Font("Courier", Font.PLAIN, 12)); /* // button replaced by toolbar butExecute = new JButton("Execute"); butExecute.addActionListener(this); pCommand.add(butExecute, BorderLayout.EAST); */ pCommand.add(txtCommandScroll, BorderLayout.CENTER); gResult = new GridSwing(); gResultTable = new JTable(gResult); gScrollPane = new JScrollPane(gResultTable); // getContentPane().setLayout(new BorderLayout()); pResult.add(gScrollPane, BorderLayout.CENTER); // Set up the tree rootNode = new DefaultMutableTreeNode("Connection"); treeModel = new DefaultTreeModel(rootNode); tTree = new JTree(treeModel); tScrollPane = new JScrollPane(tTree); tScrollPane.setPreferredSize(new Dimension(120, 400)); tScrollPane.setMinimumSize(new Dimension(70, 100)); txtCommandScroll.setPreferredSize(new Dimension(360, 100)); txtCommandScroll.setMinimumSize(new Dimension(180, 100)); gScrollPane.setPreferredSize(new Dimension(460, 300)); ewSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tScrollPane, nsSplitPane); fMain.getContentPane().add(ewSplitPane, BorderLayout.CENTER); doLayout(); fMain.pack(); }
public void create() { JFrame frame = new JFrame(); frame.getContentPane().add(new JScrollPane(jgraph)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
/** Simple test program. */ public static void main(String[] args) { final JFrame frame = new JFrame("Testing AddPersonDialog"); JButton button = new JButton("Click me"); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { FamilyTree tree = new FamilyTree(); AddPersonDialog dialog = new AddPersonDialog(frame, tree); dialog.pack(); dialog.setLocationRelativeTo(frame); dialog.setVisible(true); Person newPerson = dialog.getPerson(); if (newPerson != null) { tree.addPerson(newPerson); PrettyPrinter pretty = new PrettyPrinter(new PrintWriter(System.out, true)); pretty.dump(tree); } } }); frame.getContentPane().add(button); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(1); } }); frame.pack(); frame.setVisible(true); }
public void launchTrajectoryRenderer() { Visualizer tv = this.getTrajectoryRenderLayerBase(); List<EpisodeAnalysis> trajectories = EpisodeAnalysis.parseFilesIntoEAList(this.expertDir, this.domain, this.sp); TrajectoryRenderer tr = new TrajectoryRenderer( trajectories, GridWorldDomain.CLASSAGENT, GridWorldDomain.ATTX, GridWorldDomain.ATTY, new double[] {0, 30, .5}, new double[] {0, 30, .5}, 3.f, 10.f); tv.addRenderLayer(tr); tv.updateState(trajectories.get(0).getState(0)); JFrame frame = new JFrame(); frame.setPreferredSize(new Dimension(800, 800)); frame.getContentPane().add(tv); frame.pack(); frame.setVisible(true); }
private void registerDisposeListeners() { dialog.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { disposeFrame(); } }); // handle window closing commands for ctrl/cmd-W or hitting ESC. Toolkit.registerWindowCloseKeys( dialog.getRootPane(), new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { disposeFrame(); } }); dialog .getContentPane() .addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent e) { // System.out.println(e); KeyStroke wc = Toolkit.WINDOW_CLOSE_KEYSTROKE; if ((e.getKeyCode() == KeyEvent.VK_ESCAPE) || (KeyStroke.getKeyStrokeForEvent(e).equals(wc))) { disposeFrame(); } } }); }
public static void main(String[] args) { Chart shc = new Chart("C:/TEMP/table.csv"); JFrame frame = new JFrame("Stock History Chart for " + shc.getSymbol()); frame.getContentPane().add(shc, BorderLayout.CENTER); frame.setSize(640, 480); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
public static void main(String[] argv) throws NoSuchMethodException { f = new JFrame(); Container c = f.getContentPane(); c.setLayout(new BorderLayout()); c.add(new WordListScreen(null), BorderLayout.CENTER); f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); showFrame(true); }
/** * Create the GUI and show it. For thread safety, this method should be invoked from the * event-dispatching thread. */ private static void createAndShowGUI() { // Create and set up the window. JFrame frame = new JFrame("SplitPaneDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SplitPaneDemo splitPaneDemo = new SplitPaneDemo(); frame.getContentPane().add(splitPaneDemo.getSplitPane()); // Display the window. frame.pack(); frame.setVisible(true); }
// creates a frame with a new TreeDisplay component. // (constructor returns the TreeDisplay component--not the frame). public TreeDisplay() { // create surrounding frame JFrame frame = new JFrame("Tree Display"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // add the TreeDisplay component to the frame frame.getContentPane().add(this); // show frame frame.pack(); frame.setVisible(true); }
public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException { JFrame jf = new JFrame(); AttributesPanel colpal = new AttributesPanel(); colpal.setEntity(new FrameFact("hola")); colpal.setEntity(new FrameFact("hola")); jf.getContentPane().add(colpal); jf.pack(); jf.show(); jf.pack(); }
public static void main(String[] args) throws Exception { JFrame f = new JFrame(); CalModel cm = new CalModel(TimeZone.getDefault(), true); JCalendar jc = new JCalendarDateHHMM(); jc.setModel(cm); f.getContentPane().add((javax.swing.JPanel) jc); f.setSize(400, 400); f.pack(); f.setVisible(true); }
public static void main(String s[]) { // Getting save directory String saveDir; if (s.length > 0) { saveDir = s[0]; } else { saveDir = JOptionPane.showInputDialog( null, "Please enter directory where " + "the images is/will be saved\n\n" + "Also possible to specifiy as argument 1 when " + "running this program.", "l:\\webcamtest"); } String layout = ""; if (s.length > 1) { layout = s[1]; } // Move mouse to the point 5000,5000 px (out of the screen) Robot rob; try { rob = new Robot(); rob.setAutoDelay(500); // 0,5 s rob.mouseMove(5000, 5000); } catch (AWTException e) { e.printStackTrace(); } // Make the main window JFrame frame = new JFrame(); frame.setAlwaysOnTop(true); frame.setTitle( "Webcam capture and imagefading - " + "Vitenfabrikken Jærmuseet - " + "made by Hallvard Nygård - " + "Vitenfabrikken.no / Jaermuseet.no"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setUndecorated(true); WebcamCaptureAndFadePanel panel = new WebcamCaptureAndFadePanel(saveDir, layout); frame.getContentPane().add(panel); frame.addKeyListener(panel); frame.pack(); frame.setVisible(true); }
public static void createAndShowGUI() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } JFrame frame = new JFrame("@title@"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().add(new MainPanel()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
public static void main(String args[]) { if (args.length != 1) { System.out.println("Need the name of a cff font."); System.exit(0); } JFrame jf = new JFrame("Font test: " + args[0]); try { FileInputStream fis = new FileInputStream(args[0]); TestType1CFont panel = new TestType1CFont(fis); jf.getContentPane().add(panel); jf.pack(); jf.setVisible(true); panel.requestFocus(); } catch (IOException ioe) { } }
public static void main(String[] args) { PropertyTableModel model = new PropertyTableModel(System.getProperties()); JTable table = new JTable(); table.setModel(model); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane spane = new JScrollPane(table); JFrame frame = new JFrame("System Properties"); frame.getContentPane().add(spane); frame.pack(); frame.setVisible(true); frame.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); }; }); }
public static void main(String s[]) { if (s.length > 0) j2kfilename = s[0]; else j2kfilename = "girl"; System.out.println(j2kfilename); isApplet = false; JFrame f = new JFrame("ImageViewer"); f.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); JApplet applet = new ImageViewer(); f.getContentPane().add("Center", applet); applet.init(); f.pack(); f.setSize(new Dimension(550, 550)); f.show(); }
JFrame openMonitorGUI(String title) { try { MonitorGUI gui = new MonitorGUI(this, title); JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.addWindowListener(this); frame.getContentPane().add(gui); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle r = ge.getMaximumWindowBounds(); frame.setSize(400, 200); frame.setLocationRelativeTo(null); frame.pack(); frame.setVisible(true); return frame; } catch (Exception e) { System.out.println("9\b" + getClass().getName() + "\n\t" + e); return null; } }
private void myDoubleClick(int row, TreePath path) { if (path != null) { JFrame infoFrame = new JFrame("Object Info for: " + path); JLabel objectLabel; JLabel parentPathLabel; // Display Selected Object Name; objectLabel = new JLabel("Object: " + path.getLastPathComponent().toString()); objectLabel.setHorizontalAlignment(SwingConstants.CENTER); // Display specific object information parentPathLabel = new JLabel("Parent Path: " + path.getParentPath()); parentPathLabel.setHorizontalAlignment(SwingConstants.CENTER); // Construct infoFrame infoFrame.getContentPane().add(objectLabel, BorderLayout.CENTER); infoFrame.getContentPane().add(parentPathLabel, BorderLayout.SOUTH); infoFrame.pack(); infoFrame.setVisible(true); } }
public static void main(String[] args) { String propFileName = null; if (args.length > 0) { propFileName = args[0]; } OneBlockOperation application = new OneBlockOperation(propFileName); JFrame frame = new JFrame(); frame.setTitle(application.getClass().getName()); frame.getContentPane().add(application, BorderLayout.CENTER); application.init(); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); frame.setBounds(50, 50, 400, 150); frame.setVisible(true); }
/** * @param filenames * @exception Exception if internal error */ public ChestImageViewer(String filenames[]) throws Exception { DisplayDeviceArea[] displayDeviceAreas = getPresentationAndImageDeviceAreas(); if (displayDeviceAreas == null) { System.err.println("Cannot determine device display areas"); } else { System.err.println("Found " + displayDeviceAreas.length + " device display areas"); for (int i = 0; i < displayDeviceAreas.length; ++i) { System.err.println("[" + i + "] = " + displayDeviceAreas[i]); displayDeviceAreas[i].getFrame().setBackground(Color.black); displayDeviceAreas[i].getFrame().setVisible(true); } { // Need to actually add something to the unused left display frame, else background will not // be set to black on Windows JPanel backgroundPanel = new JPanel(); backgroundPanel.setBackground(Color.black); displayDeviceAreas[0].getFrame().getContentPane().add(backgroundPanel); displayDeviceAreas[0].getFrame().validate(); } frame = displayDeviceAreas[1].getFrame(); Container content = frame.getContentPane(); content.setLayout(new GridLayout(1, 1)); multiPanel = new JPanel(); // multiPanel.setBackground(Color.black); frameWidth = (int) frame.getWidth(); frameHeight = (int) frame.getHeight(); Dimension d = new Dimension(frameWidth, frameHeight); // multiPanel.setSize(d); multiPanel.setPreferredSize(d); multiPanel.setBackground(Color.black); content.add(multiPanel); // frame.pack(); content.validate(); loadMultiPanelFromSpecifiedFiles(filenames); } }
public static void main(String[] args) { JFrame fr = new JFrame("belajar combo box"); JPanel panel = new JPanel(); JComboBox combo = new JComboBox(); List<String> mahasiswa = new ArratList<String>(); mahasiswa.add("sidratul"); JLabel lnama = new JLabel("Nama"); panel.add(lnama); combo.addItem("tidur"); combo.addItem("makan"); combo.addItem("belajar"); panel.add(combo); fr.getContentPane().add(panel); fr.setVisible(true); fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fr.setSize(500, 400); fr.setLocationRelativeTo(null); }
public void go() { frame = new JFrame("Quiz Card Player"); JPanel mainPanel = new JPanel(); Font bigFont = new Font("sanserif", Font.BOLD, 24); display = new JTextArea(10, 20); display.setFont(bigFont); display.setLineWrap(true); display.setEditable(false); JScrollPane qScroller = new JScrollPane(display); qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); nextButton = new JButton("Show Questions"); nextButton.addActionListener(new NextCardListener()); mainPanel.add(qScroller); mainPanel.add(nextButton); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem loadMenuItem = new JMenuItem("Load Card Set"); loadMenuItem.addActionListener(new OpenMenuListener()); fileMenu.add(loadMenuItem); menuBar.add(fileMenu); frame.setJMenuBar(menuBar); frame.getContentPane().add(BorderLayout.CENTER, mainPanel); frame.setSize(640, 500); frame.setVisible(true); }
public void go() { // build gui frame = new JFrame("Quiz Card Buider"); JPanel mainPanel = new JPanel(); Font bigFont = new Font("sanserif", Font.BOLD, 24); question = new JTextArea(6, 20); question.setLineWrap(true); question.setWrapStyleWord(true); question.setFont(bigFont); JScrollPane qScroller = new JScrollPane(question); qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); answer = new JTextArea(6, 20); answer.setLineWrap(true); answer.setWrapStyleWord(true); answer.setFont(bigFont); JScrollPane aScroller = new JScrollPane(question); aScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); aScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); JButton nextButton = new JButton("Next Card"); cardList = new ArrayList<QuizCard>(); JLabel qLabel = new JLabel("Question"); JLabel aLabel = new JLabel("Answer"); mainPanel.add(qLabel); mainPanel.add(qScroller); mainPanel.add(aLabel); mainPanel.add(aScroller); mainPanel.add(nextButton); nextButton.addActionListener(new NextCardListener()); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem newMenuItem = new JMenuItem("New"); JMenuItem saveMenuItem = new JMenuItem("Save"); newMenuItem.addActionListener(new NewMenuListener()); saveMenuItem.addActionListener(new SaveMenuListener()); fileMenu.add(newMenuItem); fileMenu.add(saveMenuItem); menuBar.add(fileMenu); frame.setJMenuBar(menuBar); frame.getContentPane().add(BorderLayout.CENTER, mainPanel); frame.setSize(500, 600); frame.setVisible(true); // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }