DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links