title bar for blank frame


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: title bar for blank frame

  1. #1
    Join Date
    Nov 2003
    Posts
    29

    title bar for blank frame

    can anyone help ? i just want to construct the frame and see the menu but the menu dont show.

    Code:
    import java.awt.*;
    import javax.swing.*;
    
    public class MainFrame extends JFrame {
    public MainFrame() {
    super("******* !"); // calls constructor method of jframe with title as argument
    setSize(900, 500);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
    
    JMenu mn1 = new JMenu("Game");  //create a jmenu item object
    
    JMenuItem mn1New = new JMenuItem("New Game");
    JMenuItem mn1Quit = new JMenuItem("Quit Game");
    
    mn1.add(mn1New);
    mn1.add(mn1Quit);
    
    JMenu mn2 = new JMenu("Theme");  //jmenu container holds jMenuItem components 
    
    JRadioButtonMenuItem mn2Girl =new JRadioButtonMenuItem("Girl",true);
    JRadioButtonMenuItem mn2Van =new JRadioButtonMenuItem("Van");
    JRadioButtonMenuItem mn2Sub =new JRadioButtonMenuItem("Subway");
    
    mn2.add(mn2Girl);
    mn2.add(mn2Van);
    mn2.add(mn2Sub);
    
    JMenuBar mnb = new JMenuBar();
    
    mnb.add(mn1);
    mnb.add(mn2);
    
    setJMenuBar(mnb);
    }
    
    public static void main(String[] args) {
    MainFrame gameWin = new MainFrame();
    
    }
    }

  2. #2
    Join Date
    Nov 2003
    Posts
    29
    actually i just figured out the order is wrong - everything has to be set before setVisable i guess

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center