List of usage examples for javax.swing JComponent getComponentOrientation
public ComponentOrientation getComponentOrientation()
From source file:Main.java
/** * Initialises the {@link JDialog} for the {@link JComponent}. * //from w w w. j a v a 2 s. c o m * @param dialog * @param component * @param parentComponent */ private static void initDialog(final JDialog dialog, final JComponent component, final Component parentComponent) { dialog.setResizable(true); dialog.setComponentOrientation(component.getComponentOrientation()); Container contentPane = dialog.getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add(component, BorderLayout.CENTER); final int buttonWidth = 75; final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); buttonPanel.setBorder(BorderFactory.createEmptyBorder(2, 4, 4, 4)); buttonPanel.add(Box.createHorizontalGlue()); @SuppressWarnings("serial") final Action closeAction = new AbstractAction("Close") { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }; final JButton button = new JButton(closeAction); fixWidth(button, buttonWidth); buttonPanel.add(button); contentPane.add(buttonPanel, BorderLayout.SOUTH); if (JDialog.isDefaultLookAndFeelDecorated()) { boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations(); if (supportsWindowDecorations) { dialog.setUndecorated(true); component.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG); } } dialog.pack(); dialog.setLocationRelativeTo(parentComponent); WindowAdapter adapter = new WindowAdapter() { // private boolean gotFocus = false; public void windowClosing(WindowEvent we) { fireAction(we.getSource(), closeAction, "close"); } }; dialog.addWindowListener(adapter); dialog.addWindowFocusListener(adapter); }