List of usage examples for javax.swing JButton setPreferredSize
@BeanProperty(preferred = true, description = "The preferred size of the component.") public void setPreferredSize(Dimension preferredSize)
From source file:de.kletterfreak98.xmass.ui.WeightChart.java
public WeightChart(String title, TimeSeries values) { super(title); setIconImage(// w w w . ja v a2s. co m new ImageIcon(getClass().getClassLoader().getResource("de/kletterfreak98/xmass/resources/fav.png")) .getImage()); final String chartTitle = strings.getString("weightcourse"); final XYDataset dataset = new TimeSeriesCollection(values); final JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, strings.getString("date"), strings.getString("weightinkg"), dataset, false, true, false); final XYPlot plot = chart.getXYPlot(); plot.setDataset(1, new TimeSeriesCollection(values)); plot.mapDatasetToRangeAxis(1, 1); final XYItemRenderer renderer = plot.getRenderer(); renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); if (renderer instanceof StandardXYItemRenderer) { final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; rr.setShapesFilled(true); } final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.black); renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); plot.setRenderer(1, renderer2); final DateAxis axis = (DateAxis) plot.getDomainAxis(); SimpleDateFormat sdf; if (Main.settings.getLang().equals(Locale.GERMANY)) { sdf = new SimpleDateFormat("dd.MM.yyyy"); axis.setDateFormatOverride(sdf); } else { sdf = new SimpleDateFormat("MM/dd/yyyy"); axis.setDateFormatOverride(sdf); } final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); JPanel panel = new JPanel(); JButton close = new JButton(strings.getString("close")); close.setPreferredSize(new Dimension(close.getWidth(), 30)); close.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); panel.setLayout(new BorderLayout()); panel.add(chartPanel, BorderLayout.CENTER); panel.add(close, BorderLayout.SOUTH); panel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(panel); setUndecorated(true); }
From source file:it.iit.genomics.cru.igb.bundles.mi.business.MIWorker.java
/** * Adds a component to a JTabbedPane with a little close tab" button on the * right side of the tab.//from ww w. j a va 2 s . c o m * * @param tabbedPane * the JTabbedPane * @param c * any JComponent * @param title * the title for the tab */ public static void addClosableTab(final JTabbedPane tabbedPane, final JComponent c, final String title) { // Add the tab to the pane without any label tabbedPane.addTab(null, c); int pos = tabbedPane.indexOfComponent(c); // Create a FlowLayout that will space things 5px apart FlowLayout f = new FlowLayout(FlowLayout.CENTER, 5, 0); // Make a small JPanel with the layout and make it non-opaque JPanel pnlTab = new JPanel(f); pnlTab.setOpaque(false); // Add a JLabel with title and the left-side tab icon JLabel lblTitle = new JLabel(title); // Create a JButton for the close tab button JButton btnClose = new JButton("x"); // btnClose.setOpaque(false); int size = 17; btnClose.setPreferredSize(new Dimension(size, size)); btnClose.setToolTipText("close this tab"); // Make the button looks the same for all Laf's btnClose.setUI(new BasicButtonUI()); // Make it transparent btnClose.setContentAreaFilled(false); // No need to be focusable btnClose.setFocusable(false); btnClose.setBorder(BorderFactory.createEtchedBorder()); btnClose.setBorderPainted(false); // Making nice rollover effect // we use the same listener for all buttons btnClose.setRolloverEnabled(true); // Close the proper tab by clicking the button // Configure icon and rollover icon for button btnClose.setRolloverEnabled(true); // Set border null so the button doesnt make the tab too big btnClose.setBorder(null); // Make sure the button cant get focus, otherwise it looks funny btnClose.setFocusable(false); // Put the panel together pnlTab.add(lblTitle); pnlTab.add(btnClose); // Add a thin border to keep the image below the top edge of the tab // when the tab is selected pnlTab.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); // Now assign the component for the tab tabbedPane.setTabComponentAt(pos, pnlTab); // Add the listener that removes the tab ActionListener listener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(new JFrame(), "Are you sure you want to remove this tab? All results will be lost!", "Remove tab", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { tabbedPane.remove(c); } } }; btnClose.addActionListener(listener); // Optionally bring the new tab to the front tabbedPane.setSelectedComponent(c); }
From source file:com.floreantpos.config.ui.TerminalConfigurationView.java
public void restartPOS() { JOptionPane optionPane = new JOptionPane(Messages.getString("TerminalConfigurationView.26"), //$NON-NLS-1$ JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, Application.getApplicationIcon(), new String[] { /*Messages.getString("TerminalConfigurationView.28"),*/Messages .getString("TerminalConfigurationView.30") }); //$NON-NLS-1$ //$NON-NLS-2$ Object[] optionValues = optionPane.getComponents(); for (Object object : optionValues) { if (object instanceof JPanel) { JPanel panel = (JPanel) object; Component[] components = panel.getComponents(); for (Component component : components) { if (component instanceof JButton) { component.setPreferredSize(new Dimension(100, 80)); JButton button = (JButton) component; button.setPreferredSize(PosUIManager.getSize(100, 50)); }/*from w ww.j ava 2s .c o m*/ } } } JDialog dialog = optionPane.createDialog(Application.getPosWindow(), Messages.getString("TerminalConfigurationView.31")); //$NON-NLS-1$ dialog.setIconImage(Application.getApplicationIcon().getImage()); dialog.setLocationRelativeTo(Application.getPosWindow()); dialog.setVisible(true); Object selectedValue = (String) optionPane.getValue(); if (selectedValue != null) { if (selectedValue.equals(Messages.getString("TerminalConfigurationView.28"))) { //$NON-NLS-1$ try { Main.restart(); } catch (IOException | InterruptedException | URISyntaxException e) { } } else { } } }
From source file:hr.fer.zemris.vhdllab.platform.gui.dialog.save.SaveDialog.java
public SaveDialog(LocalizationSource source, SaveContext context) { super(source); Validate.notNull(context, "Save variant can't be null"); // setup label JLabel label = new JLabel(getMainMessage(source, context)); int width = DIALOG_WIDTH - 2 * BORDER; int height = LABEL_HEIGHT - 2 * BORDER; label.setPreferredSize(new Dimension(width, height)); label.setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER)); // setup check box list list = new CheckBoxList(); width = DIALOG_WIDTH - 2 * BORDER;//from w w w. j a v a 2 s . c om height = 0; // because list is a center component and it doesnt need // height list.setPreferredSize(new Dimension(width, height)); list.setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER)); // setup select all and deselect all buttons JButton selectAll = new JButton(source.getMessage(SELECT_ALL_MESSAGE)); selectAll.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); selectAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { list.setSelectionToAll(true); } }); JButton deselectAll = new JButton(source.getMessage(DESELECT_ALL_MESSAGE)); deselectAll.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); deselectAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { list.setSelectionToAll(false); } }); Box selectBox = Box.createHorizontalBox(); selectBox.add(selectAll); selectBox.add(Box.createRigidArea(new Dimension(BORDER, BUTTON_HEIGHT))); selectBox.add(deselectAll); selectBox.setBorder(BorderFactory.createEmptyBorder(0, 0, BORDER, 0)); // setup ok and cancel buttons JButton ok = new JButton(source.getMessage(OK_MESSAGE)); ok.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeDialog(new ArrayList<File>()); } }); JButton cancel = new JButton(source.getMessage(CANCEL_MESSAGE)); cancel.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeDialog(null); } }); Box actionBox = Box.createHorizontalBox(); actionBox.add(ok); actionBox.add(Box.createRigidArea(new Dimension(BORDER, BUTTON_HEIGHT))); actionBox.add(cancel); actionBox.setBorder(BorderFactory.createEmptyBorder(BORDER, 0, BORDER, 0)); JPanel selectPanel = new JPanel(new BorderLayout()); selectPanel.add(selectBox, BorderLayout.EAST); JPanel actionPanel = new JPanel(new BorderLayout()); actionPanel.add(actionBox, BorderLayout.EAST); JCheckBox alwaysSave = new JCheckBox(source.getMessage(ALWAYS_SAVE_MESSAGE)); alwaysSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JCheckBox checkBox = (JCheckBox) e.getSource(); Preferences preferences = Preferences.userNodeForPackage(SaveDialog.class); preferences.putBoolean(SHOULD_AUTO_SAVE, checkBox.isSelected()); } }); alwaysSave.setSelected(false); JPanel alwaysSavePanel = new JPanel(new BorderLayout()); alwaysSavePanel.add(alwaysSave, BorderLayout.WEST); JPanel lowerPanel = new JPanel(new BorderLayout()); lowerPanel.add(selectPanel, BorderLayout.NORTH); lowerPanel.add(alwaysSavePanel, BorderLayout.CENTER); lowerPanel.add(actionPanel, BorderLayout.SOUTH); this.setLayout(new BorderLayout()); JPanel messagePanel = new JPanel(new BorderLayout()); messagePanel.add(label, BorderLayout.NORTH); messagePanel.add(list, BorderLayout.CENTER); messagePanel.add(lowerPanel, BorderLayout.SOUTH); this.getContentPane().add(messagePanel, BorderLayout.CENTER); this.getRootPane().setDefaultButton(ok); this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); this.setTitle(getTitle(source, context)); }
From source file:net.mumie.coursecreator.gui.ClassChooser.java
private void buildLayout() { // Dimensions of the Dialog int width = 10; int height = 160; int buttonWidth = 100; int buttonHeight = 30; // sets the Layout this.getContentPane().setLayout(new GridBagLayout()); // the Button and Label Text String okButtonText = "Zuweisen"; String cancelButtonText = "Cancel"; headlineLabelText = ""; // the Fonts/*from w w w. j a va2 s . c o m*/ Font font = new Font("SansSerif", Font.PLAIN, 14); Font headlineLabelFont = new Font("SansSerif", Font.PLAIN, 12); Font textFieldFont = new Font("Monospaced", Font.PLAIN, 10); // GridBagContraints for rootPanel (s.b.): GridBagConstraints rootPanelStyle = createGridBagContrains(GridBagConstraints.CENTER, 4, 4, 4, 4, 0, 0); // GridBagContraints for headlineLabel: GridBagConstraints headlineLabelStyle = createGridBagContrains(GridBagConstraints.CENTER, 6, 6, 6, 6, 0, 0); // GridBagConstraints for textFieldPanel (s.b.): GridBagConstraints textFieldPanelStyle = createGridBagContrains(GridBagConstraints.CENTER, 4, 4, 4, 4, 0, 1); // GridBagConstraints for buttonPanel (s.b.): GridBagConstraints buttonPanelStyle = createGridBagContrains(GridBagConstraints.CENTER, 4, 4, 4, 4, 0, 2); // GridBagConstraints for serverTextField: GridBagConstraints serverTextFieldStyle = createGridBagContrains(GridBagConstraints.WEST, 6, 6, 6, 6, 1, 0); // GridBagContraints for okButton (s.b.): GridBagConstraints okButtonStyle = createGridBagContrains(GridBagConstraints.CENTER, 6, 6, 6, 6, 0, 0); // GridBagContraints for cancelButton (s.b.): GridBagConstraints cancelButtonStyle = createGridBagContrains(GridBagConstraints.CENTER, 6, 6, 6, 6, 1, 0); // Creating rootPanel (contains all components) JPanel rootPanel = new JPanel(new GridBagLayout()); rootPanel.setFont(font); // Creating headlineLabel: JLabel headlineLabel = new JLabel(headlineLabelText); headlineLabel.setFont(headlineLabelFont); // Creating textFieldPanel: JPanel textFieldPanel = new JPanel(new GridBagLayout()); textFieldPanel.setFont(font); // Creating classTextField: classBox = new JComboBox(this.classList); classBox.setFont(textFieldFont); String classPath = this.controller.getMetaInfoField().getMetaInfos().getClassPath(); String className = this.controller.getMetaInfoField().getMetaInfos().getClassName(); if (setSelectedClass(classPath, className) == -1) headlineLabel.setForeground(Color.RED); else headlineLabel.setForeground(Color.BLACK); headlineLabel.setText(this.headlineLabelText); // Creating buttonPanel: JPanel buttonPanel = new JPanel(new GridBagLayout()); buttonPanel.setFont(font); // okButton: JButton okButton = new JButton(okButtonText); okButton.setPreferredSize(new Dimension(buttonWidth, buttonHeight)); okButton.setActionCommand(CommandConstants.META_INFO_FIELD_OK); okButton.addActionListener(this.controller); // cancelButton: JButton cancelButton = new JButton(cancelButtonText); cancelButton.setPreferredSize(new Dimension(buttonWidth, buttonHeight)); cancelButton.setActionCommand(CommandConstants.META_INFO_FIELD_CANCEL); cancelButton.addActionListener(this.controller); // Composing the GUI: this.getContentPane().setLayout(new GridBagLayout()); this.getContentPane().add(rootPanel, rootPanelStyle); rootPanel.add(headlineLabel, headlineLabelStyle); rootPanel.add(textFieldPanel, textFieldPanelStyle); textFieldPanel.add(classBox, serverTextFieldStyle); rootPanel.add(buttonPanel, buttonPanelStyle); buttonPanel.add(okButton, okButtonStyle); buttonPanel.add(cancelButton, cancelButtonStyle); this.addWindowListener(this.windowListener); int maxString = this.headlineLabelText.length(); for (int i = 0; i < this.classList.size(); i++) { maxString = Math.max(((String) this.classList.get(i).toString()).length(), maxString); } width = Math.max(width, maxString * 8); this.setSize(width, height); }
From source file:edu.harvard.mcz.imagecapture.BulkMediaFrame.java
private void init() { thisFrame = this; setTitle("BulkMedia Preparation"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 902, 174);/*from ww w . j a v a 2 s . c om*/ JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnFile = new JMenu("File"); mnFile.setMnemonic(KeyEvent.VK_F); menuBar.add(mnFile); JMenuItem mntmPrepareDirectory = new JMenuItem("Prepare Directory"); mntmPrepareDirectory.setMnemonic(KeyEvent.VK_D); mntmPrepareDirectory.addActionListener(new PrepareDirectoryAction()); mnFile.add(mntmPrepareDirectory); JMenuItem mntmNewMenuItem = new JMenuItem("Exit"); mntmNewMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { done(); } }); JMenuItem mntmNewMenuItem_1 = new JMenuItem("Edit Properties"); mntmNewMenuItem_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { PropertiesEditor p = new PropertiesEditor(); p.pack(); p.setVisible(true); } }); mnFile.add(mntmNewMenuItem_1); mntmNewMenuItem.setMnemonic(KeyEvent.VK_X); mntmNewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK)); mnFile.add(mntmNewMenuItem); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(new BorderLayout(0, 0)); JPanel panel = new JPanel(); contentPane.add(panel, BorderLayout.CENTER); panel.setLayout(new GridLayout(3, 2, 0, 0)); JLabel lblBaseUri = new JLabel("Base URI (first part of path to images on the web)"); lblBaseUri.setHorizontalAlignment(SwingConstants.TRAILING); panel.add(lblBaseUri, "2, 2"); textField = new JTextField(); textField.setEditable(false); textField.setText(Singleton.getSingletonInstance().getProperties().getProperties() .getProperty(ImageCaptureProperties.KEY_IMAGEBASEURI)); panel.add(textField); textField.setColumns(10); JLabel lblNewLabel = new JLabel("Local Path To Base (local mount path that maps to base URI)"); lblNewLabel.setHorizontalAlignment(SwingConstants.TRAILING); panel.add(lblNewLabel); textField_1 = new JTextField(); textField_1.setEditable(false); textField_1.setText(Singleton.getSingletonInstance().getProperties().getProperties() .getProperty(ImageCaptureProperties.KEY_IMAGEBASE)); panel.add(textField_1); textField_1.setColumns(10); JLabel lblBeforeExitingWait = new JLabel( "Before exiting wait for both the Done and Thumbnails Built messages."); panel.add(lblBeforeExitingWait); JLabel lblThumbnailGenerationIs = new JLabel("Thumbnail generation is not reported on the progress bar."); panel.add(lblThumbnailGenerationIs); progressBar = new JProgressBar(); progressBar.setStringPainted(false); contentPane.add(progressBar, BorderLayout.NORTH); JPanel panel_1 = new JPanel(); contentPane.add(panel_1, BorderLayout.SOUTH); JButton btnPrepareDirectory = new JButton("Run"); btnPrepareDirectory.setToolTipText("Select a directory and prepare a bulk media file for images therein."); panel_1.add(btnPrepareDirectory); btnPrepareDirectory.addActionListener(new PrepareDirectoryAction()); btnPrepareDirectory.setPreferredSize(new Dimension(80, 25)); JButton btnExit = new JButton("Exit"); btnExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { done(); } }); panel_1.add(btnExit); }
From source file:JXTransformer.java
private JPanel createDemoPanel() { JPanel buttonPanel = new JPanel(new GridLayout(3, 2)); TitledBorder titledBorder = BorderFactory.createTitledBorder("Try three sliders below !"); Font titleFont = titledBorder.getTitleFont(); titledBorder.setTitleFont(titleFont.deriveFont(titleFont.getSize2D() + 10)); titledBorder.setTitleJustification(TitledBorder.CENTER); buttonPanel.setBorder(titledBorder); JButton b = new JButton("JButton"); b.setPreferredSize(new Dimension(100, 50)); buttonPanel.add(createTransformer(b)); Vector<String> v = new Vector<String>(); v.add("One"); v.add("Two"); v.add("Three"); JList list = new JList(v); buttonPanel.add(createTransformer(list)); buttonPanel.add(createTransformer(new JCheckBox("JCheckBox"))); JSlider slider = new JSlider(0, 100); slider.setLabelTable(slider.createStandardLabels(25, 0)); slider.setPaintLabels(true);//w w w .j ava 2s . c o m slider.setPaintTicks(true); slider.setMajorTickSpacing(10); buttonPanel.add(createTransformer(slider)); buttonPanel.add(createTransformer(new JRadioButton("JRadioButton"))); final JLabel label = new JLabel("JLabel"); label.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { Font font = label.getFont(); label.setFont(font.deriveFont(font.getSize2D() + 10)); } public void mouseExited(MouseEvent e) { Font font = label.getFont(); label.setFont(font.deriveFont(font.getSize2D() - 10)); } }); buttonPanel.add(createTransformer(label)); return buttonPanel; }
From source file:com.microsoft.azure.hdinsight.spark.ui.SparkSubmissionContentPanel.java
private void addConfigurationLineItem() { JLabel jobConfigurationLabel = new JLabel("Job configurations"); add(jobConfigurationLabel, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, 0), 0, 0)); String[] columns = { "Key", "Value", "" }; jobConfigurationTable = new JBTable(); Dimension jobConfigurationTableSize = new Dimension(320, 100); jobConfigurationTable.setPreferredScrollableViewportSize(jobConfigurationTableSize); jobConfigurationTable.setSurrendersFocusOnKeystroke(true); jobConfigurationTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jobConfigurationTable.setColumnSelectionAllowed(true); JBScrollPane scrollPane = new JBScrollPane(jobConfigurationTable); jobConfigurationTable.setFillsViewportHeight(true); scrollPane.setMinimumSize(jobConfigurationTableSize); jobConfigurationTable.addPropertyChangeListener((evt) -> { if ((evt.getPropertyName().equals("tableCellEditor") || evt.getPropertyName().equals("model")) && jobConfigurationTable.getModel() instanceof SubmissionTableModel) { SubmissionTableModel model = (SubmissionTableModel) jobConfigurationTable.getModel(); setVisibleForFixedErrorMessageLabel(ErrorMessageLabelTag.JobConfiguration.ordinal(), false); SparkSubmissionJobConfigCheckResult result = model.getFirstCheckResults(); if (result != null) { setStatusForMessageLabel(ErrorMessageLabelTag.JobConfiguration.ordinal(), true, result.getMessaqge(), result.getStatus() == SparkSubmissionJobConfigCheckStatus.Warning); }/*from w w w . jav a 2 s .c o m*/ } }); add(scrollPane, new GridBagConstraints(1, displayLayoutCurrentRow, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(margin, margin, 0, 0), 0, 0)); JButton loadJobConfigurationButton = new JButton("..."); loadJobConfigurationButton.setPreferredSize(selectedArtifactTextField.getButton().getPreferredSize()); FixedSizeButton loadJobConfigurationFixedSizeButton = new FixedSizeButton(loadJobConfigurationButton); add(loadJobConfigurationFixedSizeButton, new GridBagConstraints(2, displayLayoutCurrentRow, 0, 1, 0, 0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(margin, margin / 2, 0, margin), 0, 0)); loadJobConfigurationFixedSizeButton.setToolTipText("Load Spark config from property file"); loadJobConfigurationFixedSizeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false); fileChooserDescriptor.setTitle("Select Spark property file"); VirtualFile chooseFile = FileChooser.chooseFile(fileChooserDescriptor, null, null); if (chooseFile != null) { submitModel.loadJobConfigMapFromPropertyFile(chooseFile.getCanonicalPath()); } } }); errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()] = new JLabel(); errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()] .setForeground(DarkThemeManager.getInstance().getErrorMessageColor()); errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()].setVisible(false); add(errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()], new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, margin, 0, margin), 0, 0)); }
From source file:marytts.tools.voiceimport.DatabaseImportMain.java
protected void setupGUI() { // A scroll pane containing one labelled checkbox per component, // and a "run selected components" button below. GridBagLayout gridBagLayout = new GridBagLayout(); GridBagConstraints gridC = new GridBagConstraints(); getContentPane().setLayout(gridBagLayout); JPanel checkboxPane = new JPanel(); checkboxPane.setLayout(new BoxLayout(checkboxPane, BoxLayout.Y_AXIS)); //checkboxPane.setPreferredSize(new Dimension(300, 300)); int compIndex = 0; for (int j = 0; j < groups2Comps.length; j++) { String[] nextGroup = groups2Comps[j]; JPanel groupPane = new JPanel(); groupPane.setLayout(new BoxLayout(groupPane, BoxLayout.Y_AXIS)); groupPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(nextGroup[0]), BorderFactory.createEmptyBorder(1, 1, 1, 1))); for (int i = 1; i < nextGroup.length; i++) { JButton configButton = new JButton(); Icon configIcon = new ImageIcon(DatabaseImportMain.class.getResource("configure.png"), "Configure"); configButton.setIcon(configIcon); configButton.setPreferredSize(new Dimension(configIcon.getIconWidth(), configIcon.getIconHeight())); configButton.addActionListener(new ConfigButtonActionListener(nextGroup[i])); configButton.setBorderPainted(false); //System.out.println("Adding checkbox for "+components[i].getClass().getName()); checkboxes[compIndex] = new JCheckBox(nextGroup[i]); checkboxes[compIndex].setFocusable(true); //checkboxes[i].setPreferredSize(new Dimension(200, 30)); JPanel line = new JPanel(); line.setLayout(new BorderLayout(5, 0)); line.add(configButton, BorderLayout.WEST); line.add(checkboxes[compIndex], BorderLayout.CENTER); groupPane.add(line);//from w w w . jav a 2 s . com compIndex++; } checkboxPane.add(groupPane); } gridC.gridx = 0; gridC.gridy = 0; gridC.fill = GridBagConstraints.BOTH; JScrollPane scrollPane = new JScrollPane(checkboxPane); scrollPane.setPreferredSize(new Dimension(450, 300)); gridBagLayout.setConstraints(scrollPane, gridC); getContentPane().add(scrollPane); JButton helpButton = new JButton("Help"); helpButton.setMnemonic(KeyEvent.VK_H); helpButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { displayHelpGUI(); } }); JButton settingsButton = new JButton("Settings"); settingsButton.setMnemonic(KeyEvent.VK_S); settingsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { currentComponent = "Global properties"; displaySettingsGUI(); } }); runButton = new JButton("Run"); runButton.setMnemonic(KeyEvent.VK_R); runButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { runSelectedComponents(); } }); JButton quitAndSaveButton = new JButton("Quit"); quitAndSaveButton.setMnemonic(KeyEvent.VK_Q); quitAndSaveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { try { askIfSave(); } catch (IOException ioe) { ioe.printStackTrace(); } System.exit(0); } }); gridC.gridy = 1; JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout()); //buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.X_AXIS)); //runButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(runButton); //helpButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(helpButton); //settingsButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(settingsButton); //buttonPanel.add(Box.createHorizontalGlue()); //quitAndSaveButton.setAlignmentX(JButton.RIGHT_ALIGNMENT); buttonPanel.add(quitAndSaveButton); gridBagLayout.setConstraints(buttonPanel, gridC); getContentPane().add(buttonPanel); //getContentPane().setPreferredSize(new Dimension(300, 300)); // End program when closing window: addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { try { askIfSave(); } catch (IOException ioe) { ioe.printStackTrace(); } System.exit(0); } }); }
From source file:inet.CalculationNetworkEditor.visual.view.EditorPane.java
private void addContentToStackingEdgePanel(JPanel rightPanel, E e, Collection<E> allPhysicalCol) { //caption//from ww w . j a va2s . com JLabel caption = new JLabel("Map: " + e); caption.setSize(new Dimension(180, 20)); caption.setPreferredSize(new Dimension(180, 20)); rightPanel.add(caption, BorderLayout.NORTH); //to JPanel toPanel = new JPanel(); toPanel.setLayout(new BorderLayout()); rightPanel.add(toPanel, BorderLayout.CENTER); JLabel to = new JLabel("To:"); to.setSize(new Dimension(180, 20)); to.setPreferredSize(new Dimension(180, 20)); toPanel.add(to, BorderLayout.NORTH); // buttons edge button panel JPanel buttonsEdgePanel = new JPanel(); buttonsEdgePanel.setLayout(new BorderLayout()); toPanel.add(buttonsEdgePanel, BorderLayout.CENTER); // path listPanel //JPanel pathListPanel = new JPanel(); //pathListPanel.setLayout(new BorderLayout); defaultListModel = new DefaultListModel<E>(); pathList = new JList<E>(defaultListModel); pathList.setSize(180, 100); pathList.setPreferredSize(new Dimension(180, 100)); buttonsEdgePanel.add(pathList, BorderLayout.CENTER); // add remove edge button panel JPanel addRemoveEdgePanel = new JPanel(); addRemoveEdgePanel.setLayout(new BorderLayout()); buttonsEdgePanel.add(addRemoveEdgePanel, BorderLayout.SOUTH); // add Button JButton addButton = new JButton("add"); addRemoveEdgePanel.add(addButton, BorderLayout.LINE_START); addButton.addActionListener(editingPanelsListener); addButton.setSize(new Dimension(70, 20)); addButton.setPreferredSize(new Dimension(70, 20)); // remove Button JButton removeButton = new JButton("remove"); addRemoveEdgePanel.add(removeButton, BorderLayout.LINE_END); removeButton.addActionListener(editingPanelsListener); removeButton.setSize(new Dimension(90, 20)); removeButton.setPreferredSize(new Dimension(90, 20)); // add drop done box with all physical edges allPhysicalEdgeJCB = new JComboBox<E>(); for (E edge : allPhysicalCol) { if (!defaultListModel.contains(edge)) { allPhysicalEdgeJCB.addItem(edge); } } toPanel.add(allPhysicalEdgeJCB, BorderLayout.SOUTH); allPhysicalEdgeJCB.setSize(new Dimension(180, 30)); allPhysicalEdgeJCB.setPreferredSize(new Dimension(180, 30)); allPhysicalEdgeJCB.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); // JButton stack JButton stack = new JButton("map"); stack.addActionListener(editingPanelsListener); rightPanel.add(stack, BorderLayout.SOUTH); }