JMenubar option

Hi.
I am using VE in eclipse for building GUI.
In the GUI whenever I open the files using File --> open option, it always get appended to previously opened text in the Jtextarea instead of overwriting on it.
So can I just know how to do this.
And in the reset button I had just written a code like
TextArea.setText(""); But it doesnot clear anything the previous operations that were runned.
Like it gives the output of the current as well as the previous operations that were done.
So can anyone tell me how to fix this?
Thanks

Cross-post: [http://www.java-forums.org/new-java/29115-jmenubar-option.html]

Similar Messages

  • Event Handling - In what layer/pane is a JMenu contained?

    In what layer is a JMenu contained?
    I ask this because I am trying to figure out what object gets the event first - the component with a keybinding of WHEN_IN_FOCUSED_WINDOW or my menu. I want my menu to clear itself for certain keystrokes and allow the event to be picked up by the component that is listening for it in the focused window.
    I know the FocusManager, focused component, gets to process the event first. Then to keylisteners of super(), Keybindings, and then menubar.
    I know the JFrame implements the RootPane interface. The RootPane contains a glassPane and a layeredPane. The layered pane puts the jmenubar(optional) and content pane in the JLayered panes frameContentLayer.
    The menu is added to the JMenuBar so is the menu in the JLayeredPane PopUpLayer or is it in the FrameContentLayer?
    If the menu is part of the menubar and the menu bar is the last to get notified...
    Would the JMenu receive an event only after a component in the content layer has processed it? Will the component in the content layer that is listening for a certain keypress in the focused window even get notified since the FocusManager has the event source as the JMenu?
    If anyone has any clarification on the JMenu and how events/panes/layers work with the JMenu I would greatly appreciate your help. I understand the other components I am just confused about the JMenu.

    JMenu is contained in default_layer
    DEFAULT_LAYER
    The standard layer, where most components go. This the bottommost layer.
    PALETTE_LAYER
    The palette layer sits over the default layer. Useful for floating toolbars and palettes, so they can be positioned above other components.
    MODAL_LAYER
    The layer used for modal dialogs. They will appear on top of any toolbars, palettes, or standard components in the container.
    POPUP_LAYER
    The popup layer displays above dialogs. That way, the popup windows associated with combo boxes, tooltips, and other help text will appear above the component, palette, or dialog that generated them.
    DRAG_LAYER
    When dragging a component, reassigning it to the drag layer ensures that it is positioned over every other component in the container. When finished dragging, it can be reassigned to its normal layer.

  • How to add a JMenubar and a JTable in a JFrame in a single application

    Hi all,
    I require an urgent help from you.I am a beginer in programming Swing.I want to add a menu,combobox,and a table in a single application.I did coding as below:
    package com.BSS;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    public class newssa extends JFrame
         public JMenuBar menuBar;
         public JToolBar toolBar;
         public JFrame frame;
         private JLabel jLabel1;
         private JLabel jLabel2;
         private JLabel jLabel3;
         private JLabel jLabel4;
         private JLabel jLabel5;
         private JLabel jLabel6;
         private JComboBox jComboBox1;
         private JComboBox jComboBox2;
         private JComboBox jComboBox3;
         private JComboBox jComboBox4;
         private JComboBox jComboBox5;
         private JComboBox jComboBox6;
         private JTable jTable1;
         private JScrollPane jScrollPane1;
         private JPanel contentPane;
         public newssa()
              super();
              initializeComponent();
              this.setVisible(true);
         private void initializeComponent()
              jLabel1 = new JLabel();
              jLabel2 = new JLabel();
              jLabel3 = new JLabel();
              jLabel4 = new JLabel();
              jLabel5 = new JLabel();
              jLabel6 = new JLabel();
              jComboBox1 = new JComboBox();
              jComboBox2 = new JComboBox();
              jComboBox3 = new JComboBox();
              jComboBox4 = new JComboBox();
              jComboBox5 = new JComboBox();
              jComboBox6 = new JComboBox();
              frame=new JFrame();
              //Included here
              JMenuBar menuBar = new JMenuBar();
              JMenu general = new JMenu("General");
         menuBar.add(general);
         JMenu actions =new JMenu("Actions");
         menuBar.add(actions);
         JMenu view=new JMenu("View");
         menuBar.add(view);
         JMenu Timescale=new JMenu("TimeScale");
         menuBar.add(Timescale);
         Timescale.add("Today CTRL+D");
         Timescale.add("Current Week CTRL+W");
         Timescale.add("Current Month CTRL+M");
         Timescale.add("Current Quarter CTRL+Q");
         Timescale.add("Current Year CTRL+Y");
         Timescale.add("Custom TimeScale CTRL+U");
         JMenu start=new JMenu("Start");
         menuBar.add(start);
         JMenu options=new JMenu("Options");
         menuBar.add(options);
         JMenu help=new JMenu("Help");
         menuBar.add(help);
         JFrame.setDefaultLookAndFeelDecorated(true);
         frame.setJMenuBar(menuBar);
         frame.pack();
         frame.setVisible(true);
         toolBar = new JToolBar("Formatting");
         toolBar.addSeparator();
              //Before this included new
              String columnNames[] = { "ColorStatus", "Flash", "Service Order","Configuration","Configuration Description"};
              // Create some data
              String dataValues[][] =
                   { "blue", "flash", "ORT001" },
                   { "AVCONF", "av configuration with warrenty"}
              // Create a new table instance
              //jTable1 = new JTable( dataValues, columnNames );
              jTable1 = new JTable(dataValues,columnNames);
              jScrollPane1 = new JScrollPane(jTable1);
              contentPane = (JPanel)this.getContentPane();
              //scrollPane = new JScrollPane( table );
              //topPanel.add( scrollPane, BorderLayout.CENTER );
              // jLabel1
              jLabel1.setText("Service Centers");
              // jLabel2
              jLabel2.setText("Service Areas");
              // jLabel4
              jLabel3.setText("Skills");
              jLabel4.setText("Availablity Types");
              // jLabel5
              jLabel5.setText("From Date");
              // jLabel6
              jLabel6.setText("To");
              // jComboBox1
              jComboBox1.addItem("Coimbatore");
              jComboBox1.addItem("Chennai");
              jComboBox1.addItem("Mumbai");
              jComboBox1.addItem("New Delhi");
              jComboBox1.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jComboBox1_actionPerformed(e);
              // jComboBox2
              jComboBox2.addItem("North Zone");
              jComboBox2.addItem("South Zone");
              jComboBox2.addItem("Central Zone");
              jComboBox2.addItem("Eastern Zone");
              jComboBox2.addItem("Western Zone");
              jComboBox2.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jComboBox2_actionPerformed(e);
              // jComboBox3
              jComboBox3.addItem("Microsoft Components");
              jComboBox3.addItem("Java Technologies");
              jComboBox3.addItem("ERP");
              jComboBox3.addItem("Others");
              jComboBox3.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jComboBox3_actionPerformed(e);
              // jComboBox4
              jComboBox4.addItem("One");
              jComboBox4.addItem("Two");
              jComboBox4.addItem("Three");
              jComboBox4.addItem("Four");
              jComboBox4.addItem("Five");
              jComboBox4.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jComboBox4_actionPerformed(e);
              // jComboBox5
              jComboBox5.addItem("12/12/2004");
              jComboBox5.addItem("13/12/2004");
              jComboBox5.addItem("14/12/2004");
              jComboBox5.setEditable(true);
              jComboBox5.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jComboBox5_actionPerformed(e);
              // jComboBox6
              jComboBox6.addItem("12/11/2004");
              jComboBox6.addItem("13/11/2004");
              jComboBox6.addItem("14/11/2004");
              jComboBox6.setEditable(true);
              jComboBox6.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jComboBox6_actionPerformed(e);
              // jTable1
              jTable1.setModel(new DefaultTableModel(4, 4));
              // jScrollPane1
              jScrollPane1.setViewportView(jTable1);
              // contentPane
              contentPane.setLayout(null);
              addComponent(contentPane, jLabel1, 2,29,84,18);
              addComponent(contentPane, jLabel2, 201,33,76,18);
              addComponent(contentPane, jLabel3, 384,32,59,18);
              addComponent(contentPane, jLabel4, 2,77,85,18);
              addComponent(contentPane, jLabel5, 197,79,84,18);
              addComponent(contentPane, jLabel6, 384,80,60,18);
              addComponent(contentPane, jComboBox1, 85,32,100,22);
              addComponent(contentPane, jComboBox2, 276,32,100,22);
              addComponent(contentPane, jComboBox3, 419,30,100,22);
              addComponent(contentPane, jComboBox4, 88,76,100,22);
              addComponent(contentPane, jComboBox5, 276,79,100,22);
              addComponent(contentPane, jComboBox6, 421,78,100,22);
              addComponent(contentPane, jScrollPane1, 33,158,504,170);
              // newssa
              this.setTitle("SSA Service Scheduler");
              this.setLocation(new Point(0, 0));
              this.setSize(new Dimension(560, 485));
         /** Add Component Without a Layout Manager (Absolute Positioning) */
         private void addComponent(Container container,Component c,int x,int y,int width,int height)
              c.setBounds(x,y,width,height);
              container.add(c);
         // TODO: Add any appropriate code in the following Event Handling Methods
         private void jComboBox1_actionPerformed(ActionEvent e)
              int index = jComboBox1.getSelectedIndex();
              switch(index)
                   case 0: System.out.println("Area Coimbatore Selected "); break;
                   case 1: System.out.println("Area Chennai selected"); break;
                   case 2: System.out.println("Mumbai being selected"); break;
                   case 3: System.out.println("New Delhi being selected"); break;
         private void jComboBox2_actionPerformed(ActionEvent e)
              int index = jComboBox2.getSelectedIndex();
              switch(index)
                   case 0: System.out.println("North Zone Selcted "); break;
                   case 1: System.out.println("South Zone being selected"); break;
                   case 2: System.out.println("Central Zone being selected"); break;
                   case 3: System.out.println("Eastern Zone being selected"); break;
                   case 4: System.out.println("Western Zone being selected"); break;
         private void jComboBox3_actionPerformed(ActionEvent e)
              int index = jComboBox3.getSelectedIndex();
              switch(index)
                   case 0: System.out.println("Microsoft Components being selected"); break;
                   case 1: System.out.println("Java Technologies being selected"); break;
                   case 2: System.out.println("ERP Tehnologies being selected"); break;
                   case 3: System.out.println("Other's selected"); break;
         private void jComboBox4_actionPerformed(ActionEvent e)
              int index = jComboBox4.getSelectedIndex();
              switch(index)
                   case 0: System.out.println("One selected"); break;
                   case 1: System.out.println("Two selected"); break;
                   case 2: System.out.println("Three selected"); break;
                   case 3: System.out.println("Four selected"); break;
                   case 4: System.out.println("Five selected"); break;
         private void jComboBox5_actionPerformed(ActionEvent e)
              int index = jComboBox5.getSelectedIndex();
              switch(index)
                   case 0: System.out.println("12/12/2004 being selected"); break;
                   case 1: System.out.println("13/12/2004 being selected"); break;
                   case 2: System.out.println("14/12/2004 being selected"); break;
         private void jComboBox6_actionPerformed(ActionEvent e)
              int index = jComboBox6.getSelectedIndex();
              switch(index)
                   case 0: System.out.println("12/11/2004 being selected"); break;
                   case 1: System.out.println("13/11/2004 being selected"); break;
                   case 2: System.out.println("14/11/2004 being selected"); break;
         public static void main(String[] args)
              newssa ssa=new newssa();
              //JFrame.setDefaultLookAndFeelDecorated(true);
              //JDialog.setDefaultLookAndFeelDecorated(true);
              //JFrame frame = new JFrame("SSA Service Scheduler");
    //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //frame.setJMenuBar(ssa.menuBar);
    //frame.getContentPane( ).add(ssa.toolBar, BorderLayout.NORTH);
    //frame.getContentPane( ).add(ssa.pane, BorderLayout.CENTER);
    //frame.pack( );
    //frame.setVisible(true);
              try
                   //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                   UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
              catch (Exception ex)
                   System.out.println("Failed loading L&F: ");
                   System.out.println(ex);
    But as a O/P ,I am getting menu in a seperate windos and the rest of the combobox and jtable in a seperate window.Kindly help me to solve the application.
    VERY URGENT PLEASE..
    Thanks in advance
    with kind regds
    Satheesh.K

    But did u mean this as the next problem,Which I will come across..Yes, the second setVisible(true) seemed to be producing a smaller frame behind the main frame.
    And your JMenuBar is declared twice, but not sure if this will affect the code - haven't read it all.

  • Vertical JMenuBar width problem

    When I flip my JMenuBar vertical instead of horizontal by doing
    BoxLayout bl = new BoxLayout(this,BoxLayout.PAGE_AXIS);
    setLayout(bl);
    in a constructor for a class that extends JMenuBar. When I do that only 3 characters of each JMenu in the menubar are show. The button size is also ruffly half the width of the actual window. I am doing pack() on the JFrame that houses the JMenuBar. At the moment nothing else is in the JFrame. If I do not set the layout of my JMenuBar then I get a regular horizontal one and width is fine. It's only when I want the Menus vertical instead of horizontal. Been experimenting with all kinds of stuff and no go so far. Looking for suggestions?

    this produces a menubar, with the screen items vertical, but it takes up too much real estate
    import java.awt.*;
    import javax.swing.*;
    class Testing extends JFrame
      public Testing()
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setLocation(400,200);
        JMenu file = new JMenu("File");
        JMenuItem newItem = new JMenuItem("New");
        JMenuItem open = new JMenuItem("Open");
        JMenuItem preview = new JMenuItem("Preview");
        JMenuItem print = new JMenuItem("Print");
        JMenuItem exit = new JMenuItem("Exit");
        file.add(newItem);
        file.add(open);
        file.add(new JSeparator());
        file.add(preview);
        file.add(print);
        file.add(new JSeparator());
        file.add(exit);
        JMenu options = new JMenu("Options");
        JMenuItem font = new JMenuItem("Font");
        JMenuItem color = new JMenuItem("Color");
        options.add(font);
        options.add(color);
        JMenuBar menuBar = new JMenuBar();
        menuBar.setLayout(new GridLayout(0,1));
        menuBar.add(file);
        menuBar.add(options);
        setJMenuBar(menuBar);
        getContentPane().add(new JTextArea(5,20));
        pack();
      public static void main(String[] args){new Testing().setVisible(true);}
    }

  • JMenuBar Event Handling

    I am customizing my own menu bar, I would like to create some event handling, for the top most level, it is not a problem, but when I try to implement some event handling for the drop-down list/menu, nothing happens.
    The following is the whole class:
    package diagramillustrator;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DIM extends JMenuBar implements MouseListener
         * Creates a new instance of DIM
        public DIM()
            configFileMenu();
            configOptionsMenu();
            configAllItems();
            configMenuBar();
        //Creation and Initialization of objects
        //<editor-fold>    
        //file and options menus to be added to the menubar
        JMenu fileMenu =  new JMenu("File");
        JMenu optionsMenu = new JMenu("Options");
        //file items
        JMenuItem newItem = new JMenuItem("New");
        JMenuItem openItem = new JMenuItem("Open");
        JMenuItem saveItem = new JMenuItem("Save");
        JMenuItem printItem = new JMenuItem("Print");
        JMenuItem exitItem = new JMenuItem("Exit");
        //options items
        JMenuItem createFileItem = new JMenuItem("Create properties file");
        JMenuItem propertiesItem = new JMenuItem("Properties");
        //</editor-fold>
        //adds mouse listener to every item
        private void configAllItems()
            this.addMouseListener(this);
            fileMenu.addMouseListener(this);
            optionsMenu.addMouseListener(this);
            newItem.addMouseListener(this);
            openItem.addMouseListener(this);
            saveItem.addMouseListener(this);
            printItem.addMouseListener(this);
            exitItem.addMouseListener(this);
            createFileItem.addMouseListener(this);
            propertiesItem.addMouseListener(this);
        //creats the file menu
        private void configFileMenu()
            fileMenu.add(newItem);
            fileMenu.addSeparator();
            fileMenu.add(saveItem);
            fileMenu.add(openItem);
            fileMenu.add(printItem);
            fileMenu.addSeparator();
            fileMenu.add(exitItem);
        //creats the options menu
        private void configOptionsMenu()
            optionsMenu.add(createFileItem);
            optionsMenu.add(propertiesItem);
        //configures the menubar, adds all items to it etc
        private void configMenuBar()
            this.setLayout(new FlowLayout(FlowLayout.LEFT));
            this.add(fileMenu);
            this.add(new JSeparator(SwingConstants.VERTICAL));
            this.add(new JSeparator(SwingConstants.VERTICAL));
            this.add(optionsMenu);
            this.setToolTipText("Menu Bar");
        //event handling
        //<editor-fold>
        public void mouseClicked(MouseEvent e)
            //works
            //if(e.getSource().equals(fileMenu))this.setBackground(Color.yellow);
            //else this.setBackground(Color.black);
            //dowsn't work
            if(e.getSource().equals(newItem))this.setBackground(Color.yellow);
        public void mousePressed(MouseEvent e)
        public void mouseReleased(MouseEvent e)
        public void mouseEntered(MouseEvent e)
        public void mouseExited(MouseEvent e)
        //</editor-fold>
        //main method to test class
        public static void main(String[] args)
            JFrame f= new JFrame("Testing menu");
            f.setSize(400,400);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setJMenuBar(new DIM());
            f.show();
    } This is the troubling part:
    public void mouseClicked(MouseEvent e)
            //works
            //if(e.getSource().equals(fileMenu))this.setBackground(Color.yellow);
            //else this.setBackground(Color.black);
            //dowsn't work
            if(e.getSource().equals(newItem))this.setBackground(Color.yellow);
        } The first two lines work perfectly fine as they apply to the top most level, the rest doesn't do anything at all.
    Can anyone help me to handle events for the drop-down please?
    AndXer

    Sorry posted the prvious by mistake.
    Oh, I usually used MouseListener for buttons...I tried using ActionListener and it worked great, the only flaw is that any mouse button clicked triggers an event, I want the event to be triggered only when BUTTON_1 is clicked (like in MouseListener).
    Can that be done as I found nothing in the API. If yes, a code sample would be greatly appreciated.
    The current code for handling it is:
        if(e.getSource().equals(newItem))
             this.setBackground(Color.green);
    }Thanks,
    AndXer

  • JMenuBar & JMenu

    I have a frame where when it is called I want to show a JMenu. The only way I know how to show a JMenu is by adding it to a JMenuBar and when the user selects the title of the JMenuBar(ie. File) then the attatched JMenu is shown. In my case there is only one selection to be made from the JMemuBar, so I want to bypass that step all together and just show the JMenu in the frame that is presented because the user has no other option but to look at the JMenu(Much like when you right click in Windows) . My question again is how can I just show a JMenu without having to attatch it to a JMenuBar. In other words, I do not want the title bar just the one and only JMenu when the frame is called. How can I accomplish this?
    Ie
    JMenu list = new JMenu("List");
    list contents
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(list);
    I do not want the JMenuBar on my frame nor the included title "List". Though what I do want is the list itself when the frame is called. Again, much like right-clicking in Windows. Can someone please help me with this.

    Hi,
    Check the tutorial on how to use menus. It describes how to create a popup menu (right click on windows brings up a popup menu)
    http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html
    /Kaj

  • JMenuBar wont display properly.

    I have a JMenuBar that when I implement it is seen on the JFrame but it is only the length of the buttons and when you go to click on it, nothing comes up, its just like a little thing comes out from beneath, but when you fully maximize the window it works fine just like in Firefox or such. I have tried to repair() and some other methods but none work, does anybody have an idea to get rid of this.
    For solution I either need the JMenuBar o be fixed, or I need it to be there but to be hidden, so other classes can use it, but you cant see it. The reason for this is if ya get rid of it you get some nasty errors.

    The javax.swing.JMenuBar appears but it is not formatted correctly for the window size. I would like to make it so it fits and works p[properly,  Another option would be just to hide this JMenuBar.
    I cant really post an example.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • JMenuBar display quirks with some window managers on Linux with Java 6

    When I run this code on Windows with Java 5 or Java 6, it works fine.
    When on Linux with Java 5, it works fine.
    When on Linux with Java 6 in KDE, it works fine.
    When on Linux with Java 6 with twm or e17, the JMenu shows when I click on the JMenuBar, but goes away as soon as I release the mouse button. If I manually move or resize the window, it then works fine.
    If I remove setLocationByPlatform(true), the menu bar works, but it does not position the window by platform, which is the desired behavior.
    Am I doing something wrong, is there something wrong with both twm and e17, or is this a bug?
    import java.awt.Dimension;
    import java.awt.Label;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JFrame;
    import javax.swing.JMenuBar;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import javax.swing.WindowConstants;
    public class Test extends JFrame {
        public Test() {
            super();
            setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE );
            getContentPane().add( new Label( "Hello World" ) );
            JMenuBar mainMenu = new JMenuBar();
            setJMenuBar( mainMenu );
            JMenu helpMenu = new JMenu();
            mainMenu.add( helpMenu );
            helpMenu.setMnemonic( 'H' );
            helpMenu.setText( "Help" );
            JMenuItem help_about = new JMenuItem();
            helpMenu.add( help_about );
            help_about.setMnemonic( 'A' );
            help_about.setText( "About" );
            help_about.addActionListener(
                new ActionListener() {
                    public void actionPerformed( ActionEvent evt ) {
                        System.out.println( "HELP!" );
            pack();
            setLocationByPlatform( true );
            setVisible( true );
        public static void main( String[] args )
            throws Exception {
            java.awt.EventQueue.invokeLater(
                new Runnable() {
                    public void run() {
                        Test test = new Test();
    }

    In 10.1.3, there's an option to disable the splash screen on the Environment Page in preferences (although, of course, it's not much use if you never get to the main window because of the dialog popping up behind the splash screen... :) )
    The bug with the dialog appearing behind the splashscreen is fixed in the upcoming 11g release. FWIW, it's a problem that appears to be unique to X-based systems, where for some reason the splashscreen window ends up with some super-ueber topmost property that forces all other windows to go behind it.
    There's also a command line flag to suppress the splashscreen in 11g.
    Thanks,
    Brian

  • Java System.setProperty  (get JMenuBar on mac menu bar)

    Hi,
    I am currently building a Java application using Eclipse IDE. I have written GUI programs on OS X 10.4 before and managed to get the JMenuBar on the mac menu bar using
    System.setProperty("apple.laf.useScreenMenuBar", "true");
    But for some reason when using leopard the JMenuBar seems to disappear totally. When i don't use the above line it shows on the JFrame as it should do.
    System.setProperty("com.apple.mrj.application.apple.menu.about.name", "AppName");
    The above line doesn't work either with OS X 10.5
    Anyone have any experience with this and had any success?
    Thanks,
    Sion

    Hi Sion
    Welcome to Apple Discussions.
    You might be able to work around these problems using Jar Bundler, which takes a Jar file and converts it into a Mac OS X application. One of the options is to use the top line menu bar (instead of having it at the top of the frame).
    Find Jar Bundler in /Developer/Applications/Java Tools
    Bob

  • JMenubar hidden under JScrollPane

    Hi,
    JDK 1.3
    quick question... is there any way to stop JMenuItems in a JMenu, displayed on a JMenubar at the top of a Swing application from hidding behind the content of a Frame below it?
    I.e. when the FILE JMenu option is selected the drop down menu is hidden behind the content of the Frame.
    is there anyway to ensure the JMenuItems are always displayed 'on top'?
    The Frame is used to encapsulate the platform's WWW browser, displaying webpages. The class used to build this native frame extends java.awt.Canvas (this is the only way we could get around NT proxy server authentication) and therefore cannot be changed to use a JEditiorPane or JPane.
    Any ideas?

    All SWING components are lightweight. But you can make all popup menus to be heavyweight (like in AWT) for this call first the static method javax.swing.JPopupMenu.setDefaultLightWeightPopupEnabled(false);

  • Proper way to use JMenuBar?

    I want to use a JMenuBar to produce some "redundant" functionality into my program. Say, for instance, the user wants to print something. I can have a print button on screen an a print option in the file menu. I can have both objects call a static printRecords() menu in one of my other classes. This part isn't a problem.
    The problem I think I'm going to run into is JMenu items that try to reproduce the functionality of actions in classes that it doesn't have access to. Say, for instance, I have a JPanel full of JTextFields and it also has a button that says "Clear Fields." Currently, my design has the implementation for the button in the JPanel class. This works except that the JMenu does not have access to this method.
    What's the best approach to reducing the amount of code that I have to reuse without passing information all over the place?

    Assuming you still care about this issue (or that others do), I know I'm coming back long time after...
    The only class that I extend is the JPanel class because it makes it easier
    to create and manage the complex layout that I need.
    Are you suggesting there is a better way (...) without extending JPanel?Yes.
    Write business logic in non-graphic classes, write interaction logic into dedicated classes (depending on swing API but not extending any JComponent), and write the building and wiring of graphical components to the intercation classes in a dedicated composer class (you're right I made up this term, I don't know if a generally accepted one exists).
    I looked up the term "composer class" but couldn't find anything.
    Can you go into more detail about this term?Something along the line of:// Simple class, one text field, one clear button
    public class MyGUIComposer
      public void JFrame composeScreen()
      JFrame theFrame = new JFrame();
      JPanel mainPanel = new JPanel();
      mainPanel.setLayout(...)
      JPanel subPanel1 = new JPanel();
      final JTestField myTextField = new JTextField(...);
      Action buttonLogic = new ClearAction(myTextField);
      JButton clearButton = new JButton(buttonLogic);
    }With ClearAction.actionperformed() methods being as simple as the TextField.cleartext();
    If the configuration of the screen is more complex (e.g. lots of text fields, other widgets,...), you can use a Mediator class (this one is a known and documented design pattern). See below.
    Also, I figured I could use the same Action for the different components
    but (...)
    how would a "Clear" Action have a handle to the fields it needs to clear?It should have a handle to a Mediator object: this latter has already references to all widgets. And the clear action does not even bother clearing all buttons but just ask the Mediator to do so.
    The Mediator can itself be the composer, in this case the creation of the action becomes:
           Action buttonLogic = new ClearAction(this); // this being the mediator instanceand ClearAction.actionPerformed() becomes as simple as
    public void actionPerformed() { theMediator.clearAllFields();}And of course you write the mediator class with the method clearAllFields() which iterates through all relevant fields and clears them.
    At first it looks much more convoluted, but the Mediator really comes handy when you add features to your UI : more widgets, more interactions, more conditions (e.g. clear button clears all fields and adds a message in the status bar, and greys out the submit button only if the "Enable empty names" option is false.
    I find it better than having a JPanel subclass having to pass around the value of all options.

  • Mac jmenubar - for window object?

    Hello fellow java developers!
    I have jrame (which is my main application) that has a child awt.window object - that always is floating on top of the main jframe.
    On macintosh with java 1.4 I am seeing a problem! When I interact with the floating window object, the jfame's jmenubar dissapears! - this is on mac, so this means that since I am using the mac menubar - (the top always visible bar on the mac), that originally it has all of my program's options, but once the window gets focus, all of my programs menu items are gone!
    I am using macintosh style menubars (that appear on the top bar of the os), and since the window object cannot accept a jmenubar, I don't know what to do...
    Any ideas u brilliant people?

    thes wrote:
    Hello fellow java developers!
    I have jrame (which is my main application) that has a child awt.window object - that always is floating on top of the main jframe.
    On macintosh with java 1.4 I am seeing a problem! When I interact with the floating window object, the jfame's jmenubar dissapears! - this is on mac, so this means that since I am using the mac menubar - (the top always visible bar on the mac), that originally it has all of my program's options, but once the window gets focus, all of my programs menu items are gone!
    I am using macintosh style menubars (that appear on the top bar of the os), and since the window object cannot accept a jmenubar, I don't know what to do...
    Any ideas u brilliant people?Are we talking AWT or swing, because you mention jframe here, but it's an AWT forum.

  • Jabber Options - Phone Accounts - Voicemail -- "Spinning Wheel"

    Been trying to resolve a nagging issue.   We currently have CUCM 8.6.2-20000-2, CUPS 8.6.4-10000-28 and just put up Unity Conn 9.1.  Jabber Win clients are 9.2(1).   Several people have not been able to integrate voicemail into the Jabber client.  
    We are totally MS AD integrated.   In CUPS, I had Applications -> Cisco Jabber -> Settiings  Credentials Used For Voicemail service set to CUPS so the user would not need to supply credentials.  To help me debug, I went and changed this setting to "Not Set" so that the Phone Accounts option appears in Jabber 4 Win client. 
    So far all the people who do not work access the Phone Accounts setting in the Jabber client see the "Spinning Wheel".   They can't see the fields to enter their AD creds and the voicemail server.   Reinstall of the client does not seem to help.  There seemed to be a bug that described this but I think it was fixed in 9.1(2).  You can't display the Bug description because it contains proprietary info. 
    I have attached a screen shot of my Jabber Client Phone Account -- when I enter the credentials, I log in fine.
    Anyone seen this or know how to fix? 
    TIA --- Perry

    Well, I had TAC look at this issue. Short story is that it was an issue with one of the *many* local cache files which hid the real source of the problem.  I actually had the Mailstore misconfgured in CUPS.  I used the Exchange server's CAS IP instead of Unity Connection.   We created new Mailstore definition that used the Unity Conn IP's, created a new Voicemail Profile and associated the user to that profile.   She worked....
    I deleted my all my Jabber for Windows local cache files and I then received the "spining wheel" issue.  I moved my ID to the new Voicemail Profile with correct Mailstore and I could connect fine.   TAC spent an hour pouring through files on my PC and could not find the reason why my ID was working.   TAC indicates that in 9.x, a lot of this configuration moves to CUCM and hopefully cuts down on these issues!  PRT files from the Jabber client really did not assist them in locating the problem.
    Hope this helps....

  • Text options

    Hi all,
    i had a question regarding when writing something with the text option in photoshop, you then have the option of making it smooth, strong, sharp, crisp.
    What do these options do to the text? i cant really notice the difference, is there a recommended option for print or web that i should be using?

    Depends on a number of factors:
    how you want the type to look
    resolution
    file format (eg: gif or jpeg)
    Font attributes: weight, serif thickness, webfont
    so the answer would be very long. But thismakes an important differecne for low resoltuon digital graphics, and not so much for print.
    None - Applies no anti-aliasing
    Sharp - Type appears at its sharpest
    Crisp - Type appears somewhat sharp
    Strong - Type appears heavier
    Smooth - Type appears smoother

  • HP LaserJet Enterprise 500 color M551dn - Optional USB Device port

    Hi, I'm hoping to buy the optional wireless print server (HP Jetdirect 2700w USB Wireless Print Server J8026A). There is one problem though, the optional USB device port seems to not exist on my printer. I only notice that the USB logo is present where the port is supposed to be. The plastic in the area is squared off as though it is some sort of break away tab and the port is underneath maybe.
    There is no reference to this in the manual anywhere and I am really unsure how to proceed. I don't want to damage anything.
    If someone experienced with this model (preferably an HP Employee) can confirm the availability of the port and tell me how to access it (Is it a break away tab?). Part of the reason why I bought this printer is the optional Wireless N print server.
    Thank You in advance.

    Thank You for your reply. The port you are talking about is the front panel port for walk-up usb printing and firmware upgrades. This port is indeed available on the higher end LaserJet 500 (NON-MFP, printer only edition) as I just used it to upgrade the firmware. The port I am talking about is the one on the left side in the ports section which you use to plug in the optional print server (not the computer I/O port).
    This is shown in the official manual and the spec sheet so I'm 85% sure the port is there, hp can't advertise and mention something that is not available as this would be a big problem and make the 2700w print server incompatible when it clearly states that it is. I just need someone to confirm the availability and clear my confusion (either from HP, or another owner who bought the wireless print server 2700w).

Maybe you are looking for

  • Iphone calendar off by 1 hour after daylight savings

    i have my iphone synced to my outook 2007 through an exchange server. after daylight savings this weekend, all of my appointments are now off by 1 hour. they are all correct in my outlook and on the exchange server (verified by web browser). i've tri

  • Nano 6th generation corrupt/ resore problem in windows xp?

    My 6th generation nano is driving me crazy. I keep getting corrupt/ restore message over and over again. Does anyone know anything about some kind of conflict?

  • Problem with combination of ClobDomain and DB Trigger

    Hi all, I am using JDeveloper 10.1.2.0.0 (Build 1811), Oracle RDBMS 10.1.0.4.0 I have a DB Table which contains a CLOB column. This column is mapped in the EntityObject with the java type ClobDomain. Insert, update and delete actions are handled corr

  • New update just freezes!

    Please help.  New update now just freezes.  Can't get any of my music or the store.  I decided to just delete it from my machine and download it again.  Had the 32bit but it is now saying I havew to download the 64bit.  Did that and an error message

  • Videos Do Not Play In Order

    I've got a small number of videos I'd like to play in iTunes in sequence. I've created a video play list and placed all wanted videos into the play list. When playing videos iTunes will play the first video clip. When the first video finishes and the