JFrame not working correctly

Posted by Nick Gibson on Stack Overflow See other posts from Stack Overflow or by Nick Gibson
Published on 2010-06-17T13:55:35Z Indexed on 2010/06/18 6:13 UTC
Read the original article Hit count: 360

Filed under:
|
|
|
|

This is making me very angry, I have worked on this for 2 days, have 2 books open and have looked through them, and STILL can't get this program to run the way I want it run. I'm getting to the point where if this doesn't help, I quit.

I want a SIMPLE Frame application. It has a JComboBox centered at the top. Next to it is a text field big enough to show numeric digits such as "$49.99" Below it is a spot for a Text area showing terms of service Below that is the checkbox agreeing to the terms of service Below that is 2 buttons "Accept" and "Decline"

I Have worked on this for 2 days, here is the coding:

public class Bar extends JFrame implements ActionListener
{
    public Bar(final JFrame frame)
    {
        String[] tests = { "A+ Certification", "Network+ Certification", "Security+ Certification", "CIT Full Test Package" };
        JButton button = new JButton("Click Meh");
        add(new JLabel("Welcome to the CIT Test Program "));
        add(new JLabel("Please select which Test Package from the list below."));
        frame.setVisible(true);
        frame.setSize(250,250);
        JPanel pane1 = new JPanel(new FlowLayout());
        JPanel pane2 = new JPanel(new FlowLayout());

        JMenuBar menuBar = new JMenuBar();
        JMenu fileMenu = new JMenu("File");
        JMenu editMenu = new JMenu("Edit");
        JMenu helpMenu = new JMenu("Help");
        menuBar.add(fileMenu);
        menuBar.add(editMenu);
        menuBar.add(helpMenu);
        JMenuItem newMenu = new JMenuItem("New  (Ctrl+N)");
        JMenuItem openMenu = new JMenuItem("Open  (Ctrl+O)");
        JMenuItem saveMenu = new JMenuItem("Save  (Ctrl+S)");
        saveMenu.addActionListener(this);
        JMenuItem exitMenu = new JMenuItem("Exit  (Ctrl+W)");
        JMenuItem cutMenu = new JMenuItem("Cut  (Ctrl+X)");
        JMenuItem copyMenu = new JMenuItem("Copy  (Ctrl+C)");
        JMenuItem pasteMenu = new JMenuItem("Paste  (Ctrl+V)");
        JMenuItem infoMenu = new JMenuItem("Help  (Ctrl+H)");
        fileMenu.add(newMenu);
        fileMenu.add(openMenu);
        fileMenu.add(saveMenu);
        fileMenu.add(exitMenu);
        editMenu.add(cutMenu);
        editMenu.add(copyMenu);
        editMenu.add(pasteMenu);
        helpMenu.add(infoMenu);
        frame.setJMenuBar(menuBar);
        JComboBox packageChoice =  new JComboBox(tests);
        frame.add(packageChoice);


    }

     public void actionPerformed(ActionEvent e)
  {
  Object source = e.getSource();
  {
  }

}

EDIT: Forgot to add the second program

public class JFrameWithPanel
{
    public static void main(String[] args)
    {
         JPanel panel = new Bar(new JFrame("CIT Test Program"));
    }
}

How do I get this to have everything where I want it and show up? I'm very confused because of this and now barely even get how Frames work.

© Stack Overflow or respective owner

Related posts about java

Related posts about jframe