List of usage examples for com.jgoodies.forms.layout CellConstraints DEFAULT
Alignment DEFAULT
To view the source code for com.jgoodies.forms.layout CellConstraints DEFAULT.
Click Source Link
From source file:loci.visbio.data.SpectralWidget.java
License:Open Source License
/** Creates a new spectral mapping widget with weighted sliders. */ public SpectralWidget(final SpectralTransform mapping, final String[] text) { super();// w w w .ja va 2s. c om this.mapping = mapping; // create sliders, labels and auto-set buttons final RealType[] range = ((ImageTransform) mapping.getParent()).getRangeTypes(); final int in = range.length; final int out = mapping.getRangeCount(); weights = new JSlider[out][in]; labels = new JLabel[out][in]; final Hashtable labelHash = new Hashtable(); labelHash.put(new Integer(-PRECISION), new JLabel("-1")); labelHash.put(new Integer(0), new JLabel("0")); labelHash.put(new Integer(PRECISION), new JLabel("1")); final JButton[] negOnes = new JButton[out]; final JButton[] zeroes = new JButton[out]; final JButton[] ones = new JButton[out]; final double[][] w = mapping.getWeights(); for (int o = 0; o < out; o++) { for (int i = 0; i < in; i++) { final int value = (int) (PRECISION * w[o][i]); final JSlider s = new JSlider(-PRECISION, PRECISION, value); if (i == in - 1) { s.setMajorTickSpacing(PRECISION); s.setMinorTickSpacing(PRECISION / 10); s.setLabelTable(labelHash); s.setPaintTicks(true); s.setPaintLabels(true); } final JLabel l = new JLabel(shortString(value)); s.addChangeListener(new ChangeListener() { @Override public void stateChanged(final ChangeEvent e) { l.setText(shortString(((JSlider) e.getSource()).getValue())); } }); weights[o][i] = s; labels[o][i] = l; } negOnes[o] = new JButton("-1"); negOnes[o].setActionCommand("-1:" + o); negOnes[o].addActionListener(this); zeroes[o] = new JButton("0"); zeroes[o].setActionCommand("0:" + o); zeroes[o].addActionListener(this); ones[o] = new JButton("1"); ones[o].setActionCommand("1:" + o); ones[o].addActionListener(this); } // apply button final JButton apply = new JButton("Apply"); if (!LAFUtil.isMacLookAndFeel()) apply.setMnemonic('a'); apply.setActionCommand("apply"); apply.addActionListener(this); // lay out components final String s = "pref, 3dlu:grow, pref, 3dlu:grow, pref"; final StringBuffer cols = new StringBuffer("pref, 3dlu, " + s + ", 3dlu, pref"); for (int o = 1; o < out; o++) { cols.append(", 9dlu, " + s + ", 3dlu, pref"); } final StringBuffer rows = new StringBuffer("pref, 3dlu, pref"); for (int i = 1; i < in; i++) rows.append(", 3dlu, pref"); rows.append(", 3dlu, pref, 5dlu, pref"); final PanelBuilder builder = new PanelBuilder(new FormLayout(cols.toString(), rows.toString())); final CellConstraints cc = new CellConstraints(); for (int i = 0; i < in; i++) { final int row = 2 * i + 3; builder.addLabel(range[i].getName(), cc.xy(1, row, CellConstraints.RIGHT, CellConstraints.TOP)); } for (int o = 0; o < out; o++) { final int col = 8 * o + 3; builder.addLabel(text[o], cc.xyw(col, 1, 5, CellConstraints.CENTER, CellConstraints.DEFAULT)); for (int i = 0; i < in; i++) { final int row = 2 * i + 3; builder.add(weights[o][i], cc.xyw(col, row, 5)); builder.add(labels[o][i], cc.xy(col + 6, row, CellConstraints.DEFAULT, CellConstraints.TOP)); } final int row = 2 * in + 3; builder.add(negOnes[o], cc.xy(col, row)); builder.add(zeroes[o], cc.xy(col + 2, row)); builder.add(ones[o], cc.xy(col + 4, row)); } builder.add(ButtonBarFactory.buildCenteredBar(apply), cc.xyw(1, 2 * in + 5, 8 * out + 1)); setLayout(new BorderLayout()); add(builder.getPanel()); }
From source file:net.ishchenko.idea.nginx.configurator.ServerFieldsForm.java
License:Apache License
/** * Method generated by IntelliJ IDEA GUI Designer * >>> IMPORTANT!! <<< * DO NOT edit this method OR call it in your code! * * @noinspection ALL// ww w . j a v a 2s. co m */ private void $$$setupUI$$$() { createUIComponents(); panel = new JPanel(); panel.setLayout(new FormLayout("fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:d:grow", "center:d:noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow")); nameField = new JTextField(); nameField.setText(""); CellConstraints cc = new CellConstraints(); panel.add(nameField, cc.xy(3, 1, CellConstraints.FILL, CellConstraints.DEFAULT)); final JLabel label1 = new JLabel(); this.$$$loadLabelText$$$(label1, ResourceBundle.getBundle("net/ishchenko/idea/nginx/NginxBundle").getString("run.servername")); panel.add(label1, cc.xy(1, 1)); final JLabel label2 = new JLabel(); this.$$$loadLabelText$$$(label2, ResourceBundle.getBundle("net/ishchenko/idea/nginx/NginxBundle").getString("run.executable")); panel.add(label2, cc.xy(1, 3)); panel.add(executableField, cc.xy(3, 3, CellConstraints.FILL, CellConstraints.DEFAULT)); final JLabel label3 = new JLabel(); this.$$$loadLabelText$$$(label3, ResourceBundle.getBundle("net/ishchenko/idea/nginx/NginxBundle").getString("run.configuration")); panel.add(label3, cc.xy(1, 5)); panel.add(configurationField, cc.xy(3, 5, CellConstraints.FILL, CellConstraints.DEFAULT)); final JLabel label4 = new JLabel(); this.$$$loadLabelText$$$(label4, ResourceBundle.getBundle("net/ishchenko/idea/nginx/NginxBundle").getString("run.globals")); panel.add(label4, cc.xy(1, 9)); globalsField = new JTextField(); panel.add(globalsField, cc.xy(3, 9, CellConstraints.FILL, CellConstraints.DEFAULT)); final JLabel label5 = new JLabel(); this.$$$loadLabelText$$$(label5, ResourceBundle.getBundle("net/ishchenko/idea/nginx/NginxBundle").getString("run.pidpath")); panel.add(label5, cc.xy(1, 7)); panel.add(pidField, cc.xy(3, 7, CellConstraints.FILL, CellConstraints.DEFAULT)); }
From source file:net.ishchenko.idea.nginx.run.NginxRunSettingsForm.java
License:Apache License
/** * Method generated by IntelliJ IDEA GUI Designer * >>> IMPORTANT!! <<< * DO NOT edit this method OR call it in your code! * * @noinspection ALL//from www . jav a 2 s . c om */ private void $$$setupUI$$$() { createUIComponents(); panel = new JPanel(); panel.setLayout(new FormLayout("fill:d:grow,left:4dlu:noGrow,fill:max(d;4px):noGrow", "center:d:noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow")); serverCombo = new JComboBox(); CellConstraints cc = new CellConstraints(); panel.add(serverCombo, cc.xy(1, 1)); configureButton = new JButton(); this.$$$loadButtonText$$$(configureButton, ResourceBundle.getBundle("net/ishchenko/idea/nginx/NginxBundle").getString("run.configureButton")); panel.add(configureButton, cc.xy(3, 1)); final JPanel panel1 = new JPanel(); panel1.setLayout(new FormLayout("fill:max(d;4px):noGrow,left:4dlu:noGrow,fill:d:grow", "center:d:grow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow")); panel.add(panel1, cc.xyw(1, 3, 3)); panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), ResourceBundle.getBundle("net/ishchenko/idea/nginx/NginxBundle").getString("run.serverinfo"))); final JLabel label1 = new JLabel(); this.$$$loadLabelText$$$(label1, ResourceBundle.getBundle("net/ishchenko/idea/nginx/NginxBundle").getString("run.executable")); panel1.add(label1, cc.xy(1, 3)); final JLabel label2 = new JLabel(); this.$$$loadLabelText$$$(label2, ResourceBundle.getBundle("net/ishchenko/idea/nginx/NginxBundle").getString("run.configuration")); panel1.add(label2, cc.xy(1, 5)); executableField = new JTextField(); executableField.setEditable(false); executableField.setEnabled(true); panel1.add(executableField, cc.xy(3, 3, CellConstraints.FILL, CellConstraints.DEFAULT)); configurationField = new JTextField(); configurationField.setEditable(false); configurationField.setEnabled(true); panel1.add(configurationField, cc.xy(3, 5, CellConstraints.FILL, CellConstraints.DEFAULT)); final JLabel label3 = new JLabel(); this.$$$loadLabelText$$$(label3, ResourceBundle.getBundle("net/ishchenko/idea/nginx/NginxBundle").getString("run.globals")); panel1.add(label3, cc.xy(1, 9)); globalsField = new JTextField(); globalsField.setEditable(false); globalsField.setEnabled(true); panel1.add(globalsField, cc.xy(3, 9, CellConstraints.FILL, CellConstraints.DEFAULT)); final JLabel label4 = new JLabel(); this.$$$loadLabelText$$$(label4, ResourceBundle.getBundle("net/ishchenko/idea/nginx/NginxBundle").getString("run.pidpath")); panel1.add(label4, cc.xy(1, 7)); pidField = new JTextField(); pidField.setEditable(false); pidField.setEnabled(true); panel1.add(pidField, cc.xy(3, 7, CellConstraints.FILL, CellConstraints.DEFAULT)); final JPanel panel2 = new JPanel(); panel2.setLayout(new FormLayout("fill:d:noGrow,left:4dlu:noGrow,fill:d:grow", "center:d:noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow")); panel.add(panel2, cc.xyw(1, 5, 3)); panel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), ResourceBundle.getBundle("net/ishchenko/idea/nginx/NginxBundle").getString("run.logFiles"))); showHttpLogCheckBox = new JCheckBox(); this.$$$loadButtonText$$$(showHttpLogCheckBox, ResourceBundle.getBundle("net/ishchenko/idea/nginx/NginxBundle").getString("run.showAccessLog")); panel2.add(showHttpLogCheckBox, cc.xy(1, 1)); httpLogPathField = new JTextField(); httpLogPathField.setEditable(true); httpLogPathField.setEnabled(false); panel2.add(httpLogPathField, cc.xy(3, 1, CellConstraints.FILL, CellConstraints.DEFAULT)); showErrorLogCheckBox = new JCheckBox(); this.$$$loadButtonText$$$(showErrorLogCheckBox, ResourceBundle.getBundle("net/ishchenko/idea/nginx/NginxBundle").getString("run.showErrorLog")); panel2.add(showErrorLogCheckBox, cc.xy(1, 3)); errorLogPathField = new JTextField(); errorLogPathField.setEditable(true); errorLogPathField.setEnabled(false); panel2.add(errorLogPathField, cc.xy(3, 3, CellConstraints.FILL, CellConstraints.DEFAULT)); this.$$$loadLabelText$$$(explanationLabel, ResourceBundle.getBundle("net/ishchenko/idea/nginx/NginxBundle") .getString("run.layoutExplanation")); panel2.add(explanationLabel, cc.xyw(1, 5, 3)); }
From source file:net.jakobnielsen.aptivator.settings.SettingsDialog.java
License:Apache License
private JComponent buildStyleSheetPanel() { FormLayout formLayout = new FormLayout( // Columns "fill:default:grow, left:4dlu:noGrow, fill:50dlu:noGrow", // Rows "center:d:noGrow,top:3dlu:noGrow,center:d:grow"); // Label/* w w w .ja v a2 s . c o m*/ final JLabel mainLabel = new JLabel(); mainLabel.setText(rb.getString("form.field.stylesheets")); CellConstraints cc = new CellConstraints(); // List listModel = new DefaultListModel(); stylesheetList = new JList(listModel); stylesheetList.setSelectionMode(0); StyleSheetRenderer renderer = new StyleSheetRenderer(); stylesheetList.setCellRenderer(renderer); JScrollPane stylesheetScroll = new JScrollPane(stylesheetList); final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FormLayout( // Columns "fill:default:grow", // Rows "center:default:noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow,top:3dlu:noGrow,center:max(d;4px):noGrow")); // Buttons JButton addButton = new JButton(); addButton.setText(rb.getString("text.add")); buttonPanel.add(addButton, cc.xy(1, 1)); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { StylesheetDialog sd = new StylesheetDialog(new JFrame(), null, rb); sd.pack(); SwingTools.locateOnScreen(sd); sd.setVisible(true); if (rb.getString("text.ok").equals(sd.getAction())) { listModel.addElement(sd.getStyleSheet()); } } }); JButton editButton = new JButton(); editButton.setText(rb.getString("text.edit")); buttonPanel.add(editButton, cc.xy(1, 3)); editButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (stylesheetList.getSelectedIndex() > -1) { int idx = stylesheetList.getSelectedIndex(); StyleSheet ss = (StyleSheet) listModel.getElementAt(idx); StylesheetDialog sd = new StylesheetDialog(new JFrame(), ss, rb); sd.pack(); SwingTools.locateOnScreen(sd); sd.setVisible(true); if (rb.getString("text.ok").equals(sd.getAction())) { listModel.remove(idx); listModel.add(idx, sd.getStyleSheet()); } } } }); JButton removeButton = new JButton(); removeButton.setText(rb.getString("text.remove")); buttonPanel.add(removeButton, cc.xy(1, 5)); removeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (stylesheetList.getSelectedIndex() > -1) { listModel.remove(stylesheetList.getSelectedIndex()); } } }); // Main code PanelBuilder builder = new PanelBuilder(formLayout); builder.setDefaultDialogBorder(); builder.add(mainLabel, cc.xy(1, 1)); builder.add(stylesheetScroll, cc.xy(1, 3, CellConstraints.DEFAULT, CellConstraints.FILL)); builder.add(buttonPanel, cc.xy(3, 3, CellConstraints.DEFAULT, CellConstraints.FILL)); return builder.getPanel(); }
From source file:net.pms.medialibrary.gui.dialogs.AddAutoFolderDialog.java
License:Open Source License
private void rebuildPanel() { PanelBuilder builder;// w w w . jav a 2 s . co m CellConstraints cc = new CellConstraints(); FormLayout layout = new FormLayout("2dlu, fill:p:grow, 2dlu, p, 2dlu, p, 2dlu, fill:p:grow, 2dlu", // columns "2dlu, p, 2dlu, p, 2dlu, p"); // raws builder = new PanelBuilder(layout); builder.setOpaque(true); // Options builder.add(cbAutoFolder, cc.xy(2, 2)); builder.add(rbAscending, cc.xy(4, 2)); builder.add(rbDescending, cc.xy(6, 2)); builder.add(pMinOccurences, cc.xyw(4, 4, 5)); // Add A-Z options builder.add(cbProperty, cc.xy(2, 4)); // Add file system options builder.add(lOptionName, cc.xy(2, 4, CellConstraints.RIGHT, CellConstraints.DEFAULT)); builder.add(tfOption, cc.xyw(4, 4, 3)); builder.add(bBrowse, cc.xy(8, 4)); // Buttons builder.add(jPanelButtons, cc.xyw(2, 6, 7)); getContentPane().removeAll(); getContentPane().add(builder.getPanel()); pack(); }
From source file:net.pms.medialibrary.gui.dialogs.FileUpdateWithPluginDialog.java
License:Open Source License
private void build() { FormLayout layout = new FormLayout("5px, r:p, 5px, p, 5px, f:p:g, 5px", "5px, p, 5px, p, 5px, p, 5px, p, 5px, f:80:g, 5px, p, 5px"); PanelBuilder builder = new PanelBuilder(layout); builder.setOpaque(true);//from w w w . j av a 2 s . c om CellConstraints cc = new CellConstraints(); builder.addLabel(Messages.getString("ML.FileUpdateWithPluginDialog.lImportBy"), cc.xy(2, 2)); builder.add(rbName, cc.xy(4, 2)); builder.add(rbId, cc.xy(6, 2)); builder.addLabel(Messages.getString("ML.FileUpdateWithPluginDialog.lPlugin"), cc.xy(2, 4)); builder.add(cbPlugins, cc.xyw(4, 4, 3)); builder.add(lValueHeader, cc.xy(2, 6)); builder.add(tfValue, cc.xyw(4, 6, 3)); builder.addLabel(Messages.getString("ML.FileUpdateWithPluginDialog.lResults"), cc.xyw(2, 8, 5, CellConstraints.LEFT, CellConstraints.DEFAULT)); JPanel pResults = new JPanel(new BorderLayout()); pResults.setBorder(BorderFactory.createLineBorder(Color.lightGray)); JPanel pResultsFiller = new JPanel(); pResultsFiller.setBackground(lResults.getBackground()); pResults.add(lResults, BorderLayout.NORTH); pResults.add(pResultsFiller, BorderLayout.CENTER); JScrollPane spResults = new JScrollPane(pResults); spResults.setBorder(BorderFactory.createEmptyBorder()); builder.add(spResults, cc.xyw(2, 10, 5)); builder.add(pButtons, cc.xyw(2, 12, 5)); add(builder.getPanel()); }
From source file:net.pms.medialibrary.gui.dialogs.folderdialog.ConditionPanel.java
License:Open Source License
private Component getInheritPanel() { PanelBuilder builder;//from w w w.ja v a 2s . c om CellConstraints cc = new CellConstraints(); FormLayout layout = new FormLayout("p, 3px, p, 3px, p:grow", // columns "p"); // rows builder = new PanelBuilder(layout); builder.setOpaque(true); builder.add(lInherit, cc.xy(1, 1)); builder.add(bShowInherit, cc.xy(3, 1)); builder.add(cbInheritConditions, cc.xy(5, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT)); return builder.getPanel(); }
From source file:net.pms.medialibrary.gui.dialogs.quicktagdialog.QuickTagEntriesPanel.java
License:Open Source License
private void refresh() { if (isInitializing) { return;/*from w w w .ja v a 2 s. c o m*/ } //create the rows string String rowsString = "5px, p, 5px, "; if (quickTagEntryPanels.size() > 0) { for (int i = 0; i < quickTagEntryPanels.size(); i++) { rowsString += "p, 3px, "; } rowsString = rowsString.substring(0, rowsString.length() - 5); } rowsString += "5px"; FormLayout layout = new FormLayout("5px, 135, 5px, 135, 5px, f:210:g, 5px, p, 2px, p, 2px, p, 5px, p, 5px", rowsString); PanelBuilder builder = new PanelBuilder(layout); builder.setOpaque(true); CellConstraints cc = new CellConstraints(); //add the headers int rowIndex = 2; builder.add(new JHeader(Messages.getString("ML.QuickTagDialog.Header.Name")), cc.xy(2, rowIndex, CellConstraints.CENTER, CellConstraints.DEFAULT)); builder.add(new JHeader(Messages.getString("ML.QuickTagDialog.Header.TagName")), cc.xy(4, rowIndex, CellConstraints.CENTER, CellConstraints.DEFAULT)); builder.add(new JHeader(Messages.getString("ML.QuickTagDialog.Header.TagValue")), cc.xy(6, rowIndex, CellConstraints.CENTER, CellConstraints.DEFAULT)); builder.add(new JHeader(Messages.getString("ML.QuickTagDialog.Header.HotKey")), cc.xyw(8, rowIndex, 5, CellConstraints.CENTER, CellConstraints.DEFAULT)); //add the entries for (QuickTagEntryPanel pEntry : quickTagEntryPanels) { rowIndex += 2; builder.add(pEntry.getTfName(), cc.xy(2, rowIndex)); builder.add(pEntry.getCbTagName(), cc.xy(4, rowIndex)); builder.add(pEntry.getCbTagValue(), cc.xy(6, rowIndex)); builder.add(pEntry.getCbKeyCombination(), cc.xy(8, rowIndex)); builder.addLabel("+", cc.xy(10, rowIndex)); builder.add(pEntry.getCbVirtualKey(), cc.xy(12, rowIndex)); builder.add(pEntry.getbDelete(), cc.xy(14, rowIndex)); } removeAll(); JScrollPane spMain = new JScrollPane(builder.getPanel()); spMain.setBorder(BorderFactory.createEmptyBorder()); add(spMain); validate(); repaint(); }
From source file:net.pms.medialibrary.gui.dialogs.ScanFolderDialog.java
License:Open Source License
private void build(String folderPath) { FormLayout layout = new FormLayout("5px, p, 5px, fill:p:grow, 5px, p, 5px, p, 5px", "p, 2px, p, 5px, p, 2px, p"); PanelBuilder builder = new PanelBuilder(layout); builder.setOpaque(true);/* w w w. j a va 2 s . c om*/ CellConstraints cc = new CellConstraints(); // line 1 builder.addLabel(Messages.getString("ML.ScanFolderDialog.lFolderPath"), cc.xy(2, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT)); tfFolderPath = new JTextField(folderPath); tfFolderPath.setMinimumSize(new Dimension(300, tfFolderPath.getPreferredSize().height)); builder.add(tfFolderPath, cc.xy(4, 1)); bBrowseFolderPath = new JButton(Messages.getString("ML.ScanFolderDialog.bBrowse")); bBrowseFolderPath.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { JFileChooser fc = new JFileChooser(bBrowseFolderPath.getText()); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { tfFolderPath.setText(fc.getSelectedFile().getAbsolutePath()); } } }); builder.add(bBrowseFolderPath, cc.xy(6, 1)); cbScanSubFolders = new JCheckBox(Messages.getString("ML.ScanFolderDialog.cbScanSubFolders")); cbScanSubFolders.setSelected(true); builder.add(cbScanSubFolders, cc.xy(8, 1)); // line 2 builder.addLabel(Messages.getString("ML.ScanFolderDialog.lLookFor"), cc.xy(2, 3, CellConstraints.RIGHT, CellConstraints.DEFAULT)); JPanel pFileTypes = new JPanel(new FlowLayout()); cbScanVideo = new JCheckBox(Messages.getString("ML.ScanFolderDialog.cbScanVideo"), true); pFileTypes.add(cbScanVideo); cbScanAudio = new JCheckBox(Messages.getString("ML.ScanFolderDialog.cbScanAudio"), true); pFileTypes.add(cbScanAudio); cbScanPictures = new JCheckBox(Messages.getString("ML.ScanFolderDialog.cbScanPictures"), true); pFileTypes.add(cbScanPictures); builder.add(pFileTypes, cc.xy(4, 3, CellConstraints.LEFT, CellConstraints.DEFAULT)); cbUseFileImportPlugins = new JCheckBox(Messages.getString("ML.ScanFolderDialog.cbUsePlugins")); cbUseFileImportPlugins.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (cbUseFileImportPlugins.isSelected()) { pFileImport.setVisible(true); } else { pFileImport.setVisible(false); } pack(); } }); builder.add(cbUseFileImportPlugins, cc.xy(8, 3, CellConstraints.LEFT, CellConstraints.DEFAULT)); // file import pFileImport = new FileImportTemplatePanel(1); pFileImport.setVisible(false); pFileImport.addRepaintListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { pack(); } }); builder.add(pFileImport, cc.xyw(2, 5, 7)); // buttons bImport = new JButton(Messages.getString("ML.ScanFolderDialog.bImport")); if (bImport.getPreferredSize().width < MIN_BUTTON_WIDTH) bImport.setPreferredSize(new Dimension(MIN_BUTTON_WIDTH, bImport.getPreferredSize().height)); bImport.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { save(); File selectedFolder = new File(tfFolderPath.getText()); if (selectedFolder.isDirectory()) { setDoImport(true); instance.setVisible(false); } else { JOptionPane.showMessageDialog(null, Messages.getString("ML.ScanFolderDialog.InvalidPathMsg"), Messages.getString("ML.ScanFolderDialog.InvalidPathTitle"), JOptionPane.INFORMATION_MESSAGE); } } }); bCancel = new JButton(Messages.getString("ML.ScanFolderDialog.bCancel")); if (bCancel.getPreferredSize().width < MIN_BUTTON_WIDTH) bCancel.setPreferredSize(new Dimension(MIN_BUTTON_WIDTH, bCancel.getPreferredSize().height)); bCancel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { setDoImport(false); instance.setVisible(false); } }); bSave = new JButton(Messages.getString("ML.ScanFolderDialog.bSave")); if (bSave.getPreferredSize().width < MIN_BUTTON_WIDTH) bSave.setPreferredSize(new Dimension(MIN_BUTTON_WIDTH, bSave.getPreferredSize().height)); bSave.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { save(); } }); JPanel bPanel = new JPanel(); bPanel.setAlignmentX(CENTER_ALIGNMENT); bPanel.add(bImport); bPanel.add(bSave); bPanel.add(bCancel); builder.add(bPanel, cc.xyw(2, 7, 7)); getContentPane().add(builder.getPanel()); pack(); }
From source file:net.pms.medialibrary.gui.shared.FileImportTemplatePanel.java
License:Open Source License
/** * Places the visual components correctly in the grid. Components being shown are the combo box containing * the templates, all file properties with their list of engines and the buttons *//*from w w w. j ava 2 s . c o m*/ private void placeComponents() { FormLayout layout = new FormLayout("fill:p:grow, 5px, p, 5px, p, 5px, p", "p, 5px, fill:p:grow"); PanelBuilder builder = new PanelBuilder(layout); builder.setOpaque(true); CellConstraints cc = new CellConstraints(); //create top panel with combo box and and buttons builder.addLabel(Messages.getString("ML.FileImportConfigurationPanel.lTemplate"), cc.xy(1, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT)); builder.add(cbTemplate, cc.xy(3, 1)); builder.add(bNewTemplate, cc.xy(5, 1)); builder.add(bDeleteTemplate, cc.xy(7, 1)); builder.add(tpProperties, cc.xyw(1, 3, 7)); //build the dialog setLayout(new GridLayout()); removeAll(); add(builder.getPanel()); for (ActionListener l : repaintListeners) { l.actionPerformed(new ActionEvent(this, 0, "Repaint")); } }