Combo box menu calculation of popup size ignores horizontal scrollbar

I have a JComboBox that I've setMaximumRowCount(20). However, sometimes the combo box has as few as 2 or 3 items in it. In those cases as you probably know, Swing automatically calculates how tall the popup should be, in this case 2 rows tall.
However, this calculation ignores the horizontal scrollbar, which basically occupies a "row" itself. This means that if I have combo box with 2 items, the displayed popup will contain the first item, a horizontal scrollbar, and a vertical scrollbar (for scrolling down to the item that the horizontal scrollbar hides) . Is this a bug in Java? If so, are there any workarounds to this?
I've looked in the bug report section using the terms "combobox horizontal scrollbar popup" and couldn't find anything
thanks

the very simple strategy to do is to call removeAllItems() method for the 2nd combox box and then insert the contents. this is because the validate() method is not repeatedly called and so the contents are not updated immediately.

Similar Messages

  • LOV's in form combo box - how to change font size?

    Greetings:
    I've a table generated form (custom vs. tabular), with a combo-box field that fills with a LOV's that has as it's visible data, a rather long concatenated string. Therefore, this field makes the entire form rather wide when the LOV's contains a long string (as returned from the SQL that gathers the data).
    I've tried using the FONT tag in the 2nd tab (Form wizard) for custom layouts; that didn't work.
    Anyone have ideas for decreasing the font size of the LOV's? Else, I'll have to leave-out some of the info concatenated on that string.
    As always, thanks for you continued guidance and support...
    Ed in Tampa

    Hi,
    Changing the font size and other properties like font color, width, height, etc.. of the form elements can be achieved by using Cascading Style Sheet (CSS).
    It cannot be changed using <FONT> tag.
    In Portal, one can add the CSS attribute to the HTML tags in the custom layout of the form. But adding the CSS attribute to FORM elements (Input, select..)is not possible through Form wizards.
    However, this can be achieved by creating a form through the Dynamic Page. In this case you have to define your whole form.
    To know more about CSS you can visit: http://www.mako4css.com
    Thanks,
    Shivank

  • Combo Box Choice Calculation

    I have 3 fields. 
    Field 1 is a combo box that provides the choice BZ7 or BZS.
    Field 2 is a text box (Monthly Gross) that calculates another boxes "Base Salary" * 26 pay periods for BZ7.  I want it to be set up so that If i choose BZS that calculation will change to 24 pay periods and for BZ7 the 26.

    You can set these numbers as the Export Values for each of the options in the combo-box, and then simply use the built in Product calculation option to multiply the value of the combo-box with the "Base Salary" text field.

  • Combo box - setting the pop up size

    Howdy everyone,
    I have a combo box with large names inside it and has limited space on the screen. When I click the combo I want the pop up to enlarge in width so you can see the full names.
    Any help with this?
    Thanks,
    mj-joy.

    you might get few pointers from these two sites-
    http://www.codeguru.com/java/Swing/JComboBox/index.shtml
    http://www2.gol.com/users/tame/swing/examples/JComboBoxExamples1.html

  • Combo box with bind variable from popup

    Hi.
    I had two comboboxes on a form, one having a bind variable. It works great, with the first one as bind field.
    But i want to have the first LOV to be a POPUP. So, the second LOV (combo box) needs to be refreshed when a user has picked a value from the popup list. When i do that, the second LOV is not refresehed...
    Is there a way to do this?
    (3.0.9.8.3.A)

    Hi,
    This was a bug and is fixed in 30984.
    Thanks,
    Sharmila

  • Combo box popup width adjusting no longer work in 1.0.6_26-b03

    Previously, I was able to adjusting combo box popup's width, by referring to the technique described in [http://tips4java.wordpress.com/2010/11/28/combo-box-popup/|http://tips4java.wordpress.com/2010/11/28/combo-box-popup/]. During that time, I was using 1.0.6_24-b07.
    However, after I update my Java runtime to 1.0.6_26-b03, things broke.
    Here is the screen shoot.
    [Workable screen shoot|http://i.imgur.com/0elo7.png]
    [Not workable screen shoot|http://i.imgur.com/BeKMy.png]
    Here is the code snippet to demonstrate this problem.
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    * NewJFrame.java
    * Created on Aug 9, 2011, 4:13:41 AM
    package experiment;
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.Dimension;
    import javax.swing.JComboBox;
    import javax.swing.JList;
    import javax.swing.JScrollBar;
    import javax.swing.JScrollPane;
    import javax.swing.SwingUtilities;
    import javax.swing.event.PopupMenuEvent;
    import javax.swing.event.PopupMenuListener;
    import javax.swing.plaf.basic.BasicComboPopup;
    * @author yccheok
    public class NewJFrame extends javax.swing.JFrame {
         * Adjust popup for combo box, so that horizontal scrollbar will not display.
         * Resize JComboBox dropdown doesn't work without customized ListCellRenderer
         * http://www.camick.com/java/source/BoundsPopupMenuListener.java
         * @param comboBox The combo box
        public static void adjustPopupWidth(JComboBox comboBox) {
            if (comboBox.getItemCount() == 0) return;
            Object comp = comboBox.getAccessibleContext().getAccessibleChild(0);
            if (!(comp instanceof BasicComboPopup)) {
                return;
            BasicComboPopup popup = (BasicComboPopup)comp;
            JList list = popup.getList();
            JScrollPane scrollPane = getScrollPane(popup);
            // Just to be paranoid enough.
            if (list == null || scrollPane == null) {
                return;
            //  Determine the maximimum width to use:
            //  a) determine the popup preferred width
            //  b) ensure width is not less than the scroll pane width
            int popupWidth = list.getPreferredSize().width
                            + 5  // make sure horizontal scrollbar doesn't appear
                            + getScrollBarWidth(popup, scrollPane);
            Dimension scrollPaneSize = scrollPane.getPreferredSize();
            popupWidth = Math.max(popupWidth, scrollPaneSize.width);
            //  Adjust the width
            scrollPaneSize.width = popupWidth;
            scrollPane.setPreferredSize(scrollPaneSize);
            scrollPane.setMaximumSize(scrollPaneSize);
         *  I can't find any property on the scrollBar to determine if it will be
         *  displayed or not so use brute force to determine this.
        private static int getScrollBarWidth(BasicComboPopup popup, JScrollPane scrollPane) {
            int scrollBarWidth = 0;
            Component component = popup.getInvoker();
            if (component instanceof JComboBox) {
                JComboBox comboBox = (JComboBox)component;
                if (comboBox.getItemCount() > comboBox.getMaximumRowCount()) {
                    JScrollBar vertical = scrollPane.getVerticalScrollBar();
                    scrollBarWidth = vertical.getPreferredSize().width;
            return scrollBarWidth;
         *  Get the scroll pane used by the popup so its bounds can be adjusted
        private static JScrollPane getScrollPane(BasicComboPopup popup) {
            JList list = popup.getList();
            Container c = SwingUtilities.getAncestorOfClass(JScrollPane.class, list);
            return (JScrollPane)c;
        /** Creates new form NewJFrame */
        public NewJFrame() {
            initComponents();
            this.jComboBox1.addPopupMenuListener(getPopupMenuListener());
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
            jComboBox1 = new javax.swing.JComboBox();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4", "This is a very long text. This is a very long text" }));
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(82, 82, 82)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(242, Short.MAX_VALUE))
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(34, 34, 34)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(246, Short.MAX_VALUE))
            pack();
        }// </editor-fold>
        * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new NewJFrame().setVisible(true);
        private PopupMenuListener getPopupMenuListener() {
            return new PopupMenuListener() {
                @Override
                public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                    // We will have a much wider drop down list.
                    adjustPopupWidth(jComboBox1);
                @Override
                public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                @Override
                public void popupMenuCanceled(PopupMenuEvent e) {
        // Variables declaration - do not modify
        private javax.swing.JComboBox jComboBox1;
        // End of variables declaration
    }

    I had came across another workaround as stated here.
    [http://www.jroller.com/santhosh/entry/make_jcombobox_popup_wide_enough|http://www.jroller.com/santhosh/entry/make_jcombobox_popup_wide_enough]
    The popup's is having enough width to show all items. However, it is not perfect still, as the width is little too much. I still can see some extra space at the tailing of the list.
    The workaround is as follow.
    import javax.swing.*;
    import java.awt.*;
    import java.util.Vector;
    // got this workaround from the following bug:
    //      http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4618607
    public class WideComboBox extends JComboBox{
        public WideComboBox() {
        public WideComboBox(final Object items[]){
            super(items);
        public WideComboBox(Vector items) {
            super(items);
        public WideComboBox(ComboBoxModel aModel) {
            super(aModel);
        private boolean layingOut = false;
        public void doLayout(){
            try{
                layingOut = true;
                super.doLayout();
            }finally{
                layingOut = false;
        public Dimension getSize(){
            Dimension dim = super.getSize();
            if(!layingOut)
                dim.width = Math.max(dim.width, getPreferredSize().width);
            return dim;
    }

  • Combo Box Calculation

    I'm trying to make a custom calculation Javascript for a combo box and can't figure out the calculation.
    There are a few variables at play. I would like to incorporate a sliding scale for a student's high school gpa that looks like this:
    Students GPA:          SAT Score                   ACT Score
    2.00                          1010                            86
    2.025                        1000                            85
    Students GPA=Combo Box1
    Combo Box2=(If GPA=2.022, event.value=1010/86)
    Combo Box2=(If GPA=2.028, event value=1000/85)
    and so on (the scale continues on up to GPA=3.525
    How would I calculate that?
    Thanks for your help

    Acrobat Scripting Forum http://forums.adobe.com/community/acrobat/acrobat_scripting

  • Combo Box Calculations

    Is there any way to use the drop down box or "combo box" with numbers in a calculation for another field.
    ex.  "Combo box1"= 500 , 1000, 2000 and "Text1" calculation should be "Combo box1 - 25"
    It doesn't seem to recognize the number in "Combo Box1" when I try to do this. Any help would be greatly appreciated!
    Thanks

    What calculation option are you using?
    What code are you using?
    What do you mean by "does not recognize"?
    If you are using "Simplified field notation" you should not have spaces in your field names, unless you use the special escape character to make the space within the field name to be treated as part of the field name.
    Have you accounted for the case of no selection made?
    Have you looked at what the type of the value is from the combo box?
    Do you understand the 2 different ways that the "+" operator works with JavaScript?
    Can you provide any JavaScript console messages?
    Can you link to a sample form?

  • When I try to backup my files from photoshop elements 12 the "calculating total media size" box will only get as far as 46% and then freeze, how can I make it go to 100%

    When I try to backup my files from photoshop elements 12 the "calculating total media size" box will only get as far as 46% and then freeze, how can I make it go to 100%

    hi barbara
    thank you for your response, i appreciate it.  there's definitely nothing wrong with the mouse or trackpad, both work fine in every other application....i can also easily change size dimensions in other programs on my computer so it doesn't seem to be that either.  it seems like there is something weird going on in the way that pse and my mac are interacting with each other, just wish i knew what it was.    thank you again, wish me luck!

  • Add a Drop down menu / Combo Box into a specified cell of a multi column lsit box

    Hello,
    i have a question how to manipulate a cell of a multi column list box in that way that i can add a drop down menu or a combo box in this cell?
    Is this possible in LabView?
    Thank you!

    Wow, I took a look at the alternate code posted here at that really takes you through gyration (also a similiar comment I see on Lava) to perform what I've done with a few functions....
    See the Pics and attached VI for how its done. KISS, I added an event stucture and changed my first enum case to " " (i.e. a blank) to make it look like the other posted code....
    Attachments:
    DropDownMenuInABox.vi ‏18 KB
    DropDownMenuInABox_FP.PNG ‏18 KB
    DropDownMenuInABox_BD.PNG ‏36 KB

  • Drop down menu or combo box in jtable

    Hi there I nee urgent help I have a jtable and I am collecting information to populate the table dynamically, the problem is I some of the strings that populate certain cells is longer the the width of the cell in a particular column, I thought I could use a combo box and split the strings up so I could have some type of drop down menu showing the information, but when I populate the combo box and instantiate the defaultcell renderer with the combobox it sets all cells in that column with the same information I would like to have it displaying the actual information for every row within that column
    or if you can give me any ideas as to how I can avoid this happening or maybe an alternative method of showing these long strings in the table some kind of drop down.
    Kind Regards Michael

    the problem is I some of the strings that populate certain cells is longer the the width of the cell in a particular column,Set a tooltip to display the entire text of the cell. Here is a simple example;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class TableToolTip extends JFrame
         public TableToolTip()
              Object[][] data = { {"1234567890qwertyuiop", "A"}, {"2", "B"}, {"3", "C"} };
              String[] columnNames = {"Number","Letter"};
              JTable table = new JTable(data, columnNames)
                   public String getToolTipText( MouseEvent e )
                        int row = rowAtPoint( e.getPoint() );
                        int column = columnAtPoint( e.getPoint() );
                        Object value = getValueAt(row, column);
                        return value == null ? null : value.toString();
              JScrollPane scrollPane = new JScrollPane( table );
              getContentPane().add( scrollPane );
         public static void main(String[] args)
              TableToolTip frame = new TableToolTip();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.setSize(150, 100);
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    }If you want to get fancier than you could set the tooltip text only when the width of the text is greater than the width of the column. Here is an example of this is done with a text field. You would need to modify the code to refer the to table for the text string and the TableColumn for the width.:
    JTextField textField = new JTextField(15)
         public String getToolTipText(MouseEvent e)
              FontMetrics fm = getFontMetrics( getFont() );
              String text = getText();
              int textWidth = fm.stringWidth( text );
              return (textWidth > getSize().width ? text : null);
    textField.setToolTipText(" ");
    I thought I could use a combo box and split the strings up so I could have some type of drop down menu showing the informationIf you want to proceed with this approach then check out this posting:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=637581

  • How can I set the size of combo boxes on a toolbar

    Hi, I am trying to use setMinimumSize of a combo box on a toolbar, It doesn't seem work. The code as following? Can anyone tell me how I can do it ?
    JComboBox sw = New ComboBox();
    sw.setMinimumSize(new Dimension(10,10));
    Thank you.
    Scott

    use the method preferred size of the JComponent superclass of the combos:
    setPreferredSize
    public void setPreferredSize(Dimension preferredSize)
    Sets the preferred size of the receiving component. If preferredSize is null, the UI will be asked for the preferred size.

  • Problem w/"combo boxes" cause the user to double click for the dropdown menu, but not for everyone.

    I have created a form with Adobe Acrobad Pro 9.
    There are a few "drop-down" boxes for people to choose options from.  I created them with the "Combo box" option.  They work perfectly fine on my laptop (Lenovo T500 windows 7, with all updates up to date.)  I sent the file to another exact same computer and that's when the problem came up.  When you click on the drop-down, the list will quickly appear and then disappear.  Then if you click it again it will stay open so you can choose your option.  However this only happens on "some" computers but not everyone's.  I emailed the exact same form out to other people in my office and they do not have any problems with the form.  There is no need to double click the drop down, it will just open up properly for them.
    Has anyone come across this? And if so, is there maybe a setting on these specific laptops that is preventing the "combo box" to not work properly?  I need to use this specific laptop as a "Kiosk" like a "check out" station for users to fill out the form to check out equipment.  I will be running in Reader so people can not make changes to the form.  (both the Acrobat Pro 9 version and the (most up to date) Reader version of the PDF form does the same "double-click" problem)  I need a date drop down and an equipment type drop down.
    Any suggestions would be greatly appreciated !
    Thanks !

    I've got this kind of problem with a form of mine (designed with LCD) :
    - combo boxes with font-color changing event handlers on :enter
    - on Acrobat 9 Pro : no problem
    - on Reader 8.3 :
          - first click seems to execute the event handler but stops the combo's opening
          - second click does open the combo
    Do you have event handlers on combo:enter ?
    Could the difference between comps where it works and comps where it doesn't be Acrobat's version ?

  • Selecting item in combo box itemEditor, after passing it's dataprovider from a popup window

    Hi..
    I have a datagrid which has a combo box itemeditor in the first column. When I click on the combobox, there is an item called 'Search'. When this is selected, a pop up window appears where we can search for some contact names. The search results are populated in List component, within the pop up and on double click of any of the names from the list, all of the list content is passed on as dataprovider to the combobox itemeditor of the grid. It works fine till here. Now, how can I highlight the selected name(name on which I double click, in the list of the pop up window), as the 'selectedItem' of the combobox itemeditor? ie., as soon as I double click the name, that name should appear on that combo box. As of now, wehn I double click, the search result names are passed on as dataprovider to the combobox, but a blank entry will be selected in th combobox, instead of the selected name from teh list of the pop up window. Can you please help me out on how to achieve this? I had been cracking my head for 2days now, hasn't worked out yet for me

    Hi...
    there are two events which have been used, one is doubleclick event and the other one is on selecting the item from the list and clicking on OK button(this will be the most frequently used function, i cannot use event target event for this OK button... ) . I have attached the screen shot. Please have a look at it and let me know how can i achieve that...
    I can use custom event, but the main problem is that the inline itemeditor's details are not accessible in the code.... I can access some function from within the inline itemeditor combo box using outerDocument.myFunction() (this is something like GET). Is there a similar way, to SET the data into this itemeditor?

  • Popup sizes with Java 7

    Has anybody else noticed strange sizes for popups when using the Java 7 betas and WindowsLookAndFeel? I've searched bugs.sun.com but couldn't fine much that sounded related to what I'm seeing:
    import javax.swing.*;
    public class PopupTest {
       public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
             public void run() {
                try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                   new JFileChooser().showOpenDialog(null);
                } catch (Exception e) {
                   e.printStackTrace();
    }Try the following (NOTE: requires using WindowsLookAndFeel, I don't see the problem when using Metal, for example):
    1. Click on the "Files of type" combo box to drop down its choices, then click it again to collapse it. Do this twice or more (it seems that doing it just once isn't sufficient to see the problem)
    2. Grab its right-hand side and shrink the size of the JFileChooser horizontally.
    3. Click on the combo box again. Note that the popup containing the choices list is too wide.
    4. Now, hover the mouse over either the "Open" or "Cancel" JButton. Note that the JToolTip size was incorrectly calculated for its contents (looks to maybe the same size as the popup for the JComboBox?).
    This doesn't seem to happen for me with Java 6. Is this a known issue? Or is this just the price you pay for picking up a random Java 7 beta? :)
    Edited by: BoBear2681 on Nov 6, 2010 10:40 AM

    Hi,
    On February 2 2010 I filed a bug report that got an internal review ID of 1709860, which is NOT
    visible on the Sun Developer Network (SDN).
    I never heard of it again.
    I added a demo of the problem (executable in the JDK development test system, but also stand alone) . For me the test fails on all versions of JDK 7 that I tested. It runs fine on JDK 6.
    Could you verify that this demo reveals the same problem as you encountered?
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import sun.awt.SunToolkit;
    public class TestMenu {
         * Without a delay, SunToolkit may encounter a problem in SunToolkit (at
         * least in JDK 6, where the drop down size problem is not present).
         * Note: SunToolkit also has some mechanism to delay, but I forgot how it
         * worked.
         * <pre>
         * Exception in thread "main" sun.awt.SunToolkit$InfiniteLoop
         *         at sun.awt.SunToolkit.realSync(Unknown Source)
         *         at TestMenu.syncAndDelay(TestMenu.java:172)
         *         at TestMenu.click(TestMenu.java:88)
         *         at TestMenu.moveAndClickCenter(TestMenu.java:150)
         *         at TestMenu.main(TestMenu.java:45)
         * </pre>
         * As a bonus, the delay makes the scenario better visible for the human
         * eye.
        private static int delay = 500;
        private static JMenu[] menus = new JMenu[5];
        private static Dimension[] parentSizes;
        private static Robot robot;
        private static SunToolkit toolkit;
        public static void main(String[] args) throws Exception {
         robot = new Robot();
         toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
         parentSizes = new Dimension[menus.length];
         createGUI();
         // Open the first menu.
         // Then get the drop down size of all menu's
         moveAndClickCenter(menus[0]);
         for (int index = 0; index < menus.length; index++) {
             parentSizes[index] = getDropDownSize(index);
         // Click the last item on the last menu.
         Component item = menus[menus.length - 1]
              .getMenuComponent(menus[menus.length - 1]
                   .getMenuComponentCount() - 1);
         moveAndClickCenter(item);
         // Open the last drop down again.
         // Then get the drop down sizes once more.
         // If size not equal to previous size, then it's a bug.
         boolean bug = false;
         moveAndClickCenter(menus[menus.length - 1]);
         for (int index = menus.length - 1; index >= 0; index--) {
             Dimension currentSize = getDropDownSize(index);
             System.out.print("old: " + parentSizes[index] + ", new: "
                  + currentSize);
             if (!parentSizes[index].equals(currentSize)) {
              bug = true;
              System.out.println(" ERROR");
             } else {
              System.out.println();
         if (bug) {
             throw new RuntimeException(
                  "JMenu drop down size is changed for no reason.");
        private static Dimension getDropDownSize(int index) throws Exception {
         moveToCenter(menus[index]);
         return menus[index].getMenuComponent(0).getParent().getSize();
        private static void click() throws Exception {
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
         syncAndDelay();
        private static void createGUI() throws Exception {
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
             public void run() {
              // The L&F defines the drop down policy.
              UIManager.LookAndFeelInfo[] infos = UIManager
                   .getInstalledLookAndFeels();
              for (final UIManager.LookAndFeelInfo info : infos) {
                  if (info.getName().toLowerCase().indexOf("metal") >= 0) {
                   if (!UIManager.getLookAndFeel().getName().equals(
                        info.getName())) {
                       try {
                        UIManager.setLookAndFeel(info.getClassName());
                        System.out
                             .println("Attempt to set look and feel to "
                                  + info.getName());
                       } catch (Exception e) {
                        e.printStackTrace();
                   } else {
                       System.out
                            .println("Metal look and feel is the default");
                   break;
              System.out.println("Testing with "
                   + UIManager.getLookAndFeel().getName());
              // Setup the GUI.
              JFrame frame = new JFrame("A frame");
              frame.setJMenuBar(new JMenuBar());
              for (int menuIndex = 0; menuIndex < menus.length; menuIndex++) {
                  menus[menuIndex] = new JMenu("Menu " + menuIndex);
                  frame.getJMenuBar().add(menus[menuIndex]);
                  for (int itemIndex = 0; itemIndex <= menus.length
                       - menuIndex; itemIndex++) {
                   // It seems that the problem only occurs if the drop
                   // down is displayed outside the frame at the right
                   // (not sure though).
                   // A rather long item name.
                   JMenuItem item = new JMenuItem("Menu " + menuIndex
                        + " item " + itemIndex);
                   menus[menuIndex].add(item);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.pack();
              frame.setLocationRelativeTo(null);
              frame.setVisible(true);
         syncAndDelay();
        private static void moveAndClickCenter(Component c) throws Exception {
         moveToCenter(c);
         click();
        private static void moveToCenter(final Component c) throws Exception {
         final Point cp = new Point();
         SwingUtilities.invokeAndWait(new Runnable() {
             @Override
             public void run() {
              Point p = new Point(c.getWidth() / 2, c.getHeight() / 2);
              SwingUtilities.convertPointToScreen(p, c);
              cp.setLocation(p);
         robot.mouseMove(cp.x, cp.y);
         syncAndDelay();
        private static void syncAndDelay() throws Exception {
         if (delay > 0) {
             Thread.sleep(delay);
         toolkit.realSync();
    }Piet

Maybe you are looking for

  • How do I create multiple midi tracks each with separate external synthesizer sound

    Mac Pro OS 10.10.2, Logic Pro 10.1.1, FireFace 800 (updated), Roland XP-30 synthesizer/keyboard, Mackie mixer. XP-30 analog output to Mackie, FireFace monitor to FireFace main inputs and FireFace out to Mackie. What I can't get to work: Sound output

  • Error deploying the composite on soa_server1: Deployment Failed ..

    Hi, I am trying to access external webservice from my BPEL Process; imported the external system's wsdl with xsd into my local & change all the reference of the xsd in my wsdl ,which now pointing to local xsd etc. I am getting the following error whi

  • FM for List of all Products

    Hi , Can anyone help me in finding out the FM for the List of all Products   without specifying any input fields. Regards, Sijo.

  • [1.1.2.25.79] Program hangs after starting long runnin SQL with parameters

    Hello Forum, I'm currently tuning some SQLs with parameters that run some minutes. When I enter the SQL in the worksheet and press F9, SQL Developer asks for the parameters. But after clicking "Apply" (or whatever it is called in the english version,

  • Ok to deploy live sites?

    In the original webinar for the BETA release I asked if it was ok to deploy live sites using new apps etc and was told yes it's ok. But after seeing in this forum how much change is going on behind the scenes, sounds like it will be quite risky - cou