List of usage examples for java.awt GridBagLayout setConstraints
public void setConstraints(Component comp, GridBagConstraints constraints)
From source file:org.photovault.swingui.PhotoInfoEditor.java
protected void createUI() { setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); tabPane = new JTabbedPane(); add(tabPane, BorderLayout.CENTER); // General pane JPanel generalPane = new JPanel(); tabPane.addTab("General", generalPane); // Create the fields & their labels // Photographer field JLabel photographerLabel = new JLabel("Photographer"); photographerField = createMvTextField("photographer", 30); photographerDoc = photographerField.getDocument(); // "Fuzzy time" field JLabel fuzzyDateLabel = new JLabel("Shooting date"); fuzzyDateField = new JTextField(30); fuzzyDateDoc = fuzzyDateField.getDocument(); fuzzyDateDoc.putProperty(FIELD, PhotoInfoFields.FUZZY_SHOOT_TIME); fuzzyDateDoc.addDocumentListener(this); JLabel qualityLabel = new JLabel("Quality"); qualityField = new JComboBox(qualityStrings); qualityField.addActionListener(this); StarRating qualityStars = new StarRating(5); FieldController<Integer> qfCtrl = ctrl.getFieldController("quality"); ValueModel qualityFieldValue = new PropertyAdapter(qfCtrl, "value", true); ValueModel starCount = new PropertyAdapter(qualityStars, "selection", true); PropertyConnector.connect(qualityFieldValue, "value", starCount, "value"); // Shooting place field JLabel shootingPlaceLabel = new JLabel("Shooting place"); shootingPlaceField = createMvTextField("shotLocation.description", 30); shootingPlaceDoc = shootingPlaceField.getDocument(); JLabel shotLocRoadLabel = new JLabel("Road"); JTextField shotLocRoadField = createMvTextField("shotLocation.road", 30); JLabel shotLocSuburbLabel = new JLabel("Suburb"); JTextField shotLocSuburbField = createMvTextField("shotLocation.suburb", 30); JLabel shotLocCityLabel = new JLabel("City"); JTextField shotLocCityField = createMvTextField("shotLocation.city", 30); JLabel shotLocCountryLabel = new JLabel("Country"); JTextField shotLocCountryField = createMvTextField("shotLocation.country", 30); JLabel shotLocGeohashLabel = new JLabel("Geohash code"); JTextField shotLocGeohashField = createMvTextField("shotLocation.geoHashString", 30); shotLocGeohashField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "fillAddress"); shotLocGeohashField.getActionMap().put("fillAddress", new FindAddressAction(ctrl)); // Tags/*from ww w . j a v a2 s. c o m*/ JLabel tagLabel = new JLabel("Tags"); tagList = new TagList2(ctrl.getTagController()); tagList.setBackground(generalPane.getBackground()); // Description text JLabel descLabel = new JLabel("Description"); descriptionTextArea = new JTextArea(5, 40); descriptionTextArea.setLineWrap(true); descriptionTextArea.setWrapStyleWord(true); JScrollPane descScrollPane = new JScrollPane(descriptionTextArea); descScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); Border descBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); descBorder = BorderFactory.createTitledBorder(descBorder, "Description"); descScrollPane.setBorder(descBorder); descriptionDoc = descriptionTextArea.getDocument(); descriptionDoc.putProperty(FIELD, PhotoInfoFields.DESCRIPTION); descriptionDoc.addDocumentListener(this); // Lay out the created controls GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); generalPane.setLayout(layout); JLabel[] labels = { photographerLabel, fuzzyDateLabel, shootingPlaceLabel, shotLocGeohashLabel, shotLocRoadLabel, shotLocSuburbLabel, shotLocCityLabel, shotLocCountryLabel, qualityLabel, tagLabel }; JComponent[] fields = { photographerField, fuzzyDateField, shootingPlaceField, shotLocGeohashField, shotLocRoadField, shotLocSuburbField, shotLocCityField, shotLocCountryField, qualityStars, tagList }; addLabelTextRows(labels, fields, layout, generalPane); c = layout.getConstraints(tagList); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.0; c.weighty = 1.0; layout.setConstraints(tagList, c); generalPane.add(descScrollPane); c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; layout.setConstraints(descScrollPane, c); c = new GridBagConstraints(); c.gridwidth = 1; c.weighty = 0; c.fill = GridBagConstraints.NONE; c.gridy = GridBagConstraints.RELATIVE; c.gridy = GridBagConstraints.RELATIVE; createTechDataUI(); createFolderPaneUI(); createRightsUI(); }
From source file:org.photovault.swingui.PhotoInfoEditor.java
protected void createTechDataUI() { JPanel pane = new JPanel(); tabPane.addTab("Tech data", pane); JLabel cameraMakerLabel = new JLabel("Camera make"); JTextField cameraMakerField = createMvTextField("cameraMaker", 20); // cameraDoc = cameraField.getDocument(); JLabel cameraLabel = new JLabel("Camera model"); cameraField = createMvTextField("camera", 20); cameraDoc = cameraField.getDocument(); JLabel lensLabel = new JLabel("Lens"); lensField = createMvTextField("lens", 20); lensDoc = lensField.getDocument();/*from w w w .j a v a 2 s. co m*/ JLabel filmLabel = new JLabel("Film"); filmField = createMvTextField("film", 20); filmDoc = filmField.getDocument(); JLabel filmSpeedLabel = new JLabel("Film speed"); NumberFormatter filmSpeedFormatter = new NumberFormatter(new DecimalFormat("#########0")); filmSpeedFormatter.setValueClass(PhotoInfoFields.FILM_SPEED.getType()); filmSpeedField = new JFormattedTextField(filmSpeedFormatter); filmSpeedField.setColumns(5); filmSpeedField.addPropertyChangeListener(this); filmSpeedField.putClientProperty(FIELD, PhotoInfoFields.FILM_SPEED); JLabel shutterSpeedLabel = new JLabel("Shutter speed"); DecimalFormat shutterSpeedFormat = new DecimalFormat("###0.####"); NumberFormatter shutterSpeedFormatter = new NumberFormatter(shutterSpeedFormat); shutterSpeedFormatter.setValueClass(PhotoInfoFields.SHUTTER_SPEED.getType()); shutterSpeedField = new JFormattedTextField(shutterSpeedFormatter); shutterSpeedField.setColumns(5); shutterSpeedField.addPropertyChangeListener(this); shutterSpeedField.putClientProperty(FIELD, PhotoInfoFields.SHUTTER_SPEED); JLabel fStopLabel = new JLabel("F-stop"); DecimalFormat fStopFormat = new DecimalFormat("#0.#"); NumberFormatter fStopFormatter = new NumberFormatter(fStopFormat); fStopFormatter.setValueClass(PhotoInfoFields.FSTOP.getType()); fStopField = new JFormattedTextField(fStopFormatter); fStopField.setColumns(5); fStopField.addPropertyChangeListener(this); fStopField.putClientProperty(FIELD, PhotoInfoFields.FSTOP); JLabel focalLengthLabel = new JLabel("Focal length"); NumberFormatter focalLengthFormatter = new NumberFormatter(new DecimalFormat("#######0.#")); focalLengthFormatter.setValueClass(PhotoInfoFields.FSTOP.getType()); focalLengthField = new JFormattedTextField(focalLengthFormatter); focalLengthField.setColumns(5); focalLengthField.addPropertyChangeListener(this); focalLengthField.putClientProperty(FIELD, PhotoInfoFields.FOCAL_LENGTH); // Tech note text JLabel notesLabel = new JLabel("Tech. notes"); technoteTextArea = new JTextArea(5, 40); technoteTextArea.setLineWrap(true); technoteTextArea.setWrapStyleWord(true); JScrollPane technoteScrollPane = new JScrollPane(technoteTextArea); technoteScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); Border technoteBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); technoteBorder = BorderFactory.createTitledBorder(technoteBorder, "Description"); technoteScrollPane.setBorder(technoteBorder); technoteDoc = technoteTextArea.getDocument(); technoteDoc.putProperty(FIELD, PhotoInfoFields.TECH_NOTES); technoteDoc.addDocumentListener(this); // Lay out the created controls GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); pane.setLayout(layout); JLabel[] labels = { cameraMakerLabel, cameraLabel, lensLabel, focalLengthLabel, filmLabel, filmSpeedLabel, shutterSpeedLabel, fStopLabel }; JTextField[] fields = { cameraMakerField, cameraField, lensField, focalLengthField, filmField, filmSpeedField, shutterSpeedField, fStopField }; addLabelTextRows(labels, fields, layout, pane); pane.add(technoteScrollPane); c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; layout.setConstraints(technoteScrollPane, c); }
From source file:org.photovault.swingui.PhotoInfoEditor.java
private void createRightsUI() { JPanel pane = new JPanel(); tabPane.addTab("Rights", pane); JLabel copyrightLabel = new JLabel("Copyright"); JTextField copyrightField = createMvTextField("usageRights.copyright", 30); JLabel attributionLabel = new JLabel("Name for attribution"); JTextField attributionField = createMvTextField("usageRights.attributionName", 30); JLabel attributionUrlLabel = new JLabel("Url for attribution"); JTextField attributionUrlField = createMvTextField("usageRights.attributionUrl", 30); JLabel licenseLabel = new JLabel("License"); List<License> licenses = new ArrayList(); licenses.addAll(EnumSet.allOf(License.class)); JComboBox licenseCombo = createMvComboBox("usageRights.license", licenses); // Tech note text JLabel termsLabel = new JLabel("Usage terms"); JTextArea termsTextArea = createMvTextArea("usageRights.usageTerms", 5, 40); termsTextArea.setLineWrap(true);// w w w. j a v a 2 s. c o m termsTextArea.setWrapStyleWord(true); JScrollPane termsScrollPane = new JScrollPane(termsTextArea); termsScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); Border termsBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); termsBorder = BorderFactory.createTitledBorder(termsBorder, "Usage terms"); termsScrollPane.setBorder(termsBorder); GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); pane.setLayout(layout); JLabel[] labels = { copyrightLabel, licenseLabel, attributionLabel, attributionUrlLabel }; JComponent[] fields = { copyrightField, licenseCombo, attributionField, attributionUrlField }; addLabelTextRows(labels, fields, layout, pane); pane.add(termsScrollPane); c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; layout.setConstraints(termsScrollPane, c); }
From source file:org.photovault.swingui.PhotoInfoEditor.java
private void addLabelTextRows(JLabel[] labels, JComponent[] textFields, GridBagLayout gridbag, Container container) {/*from ww w. j a v a 2 s. c o m*/ GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.EAST; c.insets = new Insets(2, 2, 2, 2); int numLabels = labels.length; for (int i = 0; i < numLabels; i++) { c.anchor = GridBagConstraints.EAST; c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.NONE; //reset to default c.weightx = 0.0; //reset to default gridbag.setConstraints(labels[i], c); container.add(labels[i]); c.anchor = GridBagConstraints.WEST; c.gridwidth = GridBagConstraints.REMAINDER; //end row c.weightx = 1.0; gridbag.setConstraints(textFields[i], c); container.add(textFields[i]); } }
From source file:org.photovault.swingui.PhotoViewController.java
/** Creates a new instance of PhotoViewController */ public PhotoViewController(Container view, AbstractController parentController) { super(view, parentController); photoDAO = getDAOFactory().getPhotoInfoDAO(); folderDAO = getDAOFactory().getPhotoFolderDAO(); ImageIcon rotateCWIcon = getIcon("rotate_cw.png"); ImageIcon rotateCCWIcon = getIcon("rotate_ccw.png"); ImageIcon rotate180DegIcon = getIcon("rotate_180.png"); registerAction("rotate_cw", new RotateSelectedPhotoAction(this, 90, "Rotate CW", rotateCWIcon, "Rotates the selected photo 90 degrees clockwise", KeyEvent.VK_R)); registerAction("rotate_ccw", new RotateSelectedPhotoAction(this, 270, "Rotate CCW", rotateCCWIcon, "Rotates the selected photo 90 degrees counterclockwise", KeyEvent.VK_L)); registerAction("rotate_180", new RotateSelectedPhotoAction(this, 180, "Rotate 180 degrees", rotate180DegIcon, "Rotates the selected photo 180 degrees counterclockwise", KeyEvent.VK_T)); registerAction("rotate_180", new RotateSelectedPhotoAction(this, 180, "Rotate 180 degrees", rotate180DegIcon, "Rotates the selected photo 180 degrees counterclockwise", KeyEvent.VK_T)); String qualityStrings[] = { "Unevaluated", "Top", "Good", "OK", "Poor", "Unusable" }; String qualityIconnames[] = { "quality_unevaluated.png", "quality_top.png", "quality_good.png", "quality_ok.png", "quality_poor.png", "quality_unusable.png" }; KeyStroke qualityAccelerators[] = { null, KeyStroke.getKeyStroke(KeyEvent.VK_5, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), KeyStroke.getKeyStroke(KeyEvent.VK_4, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), KeyStroke.getKeyStroke(KeyEvent.VK_3, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), KeyStroke.getKeyStroke(KeyEvent.VK_2, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), KeyStroke.getKeyStroke(KeyEvent.VK_1, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), }; ImageIcon[] qualityIcons = new ImageIcon[qualityStrings.length]; for (int n = 0; n < qualityStrings.length; n++) { qualityIcons[n] = getIcon(qualityIconnames[n]); DataAccessAction qualityAction = new SetPhotoQualityAction(this, n, qualityStrings[n], qualityIcons[n], "Set quality of selected phots to \"" + qualityStrings[n] + "\"", null); qualityAction.putValue(AbstractAction.ACCELERATOR_KEY, qualityAccelerators[n]); registerAction("quality_" + n, qualityAction); registerEventListener(TaskFinishedEvent.class, new DefaultEventListener<BackgroundTask>() { public void handleEvent(DefaultEvent<BackgroundTask> event) { BackgroundTask task = event.getPayload(); if (task instanceof IndexFileTask) { IndexFileTask ifTask = (IndexFileTask) task; if (ifTask.getResult() == IndexingResult.ERROR || ifTask.getResult() == IndexingResult.NOT_IMAGE) { return; }/*w ww .j a v a2 s.co m*/ UUID volId = ifTask.getVolume().getId(); FileLocation loc = ifTask.getFileLocation(); Set<PhotoInfo> photos = ifTask.getPhotosFound(); log.debug("Found file " + loc.getFile() + " in volume " + volId); for (PhotoInfo p : photos) { log.debug(" linked to photo " + p.getUuid()); } if (collection instanceof ExtDirPhotos) { ExtDirPhotos dir = (ExtDirPhotos) collection; if (loc.getVolume().getId().equals(dir.getVolId()) && loc.getDirName().equals(dir.getDirPath())) { addPhotos(photos); updateThumbView(); } } } } }); } // Create the UI controls thumbPane = new PhotoCollectionThumbView(this, null); thumbPane.addSelectionChangeListener(new SelectionChangeListener() { public void selectionChanged(SelectionChangeEvent e) { thumbSelectionChanged(e); } }); previewPane = new JAIPhotoViewer(this); previewPane.getActionMap().put("hide_fullwindow_preview", new HidePhotoPreviewAction(this)); previewPane.getActionMap().put("move_next", thumbPane.getSelectNextAction()); previewPane.getActionMap().put("move_prev", thumbPane.getSelectPreviousAction()); // Create the split pane to display both of these components thumbScroll = new JScrollPane(thumbPane); thumbPane.setBackground(Color.WHITE); thumbScroll.getViewport().setBackground(Color.WHITE); thumbScroll.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { handleThumbAreaResize(); } }); scrollLayer = new JXLayer<JScrollPane>(thumbScroll); progressLayer = new ProgressIndicatorLayer(); scrollLayer.setUI(progressLayer); collectionPane = new JPanel(); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); layeredPane = new JLayeredPane(); layeredPane.setLayout(new StackLayout()); collectionPane.add(splitPane); collectionPane.add(layeredPane); GridBagLayout layout = new GridBagLayout(); collectionPane.setLayout(layout); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weighty = 1.0; c.weightx = 1.0; c.gridy = 0; // collectionPane.add( scrollLayer ); layout.setConstraints(splitPane, c); layout.setConstraints(layeredPane, c); // collectionPane.add( previewPane ); thumbPane.setRowHeight(200); setLayout(Layout.ONLY_THUMBS); /* Register action so that we are notified of changes to currently displayed folder */ registerEventListener(CommandExecutedEvent.class, new DefaultEventListener<DataAccessCommand>() { public void handleEvent(DefaultEvent<DataAccessCommand> event) { DataAccessCommand cmd = event.getPayload(); if (cmd instanceof ChangePhotoInfoCommand) { photoChangeCommandExecuted((ChangePhotoInfoCommand) cmd); } else if (cmd instanceof CreateCopyImageCommand) { imageCreated((CreateCopyImageCommand) cmd); } else if (cmd instanceof ApplyChangeCommand) { changeApplied((ApplyChangeCommand) cmd); } } }); }
From source file:org.photovault.swingui.tag.TagEditor2.java
/** * Initializes the UI//from www . jav a 2 s .co m */ private void initComponents() { nameField = new JTextField(8); suggestionList = new AutoCompleteList(); tagSuggestionModel = new TagSuggestionListModel(); suggestionList.setModel(tagSuggestionModel); suggestionList.setCellRenderer(new TagListCellRenderer()); String categories[] = { "Persons", "Tags" }; categoryField = new JComboBox(categories); categoryField.setEditable(true); GridBagLayout layout = new GridBagLayout(); setLayout(layout); add(nameField); add(categoryField); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.insets = new Insets(0, 0, 0, 10); layout.setConstraints(nameField, c); listener = new Listener(); nameField.addKeyListener(listener); nameField.addFocusListener(listener); suggestionList.addListSelectionListener(listener); }
From source file:org.revager.tools.GUITools.java
/** * Adds the given component to the given container with GridBagLayout. * // w ww . j av a 2 s .c o m * @param cont * the container * @param gbl * the GridBagLayout object * @param c * the component to add * @param x * the x position * @param y * the y position * @param width * the width * @param height * the height * @param weightx * the vertical weight * @param weighty * the horizontal weight * @param t * the top inset * @param l * the left inset * @param b * the bottom inset * @param r * the right inset * @param i * a GridBagConstraints constant * @param z * a GridBagConstraints constant */ public static void addComponent(Container cont, GridBagLayout gbl, Component c, int x, int y, int width, int height, double weightx, double weighty, int t, int l, int b, int r, int i, int z) { GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(t, l, b, r); gbc.fill = i; gbc.anchor = z; gbc.gridx = x; gbc.gridy = y; gbc.gridwidth = width; gbc.gridheight = height; gbc.weightx = weightx; gbc.weighty = weighty; gbl.setConstraints(c, gbc); cont.add(c); }
From source file:pcgen.gui2.coreview.CoreViewFrame.java
public void initialize(CharacterFacade character) { GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); getContentPane().setLayout(gridbag); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new Insets(2, 2, 2, 2); int col = 0;//from w w w . ja va 2 s. c o m Utility.buildConstraints(c, col, 0, 1, 1, 100, 20); JLabel label = new JLabel(LanguageBundle.getFormattedString("in_CoreView_Perspective")); //$NON-NLS-1$ gridbag.setConstraints(label, c); getContentPane().add(label); Utility.buildConstraints(c, col++, 1, 1, 1, 0, 20); gridbag.setConstraints(perspectiveChooser, c); getContentPane().add(perspectiveChooser); Utility.buildConstraints(c, 0, 2, col, 1, 0, 1000); viewTable.setAutoCreateRowSorter(true); JScrollPane pane = new JScrollPane(viewTable); pane.setPreferredSize(new Dimension(500, 300)); gridbag.setConstraints(pane, c); getContentPane().add(pane); setTitle("Core Debug View"); getContentPane().setSize(500, 400); pack(); Utility.centerComponent(this, true); }
From source file:pcgen.gui2.prefs.LocationPanel.java
/** * Instantiates a new location panel./*from w w w .ja va 2 s. c o 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:pcgen.gui2.prefs.LookAndFeelPanel.java
/** * Instantiates a new look and feel panel. *///from ww w.j a v a 2s .co m public LookAndFeelPanel(Dialog parent) { JLabel label; ButtonGroup exclusiveGroup; Border etched = null; TitledBorder title1 = BorderFactory.createTitledBorder(etched, IN_LOOK_AND_FEEL); title1.setTitleJustification(TitledBorder.LEFT); this.setBorder(title1); GridBagLayout gridbag = new GridBagLayout(); this.setLayout(gridbag); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(2, 2, 2, 2); exclusiveGroup = new ButtonGroup(); Action[] actions = LookAndFeelManager.getActions(); laf = new JRadioButton[actions.length - 1]; for (int i = 0; i < laf.length; ++i) { laf[i] = new JRadioButton(actions[i]); int whichChar = (laf[i].getText().charAt(0) == 'C') ? 1 : 0; laf[i].setMnemonic(laf[i].getText().charAt(whichChar)); Utility.buildConstraints(c, 0, i, 3, 1, 0, 0); gridbag.setConstraints(laf[i], c); this.add(laf[i]); exclusiveGroup.add(laf[i]); } skinnedLookFeel.addActionListener(actions[actions.length - 1]); skinnedLookFeel.setText(IN_SKINNED_LAF + ": "); skinnedLookFeel.setToolTipText(LanguageBundle.getString("in_Prefs_skinnedLAFTooltip")); skinnedLookFeel.setMnemonic(LanguageBundle.getMnemonic("in_mn_Prefs_skinnedLAF")); Utility.buildConstraints(c, 0, laf.length, 3, 1, 0, 0); gridbag.setConstraints(skinnedLookFeel, c); this.add(skinnedLookFeel); exclusiveGroup.add(skinnedLookFeel); Utility.buildConstraints(c, 3, laf.length, 1, 1, 1, 0); themepackLabel = new JTextField(LookAndFeelManager.getCurrentThemePack()); themepackLabel.setEditable(false); gridbag.setConstraints(themepackLabel, c); this.add(themepackLabel); Utility.buildConstraints(c, 4, laf.length, 1, 1, 0, 0); themepack = new JButton(IN_CHOOSE); themepack.setToolTipText(LanguageBundle.getString("in_Prefs_chooseSkinTooltip")); gridbag.setConstraints(themepack, c); this.add(themepack); themepack.addActionListener(prefsButtonHandler); Utility.buildConstraints(c, 0, laf.length + 1, 5, 1, 0, 0); label = new JLabel(""); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 0, laf.length + 2, 5, 1, 0, 0); label = new JLabel(LanguageBundle.getString("in_Prefs_restartInfo")); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 0, 20, 5, 1, 1, 1); c.fill = GridBagConstraints.BOTH; label = new JLabel(" "); gridbag.setConstraints(label, c); this.add(label); }