private JCheckBox getEnableGunshotCheckBox() { if (enableGunshotCheckBox == null) { enableGunshotCheckBox = new JCheckBox("Gun Shots"); enableGunshotCheckBox.setMnemonic('G'); } return enableGunshotCheckBox; }
private JCheckBox getEnableSoundCheckBox() { if (enableSoundCheckBox == null) { enableSoundCheckBox = new JCheckBox("Enable Sound"); enableSoundCheckBox.setMnemonic('E'); } return enableSoundCheckBox; }
private JCheckBox getEnableRobotCollisionCheckBox() { if (enableRobotCollisionCheckBox == null) { enableRobotCollisionCheckBox = new JCheckBox("Robot Collisions"); enableRobotCollisionCheckBox.setMnemonic('t'); enableRobotCollisionCheckBox.setDisplayedMnemonicIndex(4); } return enableRobotCollisionCheckBox; }
private JCheckBox getEnableRobotDeathCheckBox() { if (enableRobotDeathCheckBox == null) { enableRobotDeathCheckBox = new JCheckBox("Robot Death Explosions"); enableRobotDeathCheckBox.setMnemonic('x'); enableRobotDeathCheckBox.setDisplayedMnemonicIndex(13); } return enableRobotDeathCheckBox; }
private JCheckBox getEnableBulletHitCheckBox() { if (enableBulletHitCheckBox == null) { enableBulletHitCheckBox = new JCheckBox("Bullet Hit"); enableBulletHitCheckBox.setMnemonic('H'); enableBulletHitCheckBox.setDisplayedMnemonicIndex(7); } return enableBulletHitCheckBox; }
private JCheckBox getOptionsRenderingForceBulletColorCheckBox() { if (optionsRenderingForceBulletColorCheckBox == null) { optionsRenderingForceBulletColorCheckBox = new JCheckBox("Make all bullets white"); optionsRenderingForceBulletColorCheckBox.setMnemonic('M'); optionsRenderingForceBulletColorCheckBox.addActionListener(eventHandler); } return optionsRenderingForceBulletColorCheckBox; }
private JCheckBox getEnableMixerPanCheckBox() { if (enableMixerPanCheckBox == null) { enableMixerPanCheckBox = new JCheckBox("Pan"); enableMixerPanCheckBox.setMnemonic('P'); enableMixerPanCheckBox.addActionListener(eventHandler); } return enableMixerPanCheckBox; }
private JCheckBox getEnableWallCollisionCheckBox() { if (enableWallCollisionCheckBox == null) { enableWallCollisionCheckBox = new JCheckBox("Wall Collisions"); enableWallCollisionCheckBox.setMnemonic('l'); enableWallCollisionCheckBox.setDisplayedMnemonicIndex(2); } return enableWallCollisionCheckBox; }
public JCheckBox getWholeWordCheckBox() { if (wholeWordCheckBox == null) { wholeWordCheckBox = new JCheckBox(); wholeWordCheckBox.setText("Whole Words Only"); wholeWordCheckBox.setMnemonic('W'); wholeWordCheckBox.addActionListener(this); } return wholeWordCheckBox; }
private JCheckBox getOptionsRenderingBufferImagesCheckBox() { if (optionsRenderingBufferImagesCheckBox == null) { optionsRenderingBufferImagesCheckBox = new JCheckBox("Buffer images (uses memory)"); optionsRenderingBufferImagesCheckBox.setMnemonic('i'); optionsRenderingBufferImagesCheckBox.setDisplayedMnemonicIndex(7); optionsRenderingBufferImagesCheckBox.addActionListener(eventHandler); } return optionsRenderingBufferImagesCheckBox; }
public JCheckBox getCaseSensitiveCheckBox() { if (caseSensitiveCheckBox == null) { caseSensitiveCheckBox = new JCheckBox(); caseSensitiveCheckBox.setText("Case Sensitive"); caseSensitiveCheckBox.setMnemonic('v'); caseSensitiveCheckBox.setDisplayedMnemonicIndex(12); caseSensitiveCheckBox.addActionListener(this); } return caseSensitiveCheckBox; }
private JPanel getPredicatePanel() { GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); JPanel panel = new JPanel(gbl); panel.setBorder(new EmptyBorder(12, 12, 0, 11)); // TODO: make variable query widget set a package for this and ParameterUpdateDialog gbc.gridy = 0; gbc.gridx = 0; gbc.weighty = 0; gbc.weightx = 0.333; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.EAST; gbc.insets = new Insets(0, 0, 5, 5); useXQuery = new JCheckBox("Use XQuery"); useXQuery.setMnemonic('X'); useXQuery.addActionListener(this); panel.add(useXQuery, gbc); JLabel inputVariableLabel = new JLabel("Variable:"); inputVariableLabel.setHorizontalAlignment(JLabel.RIGHT); inputVariableLabel.setDisplayedMnemonic('v'); panel.add(inputVariableLabel, gbc); gbc.gridx++; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(0, 5, 5, 5); panel.add(getInputVariableComboBox(), gbc); inputVariableLabel.setLabelFor(inputVariableComboBox); gbc.gridx++; gbc.anchor = GridBagConstraints.CENTER; panel.add(getNewInputVariableQueryButton(), gbc); gbc.gridx = 0; gbc.gridy++; gbc.gridwidth = 3; gbc.weighty = 1; gbc.weightx = 1; gbc.fill = GridBagConstraints.BOTH; panel.add(getXQueryEditor(), gbc); return panel; }
GitManualPushToBranch( @NotNull Collection<GitRepository> repositories, @NotNull final Runnable performOnRefresh) { super(); myRepositories = repositories; myManualPush = new JCheckBox("Push current branch to alternative branch: ", false); myManualPush.setMnemonic('b'); myDestBranchTextField = new JTextField(20); myComment = new JBLabel("This will apply to all selected repositories", UIUtil.ComponentStyle.SMALL); myRefreshAction = new GitPushLogRefreshAction() { @Override public void actionPerformed(AnActionEvent e) { performOnRefresh.run(); } }; myRefreshButton = new ActionButton( myRefreshAction, myRefreshAction.getTemplatePresentation(), myRefreshAction.getTemplatePresentation().getText(), ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE); myRefreshButton.setFocusable(true); final ShortcutSet shortcutSet = ActionManager.getInstance().getAction(IdeActions.ACTION_REFRESH).getShortcutSet(); myRefreshAction.registerCustomShortcutSet(shortcutSet, myRefreshButton); myRemoteSelector = new RemoteSelector(getRemotesWithCommonNames(repositories)); myRemoteSelectorComponent = myRemoteSelector.createComponent(); setDefaultComponentsEnabledState(myManualPush.isSelected()); myManualPush.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean isManualPushSelected = myManualPush.isSelected(); setDefaultComponentsEnabledState(isManualPushSelected); if (isManualPushSelected) { myDestBranchTextField.requestFocus(); myDestBranchTextField.selectAll(); } } }); layoutComponents(); }
public DvcsCommitAdditionalComponent( @NotNull final Project project, @NotNull CheckinProjectPanel panel) { myCheckinPanel = panel; myPanel = new JPanel(new GridBagLayout()); final Insets insets = new Insets(2, 2, 2, 2); // add amend checkbox GridBagConstraints c = new GridBagConstraints(); // todo change to MigLayout c.gridx = 0; c.gridy = 1; c.gridwidth = 2; c.anchor = GridBagConstraints.CENTER; c.insets = insets; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; myAmend = new NonFocusableCheckBox(DvcsBundle.message("commit.amend")); myAmend.setMnemonic('m'); myAmend.setToolTipText(DvcsBundle.message("commit.amend.tooltip")); myPreviousMessage = myCheckinPanel.getCommitMessage(); myAmend.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (myAmend.isSelected()) { if (myPreviousMessage.equals( myCheckinPanel .getCommitMessage())) { // if user has already typed something, don't revert // it if (myMessagesForRoots == null) { loadMessagesInModalTask(project); // load all commit messages for all repositories } String message = constructAmendedMessage(); if (!StringUtil.isEmptyOrSpaces(message)) { myAmendedMessage = message; substituteCommitMessage(myAmendedMessage); } } } else { // there was the amended message, but user has changed it => not reverting if (myCheckinPanel.getCommitMessage().equals(myAmendedMessage)) { myCheckinPanel.setCommitMessage(myPreviousMessage); } } } }); myPanel.add(myAmend, c); }
public AmendComponent( @NotNull Project project, @NotNull RepositoryManager<? extends Repository> repoManager, @NotNull CheckinProjectPanel panel, @NotNull String title) { myRepoManager = repoManager; myCheckinPanel = panel; myAmend = new NonFocusableCheckBox(title); myAmend.setMnemonic('m'); myAmend.setToolTipText(DvcsBundle.message("commit.amend.tooltip")); myPreviousMessage = myCheckinPanel.getCommitMessage(); myAmend.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (myAmend.isSelected()) { if (myPreviousMessage.equals( myCheckinPanel .getCommitMessage())) { // if user has already typed something, don't revert // it if (myMessagesForRoots == null) { loadMessagesInModalTask(project); // load all commit messages for all repositories } String message = constructAmendedMessage(); if (!StringUtil.isEmptyOrSpaces(message)) { myAmendedMessage = message; substituteCommitMessage(myAmendedMessage); } } } else { // there was the amended message, but user has changed it => not reverting if (myCheckinPanel.getCommitMessage().equals(myAmendedMessage)) { myCheckinPanel.setCommitMessage(myPreviousMessage); } } } }); }
private JPanel createRightPanel() { final JPanel right = new JPanel(new GridBagLayout()); final GridBagConstraints rgc = new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0); myReplaceAllCb = new JCheckBox("Replace all occurrences"); myReplaceAllCb.setMnemonic('a'); myReplaceAllCb.setFocusable(false); myReplaceAllCb.setVisible(myOccurrences.length > 1); right.add(myReplaceAllCb, rgc); return right; }
private JPanel createLeftPanel() { final JPanel left = new JPanel(new GridBagLayout()); myMoveToAnotherClassCb = new JCheckBox( "Move to another class", JavaRefactoringSettings.getInstance().INTRODUCE_CONSTANT_MOVE_TO_ANOTHER_CLASS); myMoveToAnotherClassCb.setMnemonic('m'); myMoveToAnotherClassCb.setFocusable(false); left.add( myMoveToAnotherClassCb, new GridBagConstraints( 0, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); return left; }
public BnfIntroduceRulePopup(Project project, Editor editor, BnfRule rule, BnfExpression expr) { super(rule, editor, project, "Introduce Rule", new BnfExpression[0], expr); myCheckBox.setSelected(true); myCheckBox.setMnemonic('p'); myPanel.setBorder(null); myPanel.add( myCheckBox, new GridBagConstraints( 0, 1, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); myPanel.add( Box.createVerticalBox(), new GridBagConstraints( 0, 2, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); }
/** Creates the GUI. */ public void majorLayout() { // // Setup Menu // JMenuBar menuBar = new JMenuBar(); JMenu file = new JMenu(ResourceHandler.getMessage("menu.file")); file.setMnemonic(ResourceHandler.getAcceleratorKey("menu.file")); file.add(exitMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.exit"))); exitMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.exit")); exitMenuItem.addActionListener(this); menuBar.add(file); JMenu edit = new JMenu(ResourceHandler.getMessage("menu.edit")); edit.setMnemonic(ResourceHandler.getAcceleratorKey("menu.edit")); edit.add(optionMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.option"))); optionMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.option")); optionMenuItem.addActionListener(this); menuBar.add(edit); JMenu help = new JMenu(ResourceHandler.getMessage("menu.help")); help.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help")); help.add(helpMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.help"))); helpMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help")); help.add(new JSeparator()); help.add(aboutMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.about"))); aboutMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.about")); helpMenuItem.addActionListener(this); aboutMenuItem.addActionListener(this); menuBar.add(help); setJMenuBar(menuBar); // // Setup main GUI // dirLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel0")); dirTF = new JTextField(); dirBttn = new JButton(ResourceHandler.getMessage("button.browse.dir")); dirBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.dir")); matchingLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel1")); matchingTF = new JTextField(ResourceHandler.getMessage("converter_gui.lablel2")); recursiveCheckBox = new JCheckBox(ResourceHandler.getMessage("converter_gui.lablel3")); recursiveCheckBox.setMnemonic(ResourceHandler.getAcceleratorKey("converter_gui.lablel3")); backupLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel5")); backupTF = new JTextField(); backupBttn = new JButton(ResourceHandler.getMessage("button.browse.backup")); backupBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.backup")); templateLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel7")); templateCh = new TemplateFileChoice(); staticVersioningLabel = new JLabel(ResourceHandler.getMessage("static.versioning.label")); String version = System.getProperty("java.version"); if (version.indexOf("-") > 0) { version = version.substring(0, version.indexOf("-")); } int dotIndex = version.indexOf("."); dotIndex = version.indexOf(".", dotIndex + 1); String familyVersion = version.substring(0, dotIndex); MessageFormat formatter = new MessageFormat(ResourceHandler.getMessage("static.versioning.radio.button")); staticVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {version})); staticVersioningRadioButton.setMnemonic( ResourceHandler.getAcceleratorKey("static.versioning.radio.button")); formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.radio.button")); dynamicVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {familyVersion})); dynamicVersioningRadioButton.setMnemonic( ResourceHandler.getAcceleratorKey("dynamic.versioning.radio.button")); staticVersioningTextArea = new JTextArea(ResourceHandler.getMessage("static.versioning.text")); formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.text")); dynamicVersioningTextArea = new JTextArea(formatter.format(new Object[] {familyVersion})); ButtonGroup versioningButtonGroup = new ButtonGroup(); versioningButtonGroup.add(staticVersioningRadioButton); versioningButtonGroup.add(dynamicVersioningRadioButton); runBttn = new JButton(ResourceHandler.getMessage("button.convert")); runBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.convert")); recursiveCheckBox.setOpaque(false); staticVersioningRadioButton.setOpaque(false); dynamicVersioningRadioButton.setOpaque(false); staticVersioningTextArea.setEditable(false); staticVersioningTextArea.setLineWrap(true); staticVersioningTextArea.setWrapStyleWord(true); dynamicVersioningTextArea.setEditable(false); dynamicVersioningTextArea.setLineWrap(true); dynamicVersioningTextArea.setWrapStyleWord(true); staticVersioningPanel.setLayout(new BorderLayout()); staticVersioningPanel.add(staticVersioningTextArea, "Center"); staticVersioningPanel.setBorder(new LineBorder(Color.black)); dynamicVersioningPanel.setLayout(new BorderLayout()); dynamicVersioningPanel.add(dynamicVersioningTextArea, "Center"); dynamicVersioningPanel.setBorder(new LineBorder(Color.black)); if (converter.isStaticVersioning()) { staticVersioningRadioButton.setSelected(true); } else { dynamicVersioningRadioButton.setSelected(true); } addListeners(); final int buf = 10, // Buffer (between components and form) sp = 10, // Space between components vsp = 5, // Vertical space indent = 20; // Indent between form (left edge) and component GridBagConstraints gbc = new GridBagConstraints(); GridBagLayout gbl = new GridBagLayout(); getContentPane().setLayout(gbl); // // Setup top panel // GridBagLayout topLayout = new GridBagLayout(); JPanel topPanel = new JPanel(); topPanel.setOpaque(false); topPanel.setLayout(topLayout); topLayout.setConstraints( dirLabel, new GridBagConstraints( 0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0)); topLayout.setConstraints( dirTF, new GridBagConstraints( 1, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(vsp, 2, 0, 0), 0, 0)); topLayout.setConstraints( dirBttn, new GridBagConstraints( 2, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, sp, 0, 0), 0, 0)); topLayout.setConstraints( matchingLabel, new GridBagConstraints( 0, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0)); topLayout.setConstraints( matchingTF, new GridBagConstraints( 1, 1, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(vsp, 2, 0, 0), 0, 0)); topLayout.setConstraints( recursiveCheckBox, new GridBagConstraints( 2, 1, GridBagConstraints.REMAINDER, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(vsp, 10, 0, 0), 0, 0)); topLayout.setConstraints( backupLabel, new GridBagConstraints( 0, 3, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0)); topLayout.setConstraints( backupTF, new GridBagConstraints( 1, 3, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(vsp, 2, 0, 0), 0, 0)); topLayout.setConstraints( backupBttn, new GridBagConstraints( 2, 3, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, sp, 0, 0), 0, 0)); topLayout.setConstraints( templateLabel, new GridBagConstraints( 0, 4, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0)); topLayout.setConstraints( templateCh, new GridBagConstraints( 1, 4, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(vsp, 2, 0, 0), 0, 0)); topLayout.setConstraints( sep1, new GridBagConstraints( 0, 5, GridBagConstraints.REMAINDER, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 0, 0)); topLayout.setConstraints( staticVersioningLabel, new GridBagConstraints( 0, 6, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0)); topLayout.setConstraints( staticVersioningRadioButton, new GridBagConstraints( 0, 7, GridBagConstraints.REMAINDER, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(vsp, 10, 0, 0), 0, 0)); topLayout.setConstraints( staticVersioningPanel, new GridBagConstraints( 0, 8, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(vsp, 25, 10, 0), 0, 0)); topLayout.setConstraints( dynamicVersioningRadioButton, new GridBagConstraints( 0, 9, GridBagConstraints.REMAINDER, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(vsp, 10, 0, 0), 0, 0)); topLayout.setConstraints( dynamicVersioningPanel, new GridBagConstraints( 0, 10, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(vsp, 25, 0, 0), 0, 0)); topLayout.setConstraints( sep2, new GridBagConstraints( 0, 11, GridBagConstraints.REMAINDER, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 0, 10), 0, 0)); invisibleBttn = new JButton(); invisibleBttn.setVisible(false); topLayout.setConstraints( invisibleBttn, new GridBagConstraints( 2, 6, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, new Insets(indent, sp, 0, 0), 0, 0)); topPanel.add(dirLabel); topPanel.add(dirTF); topPanel.add(dirBttn); topPanel.add(matchingLabel); topPanel.add(matchingTF); topPanel.add(recursiveCheckBox); topPanel.add(backupLabel); topPanel.add(backupTF); topPanel.add(backupBttn); topPanel.add(templateLabel); topPanel.add(templateCh); topPanel.add(sep1); topPanel.add(staticVersioningLabel); topPanel.add(staticVersioningRadioButton); topPanel.add(staticVersioningPanel); topPanel.add(dynamicVersioningRadioButton); topPanel.add(dynamicVersioningPanel); topPanel.add(sep2); topPanel.add(invisibleBttn); // // Setup bottom panel // GridBagLayout buttomLayout = new GridBagLayout(); JPanel buttomPanel = new JPanel(); buttomPanel.setOpaque(false); buttomPanel.setLayout(buttomLayout); buttomLayout.setConstraints( runBttn, new GridBagConstraints( 3, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(sp, 0, 0, 0), 0, 0)); buttomPanel.add(runBttn); // // Setup main panel // GridBagLayout mainLayout = new GridBagLayout(); JPanel mainPanel = new JPanel(); mainPanel.setOpaque(false); mainPanel.setLayout(mainLayout); mainLayout.setConstraints( topPanel, new GridBagConstraints( 0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(buf, buf, 0, buf), 0, 0)); mainLayout.setConstraints( buttomPanel, new GridBagConstraints( 0, 1, 1, 1, 1, 1, GridBagConstraints.SOUTH, GridBagConstraints.HORIZONTAL, new Insets(0, buf, buf, buf), 0, 0)); mainPanel.add(topPanel); mainPanel.add(buttomPanel); Border border = BorderFactory.createEtchedBorder(); mainPanel.setBorder(border); GridBagLayout layout = new GridBagLayout(); getContentPane().setLayout(layout); layout.setConstraints( mainPanel, new GridBagConstraints( 0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); getContentPane().add(mainPanel); pack(); setResizable(false); }
public FileColorsConfigurablePanel(@NotNull final FileColorManagerImpl manager) { setLayout(new BorderLayout()); myManager = manager; final JPanel topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.X_AXIS)); myEnabledCheckBox = new JCheckBox("Enable File Colors"); myEnabledCheckBox.setMnemonic('F'); topPanel.add(myEnabledCheckBox); myTabsEnabledCheckBox = new JCheckBox("Use in Editor Tabs"); myTabsEnabledCheckBox.setMnemonic('T'); topPanel.add(myTabsEnabledCheckBox); myProjectViewEnabledCheckBox = new JCheckBox("Use in Project View"); myProjectViewEnabledCheckBox.setMnemonic('P'); topPanel.add(myProjectViewEnabledCheckBox); topPanel.add(Box.createHorizontalGlue()); add(topPanel, BorderLayout.NORTH); final JPanel mainPanel = new JPanel(new GridLayout(2, 1)); mainPanel.setPreferredSize(JBUI.size(300, 500)); mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 0)); final List<FileColorConfiguration> localConfigurations = manager.getApplicationLevelConfigurations(); myLocalTable = new FileColorSettingsTable(manager, localConfigurations) { @Override protected void apply(@NotNull List<FileColorConfiguration> configurations) { final List<FileColorConfiguration> copied = new ArrayList<FileColorConfiguration>(); try { for (final FileColorConfiguration configuration : configurations) { copied.add(configuration.clone()); } } catch (CloneNotSupportedException e) { // } manager.getModel().setConfigurations(copied, false); } }; final JPanel panel = ToolbarDecorator.createDecorator(myLocalTable) .addExtraAction( new AnActionButton("Share", AllIcons.Actions.Share) { @Override public void actionPerformed(AnActionEvent e) { share(); } @Override public boolean isEnabled() { return super.isEnabled() && myLocalTable.getSelectedRow() != -1; } }) .createPanel(); final JPanel localPanel = new JPanel(new BorderLayout()); localPanel.setBorder(IdeBorderFactory.createTitledBorder("Local colors", false)); localPanel.add(panel, BorderLayout.CENTER); mainPanel.add(localPanel); mySharedTable = new FileColorSettingsTable(manager, manager.getProjectLevelConfigurations()) { @Override protected void apply(@NotNull List<FileColorConfiguration> configurations) { final List<FileColorConfiguration> copied = new ArrayList<FileColorConfiguration>(); for (final FileColorConfiguration configuration : configurations) { try { copied.add(configuration.clone()); } catch (CloneNotSupportedException e) { assert false : "Should not happen!"; } } manager.getModel().setConfigurations(copied, true); } }; final JPanel sharedPanel = new JPanel(new BorderLayout()); sharedPanel.setBorder(IdeBorderFactory.createTitledBorder("Shared colors", false)); final JPanel shared = ToolbarDecorator.createDecorator(mySharedTable) .addExtraAction( new AnActionButton("Unshare", AllIcons.Actions.Unshare) { @Override public void actionPerformed(AnActionEvent e) { unshare(); } @Override public boolean isEnabled() { return super.isEnabled() && mySharedTable.getSelectedRow() != -1; } }) .createPanel(); sharedPanel.add(shared, BorderLayout.CENTER); mainPanel.add(sharedPanel); add(mainPanel, BorderLayout.CENTER); final JPanel infoPanel = new JPanel(new BorderLayout()); infoPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); infoPanel.add( new JLabel( "Scopes are processed from top to bottom with Local colors first.", MessageType.INFO.getDefaultIcon(), SwingConstants.LEFT)); JButton editScopes = new JButton("Manage Scopes..."); editScopes.addActionListener( new ActionListener() { @Override public void actionPerformed(@NotNull ActionEvent e) { EditScopesDialog.showDialog(myManager.getProject(), null, true); } }); infoPanel.add(editScopes, BorderLayout.EAST); add(infoPanel, BorderLayout.SOUTH); myLocalTable.getEmptyText().setText("No local colors"); mySharedTable.getEmptyText().setText("No shared colors"); }
public void show(List<Rule> rules) { if (original != null) config.restoreState(original); dialog = new JDialog(owner, true); dialog.setTitle(messages.getString("guiConfigWindowTitle")); Collections.sort(rules, new CategoryComparator()); // close dialog when user presses Escape key: final KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); final ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(@SuppressWarnings("unused") ActionEvent actionEvent) { dialog.setVisible(false); } }; final JRootPane rootPane = dialog.getRootPane(); rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); // JPanel final JPanel checkBoxPanel = new JPanel(); checkBoxPanel.setLayout(new GridBagLayout()); GridBagConstraints cons = new GridBagConstraints(); cons.anchor = GridBagConstraints.NORTHWEST; cons.gridx = 0; cons.weightx = 1.0; cons.weighty = 1.0; cons.fill = GridBagConstraints.BOTH; DefaultMutableTreeNode rootNode = createTree(rules); DefaultTreeModel treeModel = new DefaultTreeModel(rootNode); treeModel.addTreeModelListener( new TreeModelListener() { @Override public void treeNodesChanged(TreeModelEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getTreePath().getLastPathComponent(); int index = e.getChildIndices()[0]; node = (DefaultMutableTreeNode) (node.getChildAt(index)); if (node instanceof RuleNode) { RuleNode o = (RuleNode) node; if (o.getRule().isDefaultOff()) { if (o.isEnabled()) { config.getEnabledRuleIds().add(o.getRule().getId()); } else { config.getEnabledRuleIds().remove(o.getRule().getId()); } } else { if (o.isEnabled()) { config.getDisabledRuleIds().remove(o.getRule().getId()); } else { config.getDisabledRuleIds().add(o.getRule().getId()); } } } if (node instanceof CategoryNode) { CategoryNode o = (CategoryNode) node; if (o.isEnabled()) { config.getDisabledCategoryNames().remove(o.getCategory().getName()); } else { config.getDisabledCategoryNames().add(o.getCategory().getName()); } } } @Override public void treeNodesInserted(TreeModelEvent e) {} @Override public void treeNodesRemoved(TreeModelEvent e) {} @Override public void treeStructureChanged(TreeModelEvent e) {} }); configTree = new JTree(treeModel); configTree.setRootVisible(false); configTree.setEditable(false); configTree.setCellRenderer(new CheckBoxTreeCellRenderer()); TreeListener.install(configTree); checkBoxPanel.add(configTree, cons); MouseAdapter ma = new MouseAdapter() { private void handlePopupEvent(MouseEvent e) { final JTree tree = (JTree) e.getSource(); TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path == null) { return; } DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); TreePath[] paths = tree.getSelectionPaths(); boolean isSelected = false; if (paths != null) { for (TreePath selectionPath : paths) { if (selectionPath.equals(path)) { isSelected = true; } } } if (!isSelected) { tree.setSelectionPath(path); } if (node.isLeaf()) { JPopupMenu popup = new JPopupMenu(); final JMenuItem aboutRuleMenuItem = new JMenuItem(messages.getString("guiAboutRuleMenu")); aboutRuleMenuItem.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { RuleNode node = (RuleNode) tree.getSelectionPath().getLastPathComponent(); Rule rule = node.getRule(); Language lang = config.getLanguage(); if (lang == null) { lang = Language.getLanguageForLocale(Locale.getDefault()); } Tools.showRuleInfoDialog( tree, messages.getString("guiAboutRuleTitle"), rule.getDescription(), rule, messages, lang.getShortNameWithCountryAndVariant()); } }); popup.add(aboutRuleMenuItem); popup.show(tree, e.getX(), e.getY()); } } @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { handlePopupEvent(e); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { handlePopupEvent(e); } } }; configTree.addMouseListener(ma); final JPanel treeButtonPanel = new JPanel(); cons = new GridBagConstraints(); cons.gridx = 0; cons.gridy = 0; final JButton expandAllButton = new JButton(messages.getString("guiExpandAll")); treeButtonPanel.add(expandAllButton, cons); expandAllButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TreeNode root = (TreeNode) configTree.getModel().getRoot(); TreePath parent = new TreePath(root); for (Enumeration categ = root.children(); categ.hasMoreElements(); ) { TreeNode n = (TreeNode) categ.nextElement(); TreePath child = parent.pathByAddingChild(n); configTree.expandPath(child); } } }); cons.gridx = 1; cons.gridy = 0; final JButton collapseAllbutton = new JButton(messages.getString("guiCollapseAll")); treeButtonPanel.add(collapseAllbutton, cons); collapseAllbutton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TreeNode root = (TreeNode) configTree.getModel().getRoot(); TreePath parent = new TreePath(root); for (Enumeration categ = root.children(); categ.hasMoreElements(); ) { TreeNode n = (TreeNode) categ.nextElement(); TreePath child = parent.pathByAddingChild(n); configTree.collapsePath(child); } } }); final JPanel motherTonguePanel = new JPanel(); motherTonguePanel.add(new JLabel(messages.getString("guiMotherTongue")), cons); motherTongueBox = new JComboBox(getPossibleMotherTongues()); if (config.getMotherTongue() != null) { motherTongueBox.setSelectedItem(config.getMotherTongue().getTranslatedName(messages)); } motherTongueBox.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { Language motherTongue; if (motherTongueBox.getSelectedItem() instanceof String) { motherTongue = getLanguageForLocalizedName(motherTongueBox.getSelectedItem().toString()); } else { motherTongue = (Language) motherTongueBox.getSelectedItem(); } config.setMotherTongue(motherTongue); } } }); motherTonguePanel.add(motherTongueBox, cons); final JPanel portPanel = new JPanel(); portPanel.setLayout(new GridBagLayout()); // TODO: why is this now left-aligned?!?! cons = new GridBagConstraints(); cons.insets = new Insets(0, 4, 0, 0); cons.gridx = 0; cons.gridy = 0; cons.anchor = GridBagConstraints.WEST; cons.fill = GridBagConstraints.NONE; cons.weightx = 0.0f; if (!insideOOo) { serverCheckbox = new JCheckBox(Tools.getLabel(messages.getString("guiRunOnPort"))); serverCheckbox.setMnemonic(Tools.getMnemonic(messages.getString("guiRunOnPort"))); serverCheckbox.setSelected(config.getRunServer()); portPanel.add(serverCheckbox, cons); serverCheckbox.addActionListener( new ActionListener() { @Override public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) { serverPortField.setEnabled(serverCheckbox.isSelected()); serverSettingsCheckbox.setEnabled(serverCheckbox.isSelected()); } }); serverCheckbox.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { config.setRunServer(serverCheckbox.isSelected()); } }); serverPortField = new JTextField(Integer.toString(config.getServerPort())); serverPortField.setEnabled(serverCheckbox.isSelected()); serverSettingsCheckbox = new JCheckBox(Tools.getLabel(messages.getString("useGUIConfig"))); // TODO: without this the box is just a few pixels small, but why??: serverPortField.setMinimumSize(new Dimension(100, 25)); cons.gridx = 1; portPanel.add(serverPortField, cons); serverPortField .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { changedUpdate(e); } @Override public void removeUpdate(DocumentEvent e) { changedUpdate(e); } @Override public void changedUpdate(DocumentEvent e) { try { int serverPort = Integer.parseInt(serverPortField.getText()); if (serverPort > -1 && serverPort < 65536) { serverPortField.setForeground(null); config.setServerPort(serverPort); } else { serverPortField.setForeground(Color.RED); } } catch (NumberFormatException ex) { serverPortField.setForeground(Color.RED); } } }); cons.gridx = 0; cons.gridy = 10; serverSettingsCheckbox.setMnemonic(Tools.getMnemonic(messages.getString("useGUIConfig"))); serverSettingsCheckbox.setSelected(config.getUseGUIConfig()); serverSettingsCheckbox.setEnabled(config.getRunServer()); serverSettingsCheckbox.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { config.setUseGUIConfig(serverSettingsCheckbox.isSelected()); } }); portPanel.add(serverSettingsCheckbox, cons); } final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridBagLayout()); okButton = new JButton(Tools.getLabel(messages.getString("guiOKButton"))); okButton.setMnemonic(Tools.getMnemonic(messages.getString("guiOKButton"))); okButton.addActionListener(this); cancelButton = new JButton(Tools.getLabel(messages.getString("guiCancelButton"))); cancelButton.setMnemonic(Tools.getMnemonic(messages.getString("guiCancelButton"))); cancelButton.addActionListener(this); cons = new GridBagConstraints(); cons.insets = new Insets(0, 4, 0, 0); buttonPanel.add(okButton, cons); buttonPanel.add(cancelButton, cons); final Container contentPane = dialog.getContentPane(); contentPane.setLayout(new GridBagLayout()); cons = new GridBagConstraints(); cons.insets = new Insets(4, 4, 4, 4); cons.gridx = 0; cons.gridy = 0; cons.weightx = 10.0f; cons.weighty = 10.0f; cons.fill = GridBagConstraints.BOTH; contentPane.add(new JScrollPane(checkBoxPanel), cons); cons.gridx = 0; cons.gridy = 1; cons.weightx = 0.0f; cons.weighty = 0.0f; cons.fill = GridBagConstraints.NONE; cons.anchor = GridBagConstraints.LINE_END; contentPane.add(treeButtonPanel, cons); cons.gridx = 0; cons.gridy = 2; cons.weightx = 0.0f; cons.weighty = 0.0f; cons.fill = GridBagConstraints.NONE; cons.anchor = GridBagConstraints.WEST; contentPane.add(motherTonguePanel, cons); cons.gridx = 0; cons.gridy = 3; cons.weightx = 0.0f; cons.weighty = 0.0f; cons.fill = GridBagConstraints.NONE; cons.anchor = GridBagConstraints.WEST; contentPane.add(portPanel, cons); cons.gridx = 0; cons.gridy = 4; cons.weightx = 0.0f; cons.weighty = 0.0f; cons.fill = GridBagConstraints.NONE; cons.anchor = GridBagConstraints.EAST; contentPane.add(buttonPanel, cons); dialog.pack(); dialog.setSize(500, 500); // center on screen: final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); final Dimension frameSize = dialog.getSize(); dialog.setLocation( screenSize.width / 2 - frameSize.width / 2, screenSize.height / 2 - frameSize.height / 2); dialog.setLocationByPlatform(true); dialog.setVisible(true); }
private void createUI() { setThumbnailSubsampling(); final Dimension imageSize = getScaledImageSize(); thumbnailLoader = new ProgressMonitorSwingWorker<BufferedImage, Object>( this, "Loading thumbnail image...") { @Override protected BufferedImage doInBackground(ProgressMonitor pm) throws Exception { return createThumbNailImage(imageSize, pm); } @Override protected void done() { BufferedImage thumbnail = null; try { thumbnail = get(); } catch (Exception e) { if (e instanceof IOException) { showErrorDialog("Failed to load thumbnail image:\n" + e.getMessage()); } } if (thumbnail != null) { imageCanvas.setImage(thumbnail); } } }; thumbnailLoader.execute(); imageCanvas = new SliderBoxImageDisplay(imageSize.width, imageSize.height, this); imageCanvas.setSize(imageSize.width, imageSize.height); setComponentName(imageCanvas, "ImageCanvas"); imageScrollPane = new JScrollPane(imageCanvas); imageScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); imageScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); imageScrollPane .getViewport() .setExtentSize(new Dimension(MAX_THUMBNAIL_WIDTH, 2 * MAX_THUMBNAIL_WIDTH)); setComponentName(imageScrollPane, "ImageScrollPane"); subsetWidthLabel = new JLabel("####", JLabel.RIGHT); subsetHeightLabel = new JLabel("####", JLabel.RIGHT); setToVisibleButton = new JButton("Use Preview"); /*I18N*/ setToVisibleButton.setMnemonic('v'); setToVisibleButton.setToolTipText("Use coordinates of visible thumbnail area"); /*I18N*/ setToVisibleButton.addActionListener(this); setComponentName(setToVisibleButton, "UsePreviewButton"); fixSceneWidthCheck = new JCheckBox("Fix full width"); fixSceneWidthCheck.setMnemonic('w'); fixSceneWidthCheck.setToolTipText("Checks whether or not to fix the full scene width"); fixSceneWidthCheck.addActionListener(this); setComponentName(fixSceneWidthCheck, "FixWidthCheck"); fixSceneHeightCheck = new JCheckBox("Fix full height"); fixSceneHeightCheck.setMnemonic('h'); fixSceneHeightCheck.setToolTipText("Checks whether or not to fix the full scene height"); fixSceneHeightCheck.addActionListener(this); setComponentName(fixSceneHeightCheck, "FixHeightCheck"); JPanel textInputPane = GridBagUtils.createPanel(); setComponentName(textInputPane, "TextInputPane"); final JTabbedPane tabbedPane = new JTabbedPane(); setComponentName(tabbedPane, "coordinatePane"); tabbedPane.addTab("Pixel Coordinates", createPixelCoordinatesPane()); tabbedPane.addTab("Geo Coordinates", createGeoCoordinatesPane()); tabbedPane.setEnabledAt(1, canUseGeoCoordinates(product)); GridBagConstraints gbc = GridBagUtils.createConstraints("insets.left=7,anchor=WEST,fill=HORIZONTAL, weightx=1.0"); GridBagUtils.setAttributes(gbc, "gridwidth=2"); GridBagUtils.addToPanel(textInputPane, tabbedPane, gbc, "gridx=0,gridy=0"); GridBagUtils.setAttributes(gbc, "insets.top=7,gridwidth=1"); GridBagUtils.addToPanel(textInputPane, new JLabel("Scene step X:"), gbc, "gridx=0,gridy=1"); GridBagUtils.addToPanel( textInputPane, UIUtils.createSpinner(paramSX, 1, "#0"), gbc, "gridx=1,gridy=1"); GridBagUtils.setAttributes(gbc, "insets.top=1"); GridBagUtils.addToPanel(textInputPane, new JLabel("Scene step Y:"), gbc, "gridx=0,gridy=2"); GridBagUtils.addToPanel( textInputPane, UIUtils.createSpinner(paramSY, 1, "#0"), gbc, "gridx=1,gridy=2"); GridBagUtils.setAttributes(gbc, "insets.top=4"); GridBagUtils.addToPanel( textInputPane, new JLabel("Subset scene width:"), gbc, "gridx=0,gridy=3"); GridBagUtils.addToPanel(textInputPane, subsetWidthLabel, gbc, "gridx=1,gridy=3"); GridBagUtils.setAttributes(gbc, "insets.top=1"); GridBagUtils.addToPanel( textInputPane, new JLabel("Subset scene height:"), gbc, "gridx=0,gridy=4"); GridBagUtils.addToPanel(textInputPane, subsetHeightLabel, gbc, "gridx=1,gridy=4"); GridBagUtils.setAttributes(gbc, "insets.top=4,gridwidth=1"); GridBagUtils.addToPanel( textInputPane, new JLabel("Source scene width:"), gbc, "gridx=0,gridy=5"); GridBagUtils.addToPanel( textInputPane, new JLabel(String.valueOf(product.getSceneRasterWidth()), JLabel.RIGHT), gbc, "gridx=1,gridy=5"); GridBagUtils.setAttributes(gbc, "insets.top=1"); GridBagUtils.addToPanel( textInputPane, new JLabel("Source scene height:"), gbc, "gridx=0,gridy=6"); GridBagUtils.addToPanel( textInputPane, new JLabel(String.valueOf(product.getSceneRasterHeight()), JLabel.RIGHT), gbc, "gridx=1,gridy=6"); GridBagUtils.setAttributes(gbc, "insets.top=7,gridwidth=1, gridheight=2"); GridBagUtils.addToPanel(textInputPane, setToVisibleButton, gbc, "gridx=0,gridy=7"); GridBagUtils.setAttributes(gbc, "insets.top=7,gridwidth=1, gridheight=1"); GridBagUtils.addToPanel(textInputPane, fixSceneWidthCheck, gbc, "gridx=1,gridy=7"); GridBagUtils.setAttributes(gbc, "insets.top=1,gridwidth=1"); GridBagUtils.addToPanel(textInputPane, fixSceneHeightCheck, gbc, "gridx=1,gridy=8"); setLayout(new BorderLayout(4, 4)); add(imageScrollPane, BorderLayout.WEST); add(textInputPane, BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7)); updateUIState(null); imageCanvas.scrollRectToVisible(imageCanvas.getSliderBoxBounds()); }
private void createUI() { ActionListener productNodeCheckListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateUIState(); } }; checkers = new ArrayList<JCheckBox>(10); JPanel checkersPane = GridBagUtils.createPanel(); setComponentName(checkersPane, "CheckersPane"); GridBagConstraints gbc = GridBagUtils.createConstraints("insets.left=4,anchor=WEST,fill=HORIZONTAL"); for (int i = 0; i < productNodes.length; i++) { ProductNode productNode = (ProductNode) productNodes[i]; String name = productNode.getName(); JCheckBox productNodeCheck = new JCheckBox(name); productNodeCheck.setSelected(selected); productNodeCheck.setFont(SMALL_PLAIN_FONT); productNodeCheck.addActionListener(productNodeCheckListener); if (includeAlways != null && StringUtils.containsIgnoreCase(includeAlways, name)) { productNodeCheck.setSelected(true); productNodeCheck.setEnabled(false); } else if (givenProductSubsetDef != null) { productNodeCheck.setSelected(givenProductSubsetDef.containsNodeName(name)); } checkers.add(productNodeCheck); String description = productNode.getDescription(); JLabel productNodeLabel = new JLabel(description != null ? description : " "); productNodeLabel.setFont(SMALL_ITALIC_FONT); GridBagUtils.addToPanel( checkersPane, productNodeCheck, gbc, "weightx=0,gridx=0,gridy=" + i); GridBagUtils.addToPanel( checkersPane, productNodeLabel, gbc, "weightx=1,gridx=1,gridy=" + i); } // Add a last 'filler' row GridBagUtils.addToPanel( checkersPane, new JLabel(" "), gbc, "gridwidth=2,weightx=1,weighty=1,gridx=0,gridy=" + productNodes.length); ActionListener allCheckListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (e.getSource() == allCheck) { checkAllProductNodes(true); } else if (e.getSource() == noneCheck) { checkAllProductNodes(false); } updateUIState(); } }; allCheck = new JCheckBox("Select all"); allCheck.setName("selectAll"); allCheck.setMnemonic('a'); allCheck.addActionListener(allCheckListener); noneCheck = new JCheckBox("Select none"); noneCheck.setName("SelectNone"); noneCheck.setMnemonic('n'); noneCheck.addActionListener(allCheckListener); JScrollPane scrollPane = new JScrollPane(checkersPane); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); JPanel buttonRow = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 4)); buttonRow.add(allCheck); buttonRow.add(noneCheck); setLayout(new BorderLayout()); add(scrollPane, BorderLayout.CENTER); add(buttonRow, BorderLayout.SOUTH); setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7)); updateUIState(); }
public FindInProjectOptionsPanel() { matchCase.setMnemonic('m'); setLayout(new FlowLayout(FlowLayout.LEFT)); add(matchCase); }
public ThumbMaker() { super("ThumbMaker"); // grab the preferences so that they can be used to fill out the layout ThumbMakerPreferences myPrefs = ThumbMakerPreferences.getInstance(); // content pane JPanel pane = new JPanel(); pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); setContentPane(pane); // top panel JPanel top = new JPanel(); top.setLayout(new BoxLayout(top, BoxLayout.X_AXIS)); pane.add(top); // left-hand panel JPanel left = new JPanel(); left.setLayout(new BoxLayout(left, BoxLayout.Y_AXIS)); top.add(left); // horizontal padding top.add(Box.createHorizontalStrut(5)); // label for file list JLabel listLabel = GUIUtil.makeLabel("Files to process:"); listLabel.setDisplayedMnemonic('f'); String listTip = "List of files from which to create thumbnails"; listLabel.setToolTipText(listTip); left.add(GUIUtil.pad(listLabel)); // list of files to convert list = new JList(); listLabel.setLabelFor(list); list.setToolTipText(listTip); list.setModel(new DefaultListModel()); list.setDragEnabled(true); changeFilesInList = new ThumbTransferHandler(); list.setTransferHandler(changeFilesInList); left.add(new JScrollPane(list)); // progress bar progress = new JProgressBar(0, 1); progress.setString("[Drag and drop files onto list to begin]"); progress.setStringPainted(true); progress.setToolTipText("Status of thumbnail processing operation"); left.add(progress); // panel for process and remove buttons JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); // add files button addFiles = new JButton("Add Files"); addFiles.setMnemonic('d'); addFiles.setToolTipText("Add files to be processed."); addFiles.addActionListener(this); p.add(addFiles); p.add(Box.createHorizontalStrut(5)); // process button process = new JButton("Process"); process.setMnemonic('p'); process.setToolTipText("Begin creating thumbnails"); process.addActionListener(this); p.add(process); p.add(Box.createHorizontalStrut(5)); // remove button remove = new JButton("Remove"); remove.setMnemonic('v'); remove.setToolTipText("Remove selected files from the list"); remove.addActionListener(this); p.add(remove); left.add(GUIUtil.pad(p)); // right-hand panel JPanel right = new JPanel(); right.setLayout(new BoxLayout(right, BoxLayout.Y_AXIS)); top.add(right); // panel for resolution settings p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); // resolution label JLabel resLabel = GUIUtil.makeLabel("Resolution: "); resLabel.setDisplayedMnemonic('s'); resLabel.setToolTipText("Resolution of the thumbnails"); p.add(resLabel); // x resolution text box xres = GUIUtil.makeTextField(myPrefs.getStringPref(ThumbMakerPreferences.RES_WIDTH_PREF_NAME), 2); resLabel.setLabelFor(xres); xres.setToolTipText("Thumbnail width"); p.add(xres); // "by" label JLabel byLabel = GUIUtil.makeLabel(" by "); byLabel.setDisplayedMnemonic('y'); p.add(byLabel); // y resolution text box yres = GUIUtil.makeTextField(myPrefs.getStringPref(ThumbMakerPreferences.RES_HEIGHT_PREF_NAME), 2); byLabel.setLabelFor(yres); yres.setToolTipText("Thumbnail height"); p.add(yres); right.add(GUIUtil.pad(p)); right.add(Box.createVerticalStrut(8)); // aspect ratio checkbox aspect = new JCheckBox("Maintain aspect ratio", true); aspect.setMnemonic('m'); aspect.setToolTipText( "When checked, thumbnails are not stretched, " + "but rather padded with the background color."); aspect.addActionListener(this); right.add(GUIUtil.pad(aspect)); // make sure that the check box is initialized correctly aspect.setSelected( myPrefs .getStringPref(ThumbMakerPreferences.DO_MAINTAIN_ASPECT_PREF_NAME) .equalsIgnoreCase(ThumbMakerPreferences.BOOLEAN_TRUE_STRING)); // panel for background color p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); // load the color values from the preferences int redValueNumber = myPrefs.getIntegerPref(ThumbMakerPreferences.RED_VALUE_PREF_NAME); int greenValueNumber = myPrefs.getIntegerPref(ThumbMakerPreferences.GREEN_VALUE_PREF_NAME); int blueValueNumber = myPrefs.getIntegerPref(ThumbMakerPreferences.BLUE_VALUE_PREF_NAME); // background color label colorLabel = GUIUtil.makeLabel("Background color: "); String colorTip = "Thumbnail background color"; colorLabel.setToolTipText(colorTip); p.add(colorLabel); // background color colorBox = new JPanel(); colorBox.setToolTipText(colorTip); colorBox.setBorder(new LineBorder(Color.black, 1)); Dimension colorBoxSize = new Dimension(45, 15); colorBox.setMaximumSize(colorBoxSize); colorBox.setMinimumSize(colorBoxSize); colorBox.setPreferredSize(colorBoxSize); colorBox.setBackground(new Color(redValueNumber, greenValueNumber, blueValueNumber)); p.add(colorBox); right.add(GUIUtil.pad(p)); right.add(Box.createVerticalStrut(2)); // red slider redLabel = GUIUtil.makeLabel("R"); red = new JSlider(0, 255, redValueNumber); redValue = GUIUtil.makeLabel("" + redValueNumber); redValue.setToolTipText("Red color component slider"); right.add(makeSlider(redLabel, red, redValue, "Red")); // green slider greenLabel = GUIUtil.makeLabel("G"); green = new JSlider(0, 255, greenValueNumber); greenValue = GUIUtil.makeLabel("" + greenValueNumber); greenValue.setToolTipText("Green color component slider"); right.add(makeSlider(greenLabel, green, greenValue, "Green")); // blue slider blueLabel = GUIUtil.makeLabel("B"); blue = new JSlider(0, 255, blueValueNumber); blueValue = GUIUtil.makeLabel("" + blueValueNumber); right.add(makeSlider(blueLabel, blue, blueValue, "Blue")); right.add(Box.createVerticalStrut(8)); // panel for algorithm p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); // algorithm label JLabel algorithmLabel = GUIUtil.makeLabel("Algorithm: "); algorithmLabel.setDisplayedMnemonic('l'); String algorithmTip = "Resizing algorithm to use"; algorithmLabel.setToolTipText(algorithmTip); p.add(algorithmLabel); // algorithm combo box algorithm = GUIUtil.makeComboBox( new String[] {"Smooth", "Standard", "Fast", "Replicate", "Area averaging"}); algorithmLabel.setLabelFor(algorithm); algorithm.setToolTipText(algorithmTip); p.add(algorithm); // set the algorithm value from the preferences algorithm.setSelectedIndex(myPrefs.getIntegerPref(ThumbMakerPreferences.RESIZE_ALG_PREF_NAME)); right.add(GUIUtil.pad(p)); // panel for output format p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); // format label JLabel formatLabel = GUIUtil.makeLabel("Format: "); formatLabel.setDisplayedMnemonic('f'); String formatTip = "Thumbnail output format"; formatLabel.setToolTipText(formatTip); p.add(formatLabel); // format combo box format = GUIUtil.makeComboBox(new String[] {"PNG", "JPG"}); formatLabel.setLabelFor(format); format.setToolTipText(formatTip); p.add(format); // set the format value from the preferences format.setSelectedIndex(myPrefs.getIntegerPref(ThumbMakerPreferences.THUMB_FORMAT_PREF_NAME)); right.add(GUIUtil.pad(p)); right.add(Box.createVerticalStrut(5)); // panel for prepend string p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); // prepend label JLabel prependLabel = GUIUtil.makeLabel("Prepend: "); prependLabel.setDisplayedMnemonic('e'); String prependTip = "Starting string for each thumbnail filename"; prependLabel.setToolTipText(prependTip); p.add(prependLabel); // prepend field prepend = GUIUtil.makeTextField( myPrefs.getStringPref(ThumbMakerPreferences.STRING_TO_PREPEND_PREF_NAME), 4); prependLabel.setLabelFor(prepend); prepend.setToolTipText(prependTip); p.add(prepend); p.add(Box.createHorizontalStrut(5)); // append label JLabel appendLabel = GUIUtil.makeLabel("Append: "); appendLabel.setDisplayedMnemonic('a'); String appendTip = "Ending string for each thumbnail filename"; appendLabel.setToolTipText(appendTip); p.add(appendLabel); // append field append = GUIUtil.makeTextField( myPrefs.getStringPref(ThumbMakerPreferences.STRING_TO_APPEND_PREF_NAME), 4); appendLabel.setLabelFor(append); append.setToolTipText(appendTip); p.add(append); right.add(GUIUtil.pad(p)); // vertical padding right.add(Box.createVerticalGlue()); // bottom panel JPanel bottom = new JPanel(); bottom.setLayout(new BoxLayout(bottom, BoxLayout.X_AXIS)); pane.add(bottom); // output folder label JLabel outputLabel = GUIUtil.makeLabel("Output folder: "); outputLabel.setDisplayedMnemonic('o'); String outputTip = "Thumbnail output folder"; outputLabel.setToolTipText(outputTip); bottom.add(outputLabel); // output folder field String filePath = new File(myPrefs.getStringPref(ThumbMakerPreferences.FILE_PATH_STRING_PREF_NAME)) .getAbsolutePath(); output = GUIUtil.makeTextField(filePath, 8); outputLabel.setLabelFor(output); output.setToolTipText(outputTip); // start this in default and then lock down so "..." is used output.setEditable(false); output.setBackground(Color.LIGHT_GRAY); bottom.add(output); // add a file chooser button "..." dotDotDot = new JButton("..."); dotDotDot.setMnemonic('.'); dotDotDot.setToolTipText("Select destination directory."); dotDotDot.addActionListener(this); bottom.add(dotDotDot); right.add(GUIUtil.pad(p)); setFromPreferences(); addWindowListener(this); }
public void setMnemonic(char c) { myCheckbox.setMnemonic(c); }