public ActionBar(View view, boolean temp) { setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); this.view = view; this.temp = temp; add(Box.createHorizontalStrut(2)); JLabel label = new JLabel(jEdit.getProperty("view.action.prompt")); add(label); add(Box.createHorizontalStrut(12)); add(action = new ActionTextField()); action.setEnterAddsToHistory(false); Dimension max = action.getPreferredSize(); max.width = Integer.MAX_VALUE; action.setMaximumSize(max); action.addActionListener(new ActionHandler()); action.getDocument().addDocumentListener(new DocumentHandler()); if (temp) { close = new RolloverButton(GUIUtilities.loadIcon("closebox.gif")); close.addActionListener(new ActionHandler()); close.setToolTipText(jEdit.getProperty("view.action.close-tooltip")); add(close); } this.temp = temp; }
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(); }
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); }
// {{{ 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()); } // }}}