/** * Initialise le panneau du bouton de validation */ private void initPanneauBoutonValidation(){ this.setPanneauBoutousValidation(new JPanel()); this.getPanneauBoutousValidation().setLayout(new BoxLayout(this.getPanneauBoutousValidation(), BoxLayout.LINE_AXIS)); this.getPanneauBoutousValidation().setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); this.setBoutonValider(new JButton("Valider")); this.setBoutonAnnule(new JButton("Annuler")); this.getPanneauBoutousValidation().add(this.getBoutonValider()); this.getPanneauBoutousValidation().add(Box.createRigidArea(new Dimension(10, 0))); this.getPanneauBoutousValidation().add(this.getBoutonAnnule()); this.getPanneauBoutousValidation().add(Box.createHorizontalGlue()); this.getContentPane().add(this.getPanneauBoutousValidation()); this.getPanneauBoutousValidation().setVisible(true); }
public void changeOrientationOfJPanelToRight() { thePanel.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); Component panelComponents[] = thePanel.getComponents(); for (int i = 0; i < panelComponents.length; i++) { if(panelComponents[i] instanceof JPanel) { JPanel panel = (JPanel) panelComponents[i]; if(panel.getComponentOrientation().isLeftToRight()) { panel.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); } } if(panelComponents[i] instanceof JButton) { JButton button = (JButton) panelComponents[i]; if(button.getComponentOrientation().isLeftToRight()) { button.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); } } } }
public void changeOrientationOfJPanelToLeft() { thePanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); Component panelComponents[] = thePanel.getComponents(); for (int i = 0; i < panelComponents.length; i++) { if(panelComponents[i] instanceof JPanel) { JPanel panel = (JPanel) panelComponents[i]; if(!panel.getComponentOrientation().isLeftToRight()) { panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); } } if(panelComponents[i] instanceof JButton) { JButton button = (JButton) panelComponents[i]; if(!button.getComponentOrientation().isLeftToRight()) { button.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); } } } }
/** * {@inheritDoc} */ @Override public void setComponentOrientation(ComponentOrientation o) { // Some LaFs might do fun stuff, resulting in this method being called // before a border is installed. if (getBorder() instanceof GutterBorder) { // Reuse the border to preserve its color. if (o.isLeftToRight()) { ((GutterBorder)getBorder()).setEdges(0, 0, 0, 1); } else { ((GutterBorder)getBorder()).setEdges(0, 1, 0, 0); } } super.setComponentOrientation(o); }
public TestFrame() { super("TestFrame"); // The change of the orientation and the reverse order of // adding the buttons to the panel is because in Container.removeNotify() // the child components are removed in the reverse order. // We want that the focus owner (b0) would be removed first and // that the next traversable component would be b1. panel0.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); panel0.add(b2); panel0.add(b1); panel0.add(b0); panel1.add(b3); panel1.add(b4); setLayout(new FlowLayout()); add(panel0); add(panel1); pack(); panel0.setBackground(Color.red); panel1.setBackground(Color.blue); }
public void validateThird() { JViewport viewport = this.pane.getViewport(); JScrollBar scroller = this.pane.getHorizontalScrollBar(); if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) { throw new Error("unexpected component orientation"); } int value = scroller.getValue(); if (value != 0) { throw new Error("unexpected scroll value"); } int extent = viewport.getExtentSize().width; if (extent != scroller.getVisibleAmount()) { throw new Error("unexpected visible amount"); } int size = viewport.getViewSize().width; if (size != scroller.getMaximum()) { throw new Error("unexpected maximum"); } int pos = size - extent - value; if (pos != viewport.getViewPosition().x) { throw new Error("unexpected position"); } }
static void TestInvariants() { System.out.println(" TestInvariants {"); Assert(ComponentOrientation.LEFT_TO_RIGHT.isLeftToRight(), "LEFT_TO_RIGHT.isLeftToRight()"); Assert(ComponentOrientation.UNKNOWN.isLeftToRight(), "UNKNOWN.isLeftToRight()"); Assert(!ComponentOrientation.RIGHT_TO_LEFT.isLeftToRight(), "!RIGHT_TO_LEFT.isLeftToRight()"); Assert(ComponentOrientation.LEFT_TO_RIGHT.isHorizontal(), "LEFT_TO_RIGHT.isHorizontal()"); Assert(ComponentOrientation.UNKNOWN.isHorizontal(), "UNKNOWN.isHorizontal()"); Assert(ComponentOrientation.RIGHT_TO_LEFT.isHorizontal(), "RIGHT_TO_LEFT.isHorizontal()"); System.out.println(" } Pass"); }
private static void showFileChooser() throws Exception { if (tryLookAndFeel(lookAndFeelComboBox.getSelectedItem().toString())) { openChooser = new JFileChooser(); ComponentOrientation orientation = ComponentOrientation.UNKNOWN; switch (orientationComboBox.getSelectedItem().toString()) { case orientationLTR: orientation = ComponentOrientation.LEFT_TO_RIGHT; break; case orientationRTL: orientation = ComponentOrientation.RIGHT_TO_LEFT; break; } openChooser.setComponentOrientation(orientation); openChooser.showOpenDialog(frame); } }
/** Construct a FileTree */ public FileTree(File dir) { setLayout(new BorderLayout()); applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); setBorder(null); // Make a tree list with all the nodes, and make it a JTree JTree tree = new JTree(addNodes(null, dir)); tree.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); // Add a listener tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) e .getPath().getLastPathComponent(); } }); add(BorderLayout.CENTER, tree); JScrollPane scrollBarExplorer = new JScrollPane(); scrollBarExplorer.getViewport().add(tree); scrollBarExplorer.setBorder(null); add(scrollBarExplorer, BorderLayout.CENTER); }
public JFilePicker(String textFieldLabel, String buttonLabel) { setLayout(new FlowLayout(FlowLayout.CENTER, 5, 1)); // creates the GUI label = new JLabel(textFieldLabel); label.setFont(new Font("Arial", Font.BOLD, 16)); textField = new JTextField(30); textField.setFont(new Font("Arial", Font.PLAIN, 12)); textField.setText(WorkspaceFile.getPathWorkspace()); button = new JButton(buttonLabel); button.setFont(new Font("Arial", Font.BOLD, 14)); label.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); textField.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); button.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); add(button); add(textField); add(label); button.addActionListener(this); }
/** * Returns the row index of the last visible row. * */ int getLastVisibleRowIndex(JTable table) { ComponentOrientation or = table.getComponentOrientation(); Rectangle r = table.getVisibleRect(); r.translate(0, (int) r.getHeight() - 1); if (or.isLeftToRight()) r.translate((int) r.getWidth() - 1, 0); // The next if makes sure that we don't return -1 simply because // there is white space at the bottom of the table (ie, the display // area is larger than the table) if (table.rowAtPoint(r.getLocation()) == -1) { if (getFirstVisibleRowIndex(table) == -1) return -1; else return table.getModel().getRowCount() - 1; } return table.rowAtPoint(r.getLocation()); }
/** * Displays this panel in a modal resizable dialog box. */ public void displayView(View parentView) { String dialogTitle = preferences.getLocalizedString(PrintPreviewPanel.class, "printPreview.title"); JOptionPane optionPane = new JOptionPane(this, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION); if (parentView != null) { optionPane.setComponentOrientation(((JComponent) parentView).getComponentOrientation()); } JDialog dialog = optionPane.createDialog(SwingUtilities.getRootPane((JComponent) parentView), dialogTitle); dialog.applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault())); dialog.setResizable(true); // Pack again because resize decorations may have changed dialog preferred size dialog.pack(); dialog.setMinimumSize(dialog.getPreferredSize()); dialog.setVisible(true); dialog.dispose(); }
public static int getPageAxisConstant() { if (PlatformFriend.RUNNING_ON_JAVA_14_OR_HIGHER) { return BoxLayout.PAGE_AXIS; } else { ComponentOrientation componentOrientation = ComponentOrientation.getOrientation(Locale.getDefault()); if (componentOrientation.isHorizontal()) return BoxLayout.Y_AXIS; else return BoxLayout.X_AXIS; } }
/** * Constructs a <code>AbstractFormBuilder</code> * for the given FormLayout and layout container. * * @param layout the {@link FormLayout} to use * @param container the layout container * * @throws NullPointerException if the layout or container is null */ public AbstractFormBuilder(FormLayout layout, Container container) { if (layout == null) throw new NullPointerException("The layout must not be null."); if (container == null) throw new NullPointerException("The layout container must not be null."); this.container = container; this.layout = layout; container.setLayout(layout); currentCellConstraints = new CellConstraints(); ComponentOrientation orientation = container.getComponentOrientation(); leftToRight = orientation.isLeftToRight() || !orientation.isHorizontal(); }
/** * Creates a new instance using the specified parameters. * * @param player the {@link Player} this panel is to represent. * @param orientation the current {@link ComponentOrientation}. * @param engineSettings the settings panel for this {@link Player} or * {@code null}. * @param configuration the {@link PmsConfiguration}. * @param tabListenerRegistrar the {@link TranscodingTabListenerRegistrar}. */ public EnginePanel( @Nonnull Player player, @Nonnull ComponentOrientation orientation, @Nullable JComponent engineSettings, @Nonnull PmsConfiguration configuration, @Nullable TranscodingTabListenerRegistrar tabListenerRegistrar ) { super(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); if (player == null) { throw new IllegalArgumentException("player cannot be null"); } if (orientation == null) { throw new IllegalArgumentException("orientation cannot be null"); } this.player = player; this.orientation = orientation; this.engineSettings = engineSettings; this.configuration = configuration; this.cardListenerRegistrar = tabListenerRegistrar == null ? null : new CardListenerRegistrar(tabListenerRegistrar, this); build(); }
public void propertyChange(PropertyChangeEvent ev) { // If help pane was garbage collected, remove this listener from preferences HelpPane helpPane = this.helpPane.get(); UserPreferences preferences = (UserPreferences) ev.getSource(); if (helpPane == null) { preferences.removePropertyChangeListener(UserPreferences.Property.LANGUAGE, this); } else { // Update frame title and search label with new locale if (helpPane.frame != null) { helpPane.frame.setTitle(preferences.getLocalizedString(HelpPane.class, "helpFrame.title")); helpPane.frame.applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault())); } helpPane.searchLabel .setText(SwingTools.getLocalizedLabelText(preferences, HelpPane.class, "searchLabel.text")); helpPane.searchTextField.setText(""); helpPane.setMnemonics(preferences); } }
public BottomLegendToolbar(ProjectFrame frame, LayerLegendPanel panel, GeOxygeneApplication appli) { super(); this.setFrame(frame); this.setPanel(panel); this.setAppli(appli); this.initGeomBtn = new JButton(new ShowIniGeomAction(appli)); this.rawDisplayBtn = new JToggleButton(new RawDisplayAction()); this.idDisplayBtn = new JToggleButton(new DisplayIdAction()); this.eliminatedBtn = new JToggleButton(new ShowEliminatedAction()); this.add(rawDisplayBtn); this.add(initGeomBtn); this.add(idDisplayBtn); this.add(eliminatedBtn); this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); this.setFloatable(false); this.setOrientation(HORIZONTAL); }
public static final int convertToGravity(int horizontalAlign, ComponentOrientation orien){ if(orien == null){ orien = ComponentOrientation.LEFT_TO_RIGHT; } if(horizontalAlign == SwingConstants.CENTER){ return Gravity.CENTER | Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL; }else if(horizontalAlign == SwingConstants.LEFT || (orien.isLeftToRight() && horizontalAlign == SwingConstants.LEADING) || (orien.isLeftToRight() == false && horizontalAlign == SwingConstants.TRAILING)){ return Gravity.LEFT; }else if(horizontalAlign == SwingConstants.RIGHT || (orien.isLeftToRight() == false && horizontalAlign == SwingConstants.LEADING) || (orien.isLeftToRight() && horizontalAlign == SwingConstants.TRAILING)){ return Gravity.RIGHT; } return 0; }
public void propertyChange(PropertyChangeEvent ev) { // If photo panel was garbage collected, remove this listener from preferences PhotosPanel photoPanel = this.photoPanel.get(); UserPreferences preferences = (UserPreferences) ev.getSource(); if (photoPanel == null) { preferences.removePropertyChangeListener(UserPreferences.Property.LANGUAGE, this); } else { photoPanel.setComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault())); photoPanel.setComponentTexts(preferences); photoPanel.setMnemonics(preferences); } }
public void propertyChange(PropertyChangeEvent ev) { // If photo panel was garbage collected, remove this listener from preferences PhotoSizeAndQualityPanel photoPanel = this.photoPanel.get(); UserPreferences preferences = (UserPreferences) ev.getSource(); if (photoPanel == null) { preferences.removePropertyChangeListener(UserPreferences.Property.LANGUAGE, this); } else { photoPanel.setComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault())); photoPanel.setComponentTexts(preferences); photoPanel.setMnemonics(preferences); } }
private JPanel createLicensePanel() { JPanel panel = new JPanel(new GridLayout(1, 2, 5, 5)); panel.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); panel.setOpaque(false); JPanel scrollPane = this.createDetailPanel(); panel.add(scrollPane); this.createTextArea(); JScrollPane scrollPane1 = new JScrollPane(this.textArea); scrollPane1.setBorder((Border)null); panel.add(scrollPane1); return panel; }
/** * initialisation du panneaux contenant les boutons qui permettent d'ajouter * une personne */ private void initBoutonAjouter() { JPanel panneauChamp = new JPanel(); panneauChamp.setLayout(new BoxLayout(panneauChamp, BoxLayout.LINE_AXIS)); panneauChamp.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); JScrollPane pane = new JScrollPane(panneauChamp); this.add(pane, BorderLayout.EAST); pane.setVisible(true); panneauChamp.add(Box.createHorizontalGlue()); panneauChamp.add(new JLabel("Nom : ")); panneauChamp.add(Box.createRigidArea(new Dimension(5, 0))); this.nom = new JTextField(5); panneauChamp.add(nom); panneauChamp.add(Box.createRigidArea(new Dimension(10, 0))); panneauChamp.add(new JLabel("Prenom : ")); panneauChamp.add(Box.createRigidArea(new Dimension(5, 0))); this.prenom = new JTextField(5); panneauChamp.add(prenom); panneauChamp.add(Box.createRigidArea(new Dimension(10, 0))); panneauChamp.add(new JLabel("Fonction : ")); panneauChamp.add(Box.createRigidArea(new Dimension(5, 0))); this.fonction = new JTextField(10); panneauChamp.add(fonction); panneauChamp.add(Box.createRigidArea(new Dimension(20, 0))); panneauChamp.add(new JButton(new ActionAjouterPersonne())); this.add(panneauChamp); }
/** * Initialise la fenêtre */ private void initFenetre(){ this.setTitle(DEFAULT_TITLE); this.setLocationRelativeTo(null); this.setModalityType(TYPE_MODAL); this.setResizable(false); this.getContentPane().setLayout(new BoxLayout(getContentPane(),BoxLayout.PAGE_AXIS)); this.getContentPane().setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); }
protected void buildStepTitle() { ttlLabel = new JLabel(wizard.getStepDescription(wizard.getAllSteps()[0])); ttlLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory .createEmptyBorder(5, 5, 12, 5), BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager .getColor("textText")))); // NOI18N ttlPanel = new JPanel() { private static final long serialVersionUID = 1L; public void doLayout() { Dimension d = ttlLabel.getPreferredSize(); if (ttlLabel.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT) { ttlLabel.setBounds(getWidth() - d.width, 0, getWidth(), d.height); } else { ttlLabel.setBounds(0, 0, getWidth(), d.height); } } public Dimension getPreferredSize() { return ttlLabel.getPreferredSize(); } }; ttlPanel.add(ttlLabel); Font f = ttlLabel.getFont(); if (f == null) { f = UIManager.getFont("controlFont"); // NOI18N } if (f != null) { f = f.deriveFont(Font.BOLD); ttlLabel.setFont(f); } }
public void changeOrientationOfJDialogToRight() { theDialog.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); for (int i = 0; i < theDialog.getContentPane().getComponentCount(); i++) { if (theDialog.getContentPane().getComponent(i).getComponentOrientation().isLeftToRight()) { theDialog.getContentPane().getComponent(i).setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); theDialog.revalidate(); theDialog.repaint(); } } }
public void changeOrientationOfJDialogToLeft() { theDialog.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); for (int i = 0; i < theDialog.getContentPane().getComponentCount(); i++) { if (!theDialog.getContentPane().getComponent(i).getComponentOrientation().isLeftToRight()) { theDialog.getContentPane().getComponent(i).setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); theDialog.revalidate(); theDialog.repaint(); } } }
public void changeOrientationOfJFrameToRight() { theFrame.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); for (int i = 0; i < theFrame.getContentPane().getComponentCount(); i++) { if (theFrame.getContentPane().getComponent(i).getComponentOrientation().isLeftToRight()) { theFrame.getContentPane().getComponent(i).setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); theFrame.revalidate(); theFrame.repaint(); } } }
public void changeOrientationOfJFrameToLeft() { theFrame.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); for (int i = 0; i < theFrame.getContentPane().getComponentCount(); i++) { if (!theFrame.getContentPane().getComponent(i).getComponentOrientation().isLeftToRight()) { theFrame.getContentPane().getComponent(i).setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); theFrame.revalidate(); theFrame.repaint(); } } }
public void changeOrientationOfJMenubarToRight() { theMenuBar.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); for (int i = 0; i < theMenuBar.getComponentCount(); i++) { if (theMenuBar.getComponent(i).getComponentOrientation().isLeftToRight()) { theMenuBar.getComponent(i).applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); theMenuBar.revalidate(); theMenuBar.repaint(); } } }
public void changeOrientationOfJMenubarToLeft() { theMenuBar.applyComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); for (int i = 0; i < theMenuBar.getComponentCount(); i++) { if (!theMenuBar.getComponent(i).getComponentOrientation().isLeftToRight()) { theMenuBar.getComponent(i).applyComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); theMenuBar.revalidate(); theMenuBar.repaint(); } } }