public AboutDialog(View view) { super(view, jEdit.getProperty("about.title"), true); JPanel content = new JPanel(new BorderLayout()); content.setBorder(new EmptyBorder(12, 12, 12, 12)); setContentPane(content); content.add(BorderLayout.CENTER, new AboutPanel()); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); buttonPanel.setBorder(new EmptyBorder(12, 0, 0, 0)); buttonPanel.add(Box.createGlue()); close = new JButton(jEdit.getProperty("common.close")); close.addActionListener(new ActionHandler()); getRootPane().setDefaultButton(close); buttonPanel.add(close); buttonPanel.add(Box.createGlue()); content.add(BorderLayout.SOUTH, buttonPanel); pack(); setResizable(false); setLocationRelativeTo(view); show(); }
public ErrorListDialog( Frame frame, String title, String caption, Vector messages, boolean showPluginMgrButton) { super(frame, title, true); JPanel content = new JPanel(new BorderLayout(12, 12)); content.setBorder(new EmptyBorder(12, 12, 12, 12)); setContentPane(content); Box iconBox = new Box(BoxLayout.Y_AXIS); iconBox.add(new JLabel(UIManager.getIcon("OptionPane.errorIcon"))); iconBox.add(Box.createGlue()); content.add(BorderLayout.WEST, iconBox); JPanel centerPanel = new JPanel(new BorderLayout()); JLabel label = new JLabel(caption); label.setBorder(new EmptyBorder(0, 0, 6, 0)); centerPanel.add(BorderLayout.NORTH, label); JList errors = new JList(messages); errors.setCellRenderer(new ErrorListCellRenderer()); errors.setVisibleRowCount(Math.min(messages.size(), 4)); JScrollPane scrollPane = new JScrollPane( errors, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); Dimension size = scrollPane.getPreferredSize(); size.width = Math.min(size.width, 400); scrollPane.setPreferredSize(size); centerPanel.add(BorderLayout.CENTER, scrollPane); content.add(BorderLayout.CENTER, centerPanel); Box buttons = new Box(BoxLayout.X_AXIS); buttons.add(Box.createGlue()); ok = new JButton(jEdit.getProperty("common.ok")); ok.addActionListener(new ActionHandler()); if (showPluginMgrButton) { pluginMgr = new JButton(jEdit.getProperty("error-list.plugin-manager")); pluginMgr.addActionListener(new ActionHandler()); buttons.add(pluginMgr); buttons.add(Box.createHorizontalStrut(6)); } buttons.add(ok); buttons.add(Box.createGlue()); content.add(BorderLayout.SOUTH, buttons); getRootPane().setDefaultButton(ok); pack(); setLocationRelativeTo(frame); show(); }
// {{{ init() method private void init() { EditBus.addToBus(this); /* Setup panes */ JPanel content = new JPanel(new BorderLayout(12, 12)); content.setBorder(new EmptyBorder(12, 12, 12, 12)); setContentPane(content); tabPane = new JTabbedPane(); tabPane.addTab(jEdit.getProperty("manage-plugins.title"), manager = new ManagePanel(this)); tabPane.addTab( jEdit.getProperty("update-plugins.title"), updater = new InstallPanel(this, true)); tabPane.addTab( jEdit.getProperty("install-plugins.title"), installer = new InstallPanel(this, false)); EditBus.addToBus(installer); content.add(BorderLayout.CENTER, tabPane); tabPane.addChangeListener(new ListUpdater()); /* Create the buttons */ Box buttons = new Box(BoxLayout.X_AXIS); ActionListener al = new ActionHandler(); mgrOptions = new JButton(jEdit.getProperty("plugin-manager.mgr-options")); mgrOptions.addActionListener(al); pluginOptions = new JButton(jEdit.getProperty("plugin-manager.plugin-options")); pluginOptions.addActionListener(al); done = new JButton(jEdit.getProperty("plugin-manager.done")); done.addActionListener(al); buttons.add(Box.createGlue()); buttons.add(mgrOptions); buttons.add(Box.createHorizontalStrut(6)); buttons.add(pluginOptions); buttons.add(Box.createHorizontalStrut(6)); buttons.add(done); buttons.add(Box.createGlue()); getRootPane().setDefaultButton(done); content.add(BorderLayout.SOUTH, buttons); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setIconImage(GUIUtilities.getPluginIcon()); pack(); GUIUtilities.loadGeometry(this, parent, "plugin-manager"); GUIUtilities.addSizeSaver(this, parent, "plugin-manager"); setVisible(true); } // }}}
/** * Adds a JLabel and three JRadioButton instances in a ButtonGroup to the given panel with a * GridBagLayout, and returns the buttons in an array. */ private JRadioButton[] addRadioButtonTriplet(String labelText, JPanel panel) { GridBagConstraints labelConstraints = new GridBagConstraints(); labelConstraints.anchor = GridBagConstraints.WEST; labelConstraints.insets = new Insets(2, 10, 2, 10); GridBagConstraints buttonConstraints = new GridBagConstraints(); buttonConstraints.insets = labelConstraints.insets; GridBagConstraints lastGlueConstraints = new GridBagConstraints(); lastGlueConstraints.gridwidth = GridBagConstraints.REMAINDER; lastGlueConstraints.weightx = 1.0; // Create the radio buttons. JRadioButton radioButton0 = new JRadioButton(); JRadioButton radioButton1 = new JRadioButton(); JRadioButton radioButton2 = new JRadioButton(); // Put them in a button group. ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(radioButton0); buttonGroup.add(radioButton1); buttonGroup.add(radioButton2); // Add the label and the buttons to the panel. panel.add(new JLabel(labelText), labelConstraints); panel.add(radioButton0, buttonConstraints); panel.add(radioButton1, buttonConstraints); panel.add(radioButton2, buttonConstraints); panel.add(Box.createGlue(), lastGlueConstraints); return new JRadioButton[] {radioButton0, radioButton1, radioButton2}; }
public RolloverTitlePane(CollapsiblePane pane) { _layout = new CardLayout(); setLayout(_layout); _messageLabel = new JLabel(""); _messageLabel.setForeground(null); _messageLabel.setHorizontalAlignment(SwingConstants.TRAILING); add(_messageLabel, "Message"); _buttonPanel = new NullPanel(); _buttonPanel.setLayout(new JideBoxLayout(_buttonPanel, JideBoxLayout.X_AXIS)); _buttonPanel.add(Box.createGlue(), JideBoxLayout.VARY); add(_buttonPanel, "Buttons"); pane.addPropertyChangeListener( "rollover", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (Boolean.TRUE.equals(evt.getNewValue())) { showButtons(); } else { showMessage(); } } }); JideSwingUtilities.setOpaqueRecursively(this, false); }
private JComponent createToolPanel() { JComponent box = Box.createVerticalBox(); JCheckBox button = new JCheckBox(disablingItem.getText()); button.setModel(disablingItem.getModel()); box.add(Box.createGlue()); box.add(button); box.add(Box.createGlue()); JRadioButton blur = new JRadioButton(blurItem.getText()); blur.setModel(blurItem.getModel()); box.add(blur); JRadioButton emboss = new JRadioButton(embossItem.getText()); emboss.setModel(embossItem.getModel()); box.add(emboss); JRadioButton translucent = new JRadioButton(busyPainterItem.getText()); translucent.setModel(busyPainterItem.getModel()); box.add(translucent); box.add(Box.createGlue()); return box; }
private JTextField addField(JPanel directoryPanel, String label, String defaultText) { JTextField field = new JTextField(defaultText); directoryPanel.add(new JLabel(label, SwingConstants.RIGHT)); Box fieldBox = new Box(BoxLayout.Y_AXIS); fieldBox.add(Box.createGlue()); Dimension dim = field.getPreferredSize(); dim.width = Integer.MAX_VALUE; field.setMaximumSize(dim); fieldBox.add(field); fieldBox.add(Box.createGlue()); directoryPanel.add(fieldBox); JButton choose = new JButton("Choose..."); choose.setRequestFocusEnabled(false); choose.addActionListener(new ActionHandler(field)); directoryPanel.add(choose); return field; }
public Component getDemoPanel() { // register two converters. Both for CustomType but the first one is the default, the second one // is for a special case. ObjectConverterManager.registerConverter(CustomType.class, new DefaultCustomTypeConverter()); ObjectConverterManager.registerConverter( CustomType.class, new SpecialCustomTypeConverter(), SpecialCustomTypeConverter.CONTEXT); JPanel panel = new JPanel(); panel.setLayout(new JideBoxLayout(panel, BoxLayout.Y_AXIS)); CustomType[] customTypes = new CustomType[] { new CustomType(1, "JIDE Docking Framework"), new CustomType(2, "JIDE Action Framework"), new CustomType(3, "JIDE Components"), new CustomType(4, "JIDE Grids"), new CustomType(5, "JIDE Dialogs"), }; panel.add( new JLabel( "<HTML>We defined a CustomType class which has two fields. See below." + "<PRE><BR> <FONT COLOR=\"BLUE\">public class</FONT> CustomType {" + "<BR> <FONT COLOR=\"BLUE\">int</FONT> <FONT COLOR=\"PURPLE\">_intValue</FONT>;" + "<BR> String <FONT COLOR=\"PURPLE\">_stringValue</FONT>;" + "<BR> }" + "<BR></PRE>" + "</HTML>")); panel.add(Box.createVerticalStrut(24), JideBoxLayout.FIX); panel.add(new JLabel("This ListComboBox uses default converter for this custom type")); panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX); AbstractComboBox comboBox1 = createListComboBox(customTypes); panel.add(comboBox1); panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX); panel.add(new JLabel("This one uses a special converter for this custom type")); panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX); AbstractComboBox comboBox2 = createListComboBox(customTypes); // comboBox2.setEditable(false); // set the context to use the special converter. comboBox2.setConverterContext(SpecialCustomTypeConverter.CONTEXT); panel.add(comboBox2); panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX); panel.add(Box.createGlue(), JideBoxLayout.VARY); return panel; }
public static void main(String[] args) { JFrame frame = new JFrame("Demo of Additional Borders"); frame.setIconImage(JideIconsFactory.getImageIcon(JideIconsFactory.JIDE32).getImage()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new BorderLayout()); JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); panel.setLayout(new JideBoxLayout(panel, JideBoxLayout.Y_AXIS, 10)); JTextArea textField = new JTextArea(); JPanel border = new JPanel(new BorderLayout()); border.setPreferredSize(new Dimension(100, 100)); border.add(new JScrollPane(textField), BorderLayout.CENTER); border.setBorder( new JideTitledBorder( new PartialEtchedBorder(PartialEtchedBorder.LOWERED, PartialSide.NORTH), "PartialEtchedBorder")); JTextArea textField2 = new JTextArea(); JPanel border2 = new JPanel(new BorderLayout()); border2.setPreferredSize(new Dimension(100, 100)); border2.add(new JScrollPane(textField2), BorderLayout.CENTER); border2.setBorder( new JideTitledBorder( new PartialLineBorder(Color.darkGray, 1, PartialSide.NORTH), "PartialLineBorder")); JTextArea textField3 = new JTextArea(); JPanel border3 = new JPanel(new BorderLayout()); border3.setPreferredSize(new Dimension(100, 100)); border3.add(new JScrollPane(textField3), BorderLayout.CENTER); border3.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( new PartialLineBorder(Color.gray, 1, true), "Rounded Corners Border"), BorderFactory.createEmptyBorder(0, 6, 4, 6))); panel.add(border, JideBoxLayout.FLEXIBLE); panel.add(Box.createVerticalStrut(12)); panel.add(border2, JideBoxLayout.FLEXIBLE); panel.add(Box.createVerticalStrut(12)); panel.add(border3, JideBoxLayout.FLEXIBLE); panel.add(Box.createGlue(), JideBoxLayout.VARY); panel.setPreferredSize(new Dimension(500, 400)); frame.getContentPane().add(panel, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); }
private void init() { Color c = getSelectedColor(); if (c == null) chooser = new JColorChooser(); else chooser = new JColorChooser(c); getContentPane().add(BorderLayout.CENTER, chooser); Box buttons = new Box(BoxLayout.X_AXIS); buttons.add(Box.createGlue()); ok = new JButton(jEdit.getProperty("common.ok")); ok.addActionListener(this); buttons.add(ok); buttons.add(Box.createHorizontalStrut(6)); getRootPane().setDefaultButton(ok); cancel = new JButton(jEdit.getProperty("common.cancel")); cancel.addActionListener(this); buttons.add(cancel); buttons.add(Box.createGlue()); getContentPane().add(BorderLayout.SOUTH, buttons); pack(); setLocationRelativeTo(getParent()); }
/** @see pong.ApplicationState#init() */ @Override public void init() { JFrame.setDefaultLookAndFeelDecorated(false); // Set background scene. backgroundScene = new PhysicsScene(CollidableMap.getMainMenuMap(), null, null, .0f, new RandomBallStrategy()); // Create GUI. mainFrame = new PongFrame("Pong Adventures -Main menu-", backgroundScene, false, null, false); mainFrame.addWindowListener(this); mainFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); mainFrame.setResizable(false); // Setting frame to center of screen. Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint(); mainFrame.setBounds( center.x - Global.windowSize.width / 2, center.y - Global.windowSize.height / 2, Global.windowSize.width, Global.windowSize.height); newGameButton = new JButton("New Game"); newGameButton.setAlignmentX(Component.CENTER_ALIGNMENT); newGameButton.addActionListener(this); settingsButton = new JButton("Settings"); settingsButton.setAlignmentX(Component.CENTER_ALIGNMENT); settingsButton.addActionListener(this); exitButton = new JButton("Exit"); exitButton.setAlignmentX(Component.CENTER_ALIGNMENT); exitButton.addActionListener(this); Container content = mainFrame.getContentPane(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); content.add(Box.createGlue()); content.add(Box.createGlue()); content.add(newGameButton); content.add(Box.createGlue()); content.add(settingsButton); content.add(Box.createGlue()); content.add(exitButton); content.add(Box.createGlue()); content.add(Box.createGlue()); mainFrame.setVisible(true); Debugger.debugWriteln("Initializing main menu.", this.getClass()); }
/* * Create and set up a new CoreqPanel that is the correct size. Do not allow the user to modify any * of the characteristics of the panel; the panel will be the same for any course. */ public CoreqPanel() { this.setMinimumSize(new Dimension(800, 25)); this.setMaximumSize(new Dimension(2600, 26)); this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); coreqField = new JTextField(); coreqField.setMinimumSize(new Dimension(300, 20)); coreqField.setMaximumSize(new Dimension(2000, 21)); coreqType = new JComboBox(); coreqType.addItem("Credits"); coreqType.addItem("Course"); coreqType.addItem("Requirement"); coreqType.setMinimumSize(new Dimension(100, 20)); coreqType.setMaximumSize(new Dimension(100, 21)); JLabel coreqName = new JLabel("Name of Corequisite: "); this.add(coreqName); this.add(coreqField); this.add(Box.createRigidArea(new Dimension(10, 0))); this.add(coreqType); this.add(Box.createGlue()); }
public void setup() { this.varNames = params.getVarNames(); for (Object parentModel : parentModels) { if (parentModel instanceof DataWrapper) { DataWrapper wrapper = (DataWrapper) parentModel; DataModel dataModel = wrapper.getSelectedDataModel(); new IndTestChooser().adjustIndTestParams(dataModel, params); break; } else if (parentModel instanceof GraphWrapper) { GraphWrapper wrapper = (GraphWrapper) parentModel; new IndTestChooser().adjustIndTestParams(wrapper.getGraph(), params); break; } else if (parentModel instanceof DagWrapper) { DagWrapper wrapper = (DagWrapper) parentModel; new IndTestChooser().adjustIndTestParams(wrapper.getGraph(), params); break; } else if (parentModel instanceof SemGraphWrapper) { SemGraphWrapper wrapper = (SemGraphWrapper) parentModel; new IndTestChooser().adjustIndTestParams(wrapper.getGraph(), params); break; } } DataModel dataModel1 = null; Graph graph = null; for (Object parentModel1 : parentModels) { if (parentModel1 instanceof DataWrapper) { DataWrapper dataWrapper = (DataWrapper) parentModel1; dataModel1 = dataWrapper.getSelectedDataModel(); } if (parentModel1 instanceof GraphWrapper) { GraphWrapper graphWrapper = (GraphWrapper) parentModel1; graph = graphWrapper.getGraph(); } if (parentModel1 instanceof DagWrapper) { DagWrapper dagWrapper = (DagWrapper) parentModel1; graph = dagWrapper.getDag(); } if (parentModel1 instanceof SemGraphWrapper) { SemGraphWrapper semGraphWrapper = (SemGraphWrapper) parentModel1; graph = semGraphWrapper.getGraph(); } } if (dataModel1 != null) { varNames = new ArrayList(dataModel1.getVariableNames()); } else if (graph != null) { Iterator it = graph.getNodes().iterator(); varNames = new ArrayList(); Node temp; while (it.hasNext()) { temp = (Node) it.next(); if (temp.getNodeType() == NodeType.MEASURED) { varNames.add(temp.getName()); } } } else { throw new NullPointerException( "Null model (no graph or data model " + "passed to the search)."); } params.setVarNames(varNames); JButton knowledgeButton = new JButton("Edit"); IntTextField depthField = new IntTextField(params.getIndTestParams().getDepth(), 4); depthField.setFilter( new IntTextField.Filter() { public int filter(int value, int oldValue) { try { params.getIndTestParams().setDepth(value); Preferences.userRoot().putInt("depth", value); return value; } catch (Exception e) { return oldValue; } } }); double alpha = params.getIndTestParams().getAlpha(); if (!Double.isNaN(alpha)) { alphaField = new DoubleTextField(alpha, 4, NumberFormatUtil.getInstance().getNumberFormat()); alphaField.setFilter( new DoubleTextField.Filter() { public double filter(double value, double oldValue) { try { params.getIndTestParams().setAlpha(value); Preferences.userRoot().putDouble("alpha", value); return value; } catch (Exception e) { return oldValue; } } }); } setBorder(new MatteBorder(10, 10, 10, 10, super.getBackground())); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); Box b2 = Box.createHorizontalBox(); b2.add(new JLabel("Knowledge:")); b2.add(Box.createGlue()); b2.add(knowledgeButton); add(b2); add(Box.createVerticalStrut(10)); if (!Double.isNaN(alpha)) { Box b0 = Box.createHorizontalBox(); b0.add(new JLabel("Alpha Value:")); b0.add(Box.createGlue()); b0.add(alphaField); add(b0); add(Box.createVerticalStrut(10)); } Box b1 = Box.createHorizontalBox(); b1.add(new JLabel("Search Depth:")); b1.add(Box.createGlue()); b1.add(depthField); add(b1); add(Box.createVerticalStrut(10)); knowledgeButton.addActionListener( new ActionListener() { public final void actionPerformed(ActionEvent e) { openKnowledgeEditor(); } }); }
public void installComponents(JFileChooser fc) { fc.setLayout(new BorderLayout(10, 10)); fc.setAlignmentX(JComponent.CENTER_ALIGNMENT); JPanel interior = new JPanel() { public Insets getInsets() { return insets; } }; align(interior); interior.setLayout(new BoxLayout(interior, BoxLayout.PAGE_AXIS)); fc.add(interior, BorderLayout.CENTER); // PENDING(jeff) - I18N JLabel l = new JLabel(pathLabelText); l.setDisplayedMnemonic(pathLabelMnemonic); align(l); interior.add(l); File currentDirectory = fc.getCurrentDirectory(); String curDirName = null; if (currentDirectory != null) { curDirName = currentDirectory.getPath(); } pathField = new JTextField(curDirName) { public Dimension getMaximumSize() { Dimension d = super.getMaximumSize(); d.height = getPreferredSize().height; return d; } }; l.setLabelFor(pathField); align(pathField); // Change to folder on return pathField.addActionListener(getUpdateAction()); interior.add(pathField); interior.add(Box.createRigidArea(vstrut10)); // CENTER: left, right accessory JPanel centerPanel = new JPanel(); centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.LINE_AXIS)); align(centerPanel); // left panel - Filter & folderList JPanel leftPanel = new JPanel(); leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS)); align(leftPanel); // add the filter PENDING(jeff) - I18N l = new JLabel(filterLabelText); l.setDisplayedMnemonic(filterLabelMnemonic); align(l); leftPanel.add(l); filterComboBox = new JComboBox() { public Dimension getMaximumSize() { Dimension d = super.getMaximumSize(); d.height = getPreferredSize().height; return d; } }; l.setLabelFor(filterComboBox); filterComboBoxModel = createFilterComboBoxModel(); filterComboBox.setModel(filterComboBoxModel); filterComboBox.setRenderer(createFilterComboBoxRenderer()); fc.addPropertyChangeListener(filterComboBoxModel); align(filterComboBox); leftPanel.add(filterComboBox); // leftPanel.add(Box.createRigidArea(vstrut10)); // Add the Folder List PENDING(jeff) - I18N l = new JLabel(foldersLabelText); l.setDisplayedMnemonic(foldersLabelMnemonic); align(l); leftPanel.add(l); JScrollPane sp = createDirectoryList(); sp.getVerticalScrollBar().setFocusable(false); sp.getHorizontalScrollBar().setFocusable(false); l.setLabelFor(sp.getViewport().getView()); leftPanel.add(sp); // create files list JPanel rightPanel = new JPanel(); align(rightPanel); rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.PAGE_AXIS)); l = new JLabel(filesLabelText); l.setDisplayedMnemonic(filesLabelMnemonic); align(l); rightPanel.add(l); sp = createFilesList(); l.setLabelFor(sp); rightPanel.add(sp); centerPanel.add(leftPanel); centerPanel.add(Box.createRigidArea(hstrut10)); centerPanel.add(rightPanel); JComponent accessoryPanel = getAccessoryPanel(); JComponent accessory = fc.getAccessory(); if (accessoryPanel != null) { if (accessory == null) { accessoryPanel.setPreferredSize(ZERO_ACC_SIZE); accessoryPanel.setMaximumSize(ZERO_ACC_SIZE); } else { getAccessoryPanel().add(accessory, BorderLayout.CENTER); accessoryPanel.setPreferredSize(PREF_ACC_SIZE); accessoryPanel.setMaximumSize(MAX_SIZE); } align(accessoryPanel); centerPanel.add(accessoryPanel); } interior.add(centerPanel); interior.add(Box.createRigidArea(vstrut10)); // add the filename field PENDING(jeff) - I18N l = new JLabel(enterFileNameLabelText); l.setDisplayedMnemonic(enterFileNameLabelMnemonic); align(l); interior.add(l); filenameTextField = new JTextField() { public Dimension getMaximumSize() { Dimension d = super.getMaximumSize(); d.height = getPreferredSize().height; return d; } }; l.setLabelFor(filenameTextField); filenameTextField.addActionListener(getApproveSelectionAction()); align(filenameTextField); filenameTextField.setAlignmentX(JComponent.LEFT_ALIGNMENT); interior.add(filenameTextField); bottomPanel = getBottomPanel(); bottomPanel.add(new JSeparator(), BorderLayout.NORTH); // Add buttons JPanel buttonPanel = new JPanel(); align(buttonPanel); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); buttonPanel.add(Box.createGlue()); approveButton = new JButton(getApproveButtonText(fc)) { public Dimension getMaximumSize() { return new Dimension(MAX_SIZE.width, this.getPreferredSize().height); } }; approveButton.setMnemonic(getApproveButtonMnemonic(fc)); approveButton.setToolTipText(getApproveButtonToolTipText(fc)); align(approveButton); approveButton.setMargin(buttonMargin); approveButton.addActionListener(getApproveSelectionAction()); buttonPanel.add(approveButton); buttonPanel.add(Box.createGlue()); JButton updateButton = new JButton(updateButtonText) { public Dimension getMaximumSize() { return new Dimension(MAX_SIZE.width, this.getPreferredSize().height); } }; updateButton.setMnemonic(updateButtonMnemonic); updateButton.setToolTipText(updateButtonToolTipText); align(updateButton); updateButton.setMargin(buttonMargin); updateButton.addActionListener(getUpdateAction()); buttonPanel.add(updateButton); buttonPanel.add(Box.createGlue()); JButton cancelButton = new JButton(cancelButtonText) { public Dimension getMaximumSize() { return new Dimension(MAX_SIZE.width, this.getPreferredSize().height); } }; cancelButton.setMnemonic(cancelButtonMnemonic); cancelButton.setToolTipText(cancelButtonToolTipText); align(cancelButton); cancelButton.setMargin(buttonMargin); cancelButton.addActionListener(getCancelSelectionAction()); buttonPanel.add(cancelButton); buttonPanel.add(Box.createGlue()); JButton helpButton = new JButton(helpButtonText) { public Dimension getMaximumSize() { return new Dimension(MAX_SIZE.width, this.getPreferredSize().height); } }; helpButton.setMnemonic(helpButtonMnemonic); helpButton.setToolTipText(helpButtonToolTipText); align(helpButton); helpButton.setMargin(buttonMargin); helpButton.setEnabled(false); buttonPanel.add(helpButton); buttonPanel.add(Box.createGlue()); bottomPanel.add(buttonPanel, BorderLayout.SOUTH); if (fc.getControlButtonsAreShown()) { fc.add(bottomPanel, BorderLayout.SOUTH); } }
public EducAssignmentPanel() { super("‘ормирование учебных поручений"); List<Image> icons = new Vector<Image>(); icons.add(new ImageIcon("images/уп.png").getImage()); setIconImages(icons); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); this.setPreferredSize(new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT)); this.setResizable(false); Dimension dim_screen = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation( (int) dim_screen.getWidth() / 2 - DEFAULT_WIDTH / 2, (int) dim_screen.getHeight() / 2 - DEFAULT_HEIGHT / 2); setDefaultCloseOperation(EXIT_ON_CLOSE); JPanel content_top = BoxLayoutUtils.createHorizontalPanel(); // ---------------------------------------------------------- JPanel semester = BoxLayoutUtils.createHorizontalPanel(); semester.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JLabel lab_semester = new JLabel("¬ид семестра:"); semester_combo = new JComboBox<String>(); semester_combo.setBackground(Color.white); semester_combo.addItem("летний"); semester_combo.addItem("зимний"); lab_semester.setPreferredSize(new Dimension(100, 27)); lab_semester.setMaximumSize(lab_semester.getPreferredSize()); lab_semester.setMinimumSize(lab_semester.getPreferredSize()); semester_combo.setPreferredSize(new Dimension(100, 27)); semester_combo.setMaximumSize(semester_combo.getPreferredSize()); semester_combo.setMinimumSize(semester_combo.getPreferredSize()); semester.add(lab_semester); semester.add(semester_combo); JPanel bevel_semester = BoxLayoutUtils.createHorizontalPanel(); bevel_semester.setBorder(BorderFactory.createLoweredBevelBorder()); JPanel out_semester = BoxLayoutUtils.createHorizontalPanel(); out_semester.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); bevel_semester.add(semester); out_semester.add(bevel_semester); // ---------------------------------------------------------- JPanel cath = BoxLayoutUtils.createVerticalPanel(); cath.setBackground(Color.white); semester.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); CurriculumTransaction tr = new CurriculumTransaction(); ArrayList<String> cath_names = tr.getCathedras(); checks = new ArrayList<JCheckBox>(); this.checks.add(new JCheckBox("выбрать все...")); for (String name : cath_names) checks.add(new JCheckBox(name)); for (JCheckBox cur_check : checks) { cath.add(Box.createHorizontalStrut(5)); cath.add(cur_check); cur_check.setBackground(Color.white); } checks .get(0) .addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JCheckBox check = (JCheckBox) e.getSource(); if (check.isSelected()) { for (JCheckBox cur : checks) cur.setSelected(true); } else for (JCheckBox cur : checks) cur.setSelected(false); } }); cath.add(Box.createGlue()); JPanel bevel_cath = BoxLayoutUtils.createHorizontalPanel(); bevel_cath.setBorder(BorderFactory.createLoweredBevelBorder()); JPanel out_cath = BoxLayoutUtils.createHorizontalPanel(); out_cath.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5)); bevel_cath.add(new JScrollPane(cath)); out_cath.add(bevel_cath); // ---------------------------------------------------------- JPanel right = BoxLayoutUtils.createVerticalPanel(); right.add(out_semester); right.add(out_cath); content_top.add(right); chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); content_top.add(chooser); // ---------------------------------------------------------- JPanel content_create = BoxLayoutUtils.createHorizontalPanel(); content_create.add(Box.createHorizontalGlue()); create = new JButton("—формировать поручени¤"); create.setPreferredSize(new Dimension(200, 27)); create.setMinimumSize(create.getPreferredSize()); create.setMaximumSize(create.getPreferredSize()); cancel = new JButton("ќтмена"); cancel.setPreferredSize(new Dimension(100, 27)); cancel.setMinimumSize(cancel.getPreferredSize()); cancel.setMaximumSize(cancel.getPreferredSize()); content_create.add(create); content_create.add(Box.createHorizontalStrut(5)); content_create.add(cancel); content_create.add(Box.createHorizontalStrut(4)); JPanel create_empty = BoxLayoutUtils.createHorizontalPanel(); create_empty.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel content_bottom = BoxLayoutUtils.createHorizontalPanel(); content_bottom.setBorder(BorderFactory.createEtchedBorder()); create_empty.add(content_create); content_bottom.add(create_empty); JPanel content = BoxLayoutUtils.createVerticalPanel(); content.add(content_top); content.add(content_bottom); create.addActionListener(this); cancel.addActionListener(this); setContentPane(content); setVisible(true); }
// {{{ HyperSearchResults constructor public HyperSearchResults(View view) { super(new BorderLayout()); this.view = view; caption = new JLabel(); Box toolBar = new Box(BoxLayout.X_AXIS); toolBar.add(caption); toolBar.add(Box.createGlue()); ActionHandler ah = new ActionHandler(); highlight = new RolloverButton(); highlight.setToolTipText(jEdit.getProperty("hypersearch-results.highlight.label")); highlight.addActionListener(ah); toolBar.add(highlight); clear = new RolloverButton( GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.clear.icon"))); clear.setToolTipText(jEdit.getProperty("hypersearch-results.clear.label")); clear.addActionListener(ah); toolBar.add(clear); multi = new RolloverButton(); multi.setToolTipText(jEdit.getProperty("hypersearch-results.multi.label")); multi.addActionListener(ah); toolBar.add(multi); stop = new RolloverButton( GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.stop.icon"))); stop.setToolTipText(jEdit.getProperty("hypersearch-results.stop.label")); stop.addActionListener(ah); toolBar.add(stop); stop.setEnabled(false); add(BorderLayout.NORTH, toolBar); resultTreeRoot = new DefaultMutableTreeNode(); resultTreeModel = new DefaultTreeModel(resultTreeRoot); resultTree = new HighlightingTree(resultTreeModel); resultTree.setToolTipText(null); resultTree.setCellRenderer(new ResultCellRenderer()); resultTree.setVisibleRowCount(16); resultTree.setRootVisible(false); resultTree.setShowsRootHandles(true); // the ESCAPE keystroke is assigned to hideTip action by swing // it breaks the action usually assigned to close-docking-area by jEdit, // so we remove this keystroke binding bug #1955140 KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); resultTree.getInputMap().remove(keyStroke); // looks bad with the OS X L&F, apparently... if (!OperatingSystem.isMacOSLF()) resultTree.putClientProperty("JTree.lineStyle", "Angled"); resultTree.setEditable(false); resultTree.addKeyListener(new KeyHandler()); resultTree.addMouseListener(new MouseHandler()); JScrollPane scrollPane = new JScrollPane(resultTree); Dimension dim = scrollPane.getPreferredSize(); dim.width = 400; scrollPane.setPreferredSize(dim); add(BorderLayout.CENTER, scrollPane); resultTree.setTransferHandler(new ResultTreeTransferHandler()); } // }}}
private static JPanel createOptionsPanel() { JLabel header = new JLabel("Options"); header.setFont(header.getFont().deriveFont(Font.BOLD, 13)); header.setOpaque(true); header.setBackground(new Color(0, 0, 128)); header.setForeground(Color.WHITE); header.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createBevelBorder( BevelBorder.LOWERED, Color.white, Color.lightGray, Color.lightGray, Color.gray), BorderFactory.createEmptyBorder(0, 5, 0, 0))); header.setPreferredSize(new Dimension(100, 30)); final JRadioButton style1 = new JRadioButton("Toolbar Style"); final JRadioButton style2 = new JRadioButton("Toolbox Style"); final JRadioButton style3 = new JRadioButton("Flat Style"); final JRadioButton style4 = new JRadioButton("Hyperlink Style"); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(style1); buttonGroup.add(style2); buttonGroup.add(style3); buttonGroup.add(style4); JPanel switchPanel = new JPanel(new GridLayout(4, 1, 3, 3)); switchPanel.add(style1); switchPanel.add(style2); switchPanel.add(style3); switchPanel.add(style4); style1.setSelected(true); style1.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (style1.isSelected()) { for (int i = 0; i < _buttons.length; i++) { JideButton button = _buttons[i]; button.setButtonStyle(JideButton.TOOLBAR_STYLE); } } } }); style2.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (style2.isSelected()) { for (int i = 0; i < _buttons.length; i++) { JideButton button = _buttons[i]; button.setButtonStyle(JideButton.TOOLBOX_STYLE); } } } }); style3.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (style3.isSelected()) { for (int i = 0; i < _buttons.length; i++) { JideButton button = _buttons[i]; button.setButtonStyle(JideButton.FLAT_STYLE); } } } }); style4.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (style4.isSelected()) { for (int i = 0; i < _buttons.length; i++) { JideButton button = _buttons[i]; button.setButtonStyle(JideButton.HYPERLINK_STYLE); } } } }); switchPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); JPanel panel = new JPanel(); panel.setLayout(new JideBoxLayout(panel, JideBoxLayout.Y_AXIS)); panel.add(header); panel.add(switchPanel); panel.add(Box.createGlue(), JideBoxLayout.VARY); return panel; }
public LauncherFrame() { super("Марио"); setSize(WIDTH, HEIGHT); Toolkit kit = Toolkit.getDefaultToolkit(); setLocation((kit.getScreenSize().width - WIDTH) / 2, (kit.getScreenSize().height - HEIGHT) / 2); setResizable(false); final JButton game = new JButton("Game"); game.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (gameFrame == null) gameFrame = new GameFrame(LauncherFrame.this); gameFrame.setVisible(true); setVisible(false); } }); final JButton editor = new JButton("Editor"); editor.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (editorFrame == null) editorFrame = new EditorFrame(); editorFrame.setVisible(true); setVisible(false); } }); final JButton exit = new JButton("Exit"); exit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); JPanel panel = new JPanel(); Box hor1 = Box.createHorizontalBox(); hor1.add(Box.createGlue()); hor1.add(game); hor1.add(Box.createGlue()); Box hor2 = Box.createHorizontalBox(); hor2.add(Box.createGlue()); hor2.add(editor); hor2.add(Box.createGlue()); Box hor3 = Box.createHorizontalBox(); hor3.add(Box.createGlue()); hor3.add(exit); hor3.add(Box.createGlue()); Box boxVer = Box.createVerticalBox(); boxVer.add(hor1); boxVer.add(hor2); boxVer.add(hor3); panel.add(boxVer); getContentPane().add(panel, BorderLayout.CENTER); }
public ClassMemberSpecificationDialog(JDialog owner, boolean isField) { super(owner, true); setResizable(true); // Create some constraints that can be reused. GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(1, 2, 1, 2); GridBagConstraints constraintsStretch = new GridBagConstraints(); constraintsStretch.fill = GridBagConstraints.HORIZONTAL; constraintsStretch.weightx = 1.0; constraintsStretch.anchor = GridBagConstraints.WEST; constraintsStretch.insets = constraints.insets; GridBagConstraints constraintsLast = new GridBagConstraints(); constraintsLast.gridwidth = GridBagConstraints.REMAINDER; constraintsLast.anchor = GridBagConstraints.WEST; constraintsLast.insets = constraints.insets; GridBagConstraints constraintsLastStretch = new GridBagConstraints(); constraintsLastStretch.gridwidth = GridBagConstraints.REMAINDER; constraintsLastStretch.fill = GridBagConstraints.HORIZONTAL; constraintsLastStretch.weightx = 1.0; constraintsLastStretch.anchor = GridBagConstraints.WEST; constraintsLastStretch.insets = constraints.insets; GridBagConstraints panelConstraints = new GridBagConstraints(); panelConstraints.gridwidth = GridBagConstraints.REMAINDER; panelConstraints.fill = GridBagConstraints.HORIZONTAL; panelConstraints.weightx = 1.0; panelConstraints.weighty = 0.0; panelConstraints.anchor = GridBagConstraints.NORTHWEST; panelConstraints.insets = constraints.insets; GridBagConstraints stretchPanelConstraints = new GridBagConstraints(); stretchPanelConstraints.gridwidth = GridBagConstraints.REMAINDER; stretchPanelConstraints.fill = GridBagConstraints.BOTH; stretchPanelConstraints.weightx = 1.0; stretchPanelConstraints.weighty = 1.0; stretchPanelConstraints.anchor = GridBagConstraints.NORTHWEST; stretchPanelConstraints.insets = constraints.insets; GridBagConstraints labelConstraints = new GridBagConstraints(); labelConstraints.anchor = GridBagConstraints.CENTER; labelConstraints.insets = new Insets(2, 10, 2, 10); GridBagConstraints lastLabelConstraints = new GridBagConstraints(); lastLabelConstraints.gridwidth = GridBagConstraints.REMAINDER; lastLabelConstraints.anchor = GridBagConstraints.CENTER; lastLabelConstraints.insets = labelConstraints.insets; GridBagConstraints okButtonConstraints = new GridBagConstraints(); okButtonConstraints.weightx = 1.0; okButtonConstraints.weighty = 1.0; okButtonConstraints.anchor = GridBagConstraints.SOUTHEAST; okButtonConstraints.insets = new Insets(4, 4, 8, 4); GridBagConstraints cancelButtonConstraints = new GridBagConstraints(); cancelButtonConstraints.gridwidth = GridBagConstraints.REMAINDER; cancelButtonConstraints.weighty = 1.0; cancelButtonConstraints.anchor = GridBagConstraints.SOUTHEAST; cancelButtonConstraints.insets = okButtonConstraints.insets; GridBagLayout layout = new GridBagLayout(); Border etchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.RAISED); this.isField = isField; // Create the access panel. JPanel accessPanel = new JPanel(layout); accessPanel.setBorder( BorderFactory.createTitledBorder(etchedBorder, GUIResources.getMessage("access"))); accessPanel.add(Box.createGlue(), labelConstraints); accessPanel.add(new JLabel(GUIResources.getMessage("required")), labelConstraints); accessPanel.add(new JLabel(GUIResources.getMessage("not")), labelConstraints); accessPanel.add(new JLabel(GUIResources.getMessage("dontCare")), labelConstraints); accessPanel.add(Box.createGlue(), constraintsLastStretch); publicRadioButtons = addRadioButtonTriplet("Public", accessPanel); privateRadioButtons = addRadioButtonTriplet("Private", accessPanel); protectedRadioButtons = addRadioButtonTriplet("Protected", accessPanel); staticRadioButtons = addRadioButtonTriplet("Static", accessPanel); finalRadioButtons = addRadioButtonTriplet("Final", accessPanel); if (isField) { volatileRadioButtons = addRadioButtonTriplet("Volatile", accessPanel); transientRadioButtons = addRadioButtonTriplet("Transient", accessPanel); } else { synchronizedRadioButtons = addRadioButtonTriplet("Synchronized", accessPanel); nativeRadioButtons = addRadioButtonTriplet("Native", accessPanel); abstractRadioButtons = addRadioButtonTriplet("Abstract", accessPanel); strictRadioButtons = addRadioButtonTriplet("Strict", accessPanel); } // Create the type panel. JPanel typePanel = new JPanel(layout); typePanel.setBorder( BorderFactory.createTitledBorder( etchedBorder, GUIResources.getMessage(isField ? "type" : "returnType"))); typePanel.add(typeTextField, constraintsLastStretch); // Create the name panel. JPanel namePanel = new JPanel(layout); namePanel.setBorder( BorderFactory.createTitledBorder(etchedBorder, GUIResources.getMessage("name"))); namePanel.add(nameTextField, constraintsLastStretch); // Create the arguments panel. JPanel argumentsPanel = new JPanel(layout); argumentsPanel.setBorder( BorderFactory.createTitledBorder(etchedBorder, GUIResources.getMessage("arguments"))); argumentsPanel.add(argumentsTextField, constraintsLastStretch); // Create the Ok button. JButton okButton = new JButton(GUIResources.getMessage("ok")); okButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { returnValue = APPROVE_OPTION; hide(); } }); // Create the Cancel button. JButton cancelButton = new JButton(GUIResources.getMessage("cancel")); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { hide(); } }); // Add all panels to the main panel. JPanel mainPanel = new JPanel(layout); mainPanel.add(accessPanel, panelConstraints); mainPanel.add(typePanel, panelConstraints); mainPanel.add(namePanel, panelConstraints); if (!isField) { mainPanel.add(argumentsPanel, panelConstraints); } mainPanel.add(okButton, okButtonConstraints); mainPanel.add(cancelButton, cancelButtonConstraints); getContentPane().add(mainPanel); }
/** Constructor. Sets up and shows the GUI */ public TextToolsSortDialog(View view, JEditTextArea textArea) { super(view, jEdit.getProperty("text-tools.sortadvanced.label"), false); this.view = view; this.textArea = textArea; // this.data = data; // this.selection = selection; view.showWaitCursor(); sortTableModel = new SortTableModel(); // preset sortTable if there is a rect selection boolean rectSel = false; int[] selRows = TextToolsSorting.getRectSelectionRows(textArea); if (selRows != null) { // we have rectangular selection: assign values to 1st row of table sortTableModel.setValueAt(new Integer(selRows[0] + 1), 0, 0); sortTableModel.setValueAt(new Integer(selRows[1] + 1), 0, 1); rectSel = true; } sortTable = new JTable(sortTableModel); TableColumnModel cMod = sortTable.getColumnModel(); sortTable.setTableHeader((new SortTableHeader(cMod))); sortTable.setRowHeight(25); sortTable.setPreferredScrollableViewportSize(new Dimension(430, 200)); JScrollPane scroll = new JScrollPane(sortTable); JPanel content = new JPanel(new BorderLayout()); content.setBorder(new EmptyBorder(5, 8, 8, 8)); content.setLayout(new BorderLayout()); setContentPane(content); content.add(scroll, BorderLayout.CENTER); JPanel buttons = new JPanel(); buttons.setBorder(new EmptyBorder(12, 0, 0, 0)); buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS)); buttons.add(Box.createGlue()); ok = new JButton(jEdit.getProperty("common.ok")); ok.addActionListener(this); buttons.add(ok); buttons.add(Box.createHorizontalStrut(6)); getRootPane().setDefaultButton(ok); cancel = new JButton(jEdit.getProperty("common.cancel")); cancel.addActionListener(this); buttons.add(cancel); buttons.add(Box.createHorizontalStrut(6)); clear = new JButton("Clear"); clear.addActionListener(this); buttons.add(clear); buttons.add(Box.createHorizontalStrut(6)); help = new JButton("Help"); help.addActionListener(this); buttons.add(help); buttons.add(Box.createHorizontalStrut(6)); buttons.add(Box.createGlue()); content.add(buttons, BorderLayout.SOUTH); delDupsCheckBox = new JCheckBox(jEdit.getProperty("text-tools.sortadvanced.delete-identic-lines")); onlySelectionCheckBox = new JCheckBox(jEdit.getProperty("text-tools.sortadvanced.sort-only-selection")); /* dontSortCheckBox = new JCheckBox( jEdit.getProperty("text-tools.sortadvanced.dont-sort")); delDupsCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { dontSortCheckBox.setEnabled(delDupsCheckBox.isSelected()); dontSortCheckBox.setSelected(false); } }); dontSortCheckBox.setEnabled(false); */ JPanel checkBoxes = new JPanel(); if (rectSel) checkBoxes.add(onlySelectionCheckBox); checkBoxes.add(delDupsCheckBox); // checkBoxes.add(dontSortCheckBox); not used, this is an extra action content.add(checkBoxes, BorderLayout.NORTH); view.hideWaitCursor(); pack(); GUIUtilities.loadGeometry(this, "texttools-sort-control"); setLocationRelativeTo(view); setVisible(true); } // }}}
public Component getDemoPanel() { final String[] fontNames = DemoData.getFontNames(); // create file text field List<String> urls = null; try { urls = readUrls(); } catch (IOException e) { //noinspection CallToPrintStackTrace e.printStackTrace(); } JTextField urlTextField = new JTextField("http://"); urlTextField.setName("URL IntelliHint"); SelectAllUtils.install(urlTextField); ListDataIntelliHints intelliHints = new ListDataIntelliHints<String>(urlTextField, urls); intelliHints.setCaseSensitive(false); JTextField pathTextField = new JTextField(); SelectAllUtils.install(pathTextField); FileIntelliHints fileIntelliHints = new FileIntelliHints(pathTextField); fileIntelliHints.setFilter( new FilenameFilter() { public boolean accept(File dir, String name) { return !_applyFileFilter || dir.getAbsolutePath().contains("Program") || name.contains("Program"); } }); fileIntelliHints.setFolderOnly(false); fileIntelliHints.setFollowCaret(true); fileIntelliHints.setShowFullPath(false); // create file text field JTextField fileTextField = new JTextField(); fileTextField.setName("File IntelliHint"); SelectAllUtils.install(fileTextField); new FileIntelliHints(fileTextField); // create file text field JTextArea fileTextArea = new JTextArea(); new FileIntelliHints(fileTextArea); fileTextArea.setRows(4); // create file text field JTextField fontTextField = new JTextField(); fontTextField.setName("Font IntelliHint"); SelectAllUtils.install(fontTextField); ListDataIntelliHints fontIntelliHints = new ListDataIntelliHints<String>(fontTextField, fontNames); fontIntelliHints.setCaseSensitive(false); JTextField textField = new JTextField(); SelectAllUtils.install(textField); //noinspection UnusedDeclaration new AbstractListIntelliHints(textField) { protected JLabel _messageLabel; @Override public JComponent createHintsComponent() { JPanel panel = (JPanel) super.createHintsComponent(); _messageLabel = new JLabel(); panel.add(_messageLabel, BorderLayout.BEFORE_FIRST_LINE); return panel; } // update list model depending on the data in textfield public boolean updateHints(Object value) { if (value == null) { return false; } String s = value.toString(); s = s.trim(); if (s.length() == 0) { return false; } try { long l = Long.parseLong(s); boolean prime = isProbablePrime(l); _messageLabel.setText(""); if (prime) { return false; } else { Vector<Long> list = new Vector<Long>(); long nextPrime = l; for (int i = 0; i < 10; i++) { nextPrime = nextPrime(nextPrime); list.add(nextPrime); } setListData(list); _messageLabel.setText("Next 10 prime numbers:"); _messageLabel.setForeground(Color.DARK_GRAY); return true; } } catch (NumberFormatException e) { setListData(new Object[0]); _messageLabel.setText("Invalid long number"); setListData(new Object[0]); _messageLabel.setForeground(Color.RED); return true; } } }; DefaultTableModel model = new DefaultTableModel(0, 1) { private static final long serialVersionUID = -2794741068912785630L; @Override public Class<?> getColumnClass(int columnIndex) { return String.class; } @Override public String getColumnName(int column) { return "Font"; } }; model.addRow(new Object[] {"Arial"}); model.addRow(new Object[] {"Tahoma"}); SortableTable table = new SortableTable(model); table .getColumnModel() .getColumn(0) .setCellEditor( new TextFieldCellEditor(String.class) { private static final long serialVersionUID = 2023654568542192380L; @Override protected JTextField createTextField() { JTextField cellEditorTextField = new JTextField(); ListDataIntelliHints fontIntellihints = new ListDataIntelliHints<String>(cellEditorTextField, fontNames); fontIntellihints.setCaseSensitive(false); return cellEditorTextField; } }); table.setPreferredScrollableViewportSize(new Dimension(100, 100)); JPanel panel = new JPanel(); panel.setLayout(new JideBoxLayout(panel, JideBoxLayout.Y_AXIS, 3)); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); panel.add(new JLabel("ListDataIntelliHints TextField for URLs: ")); panel.add(urlTextField); panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX); // create path text field panel.add( new JLabel("FileIntelliHints TextField for paths (folders only, show partial path):")); panel.add(pathTextField); panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX); panel.add( new JLabel("FileIntelliHints TextField for files (files and folders, show full path):")); panel.add(fileTextField); panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX); panel.add(new JLabel("FileIntelliHints TextArea for files (each line is for a new file):")); panel.add(new JScrollPane(fileTextArea)); panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX); panel.add(new JLabel("IntelliHints TextField to choose a font:")); panel.add(fontTextField); panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX); panel.add(new JLabel("A custom IntelliHints for prime numbers: ")); panel.add(textField); panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX); panel.add(new JLabel("Using IntelliHint in JTable's cell editor")); panel.add(new JScrollPane(table), JideBoxLayout.FLEXIBLE); panel.add(Box.createGlue(), JideBoxLayout.VARY); return panel; }
public static JToolBar getToolbar(String label, int size, boolean hasStrings) { JToolBar toolBar = new JToolBar(); JButton buttonCut = new JButton(hasStrings ? "cut" : null, getIcon(size + "/edit-cut")); buttonCut.putClientProperty(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE); toolBar.add(buttonCut); JButton buttonCopy = new JButton(hasStrings ? "copy" : null, getIcon(size + "/edit-copy")); buttonCopy.putClientProperty(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE); buttonCopy.setEnabled(false); toolBar.add(buttonCopy); JButton buttonPaste = new JButton(getIcon(size + "/edit-paste")); toolBar.add(buttonPaste); JButton buttonSelectAll = new JButton(getIcon(size + "/edit-select-all")); toolBar.add(buttonSelectAll); JButton buttonDelete = new JButton(getIcon(size + "/edit-delete")); toolBar.add(buttonDelete); toolBar.addSeparator(); // add an inner toolbar to check the painting of toolbar // gradient and drop shadows under different skins. JToolBar innerToolbar = new JToolBar(JToolBar.HORIZONTAL); innerToolbar.setFloatable(false); JToggleButton buttonFormatCenter = new JToggleButton(getIcon(size + "/format-justify-center")); buttonFormatCenter.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 5.0f); innerToolbar.add(buttonFormatCenter); JToggleButton buttonFormatLeft = new JToggleButton(getIcon(size + "/format-justify-left")); innerToolbar.add(buttonFormatLeft); JToggleButton buttonFormatRight = new JToggleButton(getIcon(size + "/format-justify-right")); innerToolbar.add(buttonFormatRight); JToggleButton buttonFormatFill = new JToggleButton(getIcon(size + "/format-justify-fill")); buttonFormatFill.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f); innerToolbar.add(buttonFormatFill); toolBar.add(innerToolbar); toolBar.addSeparator(); if (size > 20) { JToolBar innerToolbar2 = new JToolBar(JToolBar.HORIZONTAL); innerToolbar2.setFloatable(false); JPanel innerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); innerToolbar2.add(innerPanel, BorderLayout.CENTER); final JToggleButton buttonStyleBold = new JToggleButton(getIcon(size + "/format-text-bold")); Set<Side> rightSide = EnumSet.of(Side.RIGHT); buttonStyleBold.putClientProperty(SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide); buttonStyleBold.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 3.0f); final JToggleButton buttonStyleItalic = new JToggleButton(getIcon(size + "/format-text-italic")); buttonStyleItalic.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f); buttonStyleItalic.putClientProperty( SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide); final JToggleButton buttonStyleUnderline = new JToggleButton(getIcon(size + "/format-text-underline")); buttonStyleUnderline.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f); buttonStyleUnderline.putClientProperty( SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide); final JToggleButton buttonStyleStrikethrough = new JToggleButton(getIcon(size + "/format-text-strikethrough")); buttonStyleStrikethrough.putClientProperty( SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, EnumSet.of(Side.LEFT)); buttonStyleStrikethrough.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 3.0f); buttonStyleBold.setSelected(true); innerPanel.add(buttonStyleBold); innerPanel.add(buttonStyleItalic); innerPanel.add(buttonStyleUnderline); innerPanel.add(buttonStyleStrikethrough); toolBar.add(innerToolbar2); } toolBar.add(Box.createGlue()); JButton buttonExit = new JButton(getIcon(size + "/process-stop")); buttonExit.setToolTipText("Closes the test application"); buttonExit.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); toolBar.add(buttonExit); return toolBar; }
private void initComponents() { mnuUtilities = new JMenu("Utilities"); mnuMaintenance = new JMenu("Maintenance"); mnuHelp = new JMenu("Help"); mnuUtilities.setMnemonic('U'); mnuMaintenance.setMnemonic('M'); mnuHelp.setMnemonic('H'); miSearch = new JMenuItem("Search"); miSearch.setMnemonic('S'); miObstetCalc = new JMenuItem("Obstet Calculator"); miObstetCalc.setMnemonic('O'); miExit = new JMenuItem("Exit"); miExit.setMnemonic('x'); mnuUtilities.add(miSearch); mnuUtilities.addSeparator(); mnuUtilities.add(miObstetCalc); mnuUtilities.addSeparator(); mnuUtilities.add(miExit); miBaseMalformation = new JMenuItem("Malformation"); miBaseMalformation.setMnemonic('M'); miBaseSindrom = new JMenuItem("Syndrome"); miBaseSindrom.setMnemonic('y'); miBaseTeratogen = new JMenuItem("Teratogen"); miBaseTeratogen.setMnemonic('T'); miBaseBiologic = new JMenuItem("Biological Agent"); miBaseBiologic.setMnemonic('A'); miFetalWeight = new JMenuItem("Import Fetal Weight Table"); miFetalWeight.setMnemonic('F'); miUserAdmin = new JMenuItem("Users Admin"); miUserAdmin.setMnemonic('U'); mnuMaintenance.add(miBaseMalformation); mnuMaintenance.addSeparator(); mnuMaintenance.add(miBaseSindrom); mnuMaintenance.add(miBaseTeratogen); mnuMaintenance.add(miBaseBiologic); mnuMaintenance.addSeparator(); mnuMaintenance.add(miFetalWeight); mnuMaintenance.addSeparator(); mnuMaintenance.add(miUserAdmin); miDisclaimer = new JMenuItem("Disclaimer"); miAbout = new JMenuItem("About"); mnuHelp.add(miDisclaimer); mnuHelp.addSeparator(); mnuHelp.add(miAbout); mb = new JMenuBar(); mb.add(mnuUtilities); mb.add(mnuMaintenance); mb.add(mnuHelp); mb.add(Box.createGlue()); JLabel lblUser = new JLabel(); lblUser.setText( "Active User: "******" "); mb.add(lblUser); mainBar = new JToolBar(); btnSearch = new JButton(); btnCalc = new JButton(); btnExit = new JButton(); btnSearch.setIcon(new ImageIcon(getClass().getResource("/icons/search.png"))); // NOI18N btnSearch.setToolTipText("Search"); btnSearch.setFocusable(false); btnSearch.setBorderPainted(false); btnCalc.setIcon(new ImageIcon(getClass().getResource("/icons/calculator.png"))); // NOI18N btnCalc.setToolTipText("Obstet Calculations"); btnCalc.setFocusable(false); btnCalc.setBorderPainted(false); btnExit.setIcon(new ImageIcon(getClass().getResource("/icons/exit.png"))); // NOI18N btnExit.setToolTipText("Exit"); btnExit.setFocusable(false); btnExit.setBorderPainted(false); mainBar.add(btnSearch); mainBar.add(btnCalc); mainBar.add(btnExit); mainBar.setFloatable(false); mainBar.setRollover(true); imgPanel = new JPanel(); img = new ImageIcon(getClass().getResource("/Images/logo_title.png")); lblImage = new JLabel(img); imgPanel.add(lblImage); miSearch.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new MFSearchWindow(); } }); miExit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { safeExit(); } }); miBaseMalformation.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new MalformationWindow(); } }); miBaseSindrom.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new SyndromeBaseWindow(); } }); miBaseTeratogen.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new TeratogenBaseWindow(); } }); miBaseBiologic.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new BiologicAgentWindow(); } }); miUserAdmin.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new UserWindow(); } }); miDisclaimer.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { DisclaimerWindow dis = new DisclaimerWindow(); dis.btnAgree.setVisible(false); dis.btnDisagree.setVisible(false); dis.btnClose.setVisible(true); dis.setVisible(true); } }); miAbout.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new AboutWindow(); } }); miFetalWeight.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { FileRandomTool rand = new FileRandomTool("TbGOWeight"); rand.RandomCreate(null); } catch (Exception ex) { JOptionPane.showMessageDialog( MainWindow.this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); ex.printStackTrace(System.err); } } }); miObstetCalc.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { ObstetCalculatorWindow calc = new ObstetCalculatorWindow(); calc.setVisible(true); } }); btnExit.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { safeExit(); } }); btnSearch.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { new MFSearchWindow(); } }); btnCalc.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ObstetCalculatorWindow calc = new ObstetCalculatorWindow(); calc.setVisible(true); } }); }
private void init(Font font) { JPanel content = new JPanel(new BorderLayout()); content.setBorder(new EmptyBorder(12, 12, 12, 12)); setContentPane(content); JPanel listPanel = new JPanel(new GridLayout(1, 3, 6, 6)); String[] fonts; try { fonts = getFontList(); } catch (Exception e) { Log.log(Log.ERROR, this, "Broken Java implementation!"); Log.log(Log.ERROR, this, e); fonts = new String[] {"Broken Java implementation!"}; } JPanel familyPanel = createTextFieldAndListPanel( "font-selector.family", familyField = new JTextField(), familyList = new JList(fonts)); listPanel.add(familyPanel); String[] sizes = {"9", "10", "12", "14", "16", "18", "24"}; JPanel sizePanel = createTextFieldAndListPanel( "font-selector.size", sizeField = new JTextField(), sizeList = new JList(sizes)); listPanel.add(sizePanel); String[] styles = { jEdit.getProperty("font-selector.plain"), jEdit.getProperty("font-selector.bold"), jEdit.getProperty("font-selector.italic"), jEdit.getProperty("font-selector.bolditalic") }; JPanel stylePanel = createTextFieldAndListPanel( "font-selector.style", styleField = new JTextField(), styleList = new JList(styles)); styleField.setEditable(false); listPanel.add(stylePanel); familyList.setSelectedValue(font.getFamily(), true); familyField.setText(font.getFamily()); sizeList.setSelectedValue(String.valueOf(font.getSize()), true); sizeField.setText(String.valueOf(font.getSize())); styleList.setSelectedIndex(font.getStyle()); styleField.setText((String) styleList.getSelectedValue()); ListHandler listHandler = new ListHandler(); familyList.addListSelectionListener(listHandler); sizeList.addListSelectionListener(listHandler); styleList.addListSelectionListener(listHandler); content.add(BorderLayout.NORTH, listPanel); preview = new JLabel(jEdit.getProperty("font-selector.long-text")) { public void paintComponent(Graphics g) { if (fontSelector != null) fontSelector.setAntiAliasEnabled(g); super.paintComponent(g); } }; preview.setBorder(new TitledBorder(jEdit.getProperty("font-selector.preview"))); updatePreview(); Dimension prefSize = preview.getPreferredSize(); prefSize.height = 50; preview.setPreferredSize(prefSize); content.add(BorderLayout.CENTER, preview); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS)); buttons.setBorder(new EmptyBorder(12, 0, 0, 0)); buttons.add(Box.createGlue()); ok = new JButton(jEdit.getProperty("common.ok")); ok.addActionListener(new ActionHandler()); getRootPane().setDefaultButton(ok); buttons.add(ok); buttons.add(Box.createHorizontalStrut(6)); cancel = new JButton(jEdit.getProperty("common.cancel")); cancel.addActionListener(new ActionHandler()); buttons.add(cancel); buttons.add(Box.createGlue()); content.add(BorderLayout.SOUTH, buttons); pack(); setLocationRelativeTo(getParent()); setVisible(true); }
public BookmarkSheet(Container c) { // set the layout of the data sheet c.setLayout(new BorderLayout()); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); /** Create a toolbar. */ JMenuBar toolbar = new JMenuBar(); toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.X_AXIS)); c.add(toolbar, BorderLayout.NORTH); JButton previousButton = new JButton(); previousButton.setIcon( SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.UP)); previousButton.setToolTipText("Go to previous bookmark [ Ctrl+( ]"); previousButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); previousButton.putClientProperty("JButton.segmentPosition", "first"); previousButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToPreviousBookmark(); } }); toolbar.add(previousButton); JButton nextButton = new JButton(); nextButton.setIcon( SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.DOWN)); nextButton.setToolTipText("Go to next bookmark [ Ctrl+) ]"); nextButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); nextButton.putClientProperty("JButton.segmentPosition", "last"); nextButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToNextBookmark(); } }); toolbar.add(nextButton); JButton goButton = new JButton("Go"); goButton.setToolTipText("Go to selected bookmark"); goButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); goButton.putClientProperty("JButton.segmentPosition", "only"); goButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToSelectedBookmark(); } }); toolbar.add(goButton); toolbar.add(Box.createGlue()); addButton = new JButton(); addButton.setIcon( SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.BKMK_ADD)); addButton.setToolTipText("Add bookmark for current range"); addButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); addButton.putClientProperty("JButton.segmentPosition", "first"); addButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { BookmarkController fc = BookmarkController.getInstance(); fc.addCurrentRangeToBookmarks(); } }); toolbar.add(addButton); JButton deleteButton = new JButton(); deleteButton.setIcon( SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.BKMK_RM)); deleteButton.setToolTipText("Delete selected bookmarks"); deleteButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); deleteButton.putClientProperty("JButton.segmentPosition", "last"); deleteButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { BookmarkController fc = BookmarkController.getInstance(); int[] selectedRows = table.getSelectedRows(); Arrays.sort(selectedRows); boolean delete = false; if (selectedRows.length > 0 && confirmDelete) { Object[] options = {"Yes", "No", "Yes, don't ask again"}; JLabel message = new JLabel( "Are you sure you want to delete " + selectedRows.length + " item(s)?"); message.setPreferredSize(new Dimension(300, 20)); int confirmDeleteDialog = JOptionPane.showOptionDialog( DialogUtils.getMainWindow(), message, "Confirm Delete", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (confirmDeleteDialog == 0) { delete = true; } else if (confirmDeleteDialog == 2) { delete = true; confirmDelete = false; } } else if (selectedRows.length > 0 && !confirmDelete) { delete = true; } if (delete) { for (int i = selectedRows.length - 1; i >= 0; i--) { fc.removeBookmark(selectedRows[i]); } } } }); toolbar.add(deleteButton); toolbar.add(Box.createGlue()); JButton loadButton = new JButton(); loadButton.setIcon( SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.OPEN)); loadButton.setToolTipText("Load bookmarks from file"); loadButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); loadButton.putClientProperty("JButton.segmentPosition", "first"); loadButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { loadBookmarks(table); } }); toolbar.add(loadButton); JButton saveButton = new JButton(); saveButton.setIcon( SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SAVE)); saveButton.setToolTipText("Save bookmarks to file"); saveButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); saveButton.putClientProperty("JButton.segmentPosition", "last"); saveButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveBookmarks(table); } }); toolbar.add(saveButton); // create a table (the most important component) table = new JTable(new BookmarksTableModel()); table.setAutoCreateRowSorter(true); table.setFillsViewportHeight(true); table.setShowGrid(true); table.setGridColor(Color.gray); // table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); // add the table and its header to the subpanel c.add(table.getTableHeader()); add(table); final JScrollPane sp = new JScrollPane( table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp.setWheelScrollingEnabled(false); sp.addMouseWheelListener( new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { sp.getVerticalScrollBar() .setValue(sp.getVerticalScrollBar().getValue() + e.getUnitsToScroll() * 2); } }); c.add(sp); // add glue to fill the remaining space add(Box.createGlue()); }
/** Create a font chooser dialog for the specified frame. */ public FontChooser(Frame owner) { super(owner, "Choose a Font"); // Set dialog frame and title // This dialog must be used as a modal dialog. In order to be used // as a modeless dialog, it would have to fire a PropertyChangeEvent // whenever the selected font changed, so that applications could be // notified of the user's selections. setModal(true); // Figure out what fonts are available on the system GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); fontFamilies = env.getAvailableFontFamilyNames(); // Set initial values for the properties family = fontFamilies[0]; style = Font.PLAIN; size = 18; selectedFont = new Font(family, style, size); // Create ItemChooser objects that allow the user to select font // family, style, and size. families = new ItemChooser("Family", fontFamilies, null, 0, ItemChooser.COMBOBOX); styles = new ItemChooser("Style", styleNames, styleValues, 0, ItemChooser.COMBOBOX); sizes = new ItemChooser("Size", sizeNames, null, 4, ItemChooser.COMBOBOX); // Now register event listeners to handle selections families.addItemChooserListener( new ItemChooser.Listener() { public void itemChosen(ItemChooser.Event e) { setFontFamily((String) e.getSelectedValue()); } }); styles.addItemChooserListener( new ItemChooser.Listener() { public void itemChosen(ItemChooser.Event e) { setFontStyle(((Integer) e.getSelectedValue()).intValue()); } }); sizes.addItemChooserListener( new ItemChooser.Listener() { public void itemChosen(ItemChooser.Event e) { setFontSize(Integer.parseInt((String) e.getSelectedValue())); } }); // Create a component to preview the font. preview = new JTextArea(defaultPreviewString, 5, 40); preview.setFont(selectedFont); // Create buttons to dismiss the dialog, and set handlers on them okay = new JButton("Okay"); cancel = new JButton("Cancel"); okay.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { hide(); } }); cancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { selectedFont = null; hide(); } }); // Put the ItemChoosers in a Box Box choosersBox = Box.createHorizontalBox(); choosersBox.add(Box.createHorizontalStrut(15)); choosersBox.add(families); choosersBox.add(Box.createHorizontalStrut(15)); choosersBox.add(styles); choosersBox.add(Box.createHorizontalStrut(15)); choosersBox.add(sizes); choosersBox.add(Box.createHorizontalStrut(15)); choosersBox.add(Box.createGlue()); // Put the dismiss buttons in another box Box buttonBox = Box.createHorizontalBox(); buttonBox.add(Box.createGlue()); buttonBox.add(okay); buttonBox.add(Box.createGlue()); buttonBox.add(cancel); buttonBox.add(Box.createGlue()); // Put the choosers at the top, the buttons at the bottom, and // the preview in the middle. Container contentPane = getContentPane(); contentPane.add(new JScrollPane(preview), BorderLayout.CENTER); contentPane.add(choosersBox, BorderLayout.NORTH); contentPane.add(buttonBox, BorderLayout.SOUTH); // Set the dialog size based on the component size. pack(); }
protected void _init() { setLayout(new BorderLayout()); JPanel panel = new JPanel(new GridLayout(2, 1)); showToolbar = new JCheckBox(jEdit.getProperty("options.toolbar.showToolbar")); showToolbar.setSelected(jEdit.getBooleanProperty("view.showToolbar")); panel.add(showToolbar); panel.add(new JLabel(jEdit.getProperty("options.toolbar.caption"))); add(BorderLayout.NORTH, panel); String toolbar = jEdit.getProperty("view.toolbar"); StringTokenizer st = new StringTokenizer(toolbar); listModel = new DefaultListModel(); while (st.hasMoreTokens()) { String actionName = (String) st.nextToken(); if (actionName.equals("-")) listModel.addElement(new ToolBarOptionPane.Button("-", null, null, "-")); else { EditAction action = jEdit.getAction(actionName); if (action == null) continue; String label = action.getLabel(); if (label == null) continue; Icon icon; String iconName; if (actionName.equals("-")) { iconName = null; icon = null; } else { iconName = jEdit.getProperty(actionName + ".icon"); if (iconName == null) icon = GUIUtilities.loadIcon("BrokenImage.png"); else { icon = GUIUtilities.loadIcon(iconName); if (icon == null) icon = GUIUtilities.loadIcon("BrokenImage.png"); } } listModel.addElement(new Button(actionName, iconName, icon, label)); } } list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.addListSelectionListener(new ListHandler()); list.setCellRenderer(new ButtonCellRenderer()); add(BorderLayout.CENTER, new JScrollPane(list)); JPanel buttons = new JPanel(); buttons.setBorder(new EmptyBorder(3, 0, 0, 0)); buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS)); ActionHandler actionHandler = new ActionHandler(); add = new RolloverButton(GUIUtilities.loadIcon("Plus.png")); add.setToolTipText(jEdit.getProperty("options.toolbar.add")); add.addActionListener(actionHandler); buttons.add(add); buttons.add(Box.createHorizontalStrut(6)); remove = new RolloverButton(GUIUtilities.loadIcon("Minus.png")); remove.setToolTipText(jEdit.getProperty("options.toolbar.remove")); remove.addActionListener(actionHandler); buttons.add(remove); buttons.add(Box.createHorizontalStrut(6)); moveUp = new RolloverButton(GUIUtilities.loadIcon("ArrowU.png")); moveUp.setToolTipText(jEdit.getProperty("options.toolbar.moveUp")); moveUp.addActionListener(actionHandler); buttons.add(moveUp); buttons.add(Box.createHorizontalStrut(6)); moveDown = new RolloverButton(GUIUtilities.loadIcon("ArrowD.png")); moveDown.setToolTipText(jEdit.getProperty("options.toolbar.moveDown")); moveDown.addActionListener(actionHandler); buttons.add(moveDown); buttons.add(Box.createHorizontalStrut(6)); edit = new RolloverButton(GUIUtilities.loadIcon("ButtonProperties.png")); edit.setToolTipText(jEdit.getProperty("options.toolbar.edit")); edit.addActionListener(actionHandler); buttons.add(edit); buttons.add(Box.createGlue()); updateButtons(); add(BorderLayout.SOUTH, buttons); iconList = new DefaultComboBoxModel(); st = new StringTokenizer(jEdit.getProperty("icons")); while (st.hasMoreElements()) { String icon = st.nextToken(); iconList.addElement(new IconListEntry(GUIUtilities.loadIcon(icon), icon)); } }
// {{{ InstallPanel constructor InstallPanel(PluginManager window, boolean updates) { super(new BorderLayout(12, 12)); this.window = window; this.updates = updates; setBorder(new EmptyBorder(12, 12, 12, 12)); final JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setResizeWeight(0.75); /* Setup the table */ table = new JTable(pluginModel = new PluginTableModel()); table.setShowGrid(false); table.setIntercellSpacing(new Dimension(0, 0)); table.setRowHeight(table.getRowHeight() + 2); table.setPreferredScrollableViewportSize(new Dimension(500, 200)); table.setDefaultRenderer( Object.class, new TextRenderer((DefaultTableCellRenderer) table.getDefaultRenderer(Object.class))); table.addFocusListener(new TableFocusHandler()); InputMap tableInputMap = table.getInputMap(JComponent.WHEN_FOCUSED); ActionMap tableActionMap = table.getActionMap(); tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "tabOutForward"); tableActionMap.put("tabOutForward", new KeyboardAction(KeyboardCommand.TAB_OUT_FORWARD)); tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK), "tabOutBack"); tableActionMap.put("tabOutBack", new KeyboardAction(KeyboardCommand.TAB_OUT_BACK)); tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "editPlugin"); tableActionMap.put("editPlugin", new KeyboardAction(KeyboardCommand.EDIT_PLUGIN)); tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "closePluginManager"); tableActionMap.put( "closePluginManager", new KeyboardAction(KeyboardCommand.CLOSE_PLUGIN_MANAGER)); TableColumn col1 = table.getColumnModel().getColumn(0); TableColumn col2 = table.getColumnModel().getColumn(1); TableColumn col3 = table.getColumnModel().getColumn(2); TableColumn col4 = table.getColumnModel().getColumn(3); TableColumn col5 = table.getColumnModel().getColumn(4); col1.setPreferredWidth(30); col1.setMinWidth(30); col1.setMaxWidth(30); col1.setResizable(false); col2.setPreferredWidth(180); col3.setPreferredWidth(130); col4.setPreferredWidth(70); col5.setPreferredWidth(70); JTableHeader header = table.getTableHeader(); header.setReorderingAllowed(false); header.addMouseListener(new HeaderMouseHandler()); header.setDefaultRenderer( new HeaderRenderer((DefaultTableCellRenderer) header.getDefaultRenderer())); scrollpane = new JScrollPane(table); scrollpane.getViewport().setBackground(table.getBackground()); split.setTopComponent(scrollpane); /* Create description */ JScrollPane infoPane = new JScrollPane(infoBox = new PluginInfoBox()); infoPane.setPreferredSize(new Dimension(500, 100)); split.setBottomComponent(infoPane); EventQueue.invokeLater( new Runnable() { @Override public void run() { split.setDividerLocation(0.75); } }); final JTextField searchField = new JTextField(); searchField.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) { table.dispatchEvent(e); table.requestFocus(); } } }); searchField .getDocument() .addDocumentListener( new DocumentListener() { void update() { pluginModel.setFilterString(searchField.getText()); } @Override public void changedUpdate(DocumentEvent e) { update(); } @Override public void insertUpdate(DocumentEvent e) { update(); } @Override public void removeUpdate(DocumentEvent e) { update(); } }); table.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { int i = table.getSelectedRow(), n = table.getModel().getRowCount(); if (e.getKeyCode() == KeyEvent.VK_DOWN && i == (n - 1) || e.getKeyCode() == KeyEvent.VK_UP && i == 0) { searchField.requestFocus(); searchField.selectAll(); } } }); Box filterBox = Box.createHorizontalBox(); filterBox.add(new JLabel("Filter : ")); filterBox.add(searchField); add(BorderLayout.NORTH, filterBox); add(BorderLayout.CENTER, split); /* Create buttons */ Box buttons = new Box(BoxLayout.X_AXIS); buttons.add(new InstallButton()); buttons.add(Box.createHorizontalStrut(12)); buttons.add(new SelectallButton()); buttons.add(chooseButton = new ChoosePluginSet()); buttons.add(new ClearPluginSet()); buttons.add(Box.createGlue()); buttons.add(new SizeLabel()); add(BorderLayout.SOUTH, buttons); String path = jEdit.getProperty(PluginManager.PROPERTY_PLUGINSET, ""); if (!path.isEmpty()) { loadPluginSet(path); } } // }}}
public PasteSpecialDialog(View view, TextArea textArea) { super(view, jEdit.getProperty("paste-special.title"), true); this.textArea = textArea; JPanel content = new JPanel(new BorderLayout()); content.setBorder(new EmptyBorder(12, 12, 12, 12)); setContentPane(content); Registers.Register register = Registers.getRegister('$'); Transferable transferable = register.getTransferable(); DataFlavor[] flavors = transferable.getTransferDataFlavors(); List<DataFlavor> flavorList = Arrays.asList(flavors); Vector<DataFlavor> supportedFlavors = new Vector<DataFlavor>(this.flavors.length); for (DataFlavor flavor : this.flavors) { if (flavorList.contains(flavor)) { supportedFlavors.add(flavor); } } this.flavorList = new JList(supportedFlavors); this.flavorList.setCellRenderer( new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value.equals(DataFlavor.stringFlavor)) { setText("Plain text"); } else if (value.equals(JEditDataFlavor.jEditRichTextDataFlavor)) { setText("jEdit rich text"); } else if (value.equals(JEditDataFlavor.html)) { setText("html"); } return this; } }); getContentPane().add(new JScrollPane(this.flavorList)); // {{{ Buttons JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS)); buttons.setBorder(new EmptyBorder(12, 0, 0, 0)); buttons.add(Box.createGlue()); ok = new JButton(jEdit.getProperty("common.ok")); ok.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { ok(); } }); getRootPane().setDefaultButton(ok); buttons.add(ok); buttons.add(Box.createHorizontalStrut(6)); cancel = new JButton(jEdit.getProperty("common.cancel")); cancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { cancel(); } }); buttons.add(cancel); buttons.add(Box.createGlue()); content.add(BorderLayout.SOUTH, buttons); // }}} pack(); setLocationRelativeTo(view); setVisible(true); }
public ToolBarEditDialog( Component comp, DefaultComboBoxModel iconListModel, ToolBarOptionPane.Button current) { super( GUIUtilities.getParentDialog(comp), jEdit.getProperty("options.toolbar.edit.title"), true); JPanel content = new JPanel(new BorderLayout()); content.setBorder(new EmptyBorder(12, 12, 12, 12)); setContentPane(content); ActionHandler actionHandler = new ActionHandler(); ButtonGroup grp = new ButtonGroup(); JPanel typePanel = new JPanel(new GridLayout(3, 1, 6, 6)); typePanel.setBorder(new EmptyBorder(0, 0, 6, 0)); typePanel.add(new JLabel(jEdit.getProperty("options.toolbar.edit.caption"))); separator = new JRadioButton(jEdit.getProperty("options.toolbar" + ".edit.separator")); separator.addActionListener(actionHandler); grp.add(separator); typePanel.add(separator); action = new JRadioButton(jEdit.getProperty("options.toolbar" + ".edit.action")); action.addActionListener(actionHandler); grp.add(action); typePanel.add(action); content.add(BorderLayout.NORTH, typePanel); JPanel actionPanel = new JPanel(new BorderLayout(6, 6)); ActionSet[] actionsList = jEdit.getActionSets(); Vector vec = new Vector(actionsList.length); for (int i = 0; i < actionsList.length; i++) { ActionSet actionSet = actionsList[i]; if (actionSet.getActionCount() != 0) vec.addElement(actionSet); } combo = new JComboBox(vec); combo.addActionListener(actionHandler); actionPanel.add(BorderLayout.NORTH, combo); list = new JList(); list.setVisibleRowCount(8); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); actionPanel.add(BorderLayout.CENTER, new JScrollPane(list)); JPanel iconPanel = new JPanel(new BorderLayout(0, 3)); JPanel labelPanel = new JPanel(new GridLayout(2, 1)); labelPanel.setBorder(new EmptyBorder(0, 0, 0, 12)); JPanel compPanel = new JPanel(new GridLayout(2, 1)); grp = new ButtonGroup(); labelPanel.add(builtin = new JRadioButton(jEdit.getProperty("options.toolbar.edit.builtin"))); builtin.addActionListener(actionHandler); grp.add(builtin); labelPanel.add(file = new JRadioButton(jEdit.getProperty("options.toolbar.edit.file"))); grp.add(file); file.addActionListener(actionHandler); iconPanel.add(BorderLayout.WEST, labelPanel); builtinCombo = new JComboBox(iconListModel); builtinCombo.setRenderer(new ToolBarOptionPane.IconCellRenderer()); compPanel.add(builtinCombo); fileButton = new JButton(jEdit.getProperty("options.toolbar.edit.no-icon")); fileButton.setMargin(new Insets(1, 1, 1, 1)); fileButton.setIcon(GUIUtilities.loadIcon("Blank24.gif")); fileButton.setHorizontalAlignment(SwingConstants.LEFT); fileButton.addActionListener(actionHandler); compPanel.add(fileButton); iconPanel.add(BorderLayout.CENTER, compPanel); actionPanel.add(BorderLayout.SOUTH, iconPanel); content.add(BorderLayout.CENTER, actionPanel); JPanel southPanel = new JPanel(); southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.X_AXIS)); southPanel.setBorder(new EmptyBorder(12, 0, 0, 0)); southPanel.add(Box.createGlue()); ok = new JButton(jEdit.getProperty("common.ok")); ok.addActionListener(actionHandler); getRootPane().setDefaultButton(ok); southPanel.add(ok); southPanel.add(Box.createHorizontalStrut(6)); cancel = new JButton(jEdit.getProperty("common.cancel")); cancel.addActionListener(actionHandler); southPanel.add(cancel); southPanel.add(Box.createGlue()); content.add(BorderLayout.SOUTH, southPanel); if (current == null) { action.setSelected(true); builtin.setSelected(true); updateList(); } else { if (current.actionName.equals("-")) { separator.setSelected(true); builtin.setSelected(true); } else { action.setSelected(true); ActionSet set = jEdit.getActionSetForAction(current.actionName); combo.setSelectedItem(set); updateList(); list.setSelectedValue(current, true); if (MiscUtilities.isURL(current.iconName)) { file.setSelected(true); fileIcon = current.iconName; try { fileButton.setIcon(new ImageIcon(new URL(fileIcon))); } catch (MalformedURLException mf) { Log.log(Log.ERROR, this, mf); } fileButton.setText(MiscUtilities.getFileName(fileIcon)); } else { String iconName = MiscUtilities.getFileName(current.iconName); builtin.setSelected(true); ListModel model = builtinCombo.getModel(); for (int i = 0; i < model.getSize(); i++) { ToolBarOptionPane.IconListEntry entry = (ToolBarOptionPane.IconListEntry) model.getElementAt(i); if (entry.name.equals(iconName)) { builtinCombo.setSelectedIndex(i); break; } } } } } updateEnabled(); pack(); setLocationRelativeTo(GUIUtilities.getParentDialog(comp)); show(); }