List of usage examples for java.awt ComponentOrientation LEFT_TO_RIGHT
ComponentOrientation LEFT_TO_RIGHT
To view the source code for java.awt ComponentOrientation LEFT_TO_RIGHT.
Click Source Link
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame("MenuSample Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); // File Menu, F - Mnemonic JMenu fileMenu = new JMenu("File"); fileMenu.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New"); fileMenu.add(newMenuItem);//from w w w. jav a 2 s. c om frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { FlowLayout layout = new FlowLayout(FlowLayout.LEADING, horizontalGap, verticalGap); JButton button = new JButton("Discard"); JLabel[] panels = new JLabel[5]; JFrame frame = new JFrame("Poker"); frame.setSize(width, height);//from w ww.j av a2 s. co m frame.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); JPanel deckPanel = new JPanel(layout); for (int i = 0; i < 5; i++) { panels[i] = new JLabel("" + i); deckPanel.add(panels[i]); } frame.getContentPane().add(deckPanel); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); buttonPanel.add(button); frame.getContentPane().add(buttonPanel, BorderLayout.SOUTH); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static JPanel getPanelFlowLayoutHorizontal(int w, int h, int type) { JPanel panel = new JPanel(); FlowLayout layout = new FlowLayout(); layout.setAlignment(type);/*from w ww . j a v a 2 s . c o m*/ panel.setLayout(layout); panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); panel.setPreferredSize(getControlDimension(w, h)); panel.setMinimumSize(getControlDimension(w, h)); return panel; }
From source file:Main.java
public static void SetJTableAlignment(javax.swing.JTable jTable, ComponentOrientation componentOrientation) { Font tahoma = new Font("Tahoma", Font.PLAIN, 11); int labelAlighnment = JLabel.RIGHT; int headerAlighnment = JLabel.RIGHT; if (componentOrientation == ComponentOrientation.LEFT_TO_RIGHT) { labelAlighnment = JLabel.LEFT; headerAlighnment = JLabel.LEFT; }/*from ww w .j a va 2 s. c om*/ DefaultTableCellRenderer defaultTableCellRenderer = new DefaultTableCellRenderer(); defaultTableCellRenderer.setHorizontalAlignment(labelAlighnment); // defaultTableCellRenderer.setFont(tahoma); for (int columnIndex = 0; columnIndex < jTable.getColumnCount(); columnIndex++) { if (jTable.getModel().getColumnClass(columnIndex).equals(Boolean.class)) { jTable.getColumnModel().getColumn(columnIndex).setWidth(60); jTable.getColumnModel().getColumn(columnIndex).setMaxWidth(90); jTable.getColumnModel().getColumn(columnIndex).setMinWidth(10); jTable.getColumnModel().getColumn(columnIndex).setPreferredWidth(60); continue; } if (jTable.getModel().getColumnClass(columnIndex).equals(ImageIcon.class)) { continue; } jTable.getColumnModel().getColumn(columnIndex).setCellRenderer(defaultTableCellRenderer); } DefaultTableCellRenderer renderer; renderer = (DefaultTableCellRenderer) jTable.getTableHeader().getDefaultRenderer(); renderer.setHorizontalAlignment(headerAlighnment); jTable.getTableHeader().setDefaultRenderer(renderer); }
From source file:Main.java
/** * Checks if is left orientation./*w w w. j ava 2 s . co m*/ * * @return true, if is left orientation */ public static boolean isLeftOrientation() { return defaultComponentOrientation == ComponentOrientation.LEFT_TO_RIGHT; }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT; menu.applyComponentOrientation(ori); bar.add(menu);/*from w w w . j ava 2 s. c o m*/ menu.add(new JMenuItem("Close")); menu.add(new JSeparator()); // SEPARATOR menu.add(new JMenuItem("Exit")); setJMenuBar(bar); add(new JLabel("A placeholder")); pack(); setSize(300, 300); setVisible(true); menu.doClick(100); }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT; menu.applyComponentOrientation(ori); bar.add(menu);/* w w w . j a v a 2 s .c o m*/ menu.add(new JMenuItem("Close")); menu.add(new JSeparator()); // SEPARATOR menu.add(new JMenuItem("Exit")); setJMenuBar(bar); add(new JLabel("A placeholder")); pack(); setSize(300, 300); setVisible(true); System.out.println(menu.getDelay()); }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT; menu.applyComponentOrientation(ori); bar.add(menu);// w w w. j av a2 s . c o m menu.add(new JMenuItem("Close")); menu.add(new JSeparator()); // SEPARATOR menu.add(new JMenuItem("Exit")); setJMenuBar(bar); add(new JLabel("A placeholder")); pack(); setSize(300, 300); setVisible(true); System.out.println(menu.getItemCount()); }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT; menu.applyComponentOrientation(ori); bar.add(menu);/*w w w. ja v a 2 s .c om*/ menu.add(new JMenuItem("Close")); menu.add(new JSeparator()); // SEPARATOR menu.add(new JMenuItem("Exit")); setJMenuBar(bar); add(new JLabel("A placeholder")); pack(); setSize(300, 300); setVisible(true); Component c = menu.getMenuComponent(1); }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT; menu.applyComponentOrientation(ori); bar.add(menu);//w w w . ja v a2s. c o m menu.add(new JMenuItem("Close")); menu.add(new JSeparator()); // SEPARATOR menu.add(new JMenuItem("Exit")); setJMenuBar(bar); add(new JLabel("A placeholder")); pack(); setSize(300, 300); setVisible(true); Component c = menu.getComponent(); }