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}; }
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; }
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 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(); }
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)); } }
/** 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 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); }
public DocumentPanel() { super(new BorderLayout()); JLabel lblDocument = new JLabel("Document: " + document.getTitle()); lblDocument.setBorder(new EtchedBorder()); textPane = new JTextPane(document); textPane.setEditable(false); textPane.setMargin(new Insets(5, 20, 5, 5)); textPane.setMaximumSize(new Dimension(364, 1000000000)); textPane.setPreferredSize(new Dimension(364, 400)); textPane.setMinimumSize(new Dimension(364, 10)); textPane.addCaretListener( new CaretListener() { public void caretUpdate(CaretEvent e) { int length = document.getLength(); int offset = e.getDot(); if (e.getDot() == e.getMark()) textPane.getCaret().moveDot(offset + 1); Paragraph p = lockManager.getParFromOffset(offset); int pOffset = p.getOffset(); lblCursor.setText( "Document Length=" + String.valueOf(length) + ", CaretOffset=" + String.valueOf(offset) + ", Paragraph=" + p.toString() + ", Offset in Paragraph=" + String.valueOf(offset - p.getOffset())); } }); Box box = new Box(BoxLayout.X_AXIS); box.add(textPane); box.add(Box.createGlue()); box.setBackground(Color.WHITE); box.setOpaque(true); box.setPreferredSize(new Dimension(600, 10000)); lblCursor = new JLabel("Cursor"); lblCursor.setBorder(new EtchedBorder()); JPanel boxText = new JPanel(new BorderLayout()); boxText.setBorder(new EmptyBorder(5, 5, 5, 5)); boxText.add(lblDocument, BorderLayout.NORTH); boxText.add(new JScrollPane(box), BorderLayout.CENTER); boxText.add(lblCursor, BorderLayout.SOUTH); JLabel lblPars = new JLabel("Paragraphs: "); lblPars.setBorder(new EtchedBorder()); parList = new JList(); parList.setPreferredSize(new Dimension(100, 300)); parList.setEnabled(false); JPanel boxPars = new JPanel(new BorderLayout()); boxPars.setBorder(new EmptyBorder(5, 5, 5, 5)); boxPars.add(lblPars, BorderLayout.NORTH); boxPars.add(new JScrollPane(parList), BorderLayout.CENTER); add(boxText, BorderLayout.CENTER); add(boxPars, BorderLayout.EAST); }