private void createCheckBoxes(JPanel panel) { myDeclareFinalCheckBox = new JCheckBox(UIUtil.replaceMnemonicAmpersand("Declare &final")); myDeclareFinalCheckBox.setFocusable(false); panel.add(myDeclareFinalCheckBox); myDelegateViaOverloadingMethodCheckBox = new JCheckBox(UIUtil.replaceMnemonicAmpersand("De&legate via overloading method")); myDelegateViaOverloadingMethodCheckBox.setFocusable(false); panel.add(myDelegateViaOverloadingMethodCheckBox); for (Object o : toRemoveCBs.keys()) { final JCheckBox cb = (JCheckBox) o; cb.setFocusable(false); panel.add(cb); } }
public void setEditable(boolean isEditable) { isEditable_ = isEditable; if (inputType_.equals("ALPHA") || inputType_.equals("KANJI") || inputType_.equals("NUMERIC")) { ((JTextField) component).setEditable(isEditable_); ((JTextField) component).setFocusable(isEditable_); } if (inputType_.equals("DATE")) { ((XFDateField) component).setEditable(isEditable_); ((XFDateField) component).setFocusable(isEditable_); int fieldWidth = XFUtility.getWidthOfDateValue(dialog_.getSession().getDateFormat(), 14); if (isEditable_) { this.setBounds( this.getBounds().x, this.getBounds().y, 150 + fieldWidth, XFUtility.FIELD_UNIT_HEIGHT); } else { this.setBounds( this.getBounds().x, this.getBounds().y, 124 + fieldWidth, XFUtility.FIELD_UNIT_HEIGHT); } } if (inputType_.equals("LISTBOX")) { ((JComboBox) component).setEditable(isEditable_); ((JComboBox) component).setFocusable(isEditable_); } if (inputType_.equals("CHECKBOX")) { ((JCheckBox) component).setEnabled(isEditable_); ((JCheckBox) component).setFocusable(isEditable_); } }
private JComponent createSouthPanel() { final JCheckBox checkBox = new JCheckBox(IdeBundle.message("checkbox.narrow.down.on.typing")); checkBox.setSelected(PropertiesComponent.getInstance().getBoolean(narrowDownPropertyKey, true)); checkBox.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { myShouldNarrowDown = checkBox.isSelected(); PropertiesComponent.getInstance() .setValue(narrowDownPropertyKey, Boolean.toString(myShouldNarrowDown)); if (mySpeedSearch.isPopupActive() && !StringUtil.isEmpty(mySpeedSearch.getEnteredPrefix())) { myAbstractTreeBuilder.queueUpdate(); } } }); checkBox.setFocusable(false); UIUtil.applyStyle(UIUtil.ComponentStyle.MINI, checkBox); final JPanel panel = new JPanel(new BorderLayout()); panel.add(checkBox, BorderLayout.WEST); return panel; }
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; }
private void addCheckbox(final JPanel panel, final TreeAction action) { String text = action instanceof FileStructureFilter ? ((FileStructureFilter) action).getCheckBoxText() : action instanceof FileStructureNodeProvider ? ((FileStructureNodeProvider) action).getCheckBoxText() : null; if (text == null) return; Shortcut[] shortcuts = action instanceof FileStructureFilter ? ((FileStructureFilter) action).getShortcut() : ((FileStructureNodeProvider) action).getShortcut(); final JCheckBox chkFilter = new JCheckBox(); UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, chkFilter); final boolean selected = getDefaultValue(action); chkFilter.setSelected(selected); myTreeActionsOwner.setActionIncluded( action, action instanceof FileStructureFilter ? !selected : selected); chkFilter.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { final boolean state = chkFilter.isSelected(); if (!myAutoClicked.contains(chkFilter)) { saveState(action, state); } myTreeActionsOwner.setActionIncluded( action, action instanceof FileStructureFilter ? !state : state); // final String filter = mySpeedSearch.isPopupActive() ? // mySpeedSearch.getEnteredPrefix() : null; // mySpeedSearch.hidePopup(); Object selection = ContainerUtil.getFirstItem(myAbstractTreeBuilder.getSelectedElements()); if (selection instanceof FilteringTreeStructure.FilteringNode) { selection = ((FilteringTreeStructure.FilteringNode) selection).getDelegate(); } myTreeStructure.rebuildTree(); myFilteringStructure.rebuild(); final Object sel = selection; final Runnable runnable = new Runnable() { public void run() { ApplicationManager.getApplication() .runReadAction( new Runnable() { @Override public void run() { myAbstractTreeBuilder .refilter(sel, true, false) .doWhenProcessed( new Runnable() { @Override public void run() { if (mySpeedSearch.isPopupActive()) { mySpeedSearch.refreshSelection(); } } }); } }); } }; if (ApplicationManager.getApplication().isUnitTestMode()) { runnable.run(); } else { ApplicationManager.getApplication().invokeLater(runnable); } } }); chkFilter.setFocusable(false); if (shortcuts.length > 0) { text += " (" + KeymapUtil.getShortcutText(shortcuts[0]) + ")"; new AnAction() { public void actionPerformed(final AnActionEvent e) { chkFilter.doClick(); } }.registerCustomShortcutSet(new CustomShortcutSet(shortcuts), myTree); } chkFilter.setText(text); panel.add(chkFilter); myCheckBoxes.put(action.getClass(), chkFilter); }
public GUI() { // Frame frame = new JFrame("HardwareSwap Notifier"); // Panels panel = new JPanel(); group1 = new JPanel(); group2 = new JPanel(); group3 = new JPanel(); group4 = new JPanel(); group5 = new JPanel(); group6 = new JPanel(); group7 = new JPanel(); group8 = new JPanel(); // Menu Bar menus = new JMenuBar(); fileMenu = new JMenu("File"); clearCurrent = new JMenuItem("Clear"); quitItem = new JMenuItem("Quit"); load = new JMenuItem("Load"); saveCurrent = new JMenuItem("Save All"); clearSaved = new JMenuItem("Clear Saved"); removeItem = new JMenuItem("Remove Item"); removePhone = new JMenuItem("Remove Phone"); saveCurrent = new JMenuItem("Save Current"); helpMenu = new JMenu("Help"); help = new JMenuItem("How To Use"); about = new JMenuItem("About"); // Buttons add1 = new JButton("Add"); add2 = new JButton("Add"); start = new JButton("Start"); stop = new JButton("Stop"); save1 = new JButton("Add/Save"); save2 = new JButton("Add/Save"); show = new JButton("Display Data"); add1.setFocusPainted(false); add2.setFocusPainted(false); start.setFocusPainted(false); stop.setFocusPainted(false); save1.setFocusPainted(false); save2.setFocusPainted(false); show.setFocusPainted(false); stop.setEnabled(false); // CheckBox remove = new JCheckBox("Remove items when found"); remove.setFocusable(false); // Listener ButtonListener listener = new ButtonListener(); add1.addActionListener(listener); add2.addActionListener(listener); start.addActionListener(listener); stop.addActionListener(listener); load.addActionListener(listener); save1.addActionListener(listener); save2.addActionListener(listener); saveCurrent.addActionListener(listener); show.addActionListener(listener); quitItem.addActionListener(listener); clearCurrent.addActionListener(listener); clearSaved.addActionListener(listener); saveCurrent.addActionListener(listener); help.addActionListener(listener); about.addActionListener(listener); removePhone.addActionListener(listener); removeItem.addActionListener(listener); remove.addActionListener(listener); // Carrier Selection options = new String[10]; options[0] = "AT&T"; options[1] = "Boost Mobile"; options[2] = "Cellular One"; options[3] = "Nextel"; options[4] = "T-Mobile"; options[5] = "Tracfone"; options[6] = "US Cellular"; options[7] = "Sprint"; options[8] = "Verizon"; options[9] = "Virgin Mobile"; carriers = new JComboBox<String>(options); // Text Fields searchName = new JTextField(15); item = new JTextField(15); phone = new JTextField(15); interval2 = new JTextField(15); results = new JTextArea(10, 20); JScrollPane scrollPane = new JScrollPane(results); results.setEditable(false); // Interval intOptions = new SpinnerNumberModel(5, 1, 60, 1); interval = new JSpinner(intOptions); JFormattedTextField tf = ((JSpinner.DefaultEditor) interval.getEditor()).getTextField(); tf.setHorizontalAlignment(JFormattedTextField.LEFT); // Background panelBackground = new Color(237, 237, 237); panel.setBackground(panelBackground); searchName.setBackground(panelBackground); item.setBackground(panelBackground); phone.setBackground(panelBackground); interval.setBackground(panelBackground); // Panel Layouts panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); group1.setLayout(new BoxLayout(group1, BoxLayout.PAGE_AXIS)); group2.setLayout(new BoxLayout(group2, BoxLayout.X_AXIS)); group3.setLayout(new BoxLayout(group3, BoxLayout.PAGE_AXIS)); group4.setLayout(new BoxLayout(group4, BoxLayout.X_AXIS)); group5.setLayout(new BoxLayout(group5, BoxLayout.X_AXIS)); group6.setLayout(new BoxLayout(group6, BoxLayout.X_AXIS)); group7.setLayout(new BoxLayout(group7, BoxLayout.X_AXIS)); group8.setLayout(new BoxLayout(group8, BoxLayout.X_AXIS)); // Borders searchName.setBorder( BorderFactory.createTitledBorder( null, "Search Name", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_JUSTIFICATION, null, Color.DARK_GRAY)); item.setBorder( BorderFactory.createTitledBorder( null, "Item", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_JUSTIFICATION, null, Color.DARK_GRAY)); phone.setBorder( BorderFactory.createTitledBorder( null, "Cell Phone", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_JUSTIFICATION, null, Color.DARK_GRAY)); group5.setBorder( BorderFactory.createTitledBorder( null, "Check Interval (mins)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_JUSTIFICATION, null, Color.DARK_GRAY)); // Sizes panel.setPreferredSize(new Dimension(200, 0)); searchName.setMaximumSize(new Dimension(190, 50)); item.setMaximumSize(new Dimension(190, 50)); phone.setMaximumSize(new Dimension(185, 50)); carriers.setMaximumSize(new Dimension(175, 20)); group5.setPreferredSize(new Dimension(190, 47)); group5.setMaximumSize(new Dimension(190, 47)); add1.setMaximumSize(new Dimension(90, 20)); save1.setMaximumSize(new Dimension(90, 20)); add2.setMaximumSize(new Dimension(90, 20)); save2.setMaximumSize(new Dimension(90, 20)); start.setMaximumSize(new Dimension(90, 20)); stop.setMaximumSize(new Dimension(90, 20)); show.setMaximumSize(new Dimension(120, 20)); // Add file menu items fileMenu.add(clearCurrent); fileMenu.add(clearSaved); fileMenu.add(load); fileMenu.add(removeItem); fileMenu.add(removePhone); fileMenu.add(saveCurrent); fileMenu.add(quitItem); // Add help menu items helpMenu.add(help); helpMenu.add(about); // Add to menu bar menus.add(fileMenu); menus.add(helpMenu); // Add items to panel group1.add(searchName); group1.add(item); group2.add(add1); group2.add(Box.createHorizontalStrut(10)); group2.add(save1); group6.add(remove); group3.add(phone); group3.add(Box.createVerticalStrut(10)); group3.add(carriers); group4.add(add2); group4.add(Box.createHorizontalStrut(10)); group4.add(save2); group5.add(interval); group7.add(show); group8.add(start); group8.add(Box.createHorizontalStrut(10)); group8.add(stop); panel.add(Box.createVerticalStrut(10)); panel.add(group1); panel.add(Box.createVerticalStrut(10)); panel.add(group2); panel.add(Box.createVerticalStrut(40)); panel.add(group3); panel.add(Box.createVerticalStrut(10)); panel.add(group4); panel.add(Box.createVerticalStrut(40)); panel.add(group5); panel.add(Box.createVerticalStrut(30)); panel.add(group6); panel.add(Box.createVerticalStrut(40)); panel.add(group7); panel.add(Box.createVerticalStrut(10)); panel.add(group8); panel.add(Box.createVerticalStrut(10)); // Setup frame frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setJMenuBar(menus); frame.add(scrollPane); frame.add(BorderLayout.EAST, panel); frame.pack(); frame.setSize(new Dimension(670, 620)); frame.setVisible(true); }