Open Frame from MainFrame Menu item

I created new Frame, and I want to open this frame from Main Frame menu item.
Help me

You should add an action listener to the Menu Item. In the action listener's actionPerformed(ActionEvent) method, call your frame's setVisible(boolean) method.
//frame setup
        JFrame mainFrame = new JFrame("main frame");
        final JFrame otherFrame = new JFrame("second frame");
        mainFrame.setSize(400,400);
        otherFrame.setSize(200,200);
        //menu setup
        JMenuItem item = new JMenuItem("Open my special frame");
        JMenuBar bar = new JMenuBar();
        JMenu menu = new JMenu("menu");
        bar.add(menu);
        menu.add(item);
        mainFrame.setJMenuBar( bar );
        mainFrame.setVisible( true );
        //here's the important part
        item.addActionListener( new ActionListener()
            @Override
            public void actionPerformed(ActionEvent e)
               otherFrame.setVisible(true);
    }

Similar Messages

  • Can't open nautilus from applications menu

    I find that I can't open nautilus from applications menu any more.
    In the terminal, it won't open nautilus when running 'nautilus' without specifying a location or --new-window option.
    I've checked and tried to modify /usr/share/applications/org.gnome.Nautilus.desktop and /usr/share/applications/nautilus-classic.desktop, but it didn't work.
    The values of Exec option in the two files are as follows:
    /usr/share/applications/org.gnome.Nautilus.desktop: Exec=nautilus --new-window %U
    /usr/share/applications/nautilus-classic.desktop:  Exec=nautilus --no-default-window --force-desktop
    Also, I have tried to reinstall nautilus. I didn't work, either.
    Any one can help?

    ooo wrote:
    Are you using gnome classic session? Or have you enabled desktop icons?
    Sounds like the nautilus-classic.desktop could be getting launched  during gnome-session startup, which should happen in both of the cases above.
    According to my testing, starting nautilus with 'nautilus --no-default-window --force-desktop' causes the exact behavior you're describing.
    I'm using standard gnome without desktop icons, and I don't have any issues with nautilus, so disabling them would probably help, although that could be a drag if you really want desktop icons.
    I still don't understand why the org.gnome.Nautilus.desktop wouldn't work though, since it has the --new-window flag. Apparently you can't even launch a new window via the right click menu item.
    This could happen if gnome-shell recognizes the nautilus-classic.desktop as nautilus, and starts using it's .desktop file instead when you try to launch a new window.
    If so you could probably fix this from the .desktop file somehow. I might be able to look into it later..
    I'm also using standard gnome, and I have enabled desktop icons.
    Disabling desktop icons makes it work.
    Thanks!
    I once tried to modify nautilus-classic.desktop to Exec=natilus --new-window, but it didn't help.

  • Executing a sql command from a menu item

    I am working on a forms migration from 4.5 to 10g.
    On 4.5, if I execute a sql using a sqlplus -s command, from a menu item, a window is opened showing the execution messages, if there were errors and it's details.
    It doens´t happen on 10g anymore. Is there any chance I can keep on 10g this functionality that used to work on 4.5 ??
    The procedure I use to execute the sql is:
    Menu item code:
    plus('sql_ name',null);
    Procedure:
    procedure plus(
    program in VARCHAR2, /* sql name*/
    parameters in VARCHAR2 /* aditional parameters */
    ) is
    V_USERNAME varchar2(100);
    V_PASSWORD varchar2(100);
    V_DATABASE varchar2(100);
    str varchar2(300);
    begin
    V_USERNAME := GET_APPLICATION_PROPERTY(USERNAME);
    V_PASSWORD := GET_APPLICATION_PROPERTY(PASSWORD);
    V_DATABASE := GET_APPLICATION_PROPERTY(CONNECT_STRING);
    str := V_USERNAME||'/'||V_PASSWORD||'@'||V_DATABASE;
    HOST ('sqlplus -s '||''''||str||''''||' @$PATH/'||program||' '||parameters);
    end;
    Tks a lot,

    Hello,
    With C/S versions, the Host() command execute on the machine that runs the Forms runtime, that is the client machine.
    With Web versions, Host() is also executed on the machine that runs the Forms runtime, that, this time is the application Server.
    Use the Client_Host() Webutil equivalent.
    Francois

  • Stuck in a Rut trying to activate a Dialog from a menu item

    I am building an application using Netbeans. I am stuck on getting a dialog window to open when i select a menu item. I have tried numerous alternatives and still can not seem to get it to work. I am sure it is a simple one; except, I am starting to repeat myself on the changes. I have decided to ask for help.
    The menu item is "OpenProfileMenuItem" and the method is "OpenProfileMenuItemActionPerformed". The dialog is "ProfileForm". How do I make this work?
    package BBCUtillity;
    import org.jdesktop.application.Action;
    import org.jdesktop.application.ResourceMap;
    import org.jdesktop.application.SingleFrameApplication;
    import org.jdesktop.application.FrameView;
    import org.jdesktop.application.TaskMonitor;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.Timer;
    import javax.swing.Icon;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    public class BBCUtilityView extends FrameView {
    public BBCUtilityView(SingleFrameApplication app) {
      super(app);
      initComponents();
    @Action
    public void showAboutBox() {
      if (aboutBox == null) {
       JFrame mainFrame = BBCUtility.getApplication().getMainFrame();
       aboutBox = new BBCUtilityAboutBox(mainFrame);
       aboutBox.setLocationRelativeTo(mainFrame);
      BBCUtility.getApplication().show(aboutBox);
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {}// </editor-fold>
    private void OpenProfileMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
      ProfileForm iForm = new ProfileForm();
      // TODO add your handling code here:
    // Variables declaration - do not modify
    private javax.swing.JMenuItem ImportMainDataMenuItem;
    private javax.swing.JMenuItem MergeDataMenuItem;
    private javax.swing.JMenuItem NewProfileMenuItem;
    private javax.swing.JMenuItem OpenProfileMenuItem;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    // End of variables declaration                  
    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private JDialog aboutBox;
    package BBCUtillity;
    import org.jdesktop.application.Application;
    import org.jdesktop.application.SingleFrameApplication;
    public class BBCUtility extends SingleFrameApplication {
    private mrkTable MarkerTable;
    @Override protected void startup() {
      show(new BBCUtilityView(this));
        MarkerTable = new mrkTable();
        MarkerTable.loadMarkers();
    //   MarkerTable.dumpTable();
    //   MarkerTable.saveMarkers();
    @Override protected void configureWindow(java.awt.Window root) {
    public static BBCUtility getApplication() {
      return Application.getInstance(BBCUtility.class);
      public static void main(String[] args) {
      launch(BBCUtility.class, args);
    package BBCUtillity;
    public class ProfileForm extends javax.swing.JDialog {
    /** Creates new form ProfileForm */
    public ProfileForm(java.awt.Frame parent, boolean modal) {
      super(parent, modal);
      initComponents();
      @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                         
    private void initComponents() {}// </editor-fold>                       
      private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {                                      
       // TODO add your handling code here:
    public void ProfileForm(String args[]) {
      java.awt.EventQueue.invokeLater(new Runnable() {
       public void run() {
        ProfileForm dialog = new ProfileForm(new javax.swing.JFrame(), true);
        dialog.addWindowListener(new java.awt.event.WindowAdapter() {
         @Override public void windowClosing(java.awt.event.WindowEvent e) {
          System.exit(0);
        dialog.setVisible(true);
    // Variables declaration - do not modify                    
    private javax.swing.JComboBox ModalCombo;
    private javax.swing.JComboBox ProfileCombo;
    private javax.swing.JComboBox PropCombo;
    // End of variables declaration                  

    This question should go into the Swing forum.
    I find the declaration, but no instance of OpenProfileMenuItem in your code (Java naming conventions request that variables start with lowercase characters). To this instance a listener must be attached, which when fired opens your dialog.

  • I can't open bookmarks from the menu in new tab on firefox 6.0 using the mouse middle button or right click. Is this normal?

    I can't open my bookmarks from the menu in a new tab.
    I'm wondering if this is simply not a feature and requires an add-on. I'd rather not need to use an add-on.
    can anybody help?

    Hello,
    '''Try Firefox Safe Mode''' to see if the problem goes away. Safe Mode is a troubleshooting mode, which disables most add-ons.
    ''(If you're not using it, switch to the Default theme.)''
    * You can open Firefox 4.0+ in Safe Mode by holding the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * Or open the Help menu and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''
    Thank you.

  • "open recent" from file menu not operating with snow leopard?

    is anyone else having trouble with this?
    did i accidentally disable this option? if so, how do i enable it?
    thanks

    PeterBreis0807 wrote:
    I can understand why they have done this, although agree it is not a good idea.
    Apple has made accessing the applications harder than need be, by nesting them inside the iWork folder. Without the manuals.
    The User Guide says nothing about the need to leave the iWork components in the iWork '09 folder.
    Is it difficult to understand that we don't buy three separate applications but one package?
    The soluce of three apps in one package may have several reasons:
    (1) developping Keynote then Pages then Numbers was more efficient in terms of cost than developping them as a single app.
    (2) keeping them as separated items gives the ability to load an item smaller than a treeinone app so it requires less time and use less memory.
    (3)…
    If users are too numerous to break the 'rule', I'm afraid that Apple decide to pack the three apps in a single item so the problem would be definitely solved.
    If someone want to have direct access to iWork components from the Applications menu, the correct soluce is to create aliases of thes apps and store these aliases in the Applications folder. Neat, simple and free of the described oddities.
    as in the +Open With+ in File information,
    The operating system apply a default setting for the "Open with" feature.
    There is a problem for those which want an other setting.
    But, as every user has its own needs, there will always be necessary to make individual choices.
    Which app must open a .doc file ?
    For me it's a moveit_to_thetrash tool
    for some users, it's Word
    for some, it's openOffice
    for some, it's neoOffice
    for some, it's Bean
    for some, it's Pages
    for some, it's TextEdit
    and I know users having all of them installed.
    Automatic link between a kind of doc and an app is an inaccessible dream.
    The user action is required.
    and the +Keyboard Shortcuts+ preferences.
    The decision to apply this or that shortcut to a menu item is part of the design task. I think that it's the designer which must define them, not the user. You don't change the commands of your motorcar, I don't understand why you would change those of an application.
    If you don't like the application GUI, use an other app.
    Yvan KOENIG (VALLAURIS, France) vendredi 11 septembre 2009 17:24:59
    The user is here to use program, not to design them.

  • Opening Videos from Left Menu Requires Right Click

    I have multiple Windows 7 computers with iTunes installed. I have noticed that whan trying to open videos from the left menu, the only way to get it working is to wight click on the mouse, left clicking does not work. Does anyone know anything about this and how to resolve it?

    I encountered the same problem. A quicker workaround then restarting firefox is to just minimize and maximize. Don't know why but that works.

  • Opening window from a menu option

    Is it possible to open a new Window from the menu option?
    How ?
    Thanks in Advance.
    Swati

    yes its possible by adding an actionlistener to the menuitem.

  • Getting the name of a menu from the menu item

    Hi everybody,
    I'm trying to get the name of the menu that a particular menu item is classified under, and thus far I can't figure out how. Can anyone give me a hand with this, please? I have a SSCCE that describes my efforts so far:
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JPopupMenu;
    public class MenuTester {
         public MenuTester() {
              JMenuItem item = new JMenuItem( "zzz" );
              item.addActionListener( new ActionListener() {
                   public void actionPerformed( ActionEvent e ) {
                        System.out.println( ((JPopupMenu)((JMenuItem)e.getSource()).getParent()).getLabel() );
                        System.out.println( ((JPopupMenu)((JMenuItem)e.getSource()).getParent()).getName() );
              JMenu menu = new JMenu( "test" );
                    menu.setName( "test" );
              menu.add( item );
              JMenuBar bar = new JMenuBar();
              bar.add( menu );
              JFrame frame = new JFrame();
              frame.setJMenuBar( bar );
              frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              frame.setSize( 300, 300 );
              frame.setVisible( true );
         public static void main( String args[] ) { new MenuTester(); }
    }I've tried the JPopupMenu method getLabel, and the generic Component method getName, but neither of them seem to work, even when I explicitly set the name. The result of both calls is "null", not "test" as it should be. There must be something small that I'm missing, but I'm not sure what, can anyone please tell me what it is?
    Thanks,
    Jezzica85

    JMenuItem mi = (JMenuItem)e.getSource();
    JPopupMenu popup = (JPopupMenu)mi.getParent();
    JMenu menu = (JMenu)popup.getInvoker();
    System.out.println( menu.getText() );

  • Mail photo browser will not open using button or menu item

    I have a Air 13" and recently installed Mountain Lion. Now the photo browser window in mail (apple mail) will not appear. Not from teh photo browser button on compose email or the file menu item. It worked flawlessly before. Can't find anything online about this.
    Assistance is appreciated.
    TS

    Same issue on new MBPro having just installed Mountain Lion.

  • Remove Alt+F4 accelerator from Close menu item?

    In my Swing app, I would like to remove the Alt+F4 accelerator binding from the
    Windows menu Close menu item; I still want the menu and the Close menu item,
    just without the accelerator. This would be similar to how the command prompt
    window has its menu.
    Is this doable from within Java? Or is JNI the only way it can be done?
    Alternatively, is there a way to detect that Alt+F4 was used to invoke the close operation?
    Thanks,
    : jay

    I think you need JNI, cuz I think that is handled by the OS.

  • Automatically debugging when calling a script from a menu item

    Hi All,
    I'm coming accross an issue that I was wondering if anyone can help me with or point me in the correct direction.
    I have two start up scripts.
    One runs in the "session" target engine and setups ups some custom menu items and actions which call some other custom scripts.
    The other runs in my own custom session and is used to initialize and share common constants and functions between my custom scripts.
    This all appears to run as expected and clicking on the new menu item calls the correct script however even without the ExtendedScript Toolkit running as soon as i click on the menu item it will load up the ESTK and break on the first line of the script. If I press F5 to continue processing it will finish and runs fine.
    I am currently using the excellent extendables package (http://extendables.org/) to do some HTTP and simplify UI creation which does not specify a session.
    Does anyone know what is causing the scripts to be automatically debugged or is there a setting that might be set to cause this?
    Is this being caused by "session" calling "customSession" using code that will run in the default "main" session?
    this really is irritating me at the moment so if anyone can help it would be much appreciated.
    This is all done using JavaScript in InDesign CS 5.5
    Thanks in advance

    just a quick update.
    After stripping back and stubbing out some code I have been able to trigger a "session" going to my "customSession" then to a non-session (the default) so this is not causing my issue.
    As I mentioned above i am using the extendables package and this appears to be where my issue is arrising. as soon as i include the package:
    #include "extendables/extendables.jsx"
    i get the strange behaviour of it going into debugging mode on the first line of the script being run by my menuItem eventHandler.
    This is without actually using any of the modules available in the extendables package just including it.
    I will try to post a message on the website for this package but if anybody has any ideas about what might be in there that is causing this I would appreciate any ideas/suggestions/theories.
    Cheers

  • Will EC support setting default file type and Open With from file menu?

    The default file types I can live without, but at least allow for Open With on right click from Windows Explorer.
    I currently have EC set in the Open With programs list, but EC does not comply for any files I opt to open it with (.css, .php, .html etc).
    EC open but not the file I choose.
    Also, even though the above use case is not ideal when if I do attempt an Open With when EC is already open, a new application session starts instead of attempting to open in the currently active app frame. It would be ideal to allow for single app frame, multiple files when Open With is employed.
    Darrell

    Hey Darrell,
    Thanks for the feedback. How Edge Code treats files is definitely something we know isn't ideal and it's something we're looking at fixing soon. There's currently a story on the Brackets backlog that adresses the Open With issue - https://trello.com/c/GhF1Bgf9
    And it based on howit ranks in that priority it looks like we could potentially take that into Edge Code over the next couple of months.
    This is definitely a feature that we think is important before we consider ourselves 1.0 so it's high priority.
    =Ryan
    [email protected]

  • Opening frames from an applet

    Me and a friend are making an applet, and would like it to open a new frame at some point.
    It works perfectly* on his WIN 2k IE 5.0 but somehow it does not on my WIN 2k IE 6.0
    Is it no longer legal to open new windows from an applet?
    Thanks.
    *Except for the warning. Btw, is that warning removable?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    If the window doesnt show up, you might have an exception thrown somewhere. I assume you are using a Java Plug-In since you are using IE6.0. You can bring up the java console, if you open the Java Plug-In icon in the Control Panel and enable "Show Java Console". Restart your browser and try again and see if you are getting a stacktrace in the java console.You can also see what version of java you are using in the control panel, or change it in the Java Plug-In options (Advanced tab) if you have more than one installation installed.

  • Question about behavior of "Open With" from Finder Menu

    When I highlight a pdf and go to "Open With" I get the following (default is Preview--only see one of those):
    Acrobat Reader 5.0
    Acrobat Reader 5.0
    Adobe Reader 9.1.3
    Adobe Reader 9.1.3
    Adobe Reader 9.0.0
    Adobe Reader 8.1.2
    QuickTime
    QuickTime
    Safari
    Safari
    The only Reader I have in Applications is the 9.1.3. I've put those older versions in the Trash for now.
    And I don't understand, also, why I'm seeing doubles of the same 9.1.3, the same Acrobat, the same QT, and the same Safari.
    I've restarted the computer, dumped the Finder .plist as well as cleared "Recent Applications." No change.

    You can find the locations of any reference to these applications
    by using Find in a search. Their path will appear and you will
    know where they exist. In some cases, older versions of a utility
    or some part of an application were brought into the system by
    another installer, so they may be in an unchecked folder.
    {You also should be able to choose Preview to see & read .PDFs.
    Of course, there are certain Acrobat-authored documents which
    do not work as well in Preview as they do in Adobe's reader app.}
    There is a newer version of Acrobat (reader) available for D/L
    and it has been recommended due to known security issues.
    Also, other Adobe updates for flash player are available.
    You also could use an alias of the Reader and drop the file on it
    to have a .pdf open on demand with the correct (or desired) app.
    Good luck & happy computing!

Maybe you are looking for

  • Systems in Service Registry

    SDN Team,   I am also facing the same error ( Specified provider system is not published in the Services Registry). when i am trying to create a Provider system .which is available in Service Registry....what could be the reason?and one more doubt on

  • How can i downgrade to my iOS 6? I dont like iOS7.

    Hello people, I have a iPhone 4S, I've recently upgrade to iOS7...OMG what i've i done !! I dont like it at all... the calendar and notes are pretty useless now, everything turned white, even the date cursor on "starts" option (date/hour) its hard to

  • One file to be sent to one of two message types.

    Hi, I have gone through many other messages but didn't get an answer. Please read the issue. I have one file with 4 (suppose) records out of which 2 records go to one message type and the rest to other. I have two message mappings for each message ty

  • Enterprise Portal EWA Report

    Hi, I would like to know the reason why the JCO part is not included after the extraction of EWA Report on Solution Manager? What could be the reason behind this? What are the possible solutions to eliminate this type of issue? The customer actually

  • My Macbook Pro Retina Display Woke From Sleep in the bag ...

    ... I got it out of the bag and it was steaming hot and the fan was blowing like out of ****. The battery had gone down about 20% points within the hour of my commute. I had to shut it down and leave it off for a while to cool down. Has anyone seen t