List of usage examples for java.awt Component LEFT_ALIGNMENT
float LEFT_ALIGNMENT
To view the source code for java.awt Component LEFT_ALIGNMENT.
Click Source Link
From source file:ComboBoxDemo2.java
public ComboBoxDemo2() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z", "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" }; currentPattern = patternExamples[0]; //Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Enter the pattern string or"); JLabel patternLabel2 = new JLabel("select one from the list:"); JComboBox patternList = new JComboBox(patternExamples); patternList.setEditable(true);// ww w .j a v a 2 s .c o m patternList.addActionListener(this); //Create the UI for displaying result. JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); //== // LEFT result = new JLabel(" "); result.setForeground(Color.black); result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Lay out everything. JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); patternPanel.add(patternList); JPanel resultPanel = new JPanel(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT); resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(patternPanel); add(Box.createRigidArea(new Dimension(0, 10))); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); reformat(); }
From source file:org.freeinternals.javaclassviewer.ui.JSplitPaneClassFile.java
private void createAndShowGUI(JFrame top) { // Construct class file viewer final JTreeClassFile jTreeClassFile = new JTreeClassFile(this.classFile); jTreeClassFile.addTreeSelectionListener(new TreeSelectionListener() { @Override// w w w .j a v a2s . co m public void valueChanged(final javax.swing.event.TreeSelectionEvent evt) { jTreeClassFileSelectionChanged(evt); } }); final JPanelForTree panel = new JPanelForTree(jTreeClassFile, top); final JTabbedPane tabbedPane = new JTabbedPane(); // Construct binary viewer this.binaryViewer = new JBinaryViewer(); this.binaryViewer.setData(this.classFile.getClassByteArray()); this.binaryViewerView = new JScrollPane(this.binaryViewer); this.binaryViewerView.getVerticalScrollBar().setValue(0); tabbedPane.add("Class File", this.binaryViewerView); // Construct opcode viewer this.opcode = new JTextPane(); this.opcode.setAlignmentX(Component.LEFT_ALIGNMENT); // this.opcode.setFont(new Font(Font.DIALOG_INPUT, Font.PLAIN, 14)); this.opcode.setEditable(false); this.opcode.setBorder(null); this.opcode.setContentType("text/html"); tabbedPane.add("Opcode", new JScrollPane(this.opcode)); // Class report this.report = new JTextPane(); this.report.setAlignmentX(Component.LEFT_ALIGNMENT); this.report.setEditable(false); this.report.setBorder(null); this.report.setContentType("text/html"); tabbedPane.add("Report", new JScrollPane(this.report)); this.setOrientation(JSplitPane.HORIZONTAL_SPLIT); this.setDividerSize(5); this.setDividerLocation(280); this.setLeftComponent(panel); this.setRightComponent(tabbedPane); this.binaryViewerView.getVerticalScrollBar().setValue(0); }
From source file:gda.util.userOptions.UserOptionsDialog.java
@SuppressWarnings("rawtypes") private JPanel makePane() { JPanel pane = new JPanel(); pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); Iterator<Map.Entry<String, UserOption>> iter = options.entrySet().iterator(); while (iter.hasNext()) { Map.Entry<String, UserOption> entry = iter.next(); UserOption option = entry.getValue(); if (option.defaultValue instanceof Boolean && option.description instanceof String) { JCheckBox box = new JCheckBox((String) option.description); box.setSelected((Boolean) option.value); box.setAlignmentX(Component.LEFT_ALIGNMENT); box.setAlignmentY(Component.LEFT_ALIGNMENT); components.put(entry.getKey(), box); pane.add(box);//from ww w . ja va 2 s . c om } } return pane; }
From source file:net.pandoragames.far.ui.swing.RenameFilesPanel.java
private void init(SwingConfig config, ComponentRepository componentRepository) { this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.setBorder( BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING)); this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); JLabel patternLabel = new JLabel(localizer.localize("label.find-pattern")); this.add(patternLabel); filenamePattern = new JTextField(); filenamePattern.setPreferredSize(//from w ww . j a va 2s.c om new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, config.getStandardComponentHight())); filenamePattern .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight())); filenamePattern.setAlignmentX(Component.LEFT_ALIGNMENT); UndoHistory findUndoManager = new UndoHistory(); findUndoManager.registerUndoHistory(filenamePattern); findUndoManager.registerSnapshotHistory(filenamePattern); componentRepository.getReplaceCommand().addResetable(findUndoManager); filenamePattern.getDocument().addDocumentListener(new DocumentChangeListener() { public void documentUpdated(DocumentEvent e, String text) { dataModel.setPatternString(text); updateFileTable(); } }); componentRepository.getResetDispatcher().addToBeCleared(filenamePattern); this.add(filenamePattern); JCheckBox caseBox = new JCheckBox(localizer.localize("label.ignore-case")); caseBox.setSelected(true); caseBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { dataModel.setIgnoreCase((ItemEvent.SELECTED == event.getStateChange())); updateFileTable(); } }); this.add(caseBox); JCheckBox regexBox = new JCheckBox(localizer.localize("label.regular-expression")); regexBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { dataModel.setRegexPattern((ItemEvent.SELECTED == event.getStateChange())); updateFileTable(); } }); this.add(regexBox); JPanel extensionPanel = new JPanel(); extensionPanel.setBorder(BorderFactory.createTitledBorder(localizer.localize("label.modify-extension"))); extensionPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); extensionPanel.setAlignmentX(Component.LEFT_ALIGNMENT); extensionPanel.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, 60)); extensionPanel.setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, 100)); ButtonGroup extensionGroup = new ButtonGroup(); JRadioButton protectButton = new JRadioButton(localizer.localize("label.protect-extension")); protectButton.setSelected(true); protectButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dataModel.setProtectExtension(true); updateFileTable(); } }); extensionGroup.add(protectButton); extensionPanel.add(protectButton); JRadioButton includeButton = new JRadioButton(localizer.localize("label.include-extension")); includeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dataModel.setExtensionOnly(false); dataModel.setProtectExtension(false); updateFileTable(); } }); extensionGroup.add(includeButton); extensionPanel.add(includeButton); JRadioButton onlyButton = new JRadioButton(localizer.localize("label.only-extension")); onlyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dataModel.setExtensionOnly(true); updateFileTable(); } }); extensionGroup.add(onlyButton); extensionPanel.add(onlyButton); this.add(extensionPanel); this.add(Box.createVerticalGlue()); this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); // replace JLabel replaceLabel = new JLabel(localizer.localize("label.replacement-pattern")); this.add(replaceLabel); replacePattern = new JTextField(); replacePattern.setPreferredSize( new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, config.getStandardComponentHight())); replacePattern .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight())); replacePattern.setAlignmentX(Component.LEFT_ALIGNMENT); UndoHistory undoManager = new UndoHistory(); undoManager.registerUndoHistory(replacePattern); undoManager.registerSnapshotHistory(replacePattern); componentRepository.getReplaceCommand().addResetable(undoManager); replacePattern.getDocument().addDocumentListener(new DocumentChangeListener() { public void documentUpdated(DocumentEvent e, String text) { dataModel.setReplacementString(text); updateFileTable(); } }); componentRepository.getResetDispatcher().addToBeCleared(replacePattern); this.add(replacePattern); // treat case JPanel modifyCasePanel = new JPanel(); modifyCasePanel.setBorder(BorderFactory.createTitledBorder(localizer.localize("label.modify-case"))); modifyCasePanel.setLayout(new BoxLayout(modifyCasePanel, BoxLayout.Y_AXIS)); modifyCasePanel.setAlignmentX(Component.LEFT_ALIGNMENT); modifyCasePanel.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, 100)); modifyCasePanel.setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, 200)); ButtonGroup modifyCaseGroup = new ButtonGroup(); ActionListener radioButtonListener = new ActionListener() { public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); dataModel.setTreatCase(RenameForm.CASEHANDLING.valueOf(cmd)); updateFileTable(); } }; JRadioButton lowerButton = new JRadioButton(localizer.localize("label.to-lower-case")); lowerButton.setActionCommand(RenameForm.CASEHANDLING.LOWER.name()); lowerButton.addActionListener(radioButtonListener); modifyCaseGroup.add(lowerButton); modifyCasePanel.add(lowerButton); JRadioButton upperButton = new JRadioButton(localizer.localize("label.to-upper-case")); upperButton.setActionCommand(RenameForm.CASEHANDLING.UPPER.name()); upperButton.addActionListener(radioButtonListener); modifyCaseGroup.add(upperButton); modifyCasePanel.add(upperButton); JRadioButton keepButton = new JRadioButton(localizer.localize("label.preserve-case")); keepButton.setActionCommand(RenameForm.CASEHANDLING.PRESERVE.name()); keepButton.setSelected(true); keepButton.addActionListener(radioButtonListener); modifyCaseGroup.add(keepButton); modifyCasePanel.add(keepButton); this.add(modifyCasePanel); // prevent case conflict JCheckBox caseConflictBox = new JCheckBox(localizer.localize("label.prevent-case-conflict")); caseConflictBox.setAlignmentX(Component.LEFT_ALIGNMENT); caseConflictBox.setSelected(true); caseConflictBox.setEnabled(!SwingConfig.isWindows()); // disabled on windows caseConflictBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { dataModel.setPreventCaseConflict((ItemEvent.SELECTED == event.getStateChange())); updateFileTable(); } }); this.add(caseConflictBox); this.add(Box.createVerticalGlue()); }
From source file:gdt.jgui.console.JItemPanel.java
/** * The default constructor.//from ww w . ja v a 2s.co m */ public JItemPanel() { super(); setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); setAlignmentX(Component.LEFT_ALIGNMENT); }
From source file:netcap.JcaptureConfiguration.java
/** * ??/*w ww . j ava 2 s. c o m*/ * @return */ private JPanel getNetDevicesPanel() { JPanel netPanel = ViewModules.createSimplePanel("?", Component.LEFT_ALIGNMENT, -1f, true); String[] names = getNetDeviceList(); if (names.length == 0) ViewModules.showMessageDialog(frame, "?"); netJComboBox = ViewModules.createComboBox(names); netPanel.add(netJComboBox); return netPanel; }
From source file:gdt.jgui.console.JItemPanel.java
/** * Create the item panel./*ww w . ja v a 2 s.c om*/ * @param console the main console. * @param locator$ the item's locator. * @return the item panel. */ public JItemPanel instantiate(JMainConsole console, String locator$) { try { this.console = console; this.locator$ = locator$; this.removeAll(); Properties locator = Locator.toProperties(locator$); if (Locator.LOCATOR_TRUE.equals(locator.getProperty(Locator.LOCATOR_CHECKABLE))) { checkbox = new JCheckBox(); add(checkbox); if (Locator.LOCATOR_TRUE.equals(locator.getProperty(Locator.LOCATOR_CHECKED))) if (checkbox != null) checkbox.setSelected(true); } title = new JLabel(title$, JLabel.LEFT); //title.setIcon(null); title$ = locator.getProperty(Locator.LOCATOR_TITLE); if (title$ != null) { title.setText(title$); title.setOpaque(true); title.addMouseListener(new MousePopupListener()); title.setAlignmentX(Component.LEFT_ALIGNMENT); add(title, BorderLayout.WEST); icon$ = locator.getProperty(Locator.LOCATOR_ICON); if (icon$ != null) { byte[] ba = Base64.decodeBase64(icon$); ImageIcon icon = new ImageIcon(ba); Image image = icon.getImage().getScaledInstance(24, 24, 0); icon.setImage(image); title.setIcon(icon); } } else LOGGER.info("title is null"); } catch (Exception e) { LOGGER.severe(e.toString()); } return this; }
From source file:net.pandoragames.far.ui.swing.dialog.SettingsDialog.java
private void init() { this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS)); this.setResizable(false); JPanel basePanel = new JPanel(); basePanel.setLayout(new BoxLayout(basePanel, BoxLayout.Y_AXIS)); basePanel.setBorder(// ww w . ja va2 s . com BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING)); registerCloseWindowKeyListener(basePanel); // sink for error messages MessageLabel errorField = new MessageLabel(); errorField.setMinimumSize(new Dimension(100, swingConfig.getStandardComponentHight())); errorField.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING)); TwoComponentsPanel lineError = new TwoComponentsPanel(errorField, Box.createRigidArea(new Dimension(1, swingConfig.getStandardComponentHight()))); lineError.setAlignmentX(Component.LEFT_ALIGNMENT); basePanel.add(lineError); // character set JLabel labelCharset = new JLabel(swingConfig.getLocalizer().localize("label.default-characterset")); labelCharset.setAlignmentX(Component.LEFT_ALIGNMENT); basePanel.add(labelCharset); JComboBox listCharset = new JComboBox(swingConfig.getCharsetList().toArray()); listCharset.setAlignmentX(Component.LEFT_ALIGNMENT); listCharset.setSelectedItem(swingConfig.getDefaultCharset()); listCharset.setEditable(true); listCharset.setMaximumSize( new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, swingConfig.getStandardComponentHight())); listCharset.addActionListener(new CharacterSetListener(errorField)); listCharset.setEditor(new CharacterSetEditor(errorField)); basePanel.add(listCharset); basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); // select the group selector JPanel selectorPanel = new JPanel(); selectorPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); selectorPanel.setAlignmentX(Component.LEFT_ALIGNMENT); // linePattern.setAlignmentX( Component.LEFT_ALIGNMENT ); JLabel labelSelector = new JLabel(swingConfig.getLocalizer().localize("label.group-ref-indicator")); selectorPanel.add(labelSelector); JComboBox selectorBox = new JComboBox(FARConfig.GROUPREFINDICATORLIST); selectorBox.setSelectedItem(Character.toString(groupReference)); selectorBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { JComboBox cbox = (JComboBox) event.getSource(); String indicator = (String) cbox.getSelectedItem(); groupReference = indicator.charAt(0); } }); selectorPanel.add(selectorBox); basePanel.add(selectorPanel); basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); // checkbox DO BACKUP JCheckBox doBackupFlag = new JCheckBox(swingConfig.getLocalizer().localize("label.create-backup")); doBackupFlag.setAlignmentX(Component.LEFT_ALIGNMENT); doBackupFlag.setHorizontalTextPosition(SwingConstants.LEADING); doBackupFlag.setSelected(replaceForm.isDoBackup()); doBackupFlag.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { doBackup = ItemEvent.SELECTED == event.getStateChange(); backupFlagEvent = event; } }); basePanel.add(doBackupFlag); JTextField backupDirPathTextField = new JTextField(); backupDirPathTextField.setPreferredSize( new Dimension(SwingConfig.COMPONENT_WIDTH, swingConfig.getStandardComponentHight())); backupDirPathTextField.setMaximumSize( new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, swingConfig.getStandardComponentHight())); backupDirPathTextField.setText(backupDirectory.getPath()); backupDirPathTextField.setToolTipText(backupDirectory.getPath()); backupDirPathTextField.setEditable(false); JButton openBaseDirFileChooserButton = new JButton(swingConfig.getLocalizer().localize("button.browse")); BrowseButtonListener backupDirButtonListener = new BrowseButtonListener(backupDirPathTextField, new BackUpDirectoryRepository(swingConfig, findForm, replaceForm, errorField), swingConfig.getLocalizer().localize("label.choose-backup-directory")); openBaseDirFileChooserButton.addActionListener(backupDirButtonListener); TwoComponentsPanel lineBaseDir = new TwoComponentsPanel(backupDirPathTextField, openBaseDirFileChooserButton); lineBaseDir.setAlignmentX(Component.LEFT_ALIGNMENT); basePanel.add(lineBaseDir); basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); JPanel fileInfoPanel = new JPanel(); fileInfoPanel .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), swingConfig.getLocalizer().localize("label.default-file-info"))); fileInfoPanel.setAlignmentX(Component.LEFT_ALIGNMENT); fileInfoPanel.setLayout(new BoxLayout(fileInfoPanel, BoxLayout.Y_AXIS)); JLabel fileInfoLabel = new JLabel(swingConfig.getLocalizer().localize("message.displayed-in-info-column")); fileInfoLabel.setAlignmentX(Component.LEFT_ALIGNMENT); fileInfoPanel.add(fileInfoLabel); fileInfoPanel.add(Box.createHorizontalGlue()); JRadioButton nothingRadio = new JRadioButton(swingConfig.getLocalizer().localize("label.nothing")); nothingRadio.setAlignmentX(Component.LEFT_ALIGNMENT); nothingRadio.setActionCommand(SwingConfig.DefaultFileInfo.NOTHING.name()); nothingRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.NOTHING); fileInfoOptions.add(nothingRadio); fileInfoPanel.add(nothingRadio); JRadioButton readOnlyRadio = new JRadioButton( swingConfig.getLocalizer().localize("label.read-only-warning")); readOnlyRadio.setAlignmentX(Component.LEFT_ALIGNMENT); readOnlyRadio.setActionCommand(SwingConfig.DefaultFileInfo.READONLY.name()); readOnlyRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.READONLY); fileInfoOptions.add(readOnlyRadio); fileInfoPanel.add(readOnlyRadio); JRadioButton sizeRadio = new JRadioButton(swingConfig.getLocalizer().localize("label.filesize")); sizeRadio.setAlignmentX(Component.LEFT_ALIGNMENT); sizeRadio.setActionCommand(SwingConfig.DefaultFileInfo.SIZE.name()); sizeRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.SIZE); fileInfoOptions.add(sizeRadio); fileInfoPanel.add(sizeRadio); JCheckBox showPlainBytesFlag = new JCheckBox( " " + swingConfig.getLocalizer().localize("label.show-plain-bytes")); showPlainBytesFlag.setAlignmentX(Component.LEFT_ALIGNMENT); showPlainBytesFlag.setHorizontalTextPosition(SwingConstants.LEADING); showPlainBytesFlag.setSelected(swingConfig.isShowPlainBytes()); showPlainBytesFlag.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { showBytes = ItemEvent.SELECTED == event.getStateChange(); } }); fileInfoPanel.add(showPlainBytesFlag); JRadioButton lastModifiedRadio = new JRadioButton( swingConfig.getLocalizer().localize("label.last-modified")); lastModifiedRadio.setAlignmentX(Component.LEFT_ALIGNMENT); lastModifiedRadio.setActionCommand(SwingConfig.DefaultFileInfo.LAST_MODIFIED.name()); lastModifiedRadio .setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.LAST_MODIFIED); fileInfoOptions.add(lastModifiedRadio); fileInfoPanel.add(lastModifiedRadio); basePanel.add(fileInfoPanel); // buttons JPanel buttonPannel = new JPanel(); buttonPannel.setAlignmentX(Component.LEFT_ALIGNMENT); buttonPannel.setLayout(new FlowLayout(FlowLayout.TRAILING)); // cancel JButton cancelButton = new JButton(swingConfig.getLocalizer().localize("button.cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { SettingsDialog.this.dispose(); } }); buttonPannel.add(cancelButton); // save JButton saveButton = new JButton(swingConfig.getLocalizer().localize("button.save")); saveButton.addActionListener(new SaveButtonListener()); buttonPannel.add(saveButton); this.getRootPane().setDefaultButton(saveButton); this.add(basePanel); this.add(buttonPannel); placeOnScreen(swingConfig.getScreenCenter()); }
From source file:net.pandoragames.far.ui.swing.FindFilePanel.java
private void initBaseDirPanel(SwingConfig config, ComponentRepository componentRepository) { this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); JLabel labelBaseDir = new JLabel(config.getLocalizer().localize("label.base-directory")); labelBaseDir.setAlignmentX(Component.LEFT_ALIGNMENT); this.add(labelBaseDir); baseDirPathTextField//from ww w .j a va 2 s.co m .setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH, config.getStandardComponentHight())); baseDirPathTextField .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight())); // baseDirPathTextField.setText( dataModel.getBaseDirectory().getPath() ); baseDirPathTextField.addItem(dataModel.getBaseDirectory().getPath()); baseDirPathTextField.setSelectedItem(dataModel.getBaseDirectory().getPath()); baseDirPathTextField.setToolTipText(dataModel.getBaseDirectory().getPath()); baseDirPathTextField.setEditable(false); baseDirPathTextField.addItemListener(new BaseDirectoryComboBoxListener(config, dataModel)); JButton openBaseDirFileChooserButton = new JButton(localizer.localize("button.browse")); openBaseDirFileChooserButton.requestFocusInWindow(); class BaseDirectoryRepository extends AbstractFileRepository { public BaseDirectoryRepository(FARConfig cfg, ComponentRepository repository) { super(cfg, repository.getFindForm(), repository.getReplaceForm(), repository.getMessageBox()); } public File getFile() { return farconfig.getBaseDirectory(); } public boolean setFile(File file) { if (isSubdirectory(replaceForm.getBackupDirectory(), file)) { messageBox.error(localizer.localize("message.nested-base-child")); return false; } else if (isSubdirectory(file, replaceForm.getBackupDirectory())) { messageBox.error(localizer.localize("message.nested-base-parent")); return false; } else { baseDirPathTextField.addItem(file.getPath()); baseDirPathTextField.setSelectedItem(file.getPath()); baseDirPathTextField.setToolTipText(file.getPath()); farconfig.setBaseDirectory(file); findForm.setBaseDirectory(file); return true; } } } browseButtonListener = new FindFilePanelBrowseButtonListener(baseDirPathTextField, new BaseDirectoryRepository(config, componentRepository), localizer.localize("label.choose-base-directory"), componentRepository.getFindCommand(), componentRepository.getResetDispatcher()); browseButtonListener.addActionListener(componentRepository.getSearchBaseListener()); openBaseDirFileChooserButton.addActionListener(browseButtonListener); TwoComponentsPanel lineBaseDir = new TwoComponentsPanel(baseDirPathTextField, openBaseDirFileChooserButton); lineBaseDir.setAlignmentX(Component.LEFT_ALIGNMENT); this.add(lineBaseDir); subdirFlag = new JCheckBox(localizer.localize("label.include-subdir") + ":"); subdirFlag.setSelected(dataModel.isIncludeSubDirs()); subdirFlag.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { dataModel.setIncludeSubDirs((ItemEvent.SELECTED == event.getStateChange())); if (ItemEvent.SELECTED != event.getStateChange()) subdirButton.reset(); } }); subdirFlag.addItemListener(componentRepository.getSearchBaseListener()); componentRepository.getResetDispatcher().addToBeSelected(subdirFlag); browseButtonListener.setSubdirCheckBox(subdirFlag); subdirButton = new SubdirPatternLink(dataModel, localizer, componentRepository.getSearchBaseListener(), componentRepository.getRootWindow()); componentRepository.getResetDispatcher().addResetable(subdirButton); TwoComponentsPanel subdirpanel = new TwoComponentsPanel(subdirFlag, subdirButton); subdirpanel.setAlignmentX(Component.LEFT_ALIGNMENT); this.add(subdirpanel); this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); this.add(Box.createVerticalGlue()); }
From source file:com.db4o.sync4o.ui.Db4oSyncSourceConfigPanel.java
private void setupControls() { // Layout and setup UI components... setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); add(_namePanel);//from w ww . ja v a 2 s . c om _namePanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(_fieldsPanel); _fieldsPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(_classConfigsTree); _classConfigsTree.setAlignmentX(Component.LEFT_ALIGNMENT); _classConfigsTree.setPreferredSize(new Dimension(300, 300)); add(_buttonsPanel); _buttonsPanel.setAlignmentX(Component.LEFT_ALIGNMENT); JLabel l; // Admin UI Management Panels use a title // (in a particular "title font") to identify themselves l = new JLabel("Edit Db4oSyncSource Configuration", SwingConstants.CENTER); l.setBorder(new TitledBorder("")); l.setFont(titlePanelFont); _namePanel.add(l); GridBagConstraints labelConstraints = new GridBagConstraints(); labelConstraints.gridwidth = 1; labelConstraints.fill = GridBagConstraints.NONE; labelConstraints.weightx = 0.0; labelConstraints.gridx = 0; labelConstraints.gridy = 0; labelConstraints.anchor = GridBagConstraints.EAST; GridBagConstraints fieldConstraints = new GridBagConstraints(); fieldConstraints.gridwidth = 2; fieldConstraints.fill = GridBagConstraints.HORIZONTAL; fieldConstraints.weightx = 1.0; fieldConstraints.gridx = 1; fieldConstraints.gridy = 0; _fieldsPanel.add(new JLabel("Source URI: "), labelConstraints); _fieldsPanel.add(_sourceUriValue, fieldConstraints); labelConstraints.gridy = GridBagConstraints.RELATIVE; fieldConstraints.gridy = GridBagConstraints.RELATIVE; _fieldsPanel.add(new JLabel("Name: "), labelConstraints); _fieldsPanel.add(_nameValue, fieldConstraints); fieldConstraints.gridwidth = 1; _fieldsPanel.add(new JLabel("db4o File: "), labelConstraints); _fieldsPanel.add(_dbFileValue, fieldConstraints); _dbFileValue.setEditable(false); fieldConstraints.gridwidth = 2; GridBagConstraints buttonConstraints = new GridBagConstraints(); buttonConstraints.gridwidth = 1; buttonConstraints.fill = GridBagConstraints.NONE; buttonConstraints.gridx = 2; buttonConstraints.gridy = 3; _dbFileLocateButton.setText("..."); _fieldsPanel.add(_dbFileLocateButton, buttonConstraints); buttonConstraints.gridwidth = 3; buttonConstraints.fill = GridBagConstraints.NONE; buttonConstraints.gridx = 0; buttonConstraints.gridy = GridBagConstraints.RELATIVE; buttonConstraints.anchor = GridBagConstraints.CENTER; // Ensure all the controls use the Admin UI standard font Component[] components = _fieldsPanel.getComponents(); for (int i = 0; i < components.length; i++) { Component c = components[i]; c.setFont(defaultFont); } _confirmButton.setText("Add"); _buttonsPanel.add(_confirmButton); }