List of usage examples for java.awt GridBagConstraints WEST
int WEST
To view the source code for java.awt GridBagConstraints WEST.
Click Source Link
From source file:org.kse.gui.dialogs.importexport.DImportKeyPairOpenSsl.java
private void initComponents() { GridBagConstraints gbcLbl = new GridBagConstraints(); gbcLbl.gridx = 0;// w w w . ja va 2 s. c o m gbcLbl.gridwidth = 3; gbcLbl.gridheight = 1; gbcLbl.insets = new Insets(5, 5, 5, 5); gbcLbl.anchor = GridBagConstraints.EAST; GridBagConstraints gbcEdCtrl = new GridBagConstraints(); gbcEdCtrl.gridx = 3; gbcEdCtrl.gridwidth = 3; gbcEdCtrl.gridheight = 1; gbcEdCtrl.insets = new Insets(5, 5, 5, 5); gbcEdCtrl.anchor = GridBagConstraints.WEST; jlEncrypted = new JLabel(res.getString("DImportKeyPairOpenSsl.jlEncrypted.text")); GridBagConstraints gbc_jlEncrypted = (GridBagConstraints) gbcLbl.clone(); gbc_jlEncrypted.gridy = 0; jcbEncrypted = new JCheckBox(); jcbEncrypted.setSelected(true); jcbEncrypted.setToolTipText(res.getString("DImportKeyPairOpenSsl.jcbEncrypted.tooltip")); GridBagConstraints gbc_jcbEncrypted = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jcbEncrypted.gridy = 0; jlPassword = new JLabel(res.getString("DImportKeyPairOpenSsl.jlPassword.text")); GridBagConstraints gbc_jlPassword = (GridBagConstraints) gbcLbl.clone(); gbc_jlPassword.gridy = 1; jpfPassword = new JPasswordField(15); jpfPassword.setToolTipText(res.getString("DImportKeyPairOpenSsl.jpfPassword.tooltip")); GridBagConstraints gbc_jpfPassword = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jpfPassword.gridy = 1; jlPrivateKey = new JLabel(res.getString("DImportKeyPairOpenSsl.jlPrivateKey.text")); GridBagConstraints gbc_jlPrivateKey = (GridBagConstraints) gbcLbl.clone(); gbc_jlPrivateKey.gridy = 2; jtfPrivateKeyPath = new JTextField(30); jtfPrivateKeyPath.setToolTipText(res.getString("DImportKeyPairOpenSsl.jtfPrivateKeyPath.tooltip")); GridBagConstraints gbc_jtfPrivateKeyPath = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jtfPrivateKeyPath.gridy = 2; gbc_jtfPrivateKeyPath.gridwidth = 6; jbPrivateKeyBrowse = new JButton(res.getString("DImportKeyPairOpenSsl.jbPrivateKeyBrowse.text")); PlatformUtil.setMnemonic(jbPrivateKeyBrowse, res.getString("DImportKeyPairOpenSsl.jbPrivateKeyBrowse.mnemonic").charAt(0)); jbPrivateKeyBrowse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairOpenSsl.this); privateKeyBrowsePressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairOpenSsl.this); } } }); jbPrivateKeyBrowse.setToolTipText(res.getString("DImportKeyPairOpenSsl.jbPrivateKeyBrowse.tooltip")); GridBagConstraints gbc_jbPrivateKeyBrowse = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jbPrivateKeyBrowse.gridy = 2; gbc_jbPrivateKeyBrowse.gridx = 9; jbPrivateKeyDetails = new JButton(res.getString("DImportKeyPairOpenSsl.jbPrivateKeyDetails.text")); jbPrivateKeyDetails.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairOpenSsl.this); privateKeyDetailsPressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairOpenSsl.this); } } }); PlatformUtil.setMnemonic(jbPrivateKeyDetails, res.getString("DImportKeyPairOpenSsl.jbPrivateKeyDetails.mnemonic").charAt(0)); jbPrivateKeyDetails.setToolTipText(res.getString("DImportKeyPairOpenSsl.jbPrivateKeyDetails.tooltip")); GridBagConstraints gbc_jbPrivateKeyDetails = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jbPrivateKeyDetails.gridy = 2; gbc_jbPrivateKeyDetails.gridx = 12; jlCertificate = new JLabel(res.getString("DImportKeyPairOpenSsl.jlCertificate.text")); GridBagConstraints gbc_jlCertificate = (GridBagConstraints) gbcLbl.clone(); gbc_jlCertificate.gridy = 3; jtfCertificatePath = new JTextField(30); jtfCertificatePath.setToolTipText(res.getString("DImportKeyPairOpenSsl.jtfCertificatePath.tooltip")); GridBagConstraints gbc_jtfCertificatePath = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jtfCertificatePath.gridy = 3; gbc_jtfCertificatePath.gridwidth = 6; jbCertificateBrowse = new JButton(res.getString("DImportKeyPairOpenSsl.jbCertificateBrowse.text")); jbCertificateBrowse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairOpenSsl.this); certificateBrowsePressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairOpenSsl.this); } } }); PlatformUtil.setMnemonic(jbCertificateBrowse, res.getString("DImportKeyPairOpenSsl.jbCertificateBrowse.mnemonic").charAt(0)); jbCertificateBrowse.setToolTipText(res.getString("DImportKeyPairOpenSsl.jbCertificateBrowse.tooltip")); GridBagConstraints gbc_jbCertificateBrowse = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jbCertificateBrowse.gridy = 3; gbc_jbCertificateBrowse.gridx = 9; jbCertificateDetails = new JButton(res.getString("DImportKeyPairOpenSsl.jbCertificateDetails.text")); jbCertificateDetails.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairOpenSsl.this); certificateDetailsPressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairOpenSsl.this); } } }); PlatformUtil.setMnemonic(jbCertificateDetails, res.getString("DImportKeyPairOpenSsl.jbCertificateDetails.mnemonic").charAt(0)); jbCertificateDetails.setToolTipText(res.getString("DImportKeyPairOpenSsl.jbCertificateDetails.tooltip")); GridBagConstraints gbc_jbCertificateDetails = (GridBagConstraints) gbcEdCtrl.clone(); gbc_jbCertificateDetails.gridy = 3; gbc_jbCertificateDetails.gridx = 12; jpKeyPair = new JPanel(new GridBagLayout()); jpKeyPair.setBorder(new CompoundBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new EtchedBorder()), new EmptyBorder(5, 5, 5, 5))); jpKeyPair.add(jlEncrypted, gbc_jlEncrypted); jpKeyPair.add(jcbEncrypted, gbc_jcbEncrypted); jpKeyPair.add(jlPassword, gbc_jlPassword); jpKeyPair.add(jpfPassword, gbc_jpfPassword); jpKeyPair.add(jlPrivateKey, gbc_jlPrivateKey); jpKeyPair.add(jtfPrivateKeyPath, gbc_jtfPrivateKeyPath); jpKeyPair.add(jbPrivateKeyBrowse, gbc_jbPrivateKeyBrowse); jpKeyPair.add(jbPrivateKeyDetails, gbc_jbPrivateKeyDetails); jpKeyPair.add(jlCertificate, gbc_jlCertificate); jpKeyPair.add(jtfCertificatePath, gbc_jtfCertificatePath); jpKeyPair.add(jbCertificateBrowse, gbc_jbCertificateBrowse); jpKeyPair.add(jbCertificateDetails, gbc_jbCertificateDetails); jcbEncrypted.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent evt) { if (jcbEncrypted.isSelected()) { jpfPassword.setEnabled(true); } else { jpfPassword.setEnabled(false); jpfPassword.setText(""); } } }); jbImport = new JButton(res.getString("DImportKeyPairOpenSsl.jbImport.text")); PlatformUtil.setMnemonic(jbImport, res.getString("DImportKeyPairOpenSsl.jbImport.mnemonic").charAt(0)); jbImport.setToolTipText(res.getString("DImportKeyPairOpenSsl.jbImport.tooltip")); jbImport.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DImportKeyPairOpenSsl.this); importPressed(); } finally { CursorUtil.setCursorFree(DImportKeyPairOpenSsl.this); } } }); jbCancel = new JButton(res.getString("DImportKeyPairOpenSsl.jbCancel.text")); jbCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY); jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jpButtons = PlatformUtil.createDialogButtonPanel(jbImport, jbCancel); getContentPane().setLayout(new BorderLayout()); getContentPane().add(jpKeyPair, BorderLayout.CENTER); getContentPane().add(jpButtons, BorderLayout.SOUTH); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { closeDialog(); } }); setTitle(res.getString("DImportKeyPairOpenSsl.Title")); setResizable(false); getRootPane().setDefaultButton(jbImport); pack(); }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.OtherTaskPaneUI.java
/** * Lays out the other annotations.// w ww . ja v a2 s .c o m * * @param list The collection of annotation to layout. */ private void layoutOthers(Collection list) { clearDisplay(); DocComponent doc; GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.WEST; c.insets = new Insets(1, 2, 1, 2); c.gridx = 0; c.gridy = 0; c.weightx = 0; c.weighty = 0; c.fill = GridBagConstraints.NONE; if (!CollectionUtils.isEmpty(list)) { Iterator i = list.iterator(); while (i.hasNext()) { c.gridx = 0; c.weightx = 0; c.fill = GridBagConstraints.NONE; DataObject item = (DataObject) i.next(); if (filter == Filter.SHOW_ALL || (filter == Filter.ADDED_BY_ME && model.isLinkOwner(item)) || (filter == Filter.ADDED_BY_OTHERS && model.isAnnotatedByOther(item))) { doc = new DocComponent(item, model); doc.addPropertyChangeListener(controller); otherList.add(doc); add(new JLabel(getType((AnnotationData) item) + ":"), c); c.gridx = 1; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; add(doc, c); c.gridy++; } } } }
From source file:pcgen.gui.sources.SourceSelectionDialog.java
/** * This method is called from within the constructor to * initialize the form./*from w w w.j a v a2 s.c om*/ */ private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(new java.awt.GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(4, 4, 4, 4); JLabel jLabel1 = new JLabel(LanguageBundle.getString("in_qsrc_intro")); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0.0, 0.0); getContentPane().add(jLabel1, gbc); sourceList = new javax.swing.JList(); sourceModel = new DefaultListModel(); List<String> strings = getSourceNames(); for (String string : strings) { sourceModel.addElement(string); } sourceList.setModel(sourceModel); sourceList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); sourceList.setLayoutOrientation(JList.VERTICAL_WRAP); sourceList.setVisibleRowCount(2); sourceList.setCellRenderer(new SourceListCellRenderer()); JScrollPane listScrollPane = new JScrollPane(sourceList); listScrollPane.setPreferredSize(new Dimension(480, 260)); if (lastLoadedCollection != null && lastLoadedCollection.length() > 0) { sourceList.setSelectedValue(lastLoadedCollection, true); } Utility.buildRelativeConstraints(gbc, 2, 5, 100, 100, GridBagConstraints.BOTH, GridBagConstraints.WEST); getContentPane().add(listScrollPane, gbc); JButton addButton = new JButton(LanguageBundle.getString("in_add")); addButton.setActionCommand(ACTION_ADD); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); getContentPane().add(addButton, gbc); modifyButton = new JButton(LanguageBundle.getString("in_modify")); modifyButton.setActionCommand(ACTION_MODIFY); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); getContentPane().add(modifyButton, gbc); JButton hideButton = new JButton(LanguageBundle.getString("in_hide")); hideButton.setActionCommand(ACTION_HIDE); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH); getContentPane().add(hideButton, gbc); JButton unhideButton = new JButton(LanguageBundle.getString("in_unhide")); unhideButton.setActionCommand(ACTION_UNHIDE); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH); getContentPane().add(unhideButton, gbc); deleteButton = new JButton(LanguageBundle.getString("in_delete")); deleteButton.setActionCommand(ACTION_DELETE); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH); getContentPane().add(deleteButton, gbc); JButton advancedButton = new JButton(LanguageBundle.getString("in_qsrc_advanced")); advancedButton.setActionCommand(ACTION_ADVANCED); getRootPane().setDefaultButton(advancedButton); Utility.buildRelativeConstraints(gbc, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST); getContentPane().add(advancedButton, gbc); JButton loadButton = new JButton(LanguageBundle.getString("in_load")); loadButton.setActionCommand(ACTION_LOAD); getRootPane().setDefaultButton(loadButton); Utility.buildRelativeConstraints(gbc, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.EAST); getContentPane().add(loadButton, gbc); JButton cancelButton = new JButton(LanguageBundle.getString("in_cancel")); cancelButton.setActionCommand(ACTION_CANCEL); Utility.buildRelativeConstraints(gbc, 1, 1, 0, 0); getContentPane().add(cancelButton, gbc); //Listen for actions on the buttons addButton.addActionListener(this); modifyButton.addActionListener(this); deleteButton.addActionListener(this); hideButton.addActionListener(this); unhideButton.addActionListener(this); advancedButton.addActionListener(this); loadButton.addActionListener(this); cancelButton.addActionListener(this); sourceList.addListSelectionListener(this); valueChanged(null); //Listen for actions on the list sourceList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { sourceListMouseClicked(evt); } }); pack(); }
From source file:org.ut.biolab.medsavant.client.view.component.KeyValuePairPanel.java
@SuppressWarnings("LeakingThisInConstructor") public KeyValuePairPanel(int addCols, boolean widelist) { setOpaque(false);/*from w w w . j a v a2 s .c o m*/ ViewUtil.applyVerticalBoxLayout(this); kvpPanel = ViewUtil.getClearPanel(); toolbar = ViewUtil.getClearPanel(); ViewUtil.applyHorizontalBoxLayout(toolbar); add(kvpPanel); add(toolbar); additionalColumns = addCols; keyKeyComponentMap = new HashMap<String, JLabel>(); keyValueComponentMap = new HashMap<String, JPanel>(); keyDetailComponentMap = new HashMap<String, JPanel>(); keyExtraComponentsMap = new HashMap<String, JPanel[]>(); columnConstraints = new ArrayList<GridBagConstraints>(); keysInMoreSection = new ArrayList<String>(); // Full-width detail component keyDetailConstraints = new GridBagConstraints(); keyDetailConstraints.anchor = GridBagConstraints.SOUTHWEST; keyDetailConstraints.weightx = 1.0; keyDetailConstraints.fill = GridBagConstraints.BOTH; keyDetailConstraints.gridx = 0; keyDetailConstraints.gridy = 0; keyDetailConstraints.gridwidth = GridBagConstraints.REMAINDER; // Constraints for keys GridBagConstraints keyConstraints = new GridBagConstraints(); keyConstraints.anchor = GridBagConstraints.SOUTHWEST; keyConstraints.fill = GridBagConstraints.BOTH; keyConstraints.weightx = 0; keyConstraints.gridx = 0; keyConstraints.gridy = 0; keyConstraints.ipadx = 5; // Constraints for values GridBagConstraints valueConstraints = new GridBagConstraints(); valueConstraints.anchor = GridBagConstraints.SOUTHWEST; valueConstraints.fill = GridBagConstraints.BOTH; valueConstraints.weightx = widelist ? 0 : 1; valueConstraints.gridx = 1; valueConstraints.gridy = 0; valueConstraints.ipadx = 5; columnConstraints.add(keyConstraints); columnConstraints.add(valueConstraints); // Constraints for additional columns for (int i = 0; i < additionalColumns; i++) { GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.BOTH; // 1 iff widelist and last additional column c.weightx = widelist ? ((i == additionalColumns - 1) ? 1 : 0) : 0; c.gridx = i + columnConstraints.size(); c.gridy = 0; columnConstraints.add(c); } GridBagLayout gbl = new GridBagLayout(); kvpPanel.setLayout(gbl); }
From source file:pcgen.gui2.prefs.LocationPanel.java
/** * Instantiates a new location panel./*w ww . j a v a 2 s . co m*/ */ public LocationPanel() { Border etched = null; TitledBorder title1 = BorderFactory.createTitledBorder(etched, IN_LOCATION); title1.setTitleJustification(TitledBorder.LEFT); this.setBorder(title1); GridBagLayout gridbag = new GridBagLayout(); this.setLayout(gridbag); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(2, 2, 2, 2); Utility.buildConstraints(constraints, 0, 0, 1, 1, 0, 0); JLabel label = new JLabel(IN_BROWSER_PATH + ": "); gridbag.setConstraints(label, constraints); this.add(label); Utility.buildConstraints(constraints, 1, 0, 1, 1, 1, 0); browserPath = new JTextField(String.valueOf(PCGenSettings.getBrowserPath())); // sage_sam 9 April 2003 browserPath.addFocusListener(textFieldListener); gridbag.setConstraints(browserPath, constraints); this.add(browserPath); Utility.buildConstraints(constraints, 2, 0, 1, 1, 0, 0); browserPathButton = new JButton(IN_CHOOSE); gridbag.setConstraints(browserPathButton, constraints); this.add(browserPathButton); browserPathButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(constraints, 1, 1, 1, 1, 0, 0); clearBrowserPathButton = new JButton(IN_CLEAR_BROWSER_PATH); gridbag.setConstraints(clearBrowserPathButton, constraints); this.add(clearBrowserPathButton); clearBrowserPathButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(constraints, 0, 2, 1, 1, 0, 0); JLabel in_prefs_pcgenCharacterDir = new JLabel( LanguageBundle.getString("in_Prefs_pcgenCharacterDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 2, 1, 1, 0, 0); pcgenCharacterDir = new JTextField(String.valueOf(PCGenSettings.getPcgDir())); // sage_sam 9 April 2003 pcgenCharacterDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenCharacterDir, constraints); this.add(pcgenCharacterDir); Utility.buildConstraints(constraints, 2, 2, 1, 1, 0, 0); pcgenCharacterDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenCharacterDirButton, constraints); this.add(pcgenCharacterDirButton); pcgenCharacterDirButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(constraints, 0, 3, 1, 1, 0, 0); //TODO i18n in_prefs_pcgenCharacterDir = new JLabel("PCGen Portraits Directory" + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 3, 1, 1, 0, 0); pcgenPortraitsDir = new JTextField(String.valueOf(PCGenSettings.getPortraitsDir())); // sage_sam 9 April 2003 pcgenPortraitsDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenPortraitsDir, constraints); this.add(pcgenPortraitsDir); Utility.buildConstraints(constraints, 2, 3, 1, 1, 0, 0); pcgenPortraitsDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenPortraitsDirButton, constraints); this.add(pcgenPortraitsDirButton); pcgenPortraitsDirButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(constraints, 0, 4, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel(LanguageBundle.getString("in_Prefs_pcgenDataDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 4, 1, 1, 0, 0); pcgenDataDir = new JTextField(String.valueOf(ConfigurationSettings.getPccFilesDir())); // sage_sam 9 April 2003 pcgenDataDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenDataDir, constraints); this.add(pcgenDataDir); Utility.buildConstraints(constraints, 2, 4, 1, 1, 0, 0); pcgenDataDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenDataDirButton, constraints); this.add(pcgenDataDirButton); pcgenDataDirButton.addActionListener(prefsButtonHandler); ////////////////////// Utility.buildConstraints(constraints, 0, 5, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel(LanguageBundle.getString("in_Prefs_pcgenCustomDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 5, 1, 1, 0, 0); pcgenCustomDir = new JTextField(String.valueOf(PCGenSettings.getCustomDir())); // sage_sam 9 April 2003 pcgenCustomDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenCustomDir, constraints); this.add(pcgenCustomDir); Utility.buildConstraints(constraints, 2, 5, 1, 1, 0, 0); pcgenCustomDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenCustomDirButton, constraints); this.add(pcgenCustomDirButton); pcgenCustomDirButton.addActionListener(prefsButtonHandler); //////////////////// Utility.buildConstraints(constraints, 0, 6, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel(LanguageBundle.getString("in_Prefs_pcgenVendorDataDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 6, 1, 1, 0, 0); pcgenVendorDataDir = new JTextField(String.valueOf(PCGenSettings.getVendorDataDir())); // sage_sam 9 April 2003 pcgenVendorDataDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenVendorDataDir, constraints); this.add(pcgenVendorDataDir); Utility.buildConstraints(constraints, 2, 6, 1, 1, 0, 0); pcgenVendorDataDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenVendorDataDirButton, constraints); this.add(pcgenVendorDataDirButton); pcgenVendorDataDirButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(constraints, 0, 7, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel(LanguageBundle.getString("in_Prefs_pcgenHomebrewDataDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 7, 1, 1, 0, 0); pcgenHomebrewDataDir = new JTextField(String.valueOf(PCGenSettings.getHomebrewDataDir())); pcgenHomebrewDataDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenHomebrewDataDir, constraints); this.add(pcgenHomebrewDataDir); Utility.buildConstraints(constraints, 2, 7, 1, 1, 0, 0); pcgenHomebrewDataDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenHomebrewDataDirButton, constraints); this.add(pcgenHomebrewDataDirButton); pcgenHomebrewDataDirButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(constraints, 0, 8, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel(LanguageBundle.getString("in_Prefs_pcgenDocsDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 8, 1, 1, 0, 0); pcgenDocsDir = new JTextField(String.valueOf(ConfigurationSettings.getDocsDir())); // sage_sam 9 April 2003 pcgenDocsDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenDocsDir, constraints); this.add(pcgenDocsDir); Utility.buildConstraints(constraints, 2, 8, 1, 1, 0, 0); pcgenDocsDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenDocsDirButton, constraints); this.add(pcgenDocsDirButton); pcgenDocsDirButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(constraints, 0, 9, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel(LanguageBundle.getString("in_Prefs_pcgenSystemDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 9, 1, 1, 0, 0); pcgenSystemDir = new JTextField(String.valueOf(ConfigurationSettings.getSystemsDir())); // sage_sam 9 April 2003 pcgenSystemDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenSystemDir, constraints); this.add(pcgenSystemDir); Utility.buildConstraints(constraints, 2, 9, 1, 1, 0, 0); pcgenSystemDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenSystemDirButton, constraints); this.add(pcgenSystemDirButton); pcgenSystemDirButton.addActionListener(prefsButtonHandler); // Output Sheet directory Utility.buildConstraints(constraints, 0, 10, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel(LanguageBundle.getString("in_Prefs_pcgenOutputSheetDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 10, 1, 1, 0, 0); pcgenOutputSheetDir = new JTextField(String.valueOf(ConfigurationSettings.getOutputSheetsDir())); pcgenOutputSheetDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenOutputSheetDir, constraints); this.add(pcgenOutputSheetDir); Utility.buildConstraints(constraints, 2, 10, 1, 1, 0, 0); pcgenOutputSheetDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenOutputSheetDirButton, constraints); this.add(pcgenOutputSheetDirButton); pcgenOutputSheetDirButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(constraints, 0, 11, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel(LanguageBundle.getString("in_Prefs_pcgenPreviewDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 11, 1, 1, 0, 0); pcgenPreviewDir = new JTextField(String.valueOf(ConfigurationSettings.getPreviewDir())); pcgenPreviewDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenPreviewDir, constraints); this.add(pcgenPreviewDir); Utility.buildConstraints(constraints, 2, 11, 1, 1, 0, 0); pcgenPreviewDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenPreviewDirButton, constraints); this.add(pcgenPreviewDirButton); pcgenPreviewDirButton.addActionListener(prefsButtonHandler); // Character File Backup directory Utility.buildConstraints(constraints, 0, 12, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel( LanguageBundle.getString("in_Prefs_pcgenCreateBackupCharacter") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 12, 1, 1, 0, 0); gridbag.setConstraints(pcgenCreateBackupCharacter, constraints); this.add(pcgenCreateBackupCharacter); Utility.buildConstraints(constraints, 0, 13, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel( LanguageBundle.getString("in_Prefs_pcgenBackupCharacterDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 13, 1, 1, 0, 0); pcgenBackupCharacterDir = new JTextField(String.valueOf(PCGenSettings.getBackupPcgDir())); pcgenBackupCharacterDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenBackupCharacterDir, constraints); this.add(pcgenBackupCharacterDir); Utility.buildConstraints(constraints, 2, 13, 1, 1, 0, 0); pcgenBackupCharacterDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenBackupCharacterDirButton, constraints); this.add(pcgenBackupCharacterDirButton); pcgenBackupCharacterDirButton.addActionListener(prefsButtonHandler); // Where to store options.ini file Utility.buildConstraints(constraints, 0, 14, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel(LanguageBundle.getString("in_Prefs_pcgenFilesDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); pcgenFilesDirRadio = new JRadioButton("PCGen Dir"); usersFilesDirRadio = new JRadioButton("Home Dir"); selectFilesDirRadio = new JRadioButton("Select a directory"); pcgenFilesDir = new JTextField(String.valueOf(ConfigurationSettings.getSettingsDir())); pcgenFilesDir.addFocusListener(textFieldListener); String fType = ConfigurationSettings.getSystemProperty(ConfigurationSettings.SETTINGS_FILES_PATH); if ((fType == null) || (fType.length() < 1)) { // make sure we have a default fType = ConfigurationSettings.getDefaultSettingsFilesPath(); ConfigurationSettings.setSystemProperty(ConfigurationSettings.SETTINGS_FILES_PATH, fType); } pcgenFilesDir.setText(ConfigurationSettings.getSettingsDir()); if (fType.equals(SettingsFilesPath.pcgen.name())) { pcgenFilesDirRadio.setSelected(true); } else if (fType.equals(SettingsFilesPath.user.name()) || fType.equals(SettingsFilesPath.mac_user.name()) || fType.equals(SettingsFilesPath.FD_USER.name())) { usersFilesDirRadio.setSelected(true); } else { selectFilesDirRadio.setSelected(true); } Utility.buildConstraints(constraints, 0, 15, 1, 1, 0, 0); gridbag.setConstraints(pcgenFilesDirRadio, constraints); this.add(pcgenFilesDirRadio); Utility.buildConstraints(constraints, 1, 15, 1, 1, 0, 0); gridbag.setConstraints(usersFilesDirRadio, constraints); this.add(usersFilesDirRadio); groupFilesDir = new ButtonGroup(); groupFilesDir.add(pcgenFilesDirRadio); groupFilesDir.add(usersFilesDirRadio); groupFilesDir.add(selectFilesDirRadio); pcgenFilesDirRadio.addActionListener(evt -> { pcgenFilesDir.setText(SettingsFilesPath.pcgen.getSettingsDir()); pcgenFilesDirButton.setEnabled(false); }); usersFilesDirRadio.addActionListener(evt -> { pcgenFilesDir.setText(ConfigurationSettings.getUserSettingsDirFromFilePath()); pcgenFilesDirButton.setEnabled(false); }); selectFilesDirRadio.addActionListener(evt -> { pcgenFilesDir.setText(""); pcgenFilesDirButton.setEnabled(true); }); Utility.buildConstraints(constraints, 0, 16, 1, 1, 0, 0); gridbag.setConstraints(selectFilesDirRadio, constraints); this.add(selectFilesDirRadio); Utility.buildConstraints(constraints, 1, 16, 1, 1, 0, 0); gridbag.setConstraints(pcgenFilesDir, constraints); this.add(pcgenFilesDir); Utility.buildConstraints(constraints, 2, 16, 1, 1, 0, 0); pcgenFilesDirButton = new JButton(IN_CHOOSE); pcgenFilesDirButton.setEnabled(selectFilesDirRadio.isSelected()); gridbag.setConstraints(pcgenFilesDirButton, constraints); this.add(pcgenFilesDirButton); pcgenFilesDirButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(constraints, 0, 20, 3, 1, 1, 1); constraints.fill = GridBagConstraints.BOTH; JLabel emptyLabel = new JLabel(" "); gridbag.setConstraints(emptyLabel, constraints); this.add(emptyLabel); }
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 ww . j a va 2 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:com.digitalgeneralists.assurance.ui.components.ResultsPanel.java
private void initializeComponent() { if (!this.initialized) { GridBagLayout gridbag = new GridBagLayout(); this.setLayout(gridbag); ((DefaultTableCellRenderer) resultsTable.getTableHeader().getDefaultRenderer()) .setHorizontalAlignment(JLabel.CENTER); this.resultsTable.setRowHeight(150); ListSelectionModel selectionModel = this.resultsTable.getSelectionModel(); selectionModel.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { applicationDelegate.fireEvent(new SetScanResultsMenuStateEvent(false)); resultsTable.editCellAt(resultsTable.getSelectedRow(), 0); }//from w w w . ja va 2 s .com }); GridBagConstraints resultsLabelConstraints = new GridBagConstraints(); resultsLabelConstraints.anchor = GridBagConstraints.WEST; resultsLabelConstraints.fill = GridBagConstraints.BOTH; resultsLabelConstraints.gridx = 0; resultsLabelConstraints.gridy = 0; resultsLabelConstraints.weightx = 1.0; resultsLabelConstraints.weighty = 0.1; resultsLabelConstraints.gridheight = 1; resultsLabelConstraints.gridwidth = 1; resultsLabelConstraints.insets = new Insets(5, 5, 5, 5); this.progressIndicatorConstraints.anchor = GridBagConstraints.WEST; this.progressIndicatorConstraints.fill = GridBagConstraints.BOTH; this.progressIndicatorConstraints.gridx = 0; this.progressIndicatorConstraints.gridy = 1; this.progressIndicatorConstraints.weightx = 1.0; this.progressIndicatorConstraints.weighty = 0.1; this.progressIndicatorConstraints.gridheight = 1; this.progressIndicatorConstraints.gridwidth = 1; this.progressIndicatorConstraints.insets = new Insets(5, 5, 5, 5); this.progressIndicator.setIndeterminate(true); this.resultsListConstraints.anchor = GridBagConstraints.WEST; this.resultsListConstraints.fill = GridBagConstraints.BOTH; this.resultsListConstraints.gridx = 0; this.resultsListConstraints.gridy = 2; this.resultsListConstraints.weightx = 1.0; this.resultsListConstraints.weighty = 0.9; this.resultsListConstraints.gridheight = 1; this.resultsListConstraints.gridwidth = 1; this.resultsListConstraints.insets = new Insets(5, 5, 5, 5); this.add(this.resultsLabel, resultsLabelConstraints); this.add(this.resultsScrollPane, this.resultsListConstraints); this.addAncestorListener(new AncestorListener() { public void ancestorAdded(AncestorEvent event) { resultsTable.setDefaultRenderer(ComparisonResult.class, comparisonResultListRenderer); resultsTable.setDefaultEditor(ComparisonResult.class, comparisonResultListRenderer); applicationDelegate.addEventObserver(ScanStartedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(ComparisonResultAddedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(ScanResultsLoadedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(SelectedScanChangedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(ScanCompletedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(ScanProgressEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(ResultMergeCompletedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(ScanMergeStartedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(ScanMergeProgressEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(ScanMergeCompletedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(DeletedItemRestoreCompletedEvent.class, (IEventObserver) event.getSource()); } public void ancestorRemoved(AncestorEvent event) { applicationDelegate.removeEventObserver(ScanStartedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(ComparisonResultAddedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(ScanResultsLoadedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(SelectedScanChangedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(ScanCompletedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(ScanProgressEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(ResultMergeCompletedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(ScanMergeStartedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(ScanMergeProgressEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(ScanMergeCompletedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(DeletedItemRestoreCompletedEvent.class, (IEventObserver) event.getSource()); } public void ancestorMoved(AncestorEvent event) { } }); this.initialized = true; } }
From source file:TextSamplerDemo.java
public TextSamplerDemo() { setLayout(new BorderLayout()); //Create a regular text field. JTextField textField = new JTextField(10); textField.setActionCommand(textFieldString); textField.addActionListener(this); //Create a password field. JPasswordField passwordField = new JPasswordField(10); passwordField.setActionCommand(passwordFieldString); passwordField.addActionListener(this); //Create a formatted text field. JFormattedTextField ftf = new JFormattedTextField(java.util.Calendar.getInstance().getTime()); ftf.setActionCommand(textFieldString); ftf.addActionListener(this); //Create some labels for the fields. JLabel textFieldLabel = new JLabel(textFieldString + ": "); textFieldLabel.setLabelFor(textField); JLabel passwordFieldLabel = new JLabel(passwordFieldString + ": "); passwordFieldLabel.setLabelFor(passwordField); JLabel ftfLabel = new JLabel(ftfString + ": "); ftfLabel.setLabelFor(ftf);/*ww w. j a v a 2s . co m*/ //Create a label to put messages during an action event. actionLabel = new JLabel("Type text and then Enter in a field."); actionLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); //Lay out the text controls and the labels. JPanel textControlsPane = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); textControlsPane.setLayout(gridbag); JLabel[] labels = { textFieldLabel, passwordFieldLabel, ftfLabel }; JTextField[] textFields = { textField, passwordField, ftf }; addLabelTextRows(labels, textFields, gridbag, textControlsPane); c.gridwidth = GridBagConstraints.REMAINDER; //last c.anchor = GridBagConstraints.WEST; c.weightx = 1.0; textControlsPane.add(actionLabel, c); textControlsPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Text Fields"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Create a text area. JTextArea textArea = new JTextArea("This is an editable JTextArea. " + "A text area is a \"plain\" text component, " + "which means that although it can display text " + "in any font, all of the text is in the same font."); textArea.setFont(new Font("Serif", Font.ITALIC, 16)); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); JScrollPane areaScrollPane = new JScrollPane(textArea); areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); areaScrollPane.setPreferredSize(new Dimension(250, 250)); areaScrollPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Plain Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5)), areaScrollPane.getBorder())); //Create an editor pane. JEditorPane editorPane = createEditorPane(); JScrollPane editorScrollPane = new JScrollPane(editorPane); editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(250, 145)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); //Create a text pane. JTextPane textPane = createTextPane(); JScrollPane paneScrollPane = new JScrollPane(textPane); paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); paneScrollPane.setPreferredSize(new Dimension(250, 155)); paneScrollPane.setMinimumSize(new Dimension(10, 10)); //Put the editor pane and the text pane in a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, editorScrollPane, paneScrollPane); splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(0.5); JPanel rightPane = new JPanel(new GridLayout(1, 0)); rightPane.add(splitPane); rightPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Styled Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Put everything together. JPanel leftPane = new JPanel(new BorderLayout()); leftPane.add(textControlsPane, BorderLayout.PAGE_START); leftPane.add(areaScrollPane, BorderLayout.CENTER); add(leftPane, BorderLayout.LINE_START); add(rightPane, BorderLayout.LINE_END); }
From source file:com.litt.core.security.license.gui.CustomerPanel.java
public CustomerPanel() { GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] { 0, 0, 0, 0 }; gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; gridBagLayout.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE }; gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 }; setLayout(gridBagLayout);/*from ww w . j a v a2 s .c om*/ JLabel lblProduct = new JLabel("\u4EA7\u54C1\uFF1A"); GridBagConstraints gbc_lblProduct = new GridBagConstraints(); gbc_lblProduct.insets = new Insets(0, 0, 5, 5); gbc_lblProduct.anchor = GridBagConstraints.EAST; gbc_lblProduct.gridx = 0; gbc_lblProduct.gridy = 0; add(lblProduct, gbc_lblProduct); comboBoxProduct = new JComboBox(); GridBagConstraints gbc_comboBoxProduct = new GridBagConstraints(); gbc_comboBoxProduct.insets = new Insets(0, 0, 5, 5); gbc_comboBoxProduct.fill = GridBagConstraints.HORIZONTAL; gbc_comboBoxProduct.gridx = 1; gbc_comboBoxProduct.gridy = 0; add(comboBoxProduct, gbc_comboBoxProduct); JButton btnRefresh = new JButton(""); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { initProduct(); } }); btnRefresh.setIcon(new ImageIcon(CustomerPanel.class.getResource("/images/icon_refresh.png"))); GridBagConstraints gbc_btnRefresh = new GridBagConstraints(); gbc_btnRefresh.insets = new Insets(0, 0, 5, 0); gbc_btnRefresh.gridx = 2; gbc_btnRefresh.gridy = 0; add(btnRefresh, gbc_btnRefresh); JLabel lblProductVersion = new JLabel("\u4EA7\u54C1\u7248\u672C\uFF1A"); GridBagConstraints gbc_lblProductVersion = new GridBagConstraints(); gbc_lblProductVersion.anchor = GridBagConstraints.EAST; gbc_lblProductVersion.insets = new Insets(0, 0, 5, 5); gbc_lblProductVersion.gridx = 0; gbc_lblProductVersion.gridy = 1; add(lblProductVersion, gbc_lblProductVersion); textFieldProductVersion = new VersionTextField(); textFieldProductVersion.setColumns(10); GridBagConstraints gbc_textFieldProductVersion = new GridBagConstraints(); gbc_textFieldProductVersion.anchor = GridBagConstraints.WEST; gbc_textFieldProductVersion.insets = new Insets(0, 0, 5, 5); gbc_textFieldProductVersion.gridx = 1; gbc_textFieldProductVersion.gridy = 1; add(textFieldProductVersion, gbc_textFieldProductVersion); JLabel lblCompanyName = new JLabel("\u516C\u53F8\u540D\u79F0\uFF1A"); GridBagConstraints gbc_lblCompanyName = new GridBagConstraints(); gbc_lblCompanyName.anchor = GridBagConstraints.EAST; gbc_lblCompanyName.insets = new Insets(0, 0, 5, 5); gbc_lblCompanyName.gridx = 0; gbc_lblCompanyName.gridy = 2; add(lblCompanyName, gbc_lblCompanyName); textFieldCompanyName = new JTextField(); GridBagConstraints gbc_textFieldCompanyName = new GridBagConstraints(); gbc_textFieldCompanyName.insets = new Insets(0, 0, 5, 5); gbc_textFieldCompanyName.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldCompanyName.gridx = 1; gbc_textFieldCompanyName.gridy = 2; add(textFieldCompanyName, gbc_textFieldCompanyName); textFieldCompanyName.setColumns(10); JLabel lblCustomerCode = new JLabel("\u5BA2\u6237\u7F16\u53F7\uFF1A"); GridBagConstraints gbc_lblCustomerCode = new GridBagConstraints(); gbc_lblCustomerCode.anchor = GridBagConstraints.EAST; gbc_lblCustomerCode.insets = new Insets(0, 0, 5, 5); gbc_lblCustomerCode.gridx = 0; gbc_lblCustomerCode.gridy = 3; add(lblCustomerCode, gbc_lblCustomerCode); textFieldCustomerCode = new JTextField(); GridBagConstraints gbc_textFieldCustomerCode = new GridBagConstraints(); gbc_textFieldCustomerCode.insets = new Insets(0, 0, 5, 5); gbc_textFieldCustomerCode.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldCustomerCode.gridx = 1; gbc_textFieldCustomerCode.gridy = 3; add(textFieldCustomerCode, gbc_textFieldCustomerCode); textFieldCustomerCode.setColumns(10); JLabel lblCustomerName = new JLabel("\u5BA2\u6237\u540D\u79F0\uFF1A"); GridBagConstraints gbc_lblCustomerName = new GridBagConstraints(); gbc_lblCustomerName.anchor = GridBagConstraints.EAST; gbc_lblCustomerName.insets = new Insets(0, 0, 5, 5); gbc_lblCustomerName.gridx = 0; gbc_lblCustomerName.gridy = 4; add(lblCustomerName, gbc_lblCustomerName); textFieldCustomerName = new JTextField(); GridBagConstraints gbc_textFieldCustomerName = new GridBagConstraints(); gbc_textFieldCustomerName.insets = new Insets(0, 0, 5, 5); gbc_textFieldCustomerName.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldCustomerName.gridx = 1; gbc_textFieldCustomerName.gridy = 4; add(textFieldCustomerName, gbc_textFieldCustomerName); textFieldCustomerName.setColumns(10); JLabel lblLicenseType = new JLabel("\u8BC1\u4E66\u7C7B\u578B\uFF1A"); GridBagConstraints gbc_lblLicenseType = new GridBagConstraints(); gbc_lblLicenseType.anchor = GridBagConstraints.EAST; gbc_lblLicenseType.insets = new Insets(0, 0, 5, 5); gbc_lblLicenseType.gridx = 0; gbc_lblLicenseType.gridy = 5; add(lblLicenseType, gbc_lblLicenseType); comboBoxLicenseType = new JComboBox(); GridBagConstraints gbc_comboBoxLicenseType = new GridBagConstraints(); gbc_comboBoxLicenseType.insets = new Insets(0, 0, 5, 5); gbc_comboBoxLicenseType.fill = GridBagConstraints.HORIZONTAL; gbc_comboBoxLicenseType.gridx = 1; gbc_comboBoxLicenseType.gridy = 5; add(comboBoxLicenseType, gbc_comboBoxLicenseType); JLabel lblExpiredDate = new JLabel("\u8FC7\u671F\u65F6\u95F4\uFF1A"); GridBagConstraints gbc_lblExpiredDate = new GridBagConstraints(); gbc_lblExpiredDate.insets = new Insets(0, 0, 5, 5); gbc_lblExpiredDate.gridx = 0; gbc_lblExpiredDate.gridy = 6; add(lblExpiredDate, gbc_lblExpiredDate); datePickerExpiredDate = new DatePicker(new Date(), "yyyy-MM-dd", null, null); GridBagConstraints gbc_datePicker = new GridBagConstraints(); gbc_datePicker.anchor = GridBagConstraints.WEST; gbc_datePicker.insets = new Insets(0, 0, 5, 5); gbc_datePicker.gridx = 1; gbc_datePicker.gridy = 6; add(datePickerExpiredDate, gbc_datePicker); JButton btnSave = new JButton("\u4FDD\u5B58"); btnSave.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { //???????? if (comboBoxProduct.getSelectedIndex() <= 0) { JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "??"); return; } String[] array = StringUtils.split(comboBoxProduct.getSelectedItem().toString(), '-'); String productCode = array[0]; String productName = array[1]; String customerCode = textFieldCustomerCode.getText(); //?? File configFile = ResourceUtils.getFile(Gui.HOME_PATH + File.separator + "config.xml"); Document document = XmlUtils.readXml(configFile); Element customerNode = (Element) document.selectSingleNode( "//product[@code='" + productCode + "']/customer[@code='" + customerCode + "']"); if (customerNode != null) { JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "???"); return; } String licenseId = new RandomGUID().toString(); String licenseType = Utility.splitStringAll(comboBoxLicenseType.getSelectedItem().toString(), " - ")[0]; String companyName = textFieldCompanyName.getText(); String customerName = textFieldCustomerName.getText(); String version = textFieldProductVersion.getText(); Date expiredDate = Utility.parseDate(datePickerExpiredDate.getText()); License license = new License(); license.setLicenseId(licenseId); license.setLicenseType(licenseType); license.setProductName(productName); license.setCompanyName(companyName); license.setCustomerName(customerName); license.setVersion(Version.parseVersion(version)); license.setCreateDate(new Date()); license.setExpiredDate(expiredDate); LicenseService service = new LicenseService(); String productPath = Gui.HOME_PATH + File.separator + productCode; File licenseDir = new File(productPath, customerCode); if (!licenseDir.exists()) { licenseDir.mkdir(); //? FileUtils.copyFileToDirectory(new File(productPath, "license.key"), licenseDir); } File priKeyFile = new File(Gui.HOME_PATH + File.separator + productCode, "private.key"); File licenseFile = new File(licenseDir, "license.xml"); service.save(Gui.HOME_PATH, productCode, customerCode, license, priKeyFile, licenseFile); //??zip? File customerPath = licenseFile.getParentFile(); //???license????? File licensePath = new File(customerPath.getParent(), "license"); if (!licensePath.exists() && !licensePath.isDirectory()) { licensePath.mkdir(); } else { FileUtils.cleanDirectory(licensePath); } //? FileUtils.copyDirectory(customerPath, licensePath); String currentTime = FormatDateTime.formatDateTimeNum(new Date()); ZipUtils.zip(licensePath, new File(licensePath.getParentFile(), customerCode + "-" + currentTime + ".zip")); //license FileUtils.deleteDirectory(licensePath); JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "??"); } catch (Exception e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), e1.getMessage()); } } }); GridBagConstraints gbc_btnSave = new GridBagConstraints(); gbc_btnSave.insets = new Insets(0, 0, 5, 5); gbc_btnSave.gridx = 1; gbc_btnSave.gridy = 7; add(btnSave, gbc_btnSave); //?? initData(); }
From source file:org.jets3t.apps.cockpit.gui.LoginLocalFolderPanel.java
private void initGui() { // Textual information. String descriptionText = "<html><center>" + "Your credentials are stored in encrypted files in a folder on " + "your computer. Each stored login has a nickname." + "<br><font size=\"-2\">You need to store your credentials before you can use this login method.</font>" + "</center></html>"; String folderTooltipText = "The folder containing your credentials"; String browseButtonText = "Change Folder"; String accountNicknameText = "Stored logins"; String accountNicknameTooltipText = "Nicknames of the login credentials you have stored"; String passwordLabelText = "Password"; String passwordTooltipText = "The password that protects your encrypted file. " + "This password may be left empty if you are sure your computer cannot be compromised"; // Components. JHtmlLabel descriptionLabel = new JHtmlLabel(descriptionText, hyperlinkListener); descriptionLabel.setHorizontalAlignment(JLabel.CENTER); folderPathTextField = new JTextField(this.cockpitHomeFolder.getAbsolutePath()); folderPathTextField.setEnabled(false); folderPathTextField.setToolTipText(folderTooltipText); JButton browseButton = new JButton(browseButtonText); browseButton.addActionListener(this); JHtmlLabel accountNicknamesLabel = new JHtmlLabel(accountNicknameText, hyperlinkListener); nicknamesTableModel = new ProviderCredentialsFileTableModel(); accountNicknameTable = new JTable(nicknamesTableModel); accountNicknameTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); accountNicknameTable.setShowHorizontalLines(true); accountNicknameTable.getTableHeader().setVisible(false); JScrollPane accountNicknamesScrollPane = new JScrollPane(accountNicknameTable); accountNicknamesScrollPane.setToolTipText(accountNicknameTooltipText); JHtmlLabel passwordLabel = new JHtmlLabel(passwordLabelText, hyperlinkListener); passwordPasswordField = new JPasswordField(); passwordPasswordField.setToolTipText(passwordTooltipText); int row = 0;//from w ww .j av a2s . c o m add(descriptionLabel, new GridBagConstraints(0, row++, 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); add(folderPathTextField, new GridBagConstraints(0, row, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); add(browseButton, new GridBagConstraints(1, row++, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); add(accountNicknamesLabel, new GridBagConstraints(0, row++, 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); add(accountNicknamesScrollPane, new GridBagConstraints(0, row++, 2, 1, 0, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); add(passwordLabel, new GridBagConstraints(0, row++, 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); add(passwordPasswordField, new GridBagConstraints(0, row++, 2, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); }