List of usage examples for javax.swing JPanel setAlignmentY
@BeanProperty(description = "The preferred vertical alignment of the component.") public void setAlignmentY(float alignmentY)
From source file:com.devoteam.srit.xmlloader.core.report.derived.DerivedCounter.java
public void addMouseListenerForGraph(JPanel panel) { if (/*this instanceof StatAverage || this instanceof StatFlow*/ true) { panel.addMouseListener(new MouseListener() { java.awt.Color lastColor; public void mouseClicked(MouseEvent e) { }//from w w w. ja v a 2s. c o m public void mousePressed(MouseEvent e) { JFrameRTStats.instance().getJPanelBottom().removeAll(); JPanel longpanel = generateLongRTStats(); longpanel.setAlignmentX(java.awt.Component.LEFT_ALIGNMENT); longpanel.setAlignmentY(java.awt.Component.TOP_ALIGNMENT); JFrameRTStats.instance().getJPanelBottom().add(longpanel); // We add graphics to jPanelBottom JFrameRTStats.instance().getJPanelBottom().add(getChartPanel()); // We save the StatKey selected ModelTreeRTStats.instance().setStatSelected(id); // We update the panel for display the graph JFrameRTStats.instance().updatePanel(); } public void mouseReleased(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); } public void mouseEntered(MouseEvent e) { lastColor = e.getComponent().getBackground(); e.getComponent().setBackground(ModelTreeRTStats.instance().getColorByString("selectForGraph")); } public void mouseExited(MouseEvent e) { e.getComponent().setBackground(lastColor); } }); } }
From source file:components.ConversionPanel.java
ConversionPanel(Converter myController, String myTitle, Unit[] myUnits, ConverterRangeModel myModel) { if (MULTICOLORED) { setOpaque(true);/*from w ww. j a v a 2s . com*/ setBackground(new Color(0, 255, 255)); } setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(myTitle), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Save arguments in instance variables. controller = myController; units = myUnits; title = myTitle; sliderModel = myModel; //Create the text field format, and then the text field. numberFormat = NumberFormat.getNumberInstance(); numberFormat.setMaximumFractionDigits(2); NumberFormatter formatter = new NumberFormatter(numberFormat); formatter.setAllowsInvalid(false); formatter.setCommitsOnValidEdit(true);//seems to be a no-op -- //aha -- it changes the value property but doesn't cause the result to //be parsed (that happens on focus loss/return, I think). // textField = new JFormattedTextField(formatter); textField.setColumns(10); textField.setValue(new Double(sliderModel.getDoubleValue())); textField.addPropertyChangeListener(this); //Add the combo box. unitChooser = new JComboBox(); for (int i = 0; i < units.length; i++) { //Populate it. unitChooser.addItem(units[i].description); } unitChooser.setSelectedIndex(0); sliderModel.setMultiplier(units[0].multiplier); unitChooser.addActionListener(this); //Add the slider. slider = new JSlider(sliderModel); sliderModel.addChangeListener(this); //Make the text field/slider group a fixed size //to make stacked ConversionPanels nicely aligned. JPanel unitGroup = new JPanel() { public Dimension getMinimumSize() { return getPreferredSize(); } public Dimension getPreferredSize() { return new Dimension(150, super.getPreferredSize().height); } public Dimension getMaximumSize() { return getPreferredSize(); } }; unitGroup.setLayout(new BoxLayout(unitGroup, BoxLayout.PAGE_AXIS)); if (MULTICOLORED) { unitGroup.setOpaque(true); unitGroup.setBackground(new Color(0, 0, 255)); } unitGroup.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); unitGroup.add(textField); unitGroup.add(slider); //Create a subpanel so the combo box isn't too tall //and is sufficiently wide. JPanel chooserPanel = new JPanel(); chooserPanel.setLayout(new BoxLayout(chooserPanel, BoxLayout.PAGE_AXIS)); if (MULTICOLORED) { chooserPanel.setOpaque(true); chooserPanel.setBackground(new Color(255, 0, 255)); } chooserPanel.add(unitChooser); chooserPanel.add(Box.createHorizontalStrut(100)); //Put everything together. setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); add(unitGroup); add(chooserPanel); unitGroup.setAlignmentY(TOP_ALIGNMENT); chooserPanel.setAlignmentY(TOP_ALIGNMENT); }
From source file:Converter.java
ConversionPanel(Converter myController, String myTitle, Unit[] myUnits, ConverterRangeModel myModel) { if (MULTICOLORED) { setOpaque(true);/*from w w w. ja v a 2 s . c o m*/ setBackground(new Color(0, 255, 255)); } setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(myTitle), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Save arguments in instance variables. controller = myController; units = myUnits; title = myTitle; sliderModel = myModel; // Create the text field format, and then the text field. numberFormat = NumberFormat.getNumberInstance(); numberFormat.setMaximumFractionDigits(2); NumberFormatter formatter = new NumberFormatter(numberFormat); formatter.setAllowsInvalid(false); formatter.setCommitsOnValidEdit(true);// seems to be a no-op -- // aha -- it changes the value property but doesn't cause the result to // be parsed (that happens on focus loss/return, I think). // textField = new JFormattedTextField(formatter); textField.setColumns(10); textField.setValue(new Double(sliderModel.getDoubleValue())); textField.addPropertyChangeListener(this); // Add the combo box. unitChooser = new JComboBox(); for (int i = 0; i < units.length; i++) { // Populate it. unitChooser.addItem(units[i].description); } unitChooser.setSelectedIndex(0); sliderModel.setMultiplier(units[0].multiplier); unitChooser.addActionListener(this); // Add the slider. slider = new JSlider(sliderModel); sliderModel.addChangeListener(this); // Make the text field/slider group a fixed size // to make stacked ConversionPanels nicely aligned. JPanel unitGroup = new JPanel() { public Dimension getMinimumSize() { return getPreferredSize(); } public Dimension getPreferredSize() { return new Dimension(150, super.getPreferredSize().height); } public Dimension getMaximumSize() { return getPreferredSize(); } }; unitGroup.setLayout(new BoxLayout(unitGroup, BoxLayout.PAGE_AXIS)); if (MULTICOLORED) { unitGroup.setOpaque(true); unitGroup.setBackground(new Color(0, 0, 255)); } unitGroup.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); unitGroup.add(textField); unitGroup.add(slider); // Create a subpanel so the combo box isn't too tall // and is sufficiently wide. JPanel chooserPanel = new JPanel(); chooserPanel.setLayout(new BoxLayout(chooserPanel, BoxLayout.PAGE_AXIS)); if (MULTICOLORED) { chooserPanel.setOpaque(true); chooserPanel.setBackground(new Color(255, 0, 255)); } chooserPanel.add(unitChooser); chooserPanel.add(Box.createHorizontalStrut(100)); // Put everything together. setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); add(unitGroup); add(chooserPanel); unitGroup.setAlignmentY(TOP_ALIGNMENT); chooserPanel.setAlignmentY(TOP_ALIGNMENT); }
From source file:Installer.java
public Installer(File targetDir) { ToolTipManager.sharedInstance().setDismissDelay(Integer.MAX_VALUE); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel logoSplash = new JPanel(); logoSplash.setLayout(new BoxLayout(logoSplash, BoxLayout.Y_AXIS)); try {//from www .j av a 2s .c om // Read png BufferedImage image; image = ImageIO.read(Installer.class.getResourceAsStream("logo.png")); ImageIcon icon = new ImageIcon(image); JLabel logoLabel = new JLabel(icon); logoLabel.setAlignmentX(CENTER_ALIGNMENT); logoLabel.setAlignmentY(CENTER_ALIGNMENT); logoLabel.setSize(image.getWidth(), image.getHeight()); if (!QUIET_DEV) // VIVE - hide oculus logo logoSplash.add(logoLabel); } catch (IOException e) { } catch (IllegalArgumentException e) { } userHomeDir = System.getProperty("user.home", "."); osType = System.getProperty("os.name").toLowerCase(); if (osType.contains("win")) { isWindows = true; appDataDir = System.getenv("APPDATA"); } version = "UNKNOWN"; try { InputStream ver = Installer.class.getResourceAsStream("version"); if (ver != null) { String[] tok = new BufferedReader(new InputStreamReader(ver)).readLine().split(":"); if (tok.length > 0) { jar_id = tok[0]; version = tok[1]; } } } catch (IOException e) { } // Read release notes, save to file String tmpFileName = System.getProperty("java.io.tmpdir") + releaseNotePathAddition + "Vivecraft" + version.toLowerCase() + "_release_notes.txt"; releaseNotes = new File(tmpFileName); InputStream is = Installer.class.getResourceAsStream("release_notes.txt"); if (!copyInputStreamToFile(is, releaseNotes)) { releaseNotes = null; } JLabel tag = new JLabel("Welcome! This will install Vivecraft " + version); tag.setAlignmentX(CENTER_ALIGNMENT); tag.setAlignmentY(CENTER_ALIGNMENT); logoSplash.add(tag); logoSplash.add(Box.createRigidArea(new Dimension(5, 20))); tag = new JLabel("Select path to minecraft. (The default here is almost always what you want.)"); tag.setAlignmentX(CENTER_ALIGNMENT); tag.setAlignmentY(CENTER_ALIGNMENT); logoSplash.add(tag); logoSplash.setAlignmentX(CENTER_ALIGNMENT); logoSplash.setAlignmentY(TOP_ALIGNMENT); this.add(logoSplash); JPanel entryPanel = new JPanel(); entryPanel.setLayout(new BoxLayout(entryPanel, BoxLayout.X_AXIS)); Installer.targetDir = targetDir; selectedDirText = new JTextField(); selectedDirText.setEditable(false); selectedDirText.setToolTipText("Path to minecraft"); selectedDirText.setColumns(30); entryPanel.add(selectedDirText); JButton dirSelect = new JButton(); dirSelect.setAction(new FileSelectAction()); dirSelect.setText("..."); dirSelect.setToolTipText("Select an alternative minecraft directory"); entryPanel.add(dirSelect); entryPanel.setAlignmentX(LEFT_ALIGNMENT); entryPanel.setAlignmentY(TOP_ALIGNMENT); infoLabel = new JLabel(); infoLabel.setHorizontalTextPosition(JLabel.LEFT); infoLabel.setVerticalTextPosition(JLabel.TOP); infoLabel.setAlignmentX(LEFT_ALIGNMENT); infoLabel.setAlignmentY(TOP_ALIGNMENT); infoLabel.setVisible(false); fileEntryPanel = new JPanel(); fileEntryPanel.setLayout(new BoxLayout(fileEntryPanel, BoxLayout.Y_AXIS)); fileEntryPanel.add(infoLabel); fileEntryPanel.add(entryPanel); fileEntryPanel.setAlignmentX(CENTER_ALIGNMENT); fileEntryPanel.setAlignmentY(TOP_ALIGNMENT); this.add(fileEntryPanel); this.add(Box.createVerticalStrut(5)); JPanel optPanel = new JPanel(); optPanel.setLayout(new BoxLayout(optPanel, BoxLayout.Y_AXIS)); optPanel.setAlignmentX(LEFT_ALIGNMENT); optPanel.setAlignmentY(TOP_ALIGNMENT); //Add forge options JPanel forgePanel = new JPanel(); forgePanel.setLayout(new BoxLayout(forgePanel, BoxLayout.X_AXIS)); //Create forge: no/yes buttons useForge = new JCheckBox(); AbstractAction actf = new updateActionF(); actf.putValue(AbstractAction.NAME, "Install Vivecraft with Forge " + FORGE_VERSION); useForge.setAction(actf); forgeVersion = new JComboBox(); if (!ALLOW_FORGE_INSTALL) useForge.setEnabled(false); useForge.setToolTipText( "<html>" + "If checked, installs Vivecraft with Forge support. The correct version of Forge<br>" + "(as displayed) must already be installed.<br>" + "</html>"); //Add "yes" and "which version" to the forgePanel useForge.setAlignmentX(LEFT_ALIGNMENT); forgeVersion.setAlignmentX(LEFT_ALIGNMENT); forgePanel.add(useForge); //forgePanel.add(forgeVersion); // Profile creation / update support createProfile = new JCheckBox("", true); AbstractAction actp = new updateActionP(); actp.putValue(AbstractAction.NAME, "Create Vivecraft launcher profile"); createProfile.setAction(actp); createProfile.setAlignmentX(LEFT_ALIGNMENT); createProfile.setSelected(true); createProfile.setToolTipText("<html>" + "If checked, if a Vivecraft profile doesn't already exist within the Minecraft launcher<br>" + "one is added. Then the profile is selected, and this Vivecraft version is set as the<br>" + "current version.<br>" + "</html>"); useShadersMod = new JCheckBox(); useShadersMod.setAlignmentX(LEFT_ALIGNMENT); if (!ALLOW_SHADERSMOD_INSTALL) useShadersMod.setEnabled(false); AbstractAction acts = new updateActionSM(); acts.putValue(AbstractAction.NAME, "Install Vivecraft with ShadersMod 2.3.29"); useShadersMod.setAction(acts); useShadersMod.setToolTipText("<html>" + "If checked, sets the vivecraft profile to use ShadersMod <br>" + "support." + "</html>"); useHydra = new JCheckBox("Razer Hydra support", false); useHydra.setAlignmentX(LEFT_ALIGNMENT); if (!ALLOW_HYDRA_INSTALL) useHydra.setEnabled(false); useHydra.setToolTipText("<html>" + "If checked, installs the additional Razor Hydra native library required for Razor Hydra<br>" + "support." + "</html>"); useHrtf = new JCheckBox("Enable binaural audio (Only needed once per PC)", false); useHrtf.setToolTipText("<html>" + "If checked, the installer will create the configuration file needed for OpenAL HRTF<br>" + "ear-aware sound in Minecraft (and other games).<br>" + " If the file has previously been created, you do not need to check this again.<br>" + " NOTE: Your sound card's output MUST be set to 44.1Khz.<br>" + " WARNING, will overwrite " + (isWindows ? (appDataDir + "\\alsoft.ini") : (userHomeDir + "/.alsoftrc")) + "!<br>" + " Delete the " + (isWindows ? "alsoft.ini" : "alsoftrc") + " file to disable HRTF again." + "</html>"); useHrtf.setAlignmentX(LEFT_ALIGNMENT); //Add option panels option panel forgePanel.setAlignmentX(LEFT_ALIGNMENT); //optPanel.add(forgePanel); //optPanel.add(useShadersMod); optPanel.add(createProfile); optPanel.add(useHrtf); this.add(optPanel); this.add(Box.createRigidArea(new Dimension(5, 20))); instructions = new JLabel("", SwingConstants.CENTER); instructions.setAlignmentX(CENTER_ALIGNMENT); instructions.setAlignmentY(TOP_ALIGNMENT); instructions.setForeground(Color.RED); instructions.setPreferredSize(new Dimension(20, 40)); this.add(instructions); this.add(Box.createVerticalGlue()); JLabel github = linkify("Vivecraft is open source. find it on Github", "https://github.com/jrbudda/Vivecraft_111", "Vivecraft 1.11 Github"); JLabel wiki = linkify("Vivecraft home page", "http://www.vivecraft.org", "Vivecraft Home"); JLabel donate = linkify("If you think Vivecraft is awesome, please consider donating.", "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=JVBJLN5HJJS52&lc=US&item_name=jrbudda¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted)", "jrbudda's Paypal"); JLabel optifine = linkify("Vivecraft includes OptiFine for performance. Consider donating to them as well.", "http://optifine.net/donate.php", "http://optifine.net/donate.php"); github.setAlignmentX(CENTER_ALIGNMENT); github.setHorizontalAlignment(SwingConstants.CENTER); wiki.setAlignmentX(CENTER_ALIGNMENT); wiki.setHorizontalAlignment(SwingConstants.CENTER); donate.setAlignmentX(CENTER_ALIGNMENT); donate.setHorizontalAlignment(SwingConstants.CENTER); optifine.setAlignmentX(CENTER_ALIGNMENT); optifine.setHorizontalAlignment(SwingConstants.CENTER); this.add(Box.createRigidArea(new Dimension(5, 20))); this.add(github); this.add(wiki); this.add(donate); this.add(optifine); this.setAlignmentX(LEFT_ALIGNMENT); updateFilePath(); updateInstructions(); }
From source file:nz.govt.natlib.ndha.manualdeposit.StructMapFileDescManagement.java
private void initComponents() { scrlDescription = new javax.swing.JScrollPane(); lstDescription = new javax.swing.JList(); pnlDetails = new javax.swing.JPanel(); btnMoveUp = new javax.swing.JButton(); btnMoveDown = new javax.swing.JButton(); btnAddNew = new javax.swing.JButton(); btnDelete = new javax.swing.JButton(); btnSave = new javax.swing.JButton(); btnCancel = new javax.swing.JButton(); btnClose = new javax.swing.JButton(); btnGenMainDesc = new javax.swing.JButton(); setTitle("Manage Structure Map File Descriptions"); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); addWindowListener(new java.awt.event.WindowAdapter() { public void windowOpened(java.awt.event.WindowEvent evt) { formWindowOpened(evt);// w w w.jav a 2s . c o m } public void windowClosing(java.awt.event.WindowEvent evt) { dialogWindowClosing(evt); } }); scrlDescription.setViewportView(lstDescription); JPanel panelLayer1 = new JPanel(); panelLayer1.setAlignmentY(Component.TOP_ALIGNMENT); panel_ExtraLayers = new JPanel(); panel_ExtraLayers.setAlignmentY(Component.TOP_ALIGNMENT); panel_ExtraLayers.setMinimumSize(new Dimension(300, 0)); panel_ExtraLayers.setPreferredSize(new Dimension(300, 500)); panel_ExtraLayers.setMaximumSize(new Dimension(300, 500)); panel_ExtraLayers.setVisible(false); JLabel lblDescriptionL2 = new JLabel("Layer 2"); lblDescriptionL2.setFont(new Font("Tahoma", Font.PLAIN, 11)); JLabel lblDescription_1 = new JLabel("Description"); textfldDescriptionL2 = new JTextField(); textfldDescriptionL2.setName("DescriptionL2"); textfldDescriptionL2.setColumns(10); JLabel lblFilePrefixL2 = new JLabel("File Prefix/Suffix"); textfldFilePrefixL2 = new JTextField(); textfldFilePrefixL2.setName("FilePrefixL2"); textfldFilePrefixL2.setColumns(10); JLabel lblAllowMultiplesL2 = new JLabel("Allow Multiples?"); checkAllowMultiplesL2 = new JCheckBox(""); checkAllowMultiplesL2.setName("AllowMultiplesL2"); JLabel lblDescriptionL3 = new JLabel("Layer 3"); lblDescriptionL3.setFont(new Font("Tahoma", Font.PLAIN, 11)); JLabel lblDescription_2 = new JLabel("Description"); textfldDescriptionL3 = new JTextField(); textfldDescriptionL3.setName("DescriptionL3"); textfldDescriptionL3.setColumns(10); JLabel lblFilePrefixL3 = new JLabel("File Prefix/Suffix"); textfldFilePrefixL3 = new JTextField(); textfldFilePrefixL3.setName("FilePrefixL3"); textfldFilePrefixL3.setColumns(10); JLabel lblAllowMultiplesL3 = new JLabel("Allow Multiples?"); checkAllowMultiplesL3 = new JCheckBox(""); checkAllowMultiplesL3.setName("AllowMultiplesL3"); JLabel lblDescriptionL4 = new JLabel("Layer 4"); lblDescriptionL4.setFont(new Font("Tahoma", Font.PLAIN, 11)); JLabel lblDescription_3 = new JLabel("Description"); textfldDescriptionL4 = new JTextField(); textfldDescriptionL4.setName("DescriptionL4"); textfldDescriptionL4.setColumns(10); lblFilePrefixL4 = new JLabel("File Prefix/Suffix"); textfldFilePrefixL4 = new JTextField(); textfldFilePrefixL4.setName("FilePrefixL4"); textfldFilePrefixL4.setColumns(10); lblAllowMultiplesL4 = new JLabel("Allow Multiples?"); checkAllowMultiplesL4 = new JCheckBox(""); checkAllowMultiplesL4.setName("AllowMultiplesL4"); GroupLayout gl_panel_ExtraLayers = new GroupLayout(panel_ExtraLayers); gl_panel_ExtraLayers .setHorizontalGroup(gl_panel_ExtraLayers.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_ExtraLayers.createSequentialGroup().addContainerGap() .addGroup(gl_panel_ExtraLayers.createParallelGroup(Alignment.LEADING) .addComponent(lblDescriptionL2) .addGroup(gl_panel_ExtraLayers.createSequentialGroup() .addComponent(lblDescription_1).addGap(44) .addComponent(textfldDescriptionL2, GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)) .addGroup(gl_panel_ExtraLayers.createSequentialGroup() .addComponent(lblFilePrefixL2).addGap(18) .addComponent(textfldFilePrefixL2, GroupLayout.PREFERRED_SIZE, 53, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panel_ExtraLayers.createSequentialGroup() .addComponent(lblAllowMultiplesL2).addGap(18) .addComponent(checkAllowMultiplesL2)) .addComponent(lblDescriptionL3) .addGroup(gl_panel_ExtraLayers.createSequentialGroup() .addGroup(gl_panel_ExtraLayers .createParallelGroup(Alignment.LEADING) .addComponent(lblDescription_2) .addComponent(lblFilePrefixL3) .addComponent(lblAllowMultiplesL3)) .addGroup(gl_panel_ExtraLayers .createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_ExtraLayers.createSequentialGroup() .addGap(21) .addGroup(gl_panel_ExtraLayers .createParallelGroup(Alignment.LEADING) .addComponent(textfldFilePrefixL3, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE) .addComponent( textfldDescriptionL3, GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE))) .addGroup(gl_panel_ExtraLayers.createSequentialGroup() .addGap(18) .addGroup(gl_panel_ExtraLayers .createParallelGroup(Alignment.LEADING) .addComponent(textfldDescriptionL4, GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE) .addGroup(gl_panel_ExtraLayers .createSequentialGroup() .addComponent(checkAllowMultiplesL3) .addPreferredGap( ComponentPlacement.RELATED, 172, Short.MAX_VALUE)))))) .addComponent(lblDescriptionL4).addComponent(lblDescription_3) .addGroup(gl_panel_ExtraLayers.createSequentialGroup() .addComponent(lblFilePrefixL4).addGap(18) .addComponent(textfldFilePrefixL4, GroupLayout.PREFERRED_SIZE, 54, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panel_ExtraLayers.createSequentialGroup() .addComponent(lblAllowMultiplesL4).addGap(18) .addComponent(checkAllowMultiplesL4))) .addContainerGap())); gl_panel_ExtraLayers.setVerticalGroup(gl_panel_ExtraLayers.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_ExtraLayers.createSequentialGroup().addContainerGap() .addComponent(lblDescriptionL2).addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_ExtraLayers.createParallelGroup(Alignment.BASELINE) .addComponent(lblDescription_1) .addComponent(textfldDescriptionL2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_ExtraLayers.createParallelGroup(Alignment.BASELINE) .addComponent(lblFilePrefixL2) .addComponent(textfldFilePrefixL2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_ExtraLayers.createParallelGroup(Alignment.BASELINE) .addComponent(lblAllowMultiplesL2).addComponent(checkAllowMultiplesL2)) .addGap(18).addComponent(lblDescriptionL3).addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_ExtraLayers.createParallelGroup(Alignment.BASELINE) .addComponent(lblDescription_2) .addComponent(textfldDescriptionL3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_ExtraLayers.createParallelGroup(Alignment.BASELINE) .addComponent(lblFilePrefixL3) .addComponent(textfldFilePrefixL3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_ExtraLayers.createParallelGroup(Alignment.LEADING) .addComponent(lblAllowMultiplesL3).addComponent(checkAllowMultiplesL3)) .addGap(18).addComponent(lblDescriptionL4).addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_ExtraLayers.createParallelGroup(Alignment.BASELINE) .addComponent(lblDescription_3) .addComponent(textfldDescriptionL4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_ExtraLayers.createParallelGroup(Alignment.BASELINE) .addComponent(lblFilePrefixL4) .addComponent(textfldFilePrefixL4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_ExtraLayers.createParallelGroup(Alignment.BASELINE) .addComponent(lblAllowMultiplesL4).addComponent(checkAllowMultiplesL4)) .addContainerGap(39, Short.MAX_VALUE))); panel_ExtraLayers.setLayout(gl_panel_ExtraLayers); lblDescription = new JLabel(); lblDescription.setText("Description"); textfldDescription = new JTextField(); textfldDescription.setName("Description"); textfldFilePrefix = new JTextField(); textfldFilePrefix.setName("FilePrefix"); lblFilePrefix = new JLabel(); lblFilePrefix.setText("File Prefix/Suffix"); lblPosition = new JLabel(); lblPosition.setText("Position"); cmbPosition = new JComboBox(); cmbPosition.setName("Position"); lblMandatory = new JLabel(); lblMandatory.setText("Mandatory?"); checkMandatory = new JCheckBox(); checkMandatory.setName("Mandatory"); lblAllowMultiples = new JLabel(); lblAllowMultiples.setText("Allow Multiples?"); checkAllowMultiples = new JCheckBox(); checkAllowMultiples.setName("AllowMultiples"); lblExtraLayers = new JLabel("Extra Layers?"); checkExtraLayers = new JCheckBox(""); checkExtraLayers.setName("ExtraLayers"); checkExtraLayers.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { JCheckBox button = (JCheckBox) e.getSource(); if (button.isSelected()) { panel_MainDesc.setVisible(true); panel_ExtraLayers.setVisible(true); pnlDetails.revalidate(); pnlDetails.repaint(); } else { panel_MainDesc.setVisible(false); panel_ExtraLayers.setVisible(false); pnlDetails.revalidate(); pnlDetails.repaint(); } } }); GroupLayout gl_panelLayer1 = new GroupLayout(panelLayer1); gl_panelLayer1.setHorizontalGroup(gl_panelLayer1.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelLayer1.createSequentialGroup().addContainerGap() .addGroup(gl_panelLayer1.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelLayer1.createSequentialGroup() .addGroup(gl_panelLayer1.createParallelGroup(Alignment.LEADING) .addComponent(lblFilePrefix).addComponent(lblDescription) .addComponent(lblPosition)) .addGap(18) .addGroup(gl_panelLayer1.createParallelGroup(Alignment.LEADING) .addComponent(textfldFilePrefix, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE) .addComponent(textfldDescription, GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE) .addComponent(cmbPosition, 0, 169, Short.MAX_VALUE))) .addGroup( gl_panelLayer1.createSequentialGroup() .addGroup(gl_panelLayer1.createParallelGroup(Alignment.LEADING) .addComponent(lblAllowMultiples) .addComponent(lblExtraLayers).addComponent(lblMandatory)) .addGap(18) .addGroup(gl_panelLayer1.createParallelGroup(Alignment.LEADING) .addComponent(checkExtraLayers).addComponent(checkMandatory) .addComponent(checkAllowMultiples)))) .addContainerGap())); gl_panelLayer1 .setVerticalGroup(gl_panelLayer1.createParallelGroup(Alignment.TRAILING).addGroup(Alignment.LEADING, gl_panelLayer1.createSequentialGroup().addGap(24) .addGroup(gl_panelLayer1.createParallelGroup(Alignment.BASELINE) .addComponent(lblDescription) .addComponent(textfldDescription, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelLayer1 .createParallelGroup(Alignment.BASELINE).addComponent(lblFilePrefix) .addComponent(textfldFilePrefix, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelLayer1.createParallelGroup(Alignment.BASELINE) .addComponent(lblPosition) .addComponent(cmbPosition, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(8) .addGroup(gl_panelLayer1.createParallelGroup(Alignment.LEADING) .addComponent(checkMandatory).addComponent(lblMandatory)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelLayer1.createParallelGroup(Alignment.LEADING) .addComponent(checkAllowMultiples).addComponent(lblAllowMultiples)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelLayer1.createParallelGroup(Alignment.BASELINE) .addComponent(lblExtraLayers).addComponent(checkExtraLayers)) .addContainerGap(26, Short.MAX_VALUE))); panelLayer1.setLayout(gl_panelLayer1); btnMoveUp.setPreferredSize(new java.awt.Dimension(91, 23)); btnMoveUp.setText("Move Up"); btnMoveDown.setText("Move Down"); btnAddNew.setText("Add New"); btnDelete.setText("Delete"); btnSave.setText("Save"); btnCancel.setText("Cancel"); btnClose.setText("Close"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout .createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(Alignment.TRAILING).addGroup(layout.createSequentialGroup() .addComponent(scrlDescription, GroupLayout.DEFAULT_SIZE, 172, Short.MAX_VALUE).addGap(18) .addGroup(layout.createParallelGroup(Alignment.TRAILING) .addGroup(layout.createSequentialGroup().addComponent(btnAddNew).addGap(18) .addComponent(btnDelete, GroupLayout.PREFERRED_SIZE, 75, GroupLayout.PREFERRED_SIZE) .addGap(19)) .addComponent(pnlDetails, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup() .addComponent(btnMoveUp, GroupLayout.DEFAULT_SIZE, 78, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnMoveDown, GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE).addGap(89) .addComponent(btnSave, GroupLayout.DEFAULT_SIZE, 61, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(btnCancel, GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(btnClose, GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE))) .addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout .createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout.createSequentialGroup() .addComponent(pnlDetails, GroupLayout.PREFERRED_SIZE, 597, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(btnDelete) .addComponent(btnAddNew))) .addComponent(scrlDescription, GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE)) .addGap(18) .addGroup(layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(btnMoveUp, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(btnMoveDown)) .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(btnClose) .addComponent(btnCancel).addComponent(btnSave))) .addContainerGap())); pnlDetails.setLayout(new BoxLayout(pnlDetails, BoxLayout.Y_AXIS)); panel_MainDesc = new JPanel(); panel_MainDesc.setMinimumSize(new Dimension(300, 0)); panel_MainDesc.setPreferredSize(new Dimension(300, 60)); panel_MainDesc.setMaximumSize(new Dimension(300, 60)); panel_MainDesc.setVisible(false); lblDescriptionMain = new JLabel("Main Description"); textfldDescriptionMain = new JTextField(); textfldDescriptionMain.setName("DescriptionMain"); textfldDescriptionMain.setColumns(10); btnGenMainDesc_1 = new JButton(""); btnGenMainDesc_1.setToolTipText("Generate a main description by concatenating layer descriptions."); btnGenMainDesc_1.setContentAreaFilled(false); btnGenMainDesc_1.setIcon(new ImageIcon(StructMapFileDescManagement.class .getResource("/org/jdesktop/swingx/plaf/basic/resources/month-down.png"))); GroupLayout gl_panel_MainDesc = new GroupLayout(panel_MainDesc); gl_panel_MainDesc.setHorizontalGroup(gl_panel_MainDesc.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_MainDesc.createSequentialGroup().addContainerGap() .addComponent(lblDescriptionMain).addGap(18) .addComponent(textfldDescriptionMain, GroupLayout.PREFERRED_SIZE, 165, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnGenMainDesc_1, GroupLayout.PREFERRED_SIZE, 25, Short.MAX_VALUE) .addContainerGap())); gl_panel_MainDesc.setVerticalGroup(gl_panel_MainDesc.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_MainDesc.createSequentialGroup().addContainerGap().addGroup(gl_panel_MainDesc .createParallelGroup(Alignment.LEADING) .addComponent(btnGenMainDesc_1, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panel_MainDesc.createParallelGroup(Alignment.BASELINE) .addComponent(lblDescriptionMain).addComponent(textfldDescriptionMain, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); panel_MainDesc.setLayout(gl_panel_MainDesc); pnlDetails.add(panel_MainDesc); pnlDetails.add(panelLayer1); pnlDetails.add(panel_ExtraLayers); getContentPane().setLayout(layout); pack(); }
From source file:org.intermine.install.swing.BuildProjectDialog.java
/** * Common initialisation: lays out the child components and wires up the necessary * event listeners./*w w w. j av a 2s .com*/ */ private void init() { setName("Build Project Dialog"); setTitle(Messages.getMessage("build.project.title")); releaseNumberLabel.setLabelFor(releaseNumberTextField); destinationLabel.setLabelFor(destinationTextField); Container cp = getContentPane(); GridBagConstraints cons = GridBagHelper.setup(cp); JLabel infoLabel = new JLabel(Messages.getMessage("build.project.info.message")); infoLabel.setFont(infoLabel.getFont().deriveFont(Font.PLAIN)); cons.gridwidth = 2; cons.weightx = 1; cp.add(infoLabel, cons); JPanel startPolicyPanel = new JPanel(); // startPolicyPanel.setBorder(BorderFactory.createLoweredBevelBorder()); GridBagConstraints startPolicyPanelCons = GridBagHelper.setup(startPolicyPanel); startPolicyPanelCons.gridwidth = GridBagConstraints.REMAINDER; startPolicyPanel.add(startPolicyLabel, startPolicyPanelCons); startPolicyPanelCons.gridy++; startPolicyPanelCons.gridwidth = 2; buildDbRadioButton.setFont(infoLabel.getFont().deriveFont(Font.PLAIN)); startPolicyPanel.add(buildDbRadioButton, startPolicyPanelCons); startPolicyPanelCons.gridy++; restart1RadioButton.setFont(infoLabel.getFont().deriveFont(Font.PLAIN)); startPolicyPanel.add(restart1RadioButton, startPolicyPanelCons); // startPolicyPanelCons.gridy++; // restart2RadioButton.setFont(infoLabel.getFont().deriveFont(Font.PLAIN)); // startPolicyPanel.add(restart2RadioButton, startPolicyPanelCons); // // startPolicyPanelCons.gridy++; // testRadioButton.setFont(infoLabel.getFont().deriveFont(Font.PLAIN)); // startPolicyPanel.add(testRadioButton, startPolicyPanelCons); cons.gridy++; cp.add(startPolicyPanel, cons); JPanel userDBPanel = new JPanel(); // userDBPanel.setBorder(BorderFactory.createLoweredBevelBorder()); GridBagConstraints userDBCons = GridBagHelper.setup(userDBPanel); userDBPanel.setAlignmentY(LEFT_ALIGNMENT); // cons.gridwidth = GridBagConstraints.REMAINDER; userDBPanel.add(userDBOptionsLabel, userDBCons); // userDBCons.gridy++; // nowriteUserDbRadio.setFont(infoLabel.getFont().deriveFont(Font.PLAIN)); // userDBPanel.add(nowriteUserDbRadio, userDBCons); // // userDBCons.gridy++; // writeUserDbRadio.setFont(infoLabel.getFont().deriveFont(Font.PLAIN)); // userDBPanel.add(writeUserDbRadio, userDBCons); // // userDBCons.gridy++; // overwriteUserDbRadio.setFont(infoLabel.getFont().deriveFont(Font.PLAIN)); // userDBPanel.add(overwriteUserDbRadio, userDBCons); // // cons.gridy++; // cp.add(userDBPanel, cons); cons.gridy++; cons.gridx = 0; cons.weightx = 0; cons.gridwidth = 1; cp.add(encodingLabel, cons); cons.gridx++; cons.weightx = 0.5; encodingDropdown = new JComboBox(encodings); cp.add(encodingDropdown, cons); //cp.add(encodingTextField, cons); // cons.gridy++; // cons.gridx = 0; // cons.gridwidth = 3; // cons.weightx = 1; // cp.add(serverBackupCheckBox, cons); // cons.gridy++; // cons.gridx = 0; // cons.weightx = 0; // cons.gridwidth = 1; // cp.add(destinationCheckBox, cons); // cons.gridy++; // cons.weightx = 0; // cons.gridwidth = 1; // cp.add(destinationLabel, cons); // cons.gridx++; // cons.weightx = 0.75; // cons.gridwidth = 2; // cp.add(destinationTextField, cons); cons.gridy++; cons.gridx = 0; cons.weightx = 0; cons.gridwidth = 1; cp.add(new JLabel(Messages.getMessage("build.project.dump.host")), cons); cons.gridx++; cons.weightx = 0.75; cons.gridwidth = 1; cp.add(hostTextField, cons); cons.gridy++; cons.gridx = 0; cons.weightx = 0; cons.gridwidth = 1; cp.add(new JLabel(Messages.getMessage("build.project.dump.prefix")), cons); cons.gridx++; cons.weightx = 0.75; cons.gridwidth = 1; cp.add(prefixTextField, cons); cons.gridy++; cons.gridx = 0; cp.add(releaseNumberCheckBox, cons); // cons.gridy++; // cons.weightx = 0; // cons.gridwidth = 1; // cp.add(releaseNumberLabel, cons); cons.gridx++; cons.weightx = 0.5; cp.add(releaseNumberTextField, cons); cons.gridy++; cons.gridwidth = GridBagConstraints.REMAINDER; cons.gridx = 0; cons.weightx = 1; cp.add(new ButtonPanel(buildAction, new CancelAction()), cons); // encodingTextField.setText("SQL_ASCII"); // releaseNumberLabel.setEnabled(false); releaseNumberTextField.setEnabled(false); // destinationLabel.setEnabled(false); // destinationTextField.setEnabled(false); /** * Create Button group for userdb radio buttons * @serial */ ButtonGroup userDBButtonGroup = new ButtonGroup(); userDBButtonGroup.add(writeUserDbRadio); userDBButtonGroup.add(overwriteUserDbRadio); userDBButtonGroup.add(nowriteUserDbRadio); ButtonGroup startPolicyGroup = new ButtonGroup(); startPolicyGroup.add(restart1RadioButton); startPolicyGroup.add(restart2RadioButton); startPolicyGroup.add(buildDbRadioButton); startPolicyGroup.add(testRadioButton); releaseNumberCheckBox.addActionListener( new LinkedFieldListener(releaseNumberCheckBox, releaseNumberLabel, releaseNumberTextField)); destinationCheckBox.addActionListener( new LinkedFieldListener(destinationCheckBox, destinationLabel, destinationTextField)); DocumentListener requiredTextListener = new RequiredTextListener(); releaseNumberTextField.getDocument().addDocumentListener(requiredTextListener); // destinationTextField.getDocument().addDocumentListener(requiredTextListener); hostTextField.getDocument().addDocumentListener(requiredTextListener); prefixTextField.getDocument().addDocumentListener(requiredTextListener); hostTextField.setToolTipText(Messages.getMessage("build.project.dump.host.tooltip")); hostTextField.setText("localhost"); pack(); progressDialog = new SystemProcessProgressDialog(this); progressDialog.setModalityType(ModalityType.APPLICATION_MODAL); progressDialog.setTitle(Messages.getMessage("build.project.title")); progressDialog.setInformationLabel(Messages.getMessage("build.project.message")); }