import java.awt.*; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import javax.swing.*; import sun.awt.SunToolkit; public class JComboboxTestRTLTestDemo extends JFrame { JPanel jPanel = new JPanel(); JPanel mainPanel = new JPanel(); private javax.swing.JComboBox cBox; private Robot robot; SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); public static void main(String[] args) throws Exception { JComboboxTestRTLTestDemo t = new JComboboxTestRTLTestDemo(); t.createAndShowGUI(); t.toolkit.realSync(); t.test(); System.exit(0); } private void createAndShowGUI() throws Exception { String[] cars = { "BMW" , "Lexus", "Honda", "Toyota", "Nissan" }; cBox = new javax.swing.JComboBox(cars); //cBox.setEditable(rootPaneCheckingEnabled); cBox.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); cBox.setMaximumRowCount(3); robot = new Robot(); robot.setAutoDelay(50); cBox.setEnabled(true); mainPanel.setLayout(new BorderLayout()); jPanel.add(cBox, BorderLayout.CENTER); mainPanel.add(jPanel, BorderLayout.CENTER); getContentPane().add(jPanel); setSize(300,150); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setVisible(true); } private void test() { Point p = cBox.getLocationOnScreen(); int height = cBox.getSize().height; int width = cBox.getSize().width; p.translate(width - 10, height - 10); robot.mouseMove(new Double(p.getX()).intValue(),new Double(p.getY()).intValue()); robot.mousePress(InputEvent.BUTTON1_MASK ); robot.mouseRelease(InputEvent.BUTTON1_MASK ); toolkit.realSync(); robot.delay(5000); } }