Java Code Examples for java.awt.GridBagConstraints#RELATIVE
The following examples show how to use
java.awt.GridBagConstraints#RELATIVE .
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: ServiceDialog.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public PageSetupPanel() { super(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); c.fill = GridBagConstraints.BOTH; c.insets = panelInsets; c.weightx = 1.0; c.weighty = 1.0; c.gridwidth = GridBagConstraints.REMAINDER; pnlMedia = new MediaPanel(); addToGB(pnlMedia, this, gridbag, c); pnlOrientation = new OrientationPanel(); c.gridwidth = GridBagConstraints.RELATIVE; addToGB(pnlOrientation, this, gridbag, c); pnlMargins = new MarginsPanel(); pnlOrientation.addOrientationListener(pnlMargins); pnlMedia.addMediaListener(pnlMargins); c.gridwidth = GridBagConstraints.REMAINDER; addToGB(pnlMargins, this, gridbag, c); }
Example 2
Source File: ServiceDialog.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public AppearancePanel() { super(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); c.fill = GridBagConstraints.BOTH; c.insets = panelInsets; c.weightx = 1.0; c.weighty = 1.0; c.gridwidth = GridBagConstraints.RELATIVE; pnlChromaticity = new ChromaticityPanel(); addToGB(pnlChromaticity, this, gridbag, c); c.gridwidth = GridBagConstraints.REMAINDER; pnlQuality = new QualityPanel(); addToGB(pnlQuality, this, gridbag, c); c.gridwidth = 1; pnlSides = new SidesPanel(); addToGB(pnlSides, this, gridbag, c); c.gridwidth = GridBagConstraints.REMAINDER; pnlJobAttributes = new JobAttributesPanel(); addToGB(pnlJobAttributes, this, gridbag, c); }
Example 3
Source File: ServiceDialog.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public AppearancePanel() { super(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); c.fill = GridBagConstraints.BOTH; c.insets = panelInsets; c.weightx = 1.0; c.weighty = 1.0; c.gridwidth = GridBagConstraints.RELATIVE; pnlChromaticity = new ChromaticityPanel(); addToGB(pnlChromaticity, this, gridbag, c); c.gridwidth = GridBagConstraints.REMAINDER; pnlQuality = new QualityPanel(); addToGB(pnlQuality, this, gridbag, c); c.gridwidth = 1; pnlSides = new SidesPanel(); addToGB(pnlSides, this, gridbag, c); c.gridwidth = GridBagConstraints.REMAINDER; pnlJobAttributes = new JobAttributesPanel(); addToGB(pnlJobAttributes, this, gridbag, c); }
Example 4
Source File: AboutDialog.java From ignite with Apache License 2.0 | 5 votes |
/** * License field. * * @return Grid bag constraints. */ private GridBagConstraints gbcLicenseField() { gbc.gridx = 1; gbc.gridwidth = GridBagConstraints.RELATIVE; gbc.weightx = 400; gbc.insets = new Insets(0, 10, 5, 10); return gbc; }
Example 5
Source File: AboutDialog.java From ignite with Apache License 2.0 | 5 votes |
/** * License label. * * @return Grid bag constraints. */ private GridBagConstraints gbcLicenseLabel() { gbc.gridx = 0; gbc.gridwidth = GridBagConstraints.RELATIVE; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(0, 10, 5, 0); return gbc; }
Example 6
Source File: ListViewBuilder.java From raccoon4 with Apache License 2.0 | 5 votes |
@Override protected JPanel assemble() { list = new JPanel(); list.setLayout(new GridBagLayout()); appListItems = new Vector<ListItemBuilder>(); spacer = new JPanel(); itemConstraints = new GridBagConstraints(); itemConstraints.gridx = GridBagConstraints.REMAINDER; itemConstraints.gridy = GridBagConstraints.RELATIVE; itemConstraints.anchor = GridBagConstraints.NORTHWEST; itemConstraints.fill = GridBagConstraints.NONE; itemConstraints.weightx = 0; itemConstraints.weighty = 0; itemConstraints.ipady = 5; spacerConstraints = new GridBagConstraints(); spacerConstraints.gridx = GridBagConstraints.REMAINDER; spacerConstraints.gridy = GridBagConstraints.RELATIVE; spacerConstraints.anchor = GridBagConstraints.NORTHWEST; spacerConstraints.fill = GridBagConstraints.BOTH; spacerConstraints.weightx = 1; spacerConstraints.weighty = 1; clear(); installAction = new InstallAction(globals); Messages.getLocalizer().localize(installAction, "adbinstall"); globals.get(BridgeManager.class).addBridgeListener(installAction); deleteAction = new DeleteAction(globals); Messages.getLocalizer().localize(deleteAction, "deleteapps"); exportAction = new ExportAction(globals); Messages.getLocalizer().localize(exportAction, "export"); return list; }
Example 7
Source File: TestResultsPanel.java From tmc-intellij with MIT License | 5 votes |
private void createConstraints() { GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = GridBagConstraints.RELATIVE; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.weightx = 1.0; gbc.weighty = 0.0; // don't stretch vertically gbc.insets.top = MARGIN; this.resultsListConstraints = gbc; }
Example 8
Source File: SummaryInfoTab.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
private void initComponents() { this.setFocusCycleRoot(true); this.setFocusTraversalPolicyProvider(true); this.setFocusTraversalPolicy(new SummaryTabFocusTraversalPolicy()); LanguageTableModel.initializeTable(languageTable); setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); setPanelTitle(basicsPanel, LanguageBundle.getString("in_sumCharacterBasics")); //$NON-NLS-1$ basicsPanel.setLayout(new GridBagLayout()); deityComboBox.setRenderer(infoBoxRenderer); raceComboBox.setRenderer(infoBoxRenderer); classComboBox.setRenderer(classBoxRenderer); gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 0.1; gbc.weighty = 0.7; add(basicsPanel, gbc); setPanelTitle(todoPanel, LanguageBundle.getString("in_tipsString")); //$NON-NLS-1$ initTodoPanel(todoPanel); gbc.gridy = 1; gbc.gridheight = GridBagConstraints.REMAINDER; add(todoPanel, gbc); initMiddlePanel(scoresPanel); gbc.gridy = GridBagConstraints.RELATIVE; gbc.weightx = 1; add(scoresPanel, gbc); JPanel rightPanel = new JPanel(); setPanelTitle(racePanel, LanguageBundle.getString("in_raceString")); //$NON-NLS-1$ setPanelTitle(classPanel, LanguageBundle.getString("in_sumClassLevel")); //$NON-NLS-1$ initRightPanel(rightPanel); gbc.weightx = 0.1; gbc.weighty = 1; add(rightPanel, gbc); }
Example 9
Source File: ScrLexicon.java From PolyGlot with MIT License | 5 votes |
/** * Sets up and drops the filter menu into the UI */ private void setupFilterMenu() { GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridheight = GridBagConstraints.RELATIVE; c.gridwidth = GridBagConstraints.RELATIVE; jPanel1.setLayout(new GridLayout()); jPanel1.add(fxPanel, c); jPanel1.setBackground(Color.white); fxPanel.setBackground(Color.white); final CountDownLatch latch = new CountDownLatch(1); Platform.setImplicitExit(false); Platform.runLater(() -> { fxPanel.setScene(createScene()); setupComboBoxesFX(); latch.countDown(); }); try { latch.await(); } catch (InterruptedException e) { IOHandler.writeErrorLog(e); InfoBox.error("Form Load Error", "Unable to load Lexicon: " + e.getLocalizedMessage(), core.getRootWindow()); } gridTitlePane.setTooltip(new Tooltip(FILTER_LABEL)); }
Example 10
Source File: ServiceDialog.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public PageSetupPanel() { super(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); c.fill = GridBagConstraints.BOTH; c.insets = panelInsets; c.weightx = 1.0; c.weighty = 1.0; c.gridwidth = GridBagConstraints.REMAINDER; pnlMedia = new MediaPanel(); addToGB(pnlMedia, this, gridbag, c); pnlOrientation = new OrientationPanel(); c.gridwidth = GridBagConstraints.RELATIVE; addToGB(pnlOrientation, this, gridbag, c); pnlMargins = new MarginsPanel(); pnlOrientation.addOrientationListener(pnlMargins); pnlMedia.addMediaListener(pnlMargins); c.gridwidth = GridBagConstraints.REMAINDER; addToGB(pnlMargins, this, gridbag, c); }
Example 11
Source File: ServiceDialog.java From hottub with GNU General Public License v2.0 | 5 votes |
public PageSetupPanel() { super(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); c.fill = GridBagConstraints.BOTH; c.insets = panelInsets; c.weightx = 1.0; c.weighty = 1.0; c.gridwidth = GridBagConstraints.REMAINDER; pnlMedia = new MediaPanel(); addToGB(pnlMedia, this, gridbag, c); pnlOrientation = new OrientationPanel(); c.gridwidth = GridBagConstraints.RELATIVE; addToGB(pnlOrientation, this, gridbag, c); pnlMargins = new MarginsPanel(); pnlOrientation.addOrientationListener(pnlMargins); pnlMedia.addMediaListener(pnlMargins); c.gridwidth = GridBagConstraints.REMAINDER; addToGB(pnlMargins, this, gridbag, c); }
Example 12
Source File: ServiceDialog.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public PageSetupPanel() { super(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); c.fill = GridBagConstraints.BOTH; c.insets = panelInsets; c.weightx = 1.0; c.weighty = 1.0; c.gridwidth = GridBagConstraints.REMAINDER; pnlMedia = new MediaPanel(); addToGB(pnlMedia, this, gridbag, c); pnlOrientation = new OrientationPanel(); c.gridwidth = GridBagConstraints.RELATIVE; addToGB(pnlOrientation, this, gridbag, c); pnlMargins = new MarginsPanel(); pnlOrientation.addOrientationListener(pnlMargins); pnlMedia.addMediaListener(pnlMargins); c.gridwidth = GridBagConstraints.REMAINDER; addToGB(pnlMargins, this, gridbag, c); }
Example 13
Source File: SummaryInfoTab.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
private void initComponents() { this.setFocusCycleRoot(true); this.setFocusTraversalPolicyProvider(true); this.setFocusTraversalPolicy(new SummaryTabFocusTraversalPolicy()); LanguageTableModel.initializeTable(languageTable); setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); setPanelTitle(basicsPanel, LanguageBundle.getString("in_sumCharacterBasics")); //$NON-NLS-1$ basicsPanel.setLayout(new GridBagLayout()); deityComboBox.setRenderer(infoBoxRenderer); raceComboBox.setRenderer(infoBoxRenderer); classComboBox.setRenderer(classBoxRenderer); gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 0.1; gbc.weighty = 0.7; add(basicsPanel, gbc); setPanelTitle(todoPanel, LanguageBundle.getString("in_tipsString")); //$NON-NLS-1$ initTodoPanel(todoPanel); gbc.gridy = 1; gbc.gridheight = GridBagConstraints.REMAINDER; add(todoPanel, gbc); initMiddlePanel(scoresPanel); gbc.gridy = GridBagConstraints.RELATIVE; gbc.weightx = 1; add(scoresPanel, gbc); JPanel rightPanel = new JPanel(); setPanelTitle(racePanel, LanguageBundle.getString("in_raceString")); //$NON-NLS-1$ setPanelTitle(classPanel, LanguageBundle.getString("in_sumClassLevel")); //$NON-NLS-1$ initRightPanel(rightPanel); gbc.weightx = 0.1; gbc.weighty = 1; add(rightPanel, gbc); }
Example 14
Source File: ExportImage.java From Logisim with GNU General Public License v3.0 | 4 votes |
OptionsPanel(JList<?> list) { // set up components formatPng = new JRadioButton("PNG"); formatGif = new JRadioButton("GIF"); formatJpg = new JRadioButton("JPEG"); ButtonGroup bgroup = new ButtonGroup(); bgroup.add(formatPng); bgroup.add(formatGif); bgroup.add(formatJpg); formatPng.setSelected(true); slider = new JSlider(SwingConstants.HORIZONTAL, -3 * SLIDER_DIVISIONS, 3 * SLIDER_DIVISIONS, 0); slider.setMajorTickSpacing(10); slider.addChangeListener(this); curScale = new JLabel("222%"); curScale.setHorizontalAlignment(SwingConstants.RIGHT); curScale.setVerticalAlignment(SwingConstants.CENTER); curScaleDim = new Dimension(curScale.getPreferredSize()); curScaleDim.height = Math.max(curScaleDim.height, slider.getPreferredSize().height); stateChanged(null); printerView = new JCheckBox(); printerView.setSelected(true); // set up panel gridbag = new GridBagLayout(); gbc = new GridBagConstraints(); setLayout(gridbag); // now add components into panel gbc.gridy = 0; gbc.gridx = GridBagConstraints.RELATIVE; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.insets = new Insets(5, 0, 5, 0); gbc.fill = GridBagConstraints.NONE; addGb(new JLabel(Strings.get("labelCircuits") + " ")); gbc.fill = GridBagConstraints.HORIZONTAL; addGb(new JScrollPane(list)); gbc.fill = GridBagConstraints.NONE; gbc.gridy++; addGb(new JLabel(Strings.get("labelImageFormat") + " ")); Box formatsPanel = new Box(BoxLayout.Y_AXIS); formatsPanel.add(formatPng); formatsPanel.add(formatGif); formatsPanel.add(formatJpg); addGb(formatsPanel); gbc.gridy++; addGb(new JLabel(Strings.get("labelScale") + " ")); addGb(slider); addGb(curScale); gbc.gridy++; addGb(new JLabel(Strings.get("labelPrinterView") + " ")); addGb(printerView); }
Example 15
Source File: ServiceDialog.java From hottub with GNU General Public License v2.0 | 4 votes |
public PrintServicePanel() { super(); uiFactory = psCurrent.getServiceUIFactory(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); setBorder(BorderFactory.createTitledBorder(strTitle)); String[] psnames = new String[services.length]; for (int i = 0; i < psnames.length; i++) { psnames[i] = services[i].getName(); } cbName = new JComboBox(psnames); cbName.setSelectedIndex(defaultServiceIndex); cbName.addItemListener(this); cbName.addPopupMenuListener(this); c.fill = GridBagConstraints.BOTH; c.insets = compInsets; c.weightx = 0.0; JLabel lblName = new JLabel(getMsg("label.psname"), JLabel.TRAILING); lblName.setDisplayedMnemonic(getMnemonic("label.psname")); lblName.setLabelFor(cbName); addToGB(lblName, this, gridbag, c); c.weightx = 1.0; c.gridwidth = GridBagConstraints.RELATIVE; addToGB(cbName, this, gridbag, c); c.weightx = 0.0; c.gridwidth = GridBagConstraints.REMAINDER; btnProperties = createButton("button.properties", this); addToGB(btnProperties, this, gridbag, c); c.weighty = 1.0; lblStatus = addLabel(getMsg("label.status"), gridbag, c); lblStatus.setLabelFor(null); lblType = addLabel(getMsg("label.pstype"), gridbag, c); lblType.setLabelFor(null); c.gridwidth = 1; addToGB(new JLabel(getMsg("label.info"), JLabel.TRAILING), this, gridbag, c); c.gridwidth = GridBagConstraints.RELATIVE; lblInfo = new JLabel(); lblInfo.setLabelFor(null); addToGB(lblInfo, this, gridbag, c); c.gridwidth = GridBagConstraints.REMAINDER; cbPrintToFile = createCheckBox("checkbox.printtofile", this); addToGB(cbPrintToFile, this, gridbag, c); filePermission = allowedToPrintToFile(); }
Example 16
Source File: PasswordDialog.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
private PasswordDialog(Window owner, String i18nKey, UserCredential preset, Object... args) { super(owner, i18nKey, ModalityType.APPLICATION_MODAL, args); setModal(true); if (preset != null && preset.getUsername() != null) { usernameField.setText(preset.getUsername()); } if (preset != null && preset.getPassword() != null) { passwordField.setText(new String(preset.getPassword())); rememberBox.setSelected(true); } String url = preset != null ? preset.getURL() : null; JPanel main = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.FIRST_LINE_START; c.insets = new Insets(4, 4, 4, 4); JLabel label = new ResourceLabel("authentication.username", url); label.setLabelFor(usernameField); c.gridwidth = GridBagConstraints.RELATIVE; main.add(label, c); c.gridwidth = GridBagConstraints.REMAINDER; main.add(usernameField, c); label = new ResourceLabel("authentication.password", url); label.setLabelFor(passwordField); c.gridwidth = GridBagConstraints.RELATIVE; main.add(label, c); c.gridwidth = GridBagConstraints.REMAINDER; main.add(passwordField, c); JPanel rememberPanel = new JPanel(); rememberPanel.add(rememberBox); if (Boolean.parseBoolean(ParameterService.getParameterValue(RapidMinerGUI.PROPERTY_RAPIDMINER_DISALLOW_REMEMBER_PASSWORD))) { rememberPanel.add(enforcedIcon); rememberBox.setSelected(false); rememberBox.setEnabled(false); } main.add(rememberPanel, c); layoutDefault(main, makeOkButton(), makeCancelButton()); }
Example 17
Source File: VariableTab.java From Logisim with GNU General Public License v3.0 | 4 votes |
VariableTab(VariableList data) { this.data = data; list.setModel(new VariableListModel(data)); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.addListSelectionListener(myListener); remove.addActionListener(myListener); moveUp.addActionListener(myListener); moveDown.addActionListener(myListener); add.addActionListener(myListener); rename.addActionListener(myListener); field.addActionListener(myListener); field.getDocument().addDocumentListener(myListener); JScrollPane listPane = new JScrollPane(list, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); listPane.setPreferredSize(new Dimension(100, 100)); JPanel topPanel = new JPanel(new GridLayout(3, 1)); topPanel.add(remove); topPanel.add(moveUp); topPanel.add(moveDown); JPanel fieldPanel = new JPanel(); fieldPanel.add(rename); fieldPanel.add(add); GridBagLayout gb = new GridBagLayout(); GridBagConstraints gc = new GridBagConstraints(); setLayout(gb); gc.insets = new Insets(10, 10, 0, 10); gc.fill = GridBagConstraints.BOTH; gc.weightx = 1.0; gb.setConstraints(listPane, gc); add(listPane); gc.fill = GridBagConstraints.NONE; gc.anchor = GridBagConstraints.PAGE_START; gc.weightx = 0.0; gb.setConstraints(topPanel, gc); add(topPanel); gc.gridwidth = GridBagConstraints.REMAINDER; gc.gridx = 0; gc.gridy = GridBagConstraints.RELATIVE; gc.fill = GridBagConstraints.HORIZONTAL; gb.setConstraints(field, gc); field.setBorder(BorderFactory.createLineBorder(new Color(130, 135, 144))); add(field); gb.setConstraints(fieldPanel, gc); add(fieldPanel); gc.fill = GridBagConstraints.HORIZONTAL; gb.setConstraints(error, gc); add(error); if (!data.isEmpty()) list.setSelectedValue(data.get(0), true); computeEnabled(); }
Example 18
Source File: MinimizedTab.java From Logisim with GNU General Public License v3.0 | 4 votes |
public MinimizedTab(AnalyzerModel model) { this.outputExprs = model.getOutputExpressions(); outputExprs.addOutputExpressionsListener(myListener); selector = new OutputSelector(model); selector.addItemListener(myListener); karnaughMap = new KarnaughMapPanel(model); karnaughMap.addMouseListener(new TruthTableMouseListener()); setAsExpr.addActionListener(myListener); formatChoice.addItemListener(myListener); JPanel buttons = new JPanel(new GridLayout(1, 1)); buttons.add(setAsExpr); JPanel formatPanel = new JPanel(); formatPanel.add(formatLabel); formatPanel.add(formatChoice); GridBagLayout gb = new GridBagLayout(); GridBagConstraints gc = new GridBagConstraints(); setLayout(gb); gc.gridx = 0; gc.gridy = 0; addRow(gb, gc, selector.getLabel(), selector.getComboBox()); addRow(gb, gc, formatLabel, formatChoice); gc.weightx = 0.0; gc.gridx = 0; gc.gridwidth = 2; gc.gridy = GridBagConstraints.RELATIVE; gc.fill = GridBagConstraints.BOTH; gc.anchor = GridBagConstraints.CENTER; gb.setConstraints(karnaughMap, gc); add(karnaughMap); Insets oldInsets = gc.insets; gc.insets = new Insets(20, 0, 0, 0); gb.setConstraints(minimizedExpr, gc); add(minimizedExpr); gc.insets = oldInsets; gc.fill = GridBagConstraints.NONE; gb.setConstraints(buttons, gc); add(buttons); String selected = selector.getSelectedOutput(); setAsExpr.setEnabled(selected != null && !outputExprs.isExpressionMinimal(selected)); }
Example 19
Source File: SelectExportMethodDialog.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
private static DialogDescriptor createDialog(Component parentComponent, String title, String text, String helpID, JCheckBox[] options) { final String copyToClipboardText = "Copy to Clipboard"; /*I18N*/ final String writeToFileText = "Write to File"; /*I18N*/ final String cancelText = "Cancel"; /*I18N*/ final String iconDir = "/org/esa/snap/resources/images/icons/"; final ImageIcon copyIcon = new ImageIcon(SelectExportMethodDialog.class.getResource(iconDir + "Copy16.gif")); final ImageIcon saveIcon = new ImageIcon(SelectExportMethodDialog.class.getResource(iconDir + "Save16.gif")); final JButton copyToClipboardButton = new JButton(copyToClipboardText); copyToClipboardButton.setMnemonic('b'); copyToClipboardButton.setIcon(copyIcon); final JButton writeToFileButton = new JButton(writeToFileText); writeToFileButton.setMnemonic('W'); writeToFileButton.setIcon(saveIcon); final JButton cancelButton = new JButton(cancelText); cancelButton.setMnemonic('C'); cancelButton.setIcon(null); final JPanel panel = new JPanel(new GridBagLayout()); final JPanel checkboxPanel = new JPanel(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.LINE_START; c.gridx = 0; c.gridy = GridBagConstraints.RELATIVE; for (JCheckBox option : options) { checkboxPanel.add(option, c); } c.gridx = 0; c.gridy = 0; panel.add(checkboxPanel, c); final JPanel buttonPanel = new JPanel(new FlowLayout()); c.gridy = GridBagConstraints.RELATIVE; buttonPanel.add(copyToClipboardButton, c); buttonPanel.add(writeToFileButton, c); buttonPanel.add(cancelButton, c); c.gridx = 0; c.gridy = 1; panel.add(buttonPanel, c); final JOptionPane optionPane = new JOptionPane(text, /*I18N*/ JOptionPane.QUESTION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new JPanel[]{panel}, copyToClipboardButton); final JDialog dialog = optionPane.createDialog(parentComponent, title); dialog.getContentPane().setLayout(new BoxLayout(dialog.getContentPane(), BoxLayout.Y_AXIS)); if (helpID != null) { HelpCtx.setHelpIDString((JComponent) optionPane, helpID); } // Create action listener for all 3 buttons (as instance of an anonymous class) final ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { optionPane.setValue(e.getSource()); dialog.setVisible(false); dialog.dispose(); } }; copyToClipboardButton.addActionListener(actionListener); writeToFileButton.addActionListener(actionListener); cancelButton.addActionListener(actionListener); return new DialogDescriptor(dialog, optionPane, copyToClipboardButton, writeToFileButton); }
Example 20
Source File: ServiceDialog.java From Bytecoder with Apache License 2.0 | 4 votes |
public PrintServicePanel() { super(); uiFactory = psCurrent.getServiceUIFactory(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); setBorder(BorderFactory.createTitledBorder(strTitle)); String[] psnames = new String[services.length]; for (int i = 0; i < psnames.length; i++) { psnames[i] = services[i].getName(); } cbName = new JComboBox<>(psnames); cbName.setSelectedIndex(defaultServiceIndex); cbName.addItemListener(this); cbName.addPopupMenuListener(this); c.fill = GridBagConstraints.BOTH; c.insets = compInsets; c.weightx = 0.0; JLabel lblName = new JLabel(getMsg("label.psname"), JLabel.TRAILING); lblName.setDisplayedMnemonic(getMnemonic("label.psname")); lblName.setLabelFor(cbName); addToGB(lblName, this, gridbag, c); c.weightx = 1.0; c.gridwidth = GridBagConstraints.RELATIVE; addToGB(cbName, this, gridbag, c); c.weightx = 0.0; c.gridwidth = GridBagConstraints.REMAINDER; btnProperties = createButton("button.properties", this); addToGB(btnProperties, this, gridbag, c); c.weighty = 1.0; lblStatus = addLabel(getMsg("label.status"), gridbag, c); lblStatus.setLabelFor(null); lblType = addLabel(getMsg("label.pstype"), gridbag, c); lblType.setLabelFor(null); c.gridwidth = 1; addToGB(new JLabel(getMsg("label.info"), JLabel.TRAILING), this, gridbag, c); c.gridwidth = GridBagConstraints.RELATIVE; lblInfo = new JLabel(); lblInfo.setLabelFor(null); addToGB(lblInfo, this, gridbag, c); c.gridwidth = GridBagConstraints.REMAINDER; cbPrintToFile = createCheckBox("checkbox.printtofile", this); addToGB(cbPrintToFile, this, gridbag, c); filePermission = allowedToPrintToFile(); }