Article View: borland.public.jbuilder.java.swing
Article #12693Re: Trying to display a swing menu system?
From: Matt Krevs
Date: Sat, 28 Nov 1998 00:00
Date: Sat, 28 Nov 1998 00:00
71 lines
2507 bytes
2507 bytes
You don't need the JMenuSystem class. One suggestion would be to add a
createMenu() method to your JTMSApp class and call if from your constructor.
Copy the code in the JMenuSystem constructor into the createMenu() method
and get rid of JMenuSystem alltogether.
call setMenu() for JTMSApp and everything should be OK.
Your code currently sets the menu for a JFrame that is never displayed
(JMenuSystem ), thats why you dont see the menu.
Eric Advincula wrote in message <73lgr3$eda30@forums.borland.com>...
>I have two classes. 1 JTmsApp which is the main app and JMenuSystem which
is
>the menu system
>The code in the menu system just creates a menu system. It use to be part
>of the JTmsApp and worked great. Now the menu system will not come up.
>Only the frame comes up. Any hints on why my menu system doesnt come up.
>It compiles fine no errors. ( left out all the imports to keep this message
>short )
>Am I doing something wrong. ( compiled using JDK1.2 all swing ).
>
>public class JTmsApp extends JFrame {
>
> public JTmsApp() {
> // Create the menuing system
> JMenuSystem menuSystem = new JMenuSystem();
>
> }
>
> public static void main(String[] args) {
>
> JTmsApp window = new JTmsApp();
> window.setTitle( "Tax Management System" );
> window.setSize( 640, 480 );
> window.setVisible(true);
> }
>}
>
>public class JMenuSystem extends JFrame{
>
> /* Menu system variables */
> JMenuBar menuBar;
> JMenu menuFile, menuHelp;
> JMenuItem menuExit;
>
> public JMenuSystem(){
>
> /* Create the menu bar */
> menuBar = new JMenuBar();
> setJMenuBar( menuBar );
>
> /* File menu section */
> menuFile = new JMenu( "File" );
> menuBar.add( menuFile );
> // submenu system of File menu
> menuFile.addSeparator();
> menuExit = new JMenuItem( "Exit" );
> menuFile.add( menuExit );
>
> /* Help menu section */
> menuHelp = new JMenu( "Help" );
> menuBar.add( menuHelp );
>
> }
>
>}
>
>
>
Technical Details
Message-ID:
<73n7lm$g9h3@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<73lgr3$eda30@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,509fdac7415dc047 X-Google-Attributes: gid111d45,public From: "Matt Krevs" <mattkrevs@flex.com.au> Subject: Re: Trying to display a swing menu system? Date: 1998/11/28 Message-ID: <73n7lm$g9h3@forums.borland.com> X-Deja-AN: 416327294 References: <73lgr3$eda30@forums.borland.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.swing