Java Code Examples for java.awt.FlowLayout#RIGHT
The following examples show how to use
java.awt.FlowLayout#RIGHT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GuiUtils.java From sc2gears with Apache License 2.0 | 6 votes |
/** * Adds a link-style edit list label to the bottom of the popup of the specified combo box.<br> * When the link is activated (clicked), the editTask will be run. * @param comboBox combo box to add the edit link to * @param editTask edit task to be performed when the link is activated */ public static void addEditListLinkToComboBoxPopup( final JComboBox< ? > comboBox, final Runnable editTask ) { final Object child = comboBox.getUI().getAccessibleChild( comboBox, 0 ); if ( child instanceof JPopupMenu ) { final JPanel editPanel = new JPanel( new FlowLayout( FlowLayout.RIGHT, 3, 1 ) ); final JLabel editLinkLabel = GeneralUtils.createLinkStyledLabel( Language.getText( "general.editList" ) ); editLinkLabel.addMouseListener( new MouseAdapter() { public void mousePressed( final MouseEvent event ) { comboBox.hidePopup(); editTask.run(); }; } ); editPanel.add( editLinkLabel ); ( (JPopupMenu) child ).add( editPanel ); } }
Example 2
Source File: SetSkin_ClassName.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Creates the main frame for <code>this</code> sample. */ public SetSkin_ClassName() { super("Set skin"); this.setLayout(new BorderLayout()); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JButton changeSkin = new JButton("Change skin"); changeSkin.addActionListener((ActionEvent e) -> SwingUtilities.invokeLater(() -> { changeSkin.setEnabled(false); // set new skin by class name SubstanceCortex.GlobalScope .setSkin("org.pushingpixels.substance.api.skin.BusinessSkin"); repaint(); })); controls.add(changeSkin); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
Example 3
Source File: KeyImporterView.java From pgptool with GNU General Public License v3.0 | 5 votes |
private JPanel buildPanelButtons() { JPanel ret = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); ret.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); ret.add(btnImport = new JButton()); ret.add(btnCancel = new JButton()); return ret; }
Example 4
Source File: FirstSwitchFrame.java From ramus with GNU General Public License v3.0 | 5 votes |
public FirstSwitchFrame() { setTitle(MessageFormat.format(GlobalResourcesManager .getString("File.Launcher"), Metadata.getApplicationName())); this.setIconImage(Toolkit.getDefaultToolkit().getImage( getClass().getResource("/com/ramussoft/gui/application.png"))); JPanel bottom = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JPanel buttons = new JPanel(new GridLayout(1, 2, 5, 0)); fileLocation.setPreferredSize(new Dimension(500, fileLocation .getPreferredSize().width)); fileLocation.setEditable(true); String[] files = Runner.getLastOpenedFiles(); for (String file : files) { File file2 = new File(file); if ((file2.exists()) && (file2.canRead())) { fileLocation.addItem(file); } } String lastFile = Options.getString("LAST_FILE_FIRST"); if (lastFile != null) { fileLocation.setSelectedItem(lastFile); } buttons.add(new JButton(okAction)); buttons.add(new JButton(cancelAction)); bottom.add(buttons); getContentPane().setLayout(new BorderLayout()); getContentPane().add(bottom, BorderLayout.SOUTH); getContentPane().add(createCenterPanel(), BorderLayout.CENTER); setDefaultCloseOperation(DISPOSE_ON_CLOSE); pack(); setResizable(false); setLocationRelativeTo(null); if (doNotAsk.isSelected()) { ok(); } }
Example 5
Source File: GuiUtils.java From sc2gears with Apache License 2.0 | 5 votes |
/** * Applies some formatting on the specified info label, creates a right aligned wrapper panel for it, adds it and returns the panel. * @param infoLabel info label to be wrapped * @param vgap vgap of the wrapper panel (passed to {@link FlowLayout#FlowLayout(int, int, int)} * @return the wrapper panel */ public static JPanel createRightAlignedInfoWrapperPanel( final JLabel infoLabel, final int vgap ) { GuiUtils.changeFontToItalic( infoLabel ); infoLabel.setFont( infoLabel.getFont().deriveFont( (float) ( infoLabel.getFont().getSize() - 2 ) ) ); final JPanel wrapper = new JPanel( new FlowLayout( FlowLayout.RIGHT, 5, vgap ) ); wrapper.add( infoLabel ); return wrapper; }
Example 6
Source File: ChartPanel.java From javamelody with Apache License 2.0 | 5 votes |
final void refresh() throws IOException { removeAll(); setName(graphLabel); final JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); southPanel.setOpaque(false); zoomValue = 0; final byte[] imageData = getRemoteCollector().collectJRobin(graphName, CHART_WIDTH, CHART_HEIGHT); if (imageData != null) { this.imageIcon = new ImageIcon(imageData); this.imageLabel = new MTransferableLabel(imageIcon); // ce name sera utilisé comme nom de fichier pour le drag and drop de l'image this.imageLabel.setName(graphLabel); final JScrollPane scrollPane = new JScrollPane(imageLabel); scrollPane.setHorizontalScrollBarPolicy( ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); add(scrollPane, BorderLayout.CENTER); southPanel.add(createSlider()); } else { this.imageIcon = null; this.imageLabel = null; } southPanel.add(createButtonsPanel()); add(southPanel, BorderLayout.SOUTH); }
Example 7
Source File: ExplorationCustomInfoPanel.java From mars-sim with GNU General Public License v3.0 | 5 votes |
/** * Constructor * @param siteName the site name. * @param completion the completion level. */ ExplorationSitePanel(String siteName, double completion) { // Use JPanel constructor. super(); this.completion = completion; setLayout(new GridLayout(1, 2, 3, 3)); WebPanel namePanel = new WebPanel(new FlowLayout(FlowLayout.RIGHT, 3, 3)); namePanel.setAlignmentX(CENTER_ALIGNMENT); add(namePanel); WebLabel nameLabel = new WebLabel(" " + Conversion.capitalize(siteName), SwingConstants.RIGHT); nameLabel.setAlignmentX(CENTER_ALIGNMENT); namePanel.add(nameLabel); WebPanel barPanel = new WebPanel(new FlowLayout(FlowLayout.LEFT, 3, 0)); barPanel.setAlignmentX(CENTER_ALIGNMENT); add(barPanel); completionBar = new WebProgressBar(0, 100); completionBar.setAlignmentX(CENTER_ALIGNMENT); completionBar.setStringPainted(true); completionBar.setValue((int) (completion * 100D)); barPanel.add(completionBar); }
Example 8
Source File: ScoreDialog.java From FancyBing with GNU General Public License v3.0 | 5 votes |
private ColorFields createColorEntry(String labelText, int cols, String toolTipBlack, String toolTipWhite, JComponent labels, JComponent values) { labels.add(createEntryLabel(labelText)); ColorFields colorFields = new ColorFields(); JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); panel.add(new JLabel(ICON_BLACK)); panel.add(GuiUtil.createSmallFiller()); JTextField black = new JTextField(cols); black.setHorizontalAlignment(JTextField.CENTER); colorFields.m_black = black; GuiUtil.setEditableFalse(black); if (toolTipBlack != null) black.setToolTipText(i18n(toolTipBlack)); panel.add(black); panel.add(GuiUtil.createFiller()); panel.add(new JLabel(ICON_WHITE)); panel.add(GuiUtil.createSmallFiller()); JTextField white = new JTextField(cols); white.setHorizontalAlignment(JTextField.CENTER); colorFields.m_white = white; GuiUtil.setEditableFalse(white); if (toolTipWhite != null) white.setToolTipText(i18n(toolTipWhite)); panel.add(white); values.add(panel); return colorFields; }
Example 9
Source File: ScoreDialog.java From FancyBing with GNU General Public License v3.0 | 5 votes |
private JTextField createKomiEntry(int cols, JComponent labels, JComponent values) { labels.add(createEntryLabel("LB_SCORE_KOMI")); JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); panel.add(new JLabel(ICON_WHITE)); panel.add(GuiUtil.createSmallFiller()); JTextField field = new JTextField(cols); field.setHorizontalAlignment(JTextField.CENTER); GuiUtil.setEditableFalse(field); field.setToolTipText(i18n("TT_SCORE_KOMI")); panel.add(field); values.add(panel); return field; }
Example 10
Source File: AboutDialog.java From ramus with GNU General Public License v3.0 | 5 votes |
public AboutDialog(JFrame frame, List<Plugin> plugins, List<GUIPlugin> guiPlugins) { super(frame, true); this.setTitle(GlobalResourcesManager.getString("About")); this.plugins = plugins.subList(0, plugins.size()); this.guiPlugins = guiPlugins; this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); JTabbedPane pane = new JTabbedPane(); pane.addTab(GlobalResourcesManager.getString("About.MainTab"), createAboutComponent()); pane.addTab(GlobalResourcesManager.getString("About.PluginList"), createPluginListComponent()); pane.addTab(GlobalResourcesManager.getString("About.GUIPluginList"), createGUIPluginListComponent()); pane.addTab(GlobalResourcesManager.getString("About.ThirdParts"), createThirdPartsComponnt()); JPanel panel = new JPanel(new BorderLayout()); panel.add(pane, BorderLayout.CENTER); JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); bottomPanel.add(new JButton(new AbstractAction(GlobalResourcesManager .getString("ok")) { /** * */ private static final long serialVersionUID = -8334150633007409370L; @Override public void actionPerformed(ActionEvent e) { setVisible(false); } })); panel.add(bottomPanel, BorderLayout.SOUTH); this.setContentPane(panel); setSize(600, 350); setResizable(false); setLocationRelativeTo(null); }
Example 11
Source File: XOperations.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public void loadOperations(XMBean mbean, MBeanInfo mbeanInfo) { this.mbean = mbean; this.mbeanInfo = mbeanInfo; // add operations information MBeanOperationInfo operations[] = mbeanInfo.getOperations(); invalidate(); // remove listeners, if any Component listeners[] = getComponents(); for (int i = 0; i < listeners.length; i++) { if (listeners[i] instanceof JButton) { ((JButton) listeners[i]).removeActionListener(this); } } removeAll(); setLayout(new BorderLayout()); JButton methodButton; JLabel methodLabel; JPanel innerPanelLeft, innerPanelRight; JPanel outerPanelLeft, outerPanelRight; outerPanelLeft = new JPanel(new GridLayout(operations.length, 1)); outerPanelRight = new JPanel(new GridLayout(operations.length, 1)); for (int i = 0; i < operations.length; i++) { innerPanelLeft = new JPanel(new FlowLayout(FlowLayout.RIGHT)); innerPanelRight = new JPanel(new FlowLayout(FlowLayout.LEFT)); String returnType = operations[i].getReturnType(); if (returnType == null) { methodLabel = new JLabel("null", JLabel.RIGHT); if (JConsole.isDebug()) { System.err.println( "WARNING: The operation's return type " + "shouldn't be \"null\". Check how the " + "MBeanOperationInfo for the \"" + operations[i].getName() + "\" operation has " + "been defined in the MBean's implementation code."); } } else { methodLabel = new JLabel( Utils.getReadableClassName(returnType), JLabel.RIGHT); } innerPanelLeft.add(methodLabel); if (methodLabel.getText().length() > 20) { methodLabel.setText(methodLabel.getText(). substring(methodLabel.getText(). lastIndexOf(".") + 1, methodLabel.getText().length())); } methodButton = new JButton(operations[i].getName()); methodButton.setToolTipText(operations[i].getDescription()); boolean callable = isCallable(operations[i].getSignature()); if (callable) { methodButton.addActionListener(this); } else { methodButton.setEnabled(false); } MBeanParameterInfo[] signature = operations[i].getSignature(); OperationEntry paramEntry = new OperationEntry(operations[i], callable, methodButton, this); operationEntryTable.put(methodButton, paramEntry); innerPanelRight.add(methodButton); if (signature.length == 0) { innerPanelRight.add(new JLabel("( )", JLabel.CENTER)); } else { innerPanelRight.add(paramEntry); } outerPanelLeft.add(innerPanelLeft, BorderLayout.WEST); outerPanelRight.add(innerPanelRight, BorderLayout.CENTER); } add(outerPanelLeft, BorderLayout.WEST); add(outerPanelRight, BorderLayout.CENTER); validate(); }
Example 12
Source File: Welcome.java From btdex with GNU General Public License v3.0 | 4 votes |
public Welcome(JFrame owner, boolean resetPin) { super(owner, ModalityType.APPLICATION_MODAL); setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.resetPin = resetPin; setTitle(tr(resetPin ? "welc_reset_pin" : "welc_welcome")); setResizable(false); JPanel topPanel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new GridLayout(0, 2, 4, 4)); if(!resetPin) { JPanel introPanel = new JPanel(new BorderLayout()); String title = "<html><h2>" + tr("welc_intro_header") + "</h2>"; introPanel.add(new JLabel(title), BorderLayout.PAGE_START); String intro = "<html>" + tr("welc_intro_text") + "<br><br>" + tr("welc_intro_pin"); introText = new JLabel(intro); introText.setPreferredSize(new Dimension(60, 120)); introPanel.add(introText, BorderLayout.PAGE_END); useLedgerButton = new JButton(tr("welc_use_ledger")); useLedgerButton.addActionListener(this); introPanel.add(useLedgerButton, BorderLayout.CENTER); topPanel.add(introPanel, BorderLayout.CENTER); } passphrase = new JTextArea(2, 40); passphrase.setWrapStyleWord(true); passphrase.setLineWrap(true); passphrase.setEditable(false); pin = new JPasswordField(12); pinCheck = new JPasswordField(12); acceptBox = new JCheckBox(tr("welc_wrote")); recoverBox = new JCheckBox(tr("welc_reuse")); recoverBox.addActionListener(this); JPanel recoveryPanel = new JPanel(new BorderLayout()); recoveryPanel.setBorder(BorderFactory.createTitledBorder(tr(resetPin ? "welc_prhase_to_redefine" : "welc_recovery_phrase"))); recoveryPanel.add(recoverBox, BorderLayout.PAGE_START); recoveryPanel.add(passphrase, BorderLayout.CENTER); recoveryPanel.add(acceptBox, BorderLayout.PAGE_END); topPanel.add(recoveryPanel, BorderLayout.PAGE_END); // Create a button JPanel buttonPane = new JPanel(new FlowLayout(FlowLayout.RIGHT)); calcelButton = new JButton(tr("dlg_cancel")); okButton = new JButton(tr("dlg_ok")); getRootPane().setDefaultButton(okButton); calcelButton.addActionListener(this); okButton.addActionListener(this); panel.add(new Desc(tr("dlg_pin"), pin)); panel.add(new Desc(tr("welc_reenter_pin"), pinCheck)); // buttonPane.add(acceptBox); buttonPane.add(calcelButton); buttonPane.add(okButton); // set action listener on the button JPanel content = (JPanel)getContentPane(); content.setBorder(new EmptyBorder(4, 4, 4, 4)); content.add(topPanel, BorderLayout.PAGE_START); content.add(panel, BorderLayout.CENTER); content.add(buttonPane, BorderLayout.PAGE_END); if(resetPin) { passphrase.setText(""); passphrase.setEditable(true); passphrase.requestFocus(); recoverBox.setVisible(false); acceptBox.setSelected(true); acceptBox.setVisible(false); } else newPass(); pack(); addWindowListener(new WindowAdapter() { @Override public void windowActivated(WindowEvent event) { SwingUtilities.invokeLater(new Runnable() { public void run() { acceptBox.requestFocusInWindow(); } }); } }); }
Example 13
Source File: UnregisterSkinChangeListener.java From radiance with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Creates the main frame for <code>this</code> sample. */ public UnregisterSkinChangeListener() { super("Register skin change listener"); this.setLayout(new BorderLayout()); JPanel panel = new JPanel(new FlowLayout()); // Get all skin display names and set the vector as a model // for combobox. final JComboBox<String> cb = new JComboBox<>( new Vector<>(SubstanceCortex.GlobalScope.getAllSkins().keySet())); cb.setSelectedIndex(-1); cb.addItemListener((ItemEvent evt) -> { // Get the affected item final String item = (String) evt.getItem(); if (evt.getStateChange() == ItemEvent.SELECTED) { SwingUtilities.invokeLater(() -> { try { // Get the skin info object based on // the selected skin display name SkinInfo skinInfo = SubstanceCortex.GlobalScope.getAllSkins().get(item); // Set the global skin based on the // skin class name. SubstanceCortex.GlobalScope.setSkin(skinInfo.getClassName()); SwingUtilities.updateComponentTreeUI(UnregisterSkinChangeListener.this); } catch (Exception exc) { } }); } }); panel.add(new JLabel("All skins:")); panel.add(cb); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JButton unregisterListener = new JButton("Unregister listener"); unregisterListener.addActionListener((ActionEvent e) -> SwingUtilities.invokeLater(() -> { unregisterListener.setEnabled(false); // unregister listener SubstanceCortex.GlobalScope.unregisterSkinChangeListener(listener); })); controls.add(unregisterListener); this.add(controls, BorderLayout.SOUTH); this.add(panel, BorderLayout.CENTER); // register listener SubstanceCortex.GlobalScope.registerSkinChangeListener(listener = () -> { // show dialog with skin changed message. SwingUtilities.invokeLater(() -> JOptionPane.showMessageDialog(UnregisterSkinChangeListener.this, "Skin changed")); }); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
Example 14
Source File: SetMenuGutterFillKind.java From radiance with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Creates the main frame for <code>this</code> sample. */ public SetMenuGutterFillKind() { super("Menu gutter fill kind"); setLayout(new BorderLayout()); // create sample menu bar with one menu and a few menu items JMenuBar jmb = new JMenuBar(); JMenu menu = new JMenu("menu"); menu.add(new JMenuItem("test item 1", mx.of(16, 16))); menu.add(new JMenuItem("test item 2")); menu.add(new JMenuItem("test item 3")); menu.addSeparator(); menu.add(new JMenuItem("test menu item 4")); menu.add(new JMenuItem("test menu item 5", se.of(16, 16))); menu.add(new JMenuItem("test menu item 6")); jmb.add(menu); setJMenuBar(jmb); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JComboBox<MenuGutterFillKind> menuGutterFillCombo = new JComboBox<>( new MenuGutterFillKind[] { MenuGutterFillKind.NONE, MenuGutterFillKind.SOFT, MenuGutterFillKind.HARD, MenuGutterFillKind.SOFT_FILL, MenuGutterFillKind.HARD_FILL}); menuGutterFillCombo.setRenderer(new SubstanceDefaultComboBoxRenderer(menuGutterFillCombo) { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { MenuGutterFillKind mgfk = (MenuGutterFillKind) value; return super.getListCellRendererComponent(list, mgfk.name().toLowerCase(), index, isSelected, cellHasFocus); } }); menuGutterFillCombo.setSelectedItem(MenuGutterFillKind.HARD); // based on the selected item, set the global menu gutter fill kind menuGutterFillCombo.addActionListener((ActionEvent e) -> SubstanceCortex.GlobalScope .setMenuGutterFillKind((MenuGutterFillKind) menuGutterFillCombo.getSelectedItem())); controls.add(new JLabel("Menu fill")); controls.add(menuGutterFillCombo); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
Example 15
Source File: XOperations.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public void loadOperations(XMBean mbean, MBeanInfo mbeanInfo) { this.mbean = mbean; this.mbeanInfo = mbeanInfo; // add operations information MBeanOperationInfo operations[] = mbeanInfo.getOperations(); invalidate(); // remove listeners, if any Component listeners[] = getComponents(); for (int i = 0; i < listeners.length; i++) { if (listeners[i] instanceof JButton) { ((JButton) listeners[i]).removeActionListener(this); } } removeAll(); setLayout(new BorderLayout()); JButton methodButton; JLabel methodLabel; JPanel innerPanelLeft, innerPanelRight; JPanel outerPanelLeft, outerPanelRight; outerPanelLeft = new JPanel(new GridLayout(operations.length, 1)); outerPanelRight = new JPanel(new GridLayout(operations.length, 1)); for (int i = 0; i < operations.length; i++) { innerPanelLeft = new JPanel(new FlowLayout(FlowLayout.RIGHT)); innerPanelRight = new JPanel(new FlowLayout(FlowLayout.LEFT)); String returnType = operations[i].getReturnType(); if (returnType == null) { methodLabel = new JLabel("null", JLabel.RIGHT); if (JConsole.isDebug()) { System.err.println( "WARNING: The operation's return type " + "shouldn't be \"null\". Check how the " + "MBeanOperationInfo for the \"" + operations[i].getName() + "\" operation has " + "been defined in the MBean's implementation code."); } } else { methodLabel = new JLabel( Utils.getReadableClassName(returnType), JLabel.RIGHT); } innerPanelLeft.add(methodLabel); if (methodLabel.getText().length() > 20) { methodLabel.setText(methodLabel.getText(). substring(methodLabel.getText(). lastIndexOf('.') + 1, methodLabel.getText().length())); } methodButton = new JButton(operations[i].getName()); methodButton.setToolTipText(operations[i].getDescription()); boolean callable = isCallable(operations[i].getSignature()); if (callable) { methodButton.addActionListener(this); } else { methodButton.setEnabled(false); } MBeanParameterInfo[] signature = operations[i].getSignature(); OperationEntry paramEntry = new OperationEntry(operations[i], callable, methodButton, this); operationEntryTable.put(methodButton, paramEntry); innerPanelRight.add(methodButton); if (signature.length == 0) { innerPanelRight.add(new JLabel("( )", JLabel.CENTER)); } else { innerPanelRight.add(paramEntry); } outerPanelLeft.add(innerPanelLeft, BorderLayout.WEST); outerPanelRight.add(innerPanelRight, BorderLayout.CENTER); } add(outerPanelLeft, BorderLayout.WEST); add(outerPanelRight, BorderLayout.CENTER); validate(); }
Example 16
Source File: ComboBoxPopupFlyoutOrientation.java From radiance with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Creates the main frame for <code>this</code> sample. */ public ComboBoxPopupFlyoutOrientation() { super("Combobox popup flyout orientation"); this.setLayout(new BorderLayout()); final JComboBox<String> cb = new JComboBox<>( new String[] { "Ester", "Jordi", "Jordina", "Jorge", "Sergi" }); JPanel main = new JPanel(new FlowLayout(FlowLayout.CENTER)); this.add(main, BorderLayout.CENTER); main.add(cb); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JComboBox<String> flyoutCombo = new JComboBox<>( new String[] { "default", "center", "north", "east", "west", "south" }); flyoutCombo.addActionListener((ActionEvent e) -> { Object selected = flyoutCombo.getSelectedItem(); // set popup flyout orientation based on the selected // item if ("default".equals(selected)) SubstanceCortex.ComponentScope.setComboBoxPopupFlyoutOrientation(cb, null); if ("center".equals(selected)) SubstanceCortex.ComponentScope.setComboBoxPopupFlyoutOrientation(cb, SwingConstants.CENTER); if ("north".equals(selected)) SubstanceCortex.ComponentScope.setComboBoxPopupFlyoutOrientation(cb, SwingConstants.NORTH); if ("east".equals(selected)) SubstanceCortex.ComponentScope.setComboBoxPopupFlyoutOrientation(cb, SwingConstants.EAST); if ("west".equals(selected)) SubstanceCortex.ComponentScope.setComboBoxPopupFlyoutOrientation(cb, SwingConstants.WEST); if ("south".equals(selected)) SubstanceCortex.ComponentScope.setComboBoxPopupFlyoutOrientation(cb, SwingConstants.SOUTH); }); controls.add(new JLabel("Combo popup flyout orientation")); controls.add(flyoutCombo); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
Example 17
Source File: XOperations.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public void loadOperations(XMBean mbean, MBeanInfo mbeanInfo) { this.mbean = mbean; this.mbeanInfo = mbeanInfo; // add operations information MBeanOperationInfo operations[] = mbeanInfo.getOperations(); invalidate(); // remove listeners, if any Component listeners[] = getComponents(); for (int i = 0; i < listeners.length; i++) { if (listeners[i] instanceof JButton) { ((JButton) listeners[i]).removeActionListener(this); } } removeAll(); setLayout(new BorderLayout()); JButton methodButton; JLabel methodLabel; JPanel innerPanelLeft, innerPanelRight; JPanel outerPanelLeft, outerPanelRight; outerPanelLeft = new JPanel(new GridLayout(operations.length, 1)); outerPanelRight = new JPanel(new GridLayout(operations.length, 1)); for (int i = 0; i < operations.length; i++) { innerPanelLeft = new JPanel(new FlowLayout(FlowLayout.RIGHT)); innerPanelRight = new JPanel(new FlowLayout(FlowLayout.LEFT)); String returnType = operations[i].getReturnType(); if (returnType == null) { methodLabel = new JLabel("null", JLabel.RIGHT); if (JConsole.isDebug()) { System.err.println( "WARNING: The operation's return type " + "shouldn't be \"null\". Check how the " + "MBeanOperationInfo for the \"" + operations[i].getName() + "\" operation has " + "been defined in the MBean's implementation code."); } } else { methodLabel = new JLabel( Utils.getReadableClassName(returnType), JLabel.RIGHT); } innerPanelLeft.add(methodLabel); if (methodLabel.getText().length() > 20) { methodLabel.setText(methodLabel.getText(). substring(methodLabel.getText(). lastIndexOf(".") + 1, methodLabel.getText().length())); } methodButton = new JButton(operations[i].getName()); methodButton.setToolTipText(operations[i].getDescription()); boolean callable = isCallable(operations[i].getSignature()); if (callable) { methodButton.addActionListener(this); } else { methodButton.setEnabled(false); } MBeanParameterInfo[] signature = operations[i].getSignature(); OperationEntry paramEntry = new OperationEntry(operations[i], callable, methodButton, this); operationEntryTable.put(methodButton, paramEntry); innerPanelRight.add(methodButton); if (signature.length == 0) { innerPanelRight.add(new JLabel("( )", JLabel.CENTER)); } else { innerPanelRight.add(paramEntry); } outerPanelLeft.add(innerPanelLeft, BorderLayout.WEST); outerPanelRight.add(innerPanelRight, BorderLayout.CENTER); } add(outerPanelLeft, BorderLayout.WEST); add(outerPanelRight, BorderLayout.CENTER); validate(); }
Example 18
Source File: TransportRegistrationDialog.java From Spark with Apache License 2.0 | 4 votes |
/** * Initiation Dialog with the tranport service name. * * @param serviceName the name of the transport service. */ public TransportRegistrationDialog(DomainBareJid serviceName) { setLayout(new GridBagLayout()); this.serviceName = serviceName; ResourceUtils.resButton(registerButton, Res.getString("button.save")); ResourceUtils.resButton(cancelButton, Res.getString("button.cancel")); final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonPanel.add(registerButton); registerButton.requestFocus(); buttonPanel.add(cancelButton); transport = TransportUtils.getTransport(serviceName); final TitlePanel titlePanel = new TitlePanel(transport.getTitle(), transport.getInstructions(), transport.getIcon(), true); int line = 0; add(titlePanel, new GridBagConstraints(0, line, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); line++; final JLabel usernameLabel = new JLabel(); usernameLabel.setFont(new Font("Dialog", Font.BOLD, 11)); ResourceUtils.resLabel(usernameLabel, usernameField, Res.getString("label.username") + ":"); add(usernameLabel, new GridBagConstraints(0, line, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(usernameField, new GridBagConstraints(1, line, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); line++; final JLabel passwordLabel = new JLabel(); passwordLabel.setFont(new Font("Dialog", Font.BOLD, 11)); ResourceUtils.resLabel(passwordLabel, passwordField, Res.getString("label.password") + ":"); add(passwordLabel, new GridBagConstraints(0, line, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(passwordField, new GridBagConstraints(1, line, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); if (transport.requiresNickname()) { line++; final JLabel nicknameLabel = new JLabel(); nicknameLabel.setFont(new Font("Dialog", Font.BOLD, 11)); ResourceUtils.resLabel(nicknameLabel, nicknameField, Res.getString("label.nickname") + ":"); add(nicknameLabel, new GridBagConstraints(0, line, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(nicknameField, new GridBagConstraints(1, line, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0,0)); } line++; add(buttonPanel, new GridBagConstraints(0, line, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); }
Example 19
Source File: MonitorRCWindow.java From wpcleaner with Apache License 2.0 | 4 votes |
/** * @return Window components. */ @Override protected Component createComponents() { JPanel panel = new JPanel(new GridBagLayout()); // Initialize constraints GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridheight = 1; constraints.gridwidth = 1; constraints.gridx = 0; constraints.gridy = 0; constraints.insets = new Insets(0, 0, 0, 0); constraints.ipadx = 0; constraints.ipady = 0; constraints.weightx = 0; constraints.weighty = 0; // Recent changes table constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 1; constraints.weighty = 1; modelRC = new RecentChangesTableModel(null); tableRC = new JTable(modelRC); modelRC.configureColumnModel(tableRC.getColumnModel()); JScrollPane scrollRC = new JScrollPane(tableRC); scrollRC.setMinimumSize(new Dimension(300, 200)); scrollRC.setPreferredSize(new Dimension(800, 300)); scrollRC.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); panel.add(scrollRC, constraints); constraints.gridy++; // Interesting recent changes table constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 1; constraints.weighty = 1; modelRCInteresting = new RecentChangesTableModel(null); tableRCInteresting = new JTable(modelRCInteresting); modelRCInteresting.configureColumnModel(tableRCInteresting.getColumnModel()); JScrollPane scrollRCInteresting = new JScrollPane(tableRCInteresting); scrollRCInteresting.setMinimumSize(new Dimension(300, 200)); scrollRCInteresting.setPreferredSize(new Dimension(800, 300)); scrollRCInteresting.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); panel.add(scrollRCInteresting, constraints); constraints.gridy++; // Buttons JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton buttonClose = ActionDispose.createButton(getParentComponent(), true, false); buttonPanel.add(buttonClose); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 0; constraints.weightx = 1; constraints.weighty = 0; panel.add(buttonPanel, constraints); constraints.gridy++; updateComponentState(); monitoredPages = new HashMap<String, Long>(); createDabWarning = new UpdateDabWarningTools(getWikipedia(), this, true); updateDabWarning = new UpdateDabWarningTools(getWikipedia(), this, false); API api = APIFactory.getAPI(); api.addRecentChangesListener(getWikipedia(), this); return panel; }
Example 20
Source File: CroppingPanel.java From 3Dscript with BSD 2-Clause "Simplified" License | 4 votes |
public CroppingPanel(ImagePlus image) { super(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); int near = (int)Math.floor(getNear(image)); int far = (int)Math.ceil(getFar(image)); c.gridy = 0; nearfar = addDoubleSlider( "near/far", new int[] {near, far}, new int[] {near, far}, new Color(255, 0, 0, 100), c); bbX = addDoubleSlider( "x_range", new int[] {0, image.getWidth()}, new int[] {0, image.getWidth()}, new Color(255, 0, 0, 100), c); bbY = addDoubleSlider( "y_range", new int[] {0, image.getHeight()}, new int[] {0, image.getHeight()}, new Color(255, 0, 0, 100), c); bbZ = addDoubleSlider( "z_range", new int[] {0, image.getNSlices()}, new int[] {0, image.getNSlices()}, new Color(255, 0, 0, 100), c); nearfar.addSliderChangeListener(new DoubleSlider.Listener() { @Override public void sliderChanged() { fireNearFarChanged(nearfar.getMin(), nearfar.getMax()); } }); JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0)); allChannels = new JCheckBox("Apply to all channels", true); buttons.add(allChannels); JButton b = new JButton("Cut off ROI"); buttons.add(b); c.gridx = 0; c.insets = new Insets(7, 0, 0, 0); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; c.gridwidth = GridBagConstraints.REMAINDER; gridbag.setConstraints(buttons, c); add(buttons); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new Thread() { @Override public void run() { fireCutOffROI(); } }.start(); } }); DoubleSlider.Listener bbListener = new DoubleSlider.Listener() { @Override public void sliderChanged() { fireBoundingBoxChanged( bbX.getMin(), bbY.getMin(), bbZ.getMin(), bbX.getMax(), bbY.getMax(), bbZ.getMax()); } }; bbX.addSliderChangeListener(bbListener); bbY.addSliderChangeListener(bbListener); bbZ.addSliderChangeListener(bbListener); }