List of usage examples for com.jgoodies.forms.layout Sizes PREFERRED
ComponentSize PREFERRED
To view the source code for com.jgoodies.forms.layout Sizes PREFERRED.
Click Source Link
From source file:org.eclipse.wb.internal.swing.FormLayout.model.ui.DimensionEditDialog.java
License:Open Source License
/** * Creates the size editing {@link Composite}. *///from www.j a va 2s.c om private void createSizeComposite(Composite parent) { createSeparator(parent, ModelMessages.DimensionEditDialog_size); // Composite composite = new Composite(parent, SWT.NONE); GridDataFactory.create(composite).grabH().fill().indentHC(2); GridLayoutFactory.create(composite).noMargins(); // default, preferred, minimum { Composite sizesComposite = new Composite(composite, SWT.NONE); GridDataFactory.create(sizesComposite).grabH().fill(); GridLayoutFactory.create(sizesComposite).columns(3).noMargins(); createComponentSizeButton(sizesComposite, Sizes.DEFAULT, "&default"); createComponentSizeButton(sizesComposite, Sizes.PREFERRED, "&preferred"); createComponentSizeButton(sizesComposite, Sizes.MINIMUM, "minim&um"); } // constants { Composite constantsComposite = new Composite(composite, SWT.NONE); GridDataFactory.create(constantsComposite).grabH().fill(); GridLayoutFactory.create(constantsComposite).columns(2).noMargins(); // constant size { { m_constantSizeButton = new Button(constantsComposite, SWT.RADIO); m_constantSizeButton.setText(ModelMessages.DimensionEditDialog_18); GridDataFactory.create(m_constantSizeButton).hintHC(15); m_constantSizeButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { FormSizeInfo size = m_dimension.getSize(); size.setComponentSize(null); if (size.getConstantSize() == null) { size.setConstantSize(new FormSizeConstantInfo(50, m_units[0].getUnit())); } showDimension(); } }); } // m_constantSizeComposite = new ConstantSizeComposite(constantsComposite, SWT.NONE, m_units); m_constantSizeComposite.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { FormSizeInfo size = m_dimension.getSize(); size.setConstantSize(m_constantSizeComposite.getConstantSize()); showDimension(); } }); } // lower { { m_lowerSizeButton = new Button(constantsComposite, SWT.CHECK); m_lowerSizeButton.setText(ModelMessages.DimensionEditDialog_19); m_lowerSizeButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { FormSizeInfo size = m_dimension.getSize(); size.setLowerSize(m_lowerSizeButton.getSelection()); if (size.getLowerSize() == null) { size.setLowerSize(new FormSizeConstantInfo(50, m_units[0].getUnit())); } showDimension(); } }); } // m_lowerSizeComposite = new ConstantSizeComposite(constantsComposite, SWT.NONE, m_units); m_lowerSizeComposite.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { FormSizeInfo size = m_dimension.getSize(); size.setLowerSize(m_lowerSizeComposite.getConstantSize()); showDimension(); } }); } // upper { { m_upperSizeButton = new Button(constantsComposite, SWT.CHECK); m_upperSizeButton.setText(ModelMessages.DimensionEditDialog_20); m_upperSizeButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { FormSizeInfo size = m_dimension.getSize(); size.setUpperSize(m_upperSizeButton.getSelection()); if (size.getUpperSize() == null) { size.setUpperSize(new FormSizeConstantInfo(50, m_units[0].getUnit())); } showDimension(); } }); } // m_upperSizeComposite = new ConstantSizeComposite(constantsComposite, SWT.NONE, m_units); m_upperSizeComposite.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { FormSizeInfo size = m_dimension.getSize(); size.setUpperSize(m_upperSizeComposite.getConstantSize()); showDimension(); } }); } } }
From source file:org.eclipse.wb.tests.designer.swing.model.layout.FormLayout.FormSizeInfoTest.java
License:Open Source License
public void test_FormSize_component_PREFERRED() throws Exception { FormSizeInfo size = new FormSizeInfo(Sizes.PREFERRED, true); assertTrue(size.isString());/*w w w .j a v a 2 s. c om*/ assertEquals("pref", size.getSource()); assertSame(Sizes.PREFERRED, size.getComponentSize()); assertEquals(Sizes.PREFERRED, size.getSize()); assertNull(size.getConstantSize()); // lower/upper assertFalse(size.hasLowerSize()); assertFalse(size.hasUpperSize()); assertNull(size.getLowerSize()); assertNull(size.getUpperSize()); }
From source file:org.eclipse.wb.tests.designer.swing.model.layout.FormLayout.FormSizeInfoTest.java
License:Open Source License
public void test_bounded_getDisplayString() throws Exception { check_bounded_getDisplayString(Sizes.DEFAULT, "DEFAULT", "default"); check_bounded_getDisplayString(Sizes.PREFERRED, "PREFERRED", "preferred"); check_bounded_getDisplayString(Sizes.MINIMUM, "MINIMUM", "minimum"); }
From source file:org.javad.stamp.pdf.ui.AlbumGeneratorPanel.java
License:Apache License
private void initialize() { AnnotationProcessor.process(this); setModelBean(new GenerateBean()); setBackground(new Color(248, 248, 255)); setForeground(new Color(211, 211, 211)); setDirection(GradientPanel.HORIZONTAL); setLayout(new FormLayout( new ColumnSpec[] { FormFactory.UNRELATED_GAP_COLSPEC, ColumnSpec.decode("79px"), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.bounded(Sizes.PREFERRED, Sizes.constant("250dlu", true), Sizes.constant("400dlu", true)), 1),//w ww . j ava 2 s. c o m ColumnSpec.decode("left:40px"), FormFactory.UNRELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("22dlu"), FormFactory.UNRELATED_GAP_ROWSPEC, RowSpec.decode("24px"), FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("24px"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("fill:60px:grow"), FormFactory.UNRELATED_GAP_ROWSPEC, })); add(getConfigurationLabel(), "2, 2, right, default"); add(getConfigPanel(), "4, 2, 2, 1, left, fill"); add(getInputFileLabel(), "2, 4, fill, center"); add(getInputFileText(), "4, 4, fill, center"); add(getBtnInputFile(), "5, 4, left, top"); add(getOutputFolderLabel(), "2, 6, fill, fill"); add(getOutputFolderText(), "4, 6, fill, center"); add(getBtnOutputFolder(), "5, 6, left, top"); add(getTagLabel(), "2, 8, fill, center"); add(getTagText(), "4, 8, fill, center"); add(getCheckRenderBorders(), "4, 10"); add(getCheckRenderReverse(), "4, 12, left, default"); add(getPanel(), "4, 14,fill, top"); add(getLogLabel(), "2, 16, right, top"); add(getScrollPane(), "4, 16,2,1 fill, fill"); Preferences prefs = Resources.getPreferencesNode(); String folderOutput = prefs.get(GeneratorConstants.DEFAULT_OUTPUT_FOLDER_KEY, null); String inputFile = prefs.get(GeneratorConstants.DEFAULT_INPUT_FILE_KEY, null); if (folderOutput != null) { getOutputFolderText().setText(folderOutput); } if (inputFile != null) { getInputFileText().setText(inputFile); } Logger.getLogger("org.javad").setLevel(Level.INFO); Logger.getLogger("org.javad").addHandler(new Handler() { @Override public void publish(LogRecord record) { getLogText().append(record.getMessage() + "\n"); } @Override public void flush() { } @Override public void close() throws SecurityException { getLogText().setText(null); } }); loadConfigurations(); PageConfigurations configs = PageConfigurations.getInstance(); configs.addPageConfigurationChangeHandler(this); }
From source file:org.jdesktop.swingx.demo.CustomizePromptPanel.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY // //GEN-BEGIN:initComponents // Generated using JFormDesigner Evaluation license - Peter Weishapl titledSeparator1 = new TitledSeparator(); label5 = new JLabel(); txtPrompt = new JTextField(); panel1 = new JPanel(); label1 = new JLabel(); rbHide = new JRadioButton(); rbShow = new JRadioButton(); rbHighlight = new JRadioButton(); panel2 = new JPanel(); label2 = new JLabel(); rbDefaultForeground = new JRadioButton(); rbRedForeground = new JRadioButton(); label3 = new JLabel(); rbDefaultBackground = new JRadioButton(); rbYelowBackground = new JRadioButton(); label4 = new JLabel(); rbDefaultFont = new JRadioButton(); rbItalicFont = new JRadioButton(); rbBoldFont = new JRadioButton(); rbBoldItalicFont = new JRadioButton(); CellConstraints cc = new CellConstraints(); //======== this ======== setLayout(new FormLayout( new ColumnSpec[] { FormFactory.UNRELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW) }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.UNRELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.UNRELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.UNRELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC })); //---- titledSeparator1 ---- titledSeparator1.setTitle("Prompt"); add(titledSeparator1, cc.xywh(1, 1, 4, 1)); //---- label5 ---- label5.setText("Prompt:"); add(label5, cc.xy(2, 3));//from ww w . j a va 2 s . c om //---- txtPrompt ---- txtPrompt.setText("Hello, I'm a plain JTextField. Come play with me..."); txtPrompt.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { promptChanged(e); } @Override public void keyPressed(KeyEvent e) { promptChanged(e); } @Override public void keyReleased(KeyEvent e) { promptChanged(e); } }); add(txtPrompt, cc.xy(4, 3)); //======== panel1 ======== { panel1.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.UNRELATED_GAP_COLSPEC, FormFactory.PREF_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.LEFT, Sizes.DEFAULT, FormSpec.NO_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW) }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC })); //---- label1 ---- label1.setText("When this component has the focus, the prompt should be:"); panel1.add(label1, cc.xywh(1, 1, 10, 1)); //---- rbHide ---- rbHide.setText("Hidden"); rbHide.setSelected(true); rbHide.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { focusBehaviorChanged(e); } }); panel1.add(rbHide, cc.xy(2, 3)); //---- rbShow ---- rbShow.setText("Shown"); rbShow.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { focusBehaviorChanged(e); } }); panel1.add(rbShow, cc.xy(4, 3)); //---- rbHighlight ---- rbHighlight.setText("Highlighted (Selected)"); rbHighlight.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { focusBehaviorChanged(e); } }); panel1.add(rbHighlight, cc.xy(6, 3)); } add(panel1, cc.xywh(2, 5, 3, 1)); //======== panel2 ======== { panel2.setLayout(new FormLayout( new ColumnSpec[] { new ColumnSpec(ColumnSpec.RIGHT, Sizes.PREFERRED, FormSpec.NO_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.UNRELATED_GAP_COLSPEC, new ColumnSpec(ColumnSpec.LEFT, Sizes.DEFAULT, FormSpec.NO_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC })); //---- label2 ---- label2.setText("Foreground:"); label2.setHorizontalAlignment(SwingConstants.RIGHT); panel2.add(label2, cc.xy(1, 1)); //---- rbDefaultForeground ---- rbDefaultForeground.setText("Default"); rbDefaultForeground.setSelected(true); rbDefaultForeground.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { foregroundChanged(e); } }); panel2.add(rbDefaultForeground, cc.xy(3, 1)); //---- rbRedForeground ---- rbRedForeground.setText("Red"); rbRedForeground.setForeground(Color.red); rbRedForeground.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { foregroundChanged(e); } }); panel2.add(rbRedForeground, cc.xy(5, 1)); //---- label3 ---- label3.setText("Background:"); label3.setHorizontalAlignment(SwingConstants.RIGHT); panel2.add(label3, cc.xy(1, 3)); //---- rbDefaultBackground ---- rbDefaultBackground.setText("Default"); rbDefaultBackground.setSelected(true); rbDefaultBackground.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { backgroundChanged(e); } }); panel2.add(rbDefaultBackground, cc.xy(3, 3)); //---- rbYelowBackground ---- rbYelowBackground.setText("Yellow"); rbYelowBackground.setBackground(Color.yellow); rbYelowBackground.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { backgroundChanged(e); } }); panel2.add(rbYelowBackground, cc.xy(5, 3)); //---- label4 ---- label4.setText("Font:"); label4.setHorizontalAlignment(SwingConstants.RIGHT); panel2.add(label4, cc.xy(1, 5)); //---- rbDefaultFont ---- rbDefaultFont.setText("Default"); rbDefaultFont.setSelected(true); rbDefaultFont.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { fontChanged(e); } }); panel2.add(rbDefaultFont, cc.xy(3, 5)); //---- rbItalicFont ---- rbItalicFont.setText("Italic"); rbItalicFont .setFont(rbItalicFont.getFont().deriveFont(rbItalicFont.getFont().getStyle() | Font.ITALIC)); rbItalicFont.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { fontChanged(e); } }); panel2.add(rbItalicFont, cc.xy(5, 5)); //---- rbBoldFont ---- rbBoldFont.setText("Bold"); rbBoldFont.setFont(rbBoldFont.getFont().deriveFont(rbBoldFont.getFont().getStyle() | Font.BOLD)); rbBoldFont.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { fontChanged(e); } }); panel2.add(rbBoldFont, cc.xy(7, 5)); //---- rbBoldItalicFont ---- rbBoldItalicFont.setText("Bold & Italic"); rbBoldItalicFont.setFont(rbBoldItalicFont.getFont().deriveFont(Font.BOLD | Font.ITALIC)); rbBoldItalicFont.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { fontChanged(e); } }); panel2.add(rbBoldItalicFont, cc.xy(9, 5)); } add(panel2, cc.xywh(2, 7, 3, 1)); //---- buttonGroup1 ---- ButtonGroup buttonGroup1 = new ButtonGroup(); buttonGroup1.add(rbHide); buttonGroup1.add(rbShow); buttonGroup1.add(rbHighlight); //---- buttonGroup2 ---- ButtonGroup buttonGroup2 = new ButtonGroup(); buttonGroup2.add(rbDefaultForeground); buttonGroup2.add(rbRedForeground); //---- buttonGroup3 ---- ButtonGroup buttonGroup3 = new ButtonGroup(); buttonGroup3.add(rbDefaultBackground); buttonGroup3.add(rbYelowBackground); //---- buttonGroup4 ---- ButtonGroup buttonGroup4 = new ButtonGroup(); buttonGroup4.add(rbDefaultFont); buttonGroup4.add(rbItalicFont); buttonGroup4.add(rbBoldFont); buttonGroup4.add(rbBoldItalicFont); // //GEN-END:initComponents }
From source file:repast.simphony.freezedry.datasource.JDBCConnectPanel.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner non-commercial license DefaultComponentFactory compFactory = DefaultComponentFactory.getInstance(); separator1 = compFactory.createSeparator("Database Connection Properties"); label1 = new JLabel(); urlField = new JTextField(); label2 = new JLabel(); driverField = new JTextField(); separator2 = compFactory.createSeparator("Database User Properties"); label3 = new JLabel(); userNameField = new JTextField(); label4 = new JLabel(); passwordField = new JPasswordField(); separator3 = compFactory.createSeparator("Last Connection Messages"); infoLabel = new JLabel(); errorLabel = new JLabel(); CellConstraints cc = new CellConstraints(); //======== this ======== setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.PREFERRED, FormSpec.DEFAULT_GROW) }, new RowSpec[] { new RowSpec(RowSpec.FILL, Sizes.DEFAULT, FormSpec.NO_GROW), FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC })); add(separator1, cc.xywh(1, 1, 3, 1)); //---- label1 ---- label1.setText("URL"); add(label1, cc.xy(1, 3));/*from ww w . ja va2 s .c o m*/ add(urlField, cc.xy(3, 3)); //---- label2 ---- label2.setText("Driver"); add(label2, cc.xy(1, 5)); add(driverField, cc.xy(3, 5)); add(separator2, cc.xywh(1, 7, 3, 1)); //---- label3 ---- label3.setText("User Name"); add(label3, cc.xy(1, 9)); add(userNameField, cc.xy(3, 9)); //---- label4 ---- label4.setText("Password"); add(label4, cc.xy(1, 11)); add(passwordField, cc.xy(3, 11)); add(separator3, cc.xywh(1, 13, 3, 1)); //---- infoLabel ---- infoLabel.setText("info"); infoLabel.setHorizontalAlignment(SwingConstants.CENTER); add(infoLabel, cc.xywh(1, 15, 3, 1)); //---- errorLabel ---- errorLabel.setText("error"); errorLabel.setForeground(Color.red); add(errorLabel, cc.xywh(1, 17, 3, 1)); // JFormDesigner - End of component initialization //GEN-END:initComponents // infoLabel.setPreferredSize(new Dimension(50, errorLabel.getPreferredSize().height)); errorLabel.setPreferredSize(new Dimension(50, errorLabel.getPreferredSize().height)); errorLabel.setText(""); infoLabel.setText(""); }
From source file:repast.simphony.freezedry.gui.DFDirectoryChooserStep.java
@SuppressWarnings("serial") private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner non-commercial license DefaultComponentFactory compFactory = DefaultComponentFactory.getInstance(); separator3 = compFactory.createSeparator("Data Loader Details"); label2 = new JLabel(); dirNameField = new JTextField(); browseButton = new JButton(); separator2 = compFactory.createSeparator("Data File Details"); panel1 = new JPanel(); commaButton = new JRadioButton(); colonButton = new JRadioButton(); semiColonButton = new JRadioButton(); tabButton = new JRadioButton(); spaceButton = new JRadioButton(); panel2 = new JPanel(); otherButton = new JRadioButton(); otherField = new JTextField(); CellConstraints cc = new CellConstraints(); //======== this ======== setLayout(new FormLayout( new ColumnSpec[] { new ColumnSpec(ColumnSpec.LEFT, Sizes.DEFAULT, FormSpec.NO_GROW), FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.PREFERRED, FormSpec.DEFAULT_GROW), FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.RIGHT, Sizes.DEFAULT, FormSpec.NO_GROW) }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC })); add(separator3, cc.xywh(1, 1, 5, 1)); //---- label2 ---- label2.setText("Data File:"); add(label2, cc.xy(1, 3));/*from w w w . java 2 s .c o m*/ //---- dirNameField ---- dirNameField.setText("c:\\program files\\example\\exampel32\\data.csv"); add(dirNameField, cc.xy(3, 3)); //---- browseButton ---- browseButton.setText("Browse..."); browseButton.setMnemonic('B'); browseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { browseButtonActionPerformed(e); } }); add(browseButton, cc.xy(5, 3)); add(separator2, cc.xywh(1, 5, 5, 1)); //======== panel1 ======== { panel1.setLayout(new GridBagLayout()); ((GridBagLayout) panel1.getLayout()).columnWidths = new int[] { 0, 0, 0, 0, 0 }; ((GridBagLayout) panel1.getLayout()).rowHeights = new int[] { 0, 0, 0, 0 }; ((GridBagLayout) panel1.getLayout()).columnWeights = new double[] { 1.0, 1.0, 1.0, 0.0, 1.0E-4 }; ((GridBagLayout) panel1.getLayout()).rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0E-4 }; //---- commaButton ---- commaButton.setText("Comma (,)"); commaButton.setSelected(true); panel1.add(commaButton, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); //---- colonButton ---- colonButton.setText("Colon (:)"); panel1.add(colonButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); //---- semiColonButton ---- semiColonButton.setText("Semicolon (;)"); panel1.add(semiColonButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); //---- tabButton ---- tabButton.setText("Tab"); panel1.add(tabButton, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); //---- spaceButton ---- spaceButton.setText("Space"); panel1.add(spaceButton, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); //======== panel2 ======== { panel2.setLayout(new GridBagLayout()); ((GridBagLayout) panel2.getLayout()).columnWidths = new int[] { 0, 25, 0 }; ((GridBagLayout) panel2.getLayout()).rowHeights = new int[] { 0, 0 }; ((GridBagLayout) panel2.getLayout()).columnWeights = new double[] { 0.0, 0.0, 1.0E-4 }; ((GridBagLayout) panel2.getLayout()).rowWeights = new double[] { 0.0, 1.0E-4 }; //---- otherButton ---- otherButton.setText("Other:"); otherButton.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { otherButtonStateChanged(e); } }); panel2.add(otherButton, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); //---- otherField ---- otherField.setEnabled(false); panel2.add(otherField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); } panel1.add(panel2, new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); } add(panel1, cc.xywh(1, 7, 5, 1)); //---- delimiterGroup ---- ButtonGroup delimiterGroup = new ButtonGroup(); delimiterGroup.add(commaButton); delimiterGroup.add(colonButton); delimiterGroup.add(semiColonButton); delimiterGroup.add(tabButton); delimiterGroup.add(spaceButton); delimiterGroup.add(otherButton); // JFormDesigner - End of component initialization //GEN-END:initComponents Enumeration<AbstractButton> enumer = delimiterGroup.getElements(); while (enumer.hasMoreElements()) { enumer.nextElement().addActionListener(this); } dirNameField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { setComplete(isFileNameValid() && !(otherButton.isSelected() && otherField.getText().equals(""))); } public void removeUpdate(DocumentEvent e) { setComplete(isFileNameValid() && !(otherButton.isSelected() && otherField.getText().equals(""))); } public void changedUpdate(DocumentEvent e) { } }); dirNameField.setText(""); dirNameField.grabFocus(); otherField.setDocument(new PlainDocument() { @Override public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { if (offs != 0) { return; } if (str.length() > 0) { super.insertString(offs, str.substring(0, 1), a); } } }); }
From source file:uk.ac.ebi.caf.component.factory.PreferencePanelFactory.java
License:Open Source License
public static void getPreferenceEditor(final BooleanPreference preference, JComponent component, final Action onFocusLost, FormLayout layout) { final JLabel label = LabelFactory.newFormLabel(preference.getName(), preference.getDescription()); final JCheckBox active = new JCheckBox(); active.setSelected(preference.get()); component.add(label, cc.xy(1, layout.getRowCount())); component.add(active, cc.xy(3, layout.getRowCount())); layout.appendRow(new RowSpec(Sizes.DLUY4)); layout.appendRow(new RowSpec(Sizes.PREFERRED)); active.addChangeListener(new ChangeListener() { @Override// w w w. j ava2 s .co m public void stateChanged(ChangeEvent e) { preference.put(active.isSelected()); onFocusLost.actionPerformed( new ActionEvent(active, ActionEvent.ACTION_PERFORMED, "Object state updated")); } }); }
From source file:uk.ac.ebi.caf.component.factory.PreferencePanelFactory.java
License:Open Source License
public static void getPreferenceEditor(final IntegerPreference preference, final JComponent component, final Action onFocusLost, FormLayout layout) { final JLabel label = LabelFactory.newFormLabel(preference.getName(), preference.getDescription()); final SpinnerNumberModel model = new SpinnerNumberModel(preference.get().intValue(), Integer.MIN_VALUE, Integer.MAX_VALUE, 1); final JSpinner spinner = new JSpinner(model); spinner.setEditor(new JSpinner.NumberEditor(spinner, "#")); // spinner.setPreferredSize(new Dimension(64, spinner.getPreferredSize().height)); component.add(label, cc.xy(1, layout.getRowCount())); component.add(spinner, cc.xy(3, layout.getRowCount())); layout.appendRow(new RowSpec(Sizes.DLUY4)); layout.appendRow(new RowSpec(Sizes.PREFERRED)); spinner.addChangeListener(new ChangeListener() { @Override/*from w w w .j ava 2 s . c o m*/ public void stateChanged(ChangeEvent e) { if (!preference.get().equals(spinner.getValue())) { preference.put((Integer) model.getValue()); } } }); addFocusLostAction(spinner, onFocusLost, preference); }
From source file:uk.ac.ebi.caf.component.factory.PreferencePanelFactory.java
License:Open Source License
public static void getPreferenceEditor(final StringPreference preference, final JComponent component, final Action onFocusLost, FormLayout layout) { final JLabel label = LabelFactory.newFormLabel(preference.getName(), preference.getDescription()); final JTextField field = FieldFactory.newField(preference.get()); component.add(label, cc.xy(1, layout.getRowCount())); component.add(field, cc.xy(3, layout.getRowCount())); layout.appendRow(new RowSpec(Sizes.DLUY4)); layout.appendRow(new RowSpec(Sizes.PREFERRED)); // fires to change the preference an the focus lost action final Timer timer = new Timer(1750, new ActionListener() { @Override/* w ww. j av a 2 s . c om*/ public void actionPerformed(ActionEvent e) { String value = field.getText(); if (!value.equals(preference.get())) { if (field.getText().isEmpty()) { field.setText(preference.getDefault()); } else { preference.put(value); onFocusLost.actionPerformed(e); } } } }); timer.setRepeats(false); field.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { timer.restart(); } @Override public void removeUpdate(DocumentEvent e) { timer.restart(); } @Override public void changedUpdate(DocumentEvent e) { timer.restart(); } }); }