public void showItem() { if (!this.editorPanel.getViewer().isLanguageFunctionAvailable()) { return; } this.highlight = this.editorPanel .getEditor() .addHighlight(this.position, this.position + this.word.length(), null, true); final FindSynonymsActionHandler _this = this; QTextEditor editor = this.editorPanel.getEditor(); Rectangle r = null; try { r = editor.modelToView(this.position); } catch (Exception e) { // BadLocationException! Environment.logError("Location: " + this.position + " is not valid", e); UIUtils.showErrorMessage(this.editorPanel, "Unable to display synonyms."); return; } int y = r.y; // Show a panel of all the items. final QPopup p = this.popup; p.setOpaque(false); Synonyms syns = null; try { syns = this.projectViewer.getSynonymProvider().getSynonyms(this.word); } catch (Exception e) { UIUtils.showErrorMessage(this.editorPanel, "Unable to display synonyms."); Environment.logError("Unable to lookup synonyms for: " + word, e); return; } if ((syns.words.size() == 0) && (this.word.toLowerCase().endsWith("ed"))) { // Trim off the ed and try again. try { syns = this.projectViewer.getSynonyms(this.word.substring(0, this.word.length() - 2)); } catch (Exception e) { UIUtils.showErrorMessage(this.editorPanel, "Unable to display synonyms."); Environment.logError("Unable to lookup synonyms for: " + word, e); return; } } if ((syns.words.size() == 0) && (this.word.toLowerCase().endsWith("s"))) { // Trim off the ed and try again. try { syns = this.projectViewer.getSynonyms(this.word.substring(0, this.word.length() - 1)); } catch (Exception e) { UIUtils.showErrorMessage(this.editorPanel, "Unable to display synonyms."); Environment.logError("Unable to lookup synonyms for: " + word, e); return; } } StringBuilder sb = new StringBuilder(); if (syns.words.size() > 0) { sb.append("6px"); for (int i = 0; i < syns.words.size(); i++) { if (sb.length() > 0) { sb.append(", "); } sb.append("p, 3px, [p,90px], 5px"); } /* if (syns.words.size () > 0) { sb.append (",5px"); } */ } else { sb.append("6px, p, 6px"); } FormLayout summOnly = new FormLayout("3px, fill:380px:grow, 3px", sb.toString()); PanelBuilder pb = new PanelBuilder(summOnly); CellConstraints cc = new CellConstraints(); int ind = 2; Map<String, String> names = new HashMap(); names.put(Synonyms.ADJECTIVE + "", "Adjectives"); names.put(Synonyms.NOUN + "", "Nouns"); names.put(Synonyms.VERB + "", "Verbs"); names.put(Synonyms.ADVERB + "", "Adverbs"); names.put(Synonyms.OTHER + "", "Other"); if (syns.words.size() == 0) { JLabel l = new JLabel("No synonyms found."); l.setFont(l.getFont().deriveFont(Font.ITALIC)); pb.add(l, cc.xy(2, 2)); } // Determine what type of word we are looking for. for (Synonyms.Part i : syns.words) { JLabel l = new JLabel(names.get(i.type + "")); l.setFont(l.getFont().deriveFont(Font.ITALIC)); l.setFont(l.getFont().deriveFont((float) UIUtils.getEditorFontSize(10))); l.setBorder( new CompoundBorder( new MatteBorder(0, 0, 1, 0, Environment.getBorderColor()), new EmptyBorder(0, 0, 3, 0))); pb.add(l, cc.xy(2, ind)); ind += 2; HTMLEditorKit kit = new HTMLEditorKit(); HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument(); JTextPane t = new JTextPane(doc); t.setEditorKit(kit); t.setEditable(false); t.setOpaque(false); StringBuilder buf = new StringBuilder( "<style>a { text-decoration: none; } a:hover { text-decoration: underline; }</style><span style='color: #000000; font-size: " + ((int) UIUtils.getEditorFontSize(10) /*t.getFont ().getSize () + 2*/) + "pt; font-family: " + t.getFont().getFontName() + ";'>"); for (int x = 0; x < i.words.size(); x++) { String w = (String) i.words.get(x); buf.append("<a class='x' href='http://" + w + "'>" + w + "</a>"); if (x < (i.words.size() - 1)) { buf.append(", "); } } buf.append("</span>"); t.setText(buf.toString()); t.addHyperlinkListener( new HyperlinkAdapter() { public void hyperlinkUpdate(HyperlinkEvent ev) { if (ev.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { QTextEditor ed = _this.editorPanel.getEditor(); ed.replaceText( _this.position, _this.position + _this.word.length(), ev.getURL().getHost()); ed.removeHighlight(_this.highlight); _this.popup.setVisible(false); _this.projectViewer.fireProjectEvent( ProjectEvent.SYNONYM, ProjectEvent.REPLACE, ev.getURL().getHost()); } } }); // Annoying that we have to do this but it prevents the text from being too small. t.setSize(new Dimension(380, Short.MAX_VALUE)); JScrollPane sp = new JScrollPane(t); t.setCaretPosition(0); sp.setOpaque(false); sp.getVerticalScrollBar().setValue(0); /* sp.setPreferredSize (t.getPreferredSize ()); sp.setMaximumSize (new Dimension (380, 75)); */ sp.getViewport().setOpaque(false); sp.setOpaque(false); sp.setBorder(null); sp.getViewport().setBackground(Color.WHITE); sp.setAlignmentX(Component.LEFT_ALIGNMENT); pb.add(sp, cc.xy(2, ind)); ind += 2; } JPanel pan = pb.getPanel(); pan.setOpaque(true); pan.setBackground(Color.WHITE); this.popup.setContent(pan); // r.y -= this.editorPanel.getScrollPane ().getVerticalScrollBar ().getValue (); Point po = SwingUtilities.convertPoint(editor, r.x, r.y, this.editorPanel); r.x = po.x; r.y = po.y; // Subtract the insets of the editorPanel. Insets ins = this.editorPanel.getInsets(); r.x -= ins.left; r.y -= ins.top; this.editorPanel.showPopupAt(this.popup, r, "above", true); }
private void buildExternalsPanel() { FormBuilder builder = FormBuilder.create().layout(new FormLayout("fill:pref:grow", "p")); int row = 1; for (ExternalFileEntry efe : externals) { builder.add(efe.getPanel()).xy(1, row); builder.appendRows("2dlu, p"); row += 2; } builder.add(Box.createVerticalGlue()).xy(1, row); builder.appendRows("2dlu, p, 2dlu, p"); builder.add(addExtPan).xy(1, row + 2); builder.add(Box.createVerticalGlue()).xy(1, row + 2); // builder.getPanel().setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.green)); // externalFilesPanel.setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.red)); JScrollPane pane = new JScrollPane(builder.getPanel()); pane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); externalFilesPanel.setMinimumSize(new Dimension(400, 400)); externalFilesPanel.setPreferredSize(new Dimension(400, 400)); externalFilesPanel.removeAll(); externalFilesPanel.add(pane, BorderLayout.CENTER); externalFilesPanel.revalidate(); externalFilesPanel.repaint(); }
private MainPanel() { super(new GridLayout(3, 1, 5, 5)); final JTree tree = new JTree(); final JCheckBox c = new JCheckBox("CheckBox", true); c.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { tree.setEnabled(c.isSelected()); } }); c.setFocusPainted(false); JScrollPane l1 = new JScrollPane(tree); l1.setBorder(new ComponentTitledBorder(c, l1, BorderFactory.createEtchedBorder())); JLabel icon = new JLabel(new ImageIcon(getClass().getResource("16x16.png"))); JLabel l2 = new JLabel("<html>aaaaaaaaaaaaaaaa<br>bbbbbbbbbbbbbbbbb"); l2.setBorder(new ComponentTitledBorder(icon, l2, BorderFactory.createEtchedBorder())); JButton b = new JButton("Button"); b.setFocusPainted(false); JLabel l3 = new JLabel("ccccccccccccccc"); l3.setBorder(new ComponentTitledBorder(b, l3, BorderFactory.createEtchedBorder())); add(l1); add(l2); add(l3); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setPreferredSize(new Dimension(320, 240)); }
public JComponent buildRightTabbedPane() { cl = new CardLayout(); tabbedPane = new JPanel(cl); tabbedPane.setBorder(BorderFactory.createEmptyBorder()); JScrollPane scrollPane = new JScrollPane(tabbedPane); scrollPane.setBorder(BorderFactory.createEmptyBorder()); return scrollPane; }
/** * Static Init * * @throws Exception */ void jbInit() throws Exception { mainPanel.setLayout(mainLayout); mainLayout.setHgap(2); mainLayout.setVgap(2); infoPane.setBorder(BorderFactory.createLoweredBevelBorder()); infoPane.setPreferredSize(new Dimension(500, 400)); getContentPane().add(mainPanel); mainPanel.add(infoPane, BorderLayout.CENTER); mainPanel.add(confirmPanel, BorderLayout.SOUTH); infoPane.getViewport().add(info, null); confirmPanel.addActionListener(this); } // jbInit
/** Constructor */ public ServiceFilterPanel(String text, Vector list) { empty_border = new EmptyBorder(5, 5, 0, 5); indent_border = new EmptyBorder(5, 25, 5, 5); service_box = new JCheckBox(text); service_box.addActionListener(this); service_data = new Vector(); if (list != null) { service_box.setSelected(true); service_data = (Vector) list.clone(); } service_list = new JList(service_data); service_list.setBorder(new EtchedBorder()); service_list.setVisibleRowCount(5); service_list.addListSelectionListener(this); service_list.setEnabled(service_box.isSelected()); service_scroll = new JScrollPane(service_list); service_scroll.setBorder(new EtchedBorder()); remove_service_button = new JButton("Remove"); remove_service_button.addActionListener(this); remove_service_button.setEnabled(false); remove_service_panel = new JPanel(); remove_service_panel.setLayout(new FlowLayout()); remove_service_panel.add(remove_service_button); service_area = new JPanel(); service_area.setLayout(new BorderLayout()); service_area.add(service_scroll, BorderLayout.CENTER); service_area.add(remove_service_panel, BorderLayout.EAST); service_area.setBorder(indent_border); add_service_field = new JTextField(); add_service_field.addActionListener(this); add_service_field.getDocument().addDocumentListener(this); add_service_field.setEnabled(service_box.isSelected()); add_service_button = new JButton("Add"); add_service_button.addActionListener(this); add_service_button.setEnabled(false); add_service_panel = new JPanel(); add_service_panel.setLayout(new BorderLayout()); JPanel dummy = new JPanel(); dummy.setBorder(empty_border); add_service_panel.add(dummy, BorderLayout.WEST); add_service_panel.add(add_service_button, BorderLayout.EAST); add_service_area = new JPanel(); add_service_area.setLayout(new BorderLayout()); add_service_area.add(add_service_field, BorderLayout.CENTER); add_service_area.add(add_service_panel, BorderLayout.EAST); add_service_area.setBorder(indent_border); setLayout(new BorderLayout()); add(service_box, BorderLayout.NORTH); add(service_area, BorderLayout.CENTER); add(add_service_area, BorderLayout.SOUTH); setBorder(empty_border); }
private void jbInit() throws Exception { titledBorder1 = new TitledBorder(""); this.setLayout(borderLayout1); this.setBorder(titledBorder1); titledBorder1.setTitleColor(Color.blue); titledBorder1.setTitle( ClientSettings.getInstance().getResources().getResource("documents filter")); this.add(sp, BorderLayout.CENTER); sp.setBorder(BorderFactory.createEmptyBorder()); sp.getViewport().add(innerPanel, null); sp.setAutoscrolls(true); innerPanel.setLayout(gridBagLayout1); }
private void init() { setSize(800, 600); cp = getContentPane(); cp.setLayout(null); btnResize.addActionListener(this); btnResize.setLocation(0, 0); btnResize.setSize(100, 30); sp.setLocation(0, 31); sp.setBorder(BorderFactory.createLineBorder(Color.blue, 2)); editorPane.setBorder(BorderFactory.createLineBorder(Color.red, 2)); step.setLocation(0, 31); step.setSize(100, 100); cp.add(step); // cp.add(sp); cp.add(btnResize); }
private void init() { setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener( new WindowAdapter() { @Override public void windowClosing(final WindowEvent e) { cleanExit(); } }); addWindowStateListener( new WindowStateListener() { public void windowStateChanged(final WindowEvent arg0) { switch (arg0.getID()) { case WindowEvent.WINDOW_ICONIFIED: lessCpu(true); break; case WindowEvent.WINDOW_DEICONIFIED: lessCpu(false); break; } } }); setIconImage(Configuration.getImage(Configuration.Paths.Resources.ICON)); JPopupMenu.setDefaultLightWeightPopupEnabled(false); WindowUtil.setFrame(this); panel = new BotPanel(); menuBar = new BotMenuBar(this); toolBar = new BotToolBar(this, menuBar); panel.setFocusTraversalKeys(0, new HashSet<AWTKeyStroke>()); new BotKeyboardShortcuts(KeyboardFocusManager.getCurrentKeyboardFocusManager(), this, this); menuBar.setBot(null); setJMenuBar(menuBar); textScroll = new JScrollPane( TextAreaLogHandler.TEXT_AREA, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); textScroll.setBorder(null); textScroll.setPreferredSize(new Dimension(PANEL_WIDTH, 120)); textScroll.setVisible(true); JScrollPane scrollableBotPanel = new JScrollPane(panel); add(toolBar, BorderLayout.NORTH); add(scrollableBotPanel, BorderLayout.CENTER); add(textScroll, BorderLayout.SOUTH); }
public TextAreaCellEditor() { super(); scroll = new JScrollPane(this); scroll.setBorder(BorderFactory.createEmptyBorder()); // scroll.setViewportBorder(BorderFactory.createEmptyBorder()); setLineWrap(true); setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4)); KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK); getInputMap(JComponent.WHEN_FOCUSED).put(enter, KEY); getActionMap() .put( KEY, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { stopCellEditing(); } }); }
QueryPanel(ControlHandler c) { // initialize the important stuff control = c; control.setQueryPanel(this); // make a few buttons and fields JButton queryButton = new JButton("Query"); queryField = new JTextField("", 30); // query socketField = new JTextField("0", 3); JButton downloadButton = new JButton("Download"); // add actions queryButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { sendQuery(); } }); downloadButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { startDownload(); } }); // initialize the query table queryModel = new QueryTableModel(3, control.getQueryVector()); queryTable = new JTable(queryModel); queryTable.addMouseListener(new TableListener()); // TableColumnModel columnModel = new TableColumn(); // columnModel.getColumn(0).setWidth(350); JScrollPane scrollPane = new JScrollPane(queryTable); scrollPane.setPreferredSize(new Dimension(625, 150)); scrollPane.setBorder(BorderFactory.createLoweredBevelBorder()); // Create a panel to hold the query search JPanel commandPanel = new JPanel(); commandPanel.add(queryButton); commandPanel.add(queryField); commandPanel.add(downloadButton); add(commandPanel); // Create a panel to hold the download button JPanel query = new JPanel(); query.setBorder(BorderFactory.createTitledBorder("Queries")); query.add(scrollPane); add(query); // --------------------------------------------------------------------- // Download Table downloadModel = new DownloadTableModel(3, control.getDownloadVector()); downloadTable = new JTable(downloadModel); downloadTable.addMouseListener(new TableListener()); JScrollPane downloadPane = new JScrollPane(downloadTable); downloadPane.setPreferredSize(new Dimension(625, 80)); downloadPane.setBorder(BorderFactory.createLoweredBevelBorder()); // Buttons JButton cancelDownload = new JButton("Cancel Selected"); JButton cancelAllDownload = new JButton("Cancel All"); JButton clearDownloadButton = new JButton("Clear completed"); cancelDownload.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { control.removeDownloadAt(downloadRow); } }); clearDownloadButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { control.removeCompletedDownloads(); } }); // A panel for the buttons and things JPanel downloadCommand = new JPanel(); downloadCommand.add(cancelDownload); downloadCommand.add(cancelAllDownload); downloadCommand.add(clearDownloadButton); JPanel down = new JPanel(); down.setBorder(BorderFactory.createTitledBorder("Downloads")); down.add(downloadPane); add(down); add(downloadCommand); }
protected JComponent createCenterPanel() { JPanel panel = new JPanel(new GridBagLayout()); // Single/Double click JPanel clickCountPanel = new JPanel(new GridBagLayout()); clickCountPanel.setBorder( IdeBorderFactory.createTitledBorder( KeyMapBundle.message("mouse.shortcut.dialog.click.count.border"), false, true, true)); panel.add( clickCountPanel, new GridBagConstraints( 0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); clickCountPanel.add( myRbSingleClick, new GridBagConstraints( 0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 10), 0, 0)); clickCountPanel.add( myRbDoubleClick, new GridBagConstraints( 1, 0, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { updatePreviewAndConflicts(); } }; myRbSingleClick.addActionListener(listener); myRbDoubleClick.addActionListener(listener); // Click pad JPanel clickPadPanel = new JPanel(new BorderLayout()); panel.add( clickPadPanel, new GridBagConstraints( 0, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 4, 0), 0, 0)); clickPadPanel.setBorder( IdeBorderFactory.createTitledBorder( KeyMapBundle.message("mouse.shortcut.dialog.click.pad.border"), false, true, true)); myClickPad.setPreferredSize(new Dimension(260, 60)); clickPadPanel.add(myClickPad, BorderLayout.CENTER); // Shortcut preview JPanel previewPanel = new JPanel(new GridBagLayout()); previewPanel.setBorder( IdeBorderFactory.createTitledBorder( KeyMapBundle.message("mouse.shortcut.dialog.shortcut.preview.border"), false, true, true)); panel.add( previewPanel, new GridBagConstraints( 0, 2, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 4, 0), 0, 0)); previewPanel.add( myLblPreview, new GridBagConstraints( 0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); // Conflicts panel JPanel conflictsPanel = new JPanel(new GridBagLayout()); conflictsPanel.setBorder( IdeBorderFactory.createTitledBorder( KeyMapBundle.message("mouse.shortcut.dialog.conflicts.border"), false, true, true)); panel.add( conflictsPanel, new GridBagConstraints( 0, 3, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); myTarConflicts.setPreferredSize(new Dimension(260, 60)); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTarConflicts); scrollPane.setBorder(null); conflictsPanel.add( scrollPane, new GridBagConstraints( 0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); return panel; }
private void init() { setName("Dialogs"); setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); informationButton = new JButton("Information dialog"); informationButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog( parent, "Information dialog", "Information", JOptionPane.INFORMATION_MESSAGE); } }); confirmationButton = new JButton("Confirmation dialog"); confirmationButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog( parent, "Confirmation dialog", "Confirmation", JOptionPane.QUESTION_MESSAGE); } }); warningButton = new JButton("Warning dialog"); warningButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog( parent, "Warning dialog", "Warning", JOptionPane.WARNING_MESSAGE); } }); errorButton = new JButton("Error dialog"); errorButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog( parent, "Error dialog", "Error", JOptionPane.ERROR_MESSAGE); } }); optionButton = new JButton("Option dialog"); optionButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Object[] options = {"Yes", "No"}; int confirm = JOptionPane.showOptionDialog( null, "Please select yes or no using the keyboard (tab/enter) keys\n", "Confirmation Required", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); if (confirm == 0 || confirm == 1) optionButton.setText("Option dialog. Selected: " + options[confirm]); else optionButton.setText("Option dialog. Selected: nothing "); } }); nativeFileChooserButton = new JButton("Native FileChooser dialog"); nativeFileChooserButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { fileDialog = new FileDialog(JOptionPane.getFrameForComponent(parent), "Open File"); fileDialog.setResizable(true); fileDialog.setVisible(true); } }); fileChooserButton = new JButton("FileChooser dialog"); fileChooserButton.setEnabled(!(parent instanceof JApplet)); fileChooserButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); int result = fc.showOpenDialog(parent); } }); colorChooserButton = new JButton("ColorChooser dialog"); colorChooserButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Color c = JColorChooser.showDialog(parent, "JColorChooser", Color.blue); } }); JPanel contentPanel = new JPanel(new GridBagLayout()); GridBagHelper.addComponent( contentPanel, informationButton, 0, 0, 1, 1, 16, 8, 0, 4, 0.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); GridBagHelper.addComponent( contentPanel, confirmationButton, 0, 1, 1, 1, 16, 8, 0, 4, 0.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); GridBagHelper.addComponent( contentPanel, warningButton, 0, 2, 1, 1, 16, 8, 0, 4, 0.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); GridBagHelper.addComponent( contentPanel, errorButton, 0, 3, 1, 1, 16, 8, 0, 4, 0.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); GridBagHelper.addComponent( contentPanel, optionButton, 0, 4, 1, 1, 16, 8, 0, 4, 0.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); GridBagHelper.addComponent( contentPanel, nativeFileChooserButton, 0, 5, 1, 1, 16, 8, 0, 4, 0.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); GridBagHelper.addComponent( contentPanel, fileChooserButton, 0, 6, 1, 1, 16, 8, 0, 4, 0.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); GridBagHelper.addComponent( contentPanel, colorChooserButton, 0, 7, 1, 1, 16, 8, 0, 4, 0.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); JScrollPane scrollPane = new JScrollPane(contentPanel); scrollPane.setBorder(BorderFactory.createEmptyBorder()); add(scrollPane, BorderLayout.CENTER); }
public WizardPopup(@Nullable JBPopup aParent, @NotNull PopupStep<Object> aStep) { myParent = (WizardPopup) aParent; myStep = aStep; mySpeedSearch.setEnabled(myStep.isSpeedSearchEnabled()); final JComponent content = createContent(); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(content); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.getHorizontalScrollBar().setBorder(null); scrollPane.getActionMap().get("unitScrollLeft").setEnabled(false); scrollPane.getActionMap().get("unitScrollRight").setEnabled(false); scrollPane.setBorder(null); final Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext()); init( project, scrollPane, getPreferredFocusableComponent(), true, true, true, null, false, aStep.getTitle(), null, true, null, false, null, null, null, false, null, true, false, true, null, 0f, null, true, false, new Component[0], null, SwingConstants.LEFT, true, Collections.<Pair<ActionListener, KeyStroke>>emptyList(), null, null, false, true, true, true, null); registerAction( "disposeAll", KeyEvent.VK_ESCAPE, InputEvent.SHIFT_MASK, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (mySpeedSearch.isHoldingFilter()) { mySpeedSearch.reset(); } else { disposeAll(); } } }); AbstractAction goBackAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { goBack(); } }; registerAction("goBack3", KeyEvent.VK_ESCAPE, 0, goBackAction); myMnemonicsSearch = new MnemonicsSearch(this) { @Override protected void select(Object value) { onSelectByMnemonic(value); } }; }
protected void initComponents() { int border = 6; this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.setBorder( new CompoundBorder( BorderFactory.createEmptyBorder(9, 9, 9, 9), new TitledBorder("Download"))); this.setToolTipText("Layer imagery bulk download."); final JPanel locationPanel = new JPanel(new BorderLayout(5, 5)); JLabel locationLabel = new JLabel(" Cache:"); final JLabel locationName = new JLabel(""); JButton locationButton = new JButton("..."); locationPanel.add(locationLabel, BorderLayout.WEST); locationPanel.add(locationName, BorderLayout.CENTER); locationPanel.add(locationButton, BorderLayout.EAST); this.add(locationPanel); locationButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setMultiSelectionEnabled(false); int status = fc.showOpenDialog(locationPanel); if (status == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); if (file != null) { locationName.setText(file.getPath()); cache = new BasicDataFileStore(file); updateRetrievablePanels(selector.getSector()); } } } }); // Select sector button JPanel sectorPanel = new JPanel(new GridLayout(0, 1, 0, 0)); sectorPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border)); selectButton = new JButton("Select sector"); selectButton.setToolTipText("Press Select then press and drag button 1 on globe"); selectButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { selectButtonActionPerformed(event); } }); sectorPanel.add(selectButton); sectorLabel = new JLabel("-"); sectorLabel.setPreferredSize(new Dimension(350, 16)); sectorLabel.setHorizontalAlignment(JLabel.CENTER); sectorPanel.add(sectorLabel); this.add(sectorPanel); // Retrievable list combo and start button JPanel retrievablesPanel = new JPanel(); retrievablesPanel.setLayout(new BoxLayout(retrievablesPanel, BoxLayout.Y_AXIS)); retrievablesPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border)); // RetrievablePanel list for (JPanel panel : this.retrievables) { retrievablesPanel.add(panel); } this.add(retrievablesPanel); // Start button JPanel startPanel = new JPanel(new GridLayout(0, 1, 0, 0)); startPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border)); startButton = new JButton("Start download"); startButton.setEnabled(false); startButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { startButtonActionPerformed(event); } }); startPanel.add(startButton); this.add(startPanel); // Download monitor panel monitorPanel = new JPanel(); monitorPanel.setLayout(new BoxLayout(monitorPanel, BoxLayout.Y_AXIS)); monitorPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border)); // this.add(monitorPanel); // Put the monitor panel in a scroll pane. JPanel dummyPanel = new JPanel(new BorderLayout()); dummyPanel.add(monitorPanel, BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(dummyPanel); scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); scrollPane.setPreferredSize(new Dimension(350, 200)); this.add(scrollPane); }
private void init() { input = new JTextField[nInputs]; double[] rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; rowWeights[nInputs + 2] = 1.0; GridBagLayout gbl_functionPanel = new GridBagLayout(); gbl_functionPanel.columnWidths = new int[] {5, 0, 50, 50, 30, 25, 5, 0}; gbl_functionPanel.rowHeights = new int[] {10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10}; gbl_functionPanel.columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; gbl_functionPanel.rowWeights = rowWeights; this.setLayout(gbl_functionPanel); // Function input field. for (int i = 0; i < nInputs; i++) { // Creation. input[i] = new JTextField(); GridBagConstraints gbc_stdFuncInput = new GridBagConstraints(); gbc_stdFuncInput.gridwidth = 4; gbc_stdFuncInput.insets = new Insets(0, 0, 5, 5); gbc_stdFuncInput.fill = GridBagConstraints.HORIZONTAL; gbc_stdFuncInput.anchor = GridBagConstraints.NORTH; gbc_stdFuncInput.gridx = 2; gbc_stdFuncInput.gridy = i + 1; // Setup. GuiUtil.setupUndoListener(input[i]); setupInputListeners(input[i]); this.add(input[i], gbc_stdFuncInput); } // Labels for the input fields String[] labelNames = labelNames(); for (int i = 0; i < labelNames.length; i++) { GridBagConstraints gbc_FuncLabel = new GridBagConstraints(); gbc_FuncLabel.gridwidth = 1; gbc_FuncLabel.insets = new Insets(0, 0, 5, 5); gbc_FuncLabel.fill = GridBagConstraints.HORIZONTAL; gbc_FuncLabel.anchor = GridBagConstraints.CENTER; gbc_FuncLabel.gridx = 1; gbc_FuncLabel.gridy = i + 1; JLabel label = new JLabel(labelNames[i]); this.add(label, gbc_FuncLabel); } // OptionPanel. mainOP = new JPanel(); mainOP.setBorder(BorderFactory.createEtchedBorder()); GridBagConstraints gbc_mainOP = new GridBagConstraints(); gbc_mainOP.fill = GridBagConstraints.BOTH; gbc_mainOP.gridwidth = 5; gbc_mainOP.insets = new Insets(0, 0, 5, 5); gbc_mainOP.gridx = 1; gbc_mainOP.gridy = nInputs + 1; this.add(mainOP, gbc_mainOP); gridOP = getGridOptionPanel(); gridOP.addFunctionListener(createGridOptionPanelListener()); apperanceOP = new AppearanceOptionPanel(colorList, map); mainOP.setLayout(new BoxLayout(mainOP, BoxLayout.Y_AXIS)); mainOP.add((Component) gridOP); mainOP.add(apperanceOP); // The standard function list outerFuncTab = new JPanel(); funcPanelWrapper = new JScrollPane(outerFuncTab); funcPanelWrapper.setBorder(BorderFactory.createEtchedBorder()); funcPanelWrapper.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); funcPanelWrapper.setMinimumSize(new Dimension(310, 500)); GridBagConstraints gbc_funcPanelWrapper = new GridBagConstraints(); gbc_funcPanelWrapper.fill = GridBagConstraints.BOTH; gbc_funcPanelWrapper.gridwidth = 5; gbc_funcPanelWrapper.insets = new Insets(0, 0, 5, 5); gbc_funcPanelWrapper.gridx = 1; gbc_funcPanelWrapper.gridy = nInputs + 2; ; this.add(funcPanelWrapper, gbc_funcPanelWrapper); GridBagLayout gbl_stdFuncPanel = new GridBagLayout(); gbl_stdFuncPanel.columnWidths = new int[] {0, 0}; gbl_stdFuncPanel.rowHeights = new int[] {0, 0}; gbl_stdFuncPanel.columnWeights = new double[] {1.0, Double.MIN_VALUE}; gbl_stdFuncPanel.rowWeights = new double[] {1.0, Double.MIN_VALUE}; outerFuncTab.setLayout(gbl_stdFuncPanel); innerFuncTab = new JPanel(); GridBagConstraints gbc_innerFuncPanel = new GridBagConstraints(); gbc_innerFuncPanel.anchor = GridBagConstraints.NORTH; gbc_innerFuncPanel.fill = GridBagConstraints.HORIZONTAL; gbc_innerFuncPanel.gridx = 0; gbc_innerFuncPanel.gridy = 0; outerFuncTab.add(innerFuncTab, gbc_innerFuncPanel); innerFuncTab.setLayout(new BoxLayout(innerFuncTab, BoxLayout.Y_AXIS)); }
private void jbInit() throws Exception { border1 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151)); border2 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151)); border3 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178)); titledBorder1 = new TitledBorder(border3, "Subject"); border4 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178)); titledBorder2 = new TitledBorder(border4, "Message"); border5 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178)); titledBorder3 = new TitledBorder(border5, "Subject"); border6 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151)); titledBorder4 = new TitledBorder(border6, "Message"); border7 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151)); titledBorder5 = new TitledBorder(border7, "Messages"); border8 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151)); titledBorder6 = new TitledBorder(border8, "Online Users"); border9 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178)); titledBorder7 = new TitledBorder(border9, "Send Message"); this.getContentPane().setLayout(borderLayout1); jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT); jSplitPane1.setBorder(border1); jSplitPane1.setLastDividerLocation(250); jSplitPane1.setResizeWeight(1.0); jLabelServer.setRequestFocusEnabled(true); jLabelServer.setText("Server"); jLabelUserId.setText("User Id"); jTextFieldServer.setPreferredSize(new Dimension(75, 20)); jTextFieldServer.setText(""); jTextFieldUser.setPreferredSize(new Dimension(75, 20)); jTextFieldUser.setText(""); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setJMenuBar(jMenuBarMain); this.setTitle("Message Client"); jLabeltargetUser.setText("Target"); jTextFieldTargetUser.setPreferredSize(new Dimension(75, 20)); jTextFieldTargetUser.setText(""); jPanelSendMessages.setBorder(border2); jPanelSendMessages.setMaximumSize(new Dimension(32767, 32767)); jPanelSendMessages.setOpaque(false); jPanelSendMessages.setPreferredSize(new Dimension(96, 107)); jPanelSendMessages.setRequestFocusEnabled(true); jPanelSendMessages.setToolTipText(""); jPanelSendMessages.setLayout(verticalFlowLayout1); jTextFieldSendSubject.setBorder(titledBorder3); jTextFieldSendSubject.setText(""); jTextFieldSendSubject.addKeyListener(new Client_jTextFieldSendSubject_keyAdapter(this)); jSplitPane2.setOrientation(JSplitPane.HORIZONTAL_SPLIT); jScrollPane1.setBorder(titledBorder5); jScrollPane2.setBorder(titledBorder6); jToggleButtonRegister.setText("Register"); jToggleButtonRegister.addActionListener(new Client_jToggleButtonRegister_actionAdapter(this)); jButtonMultiConnect.setText("Multi-Connect"); jButtonMultiConnect.addActionListener(new Client_jButtonMultiConnect_actionAdapter(this)); jListOnlineUsers.addMouseListener(new Client_jListOnlineUsers_mouseAdapter(this)); jToggleButtonConnect.setText("Connect"); jToggleButtonConnect.addActionListener(new Client_jToggleButtonConnect_actionAdapter(this)); jTextPaneDisplayMessages.setEditable(false); jTextPaneDisplayMessages.addMouseListener( new Client_jTextPaneDisplayMessages_mouseAdapter(this)); jTextFieldSendMessages.setBorder(titledBorder7); jTextFieldSendMessages.setToolTipText(""); jTextFieldSendMessages.addKeyListener(new Client_jTextFieldSendMessages_keyAdapter(this)); jButtonMessageStresser.setText("Msg Stresser"); jButtonMessageStresser.addActionListener( new Client_jToggleButtonMessageStresser_actionAdapter(this)); jMenuItemClearMessages.setText("Clear Messages"); jMenuItemClearMessages.addActionListener(new Client_jMenuItemClearMessages_actionAdapter(this)); jMenuServer.setText("Server"); jMenuItemServerConnect.setText("Connect"); jMenuItemServerConnect.addActionListener(new Client_jMenuItemServerConnect_actionAdapter(this)); jMenuItemServerDisconnect.setText("Disconnect"); jMenuItemServerDisconnect.addActionListener( new Client_jMenuItemServerDisconnect_actionAdapter(this)); jMenuOptions.setText("Options"); jMenuTest.setText("Test"); jMenuItemOptionsRegister.setText("Register"); jMenuItemOptionsRegister.addActionListener( new Client_jMenuItemOptionsRegister_actionAdapter(this)); jMenuItemOptionsDeregister.setText("Deregister"); jMenuItemOptionsDeregister.addActionListener( new Client_jMenuItemOptionsDeregister_actionAdapter(this)); jMenuItemOptionsEavesdrop.setText("Eavesdrop"); jMenuItemOptionsEavesdrop.addActionListener( new Client_jMenuItemOptionsEavesdrop_actionAdapter(this)); jMenuItemOptionsUneavesdrop.setText("Uneavesdrop"); jMenuItemOptionsUneavesdrop.addActionListener( new Client_jMenuItemOptionsUneavesdrop_actionAdapter(this)); jMenuItemTestMulticonnect.setText("Multiconnect"); jMenuItemTestMulticonnect.addActionListener( new Client_jMenuItemTestMulticonnect_actionAdapter(this)); jMenuItemTestMessageStresser.setText("Message Stresser"); jMenuItemTestMessageStresser.addActionListener( new Client_jMenuItemTestMessageStresser_actionAdapter(this)); jMenuItemTestMultidisconnect.setText("Multidisconnect"); jMenuItemTestMultidisconnect.addActionListener( new Client_jMenuItemTestMultidisconnect_actionAdapter(this)); jMenuItemOptionsGlobalEavesdrop.setText("Global Eavesdrop"); jMenuItemOptionsGlobalEavesdrop.addActionListener( new Client_jMenuItemOptionsGlobalEavesdrop_actionAdapter(this)); jMenuItemOptionsGlobalUneavesdrop.setEnabled(false); jMenuItemOptionsGlobalUneavesdrop.setText("Global Uneavesdrop"); jMenuItemOptionsGlobalUneavesdrop.addActionListener( new Client_jMenuItemOptionsGlobalUneavesdrop_actionAdapter(this)); jLabelPwd.setText("Pwd"); jPasswordFieldPwd.setMinimumSize(new Dimension(11, 20)); jPasswordFieldPwd.setPreferredSize(new Dimension(75, 20)); jPasswordFieldPwd.setText(""); jMenuItemScheduleCommand.setText("Schedule Command"); jMenuItemScheduleCommand.addActionListener( new Client_jMenuItemScheduleCommand_actionAdapter(this)); jMenuItemEditScheduledCommands.setText("Edit Scheduled Commands"); jMenuItemEditScheduledCommands.addActionListener( new Client_jMenuItemEditScheduledCommands_actionAdapter(this)); jPanelSendMessages.add(jTextFieldSendSubject, null); jPanelSendMessages.add(jTextFieldSendMessages, null); jSplitPane1.add(jSplitPane2, JSplitPane.TOP); jSplitPane2.add(jScrollPane1, JSplitPane.TOP); jScrollPane1.getViewport().add(jTextPaneDisplayMessages, null); jSplitPane2.add(jScrollPane2, JSplitPane.BOTTOM); jScrollPane2.getViewport().add(jListOnlineUsers, null); this.getContentPane().add(jSplitPane1, BorderLayout.CENTER); jSplitPane1.add(jPanelSendMessages, JSplitPane.BOTTOM); this.getContentPane().add(jPanel1, BorderLayout.NORTH); jPanel1.add(jLabelServer, null); jPanel1.add(jTextFieldServer, null); jPanel1.add(jLabelUserId, null); jPanel1.add(jTextFieldUser, null); jPanel1.add(jLabelPwd, null); jPanel1.add(jPasswordFieldPwd, null); jPanel1.add(jLabeltargetUser, null); jPanel1.add(jTextFieldTargetUser, null); jPanel1.add(jToggleButtonConnect, null); jPanel1.add(jToggleButtonRegister, null); jPanel1.add(jButtonMultiConnect, null); jPanel1.add(jButtonMessageStresser, null); jPopupMenuMessageArea.add(jMenuItemClearMessages); jMenuBarMain.add(jMenuServer); jMenuBarMain.add(jMenuOptions); jMenuBarMain.add(jMenuTest); jMenuServer.add(jMenuItemServerConnect); jMenuServer.add(jMenuItemServerDisconnect); jMenuOptions.add(jMenuItemOptionsRegister); jMenuOptions.add(jMenuItemOptionsDeregister); jMenuOptions.add(jMenuItemOptionsEavesdrop); jMenuOptions.add(jMenuItemOptionsUneavesdrop); jMenuOptions.add(jMenuItemOptionsGlobalEavesdrop); jMenuOptions.add(jMenuItemOptionsGlobalUneavesdrop); jMenuTest.add(jMenuItemTestMulticonnect); jMenuTest.add(jMenuItemTestMultidisconnect); jMenuTest.add(jMenuItemTestMessageStresser); jMenuTest.add(jMenuItemScheduleCommand); jMenuTest.add(jMenuItemEditScheduledCommands); jSplitPane1.setDividerLocation(200); jSplitPane2.setDividerLocation(600); jListOnlineUsers.setCellRenderer(new OnlineListCellRenderer()); jListOnlineUsers.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); jMenuItemTestMulticonnect.setEnabled(true); jMenuItemTestMultidisconnect.setEnabled(false); jMenuItemServerConnect.setEnabled(true); jMenuItemServerDisconnect.setEnabled(false); jMenuItemOptionsRegister.setEnabled(true); jMenuItemOptionsDeregister.setEnabled(false); }
public OrderTrans2() { super(windowTitle); int i; int currentPanel; // Value to specify which is the current panel in the vector JPanel subPanel = new JPanel(); // value used when adding sliders to the frame Runtime program = Runtime.getRuntime(); Container content = getContentPane(); createSliderVector(); createPanelVector(); getCodeSwapString(); /** Set code-swap strings' value. */ /** Get current OS of the system. */ if (System.getProperty("os.name").startsWith("Windows")) isWindows = true; else isWindows = false; /** Add the radio buttons to the group */ radioGrp.add(firstBox); radioGrp.add(secondBox); /** Set interactive buttons for the user interface */ JButton exeButton = new JButton("Execute"); exeButton.setToolTipText("Re-execute the program"); JButton resetButton = new JButton("Reset"); resetButton.setToolTipText("Reset Value"); JButton exitButton = new JButton("Exit"); exitButton.setToolTipText("Exit the Program"); // Create the main panel that contains everything. JPanel mainPanel = new JPanel(); // Create the panel that contains the sliders JPanel subPanel1 = new JPanel(); // Create the panel that contains the checkboxes JPanel subPanel2 = new JPanel(); // Create the panel that contains the buttons JPanel subPanel3 = new JPanel(); // JScrollPane scrollPane = new JScrollPane(); // main text pane with scroll bars content.add(mainPanel, BorderLayout.SOUTH); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); content.add(scrollPane, BorderLayout.CENTER); scrollPane.setBorder(BorderFactory.createLoweredBevelBorder()); scrollPane.getViewport().add(textPane); mainPanel.add(subPanel1); mainPanel.add(subPanel2); mainPanel.add(subPanel3); subPanel1.setLayout(new GridLayout(0, 1)); /** Add subPanel elements to the subPanel1, each would be a row of sliders */ for (i = 0; i < ROWS; i++) subPanel1.add((JPanel) vSubPanel.elementAt(i)); /** Set the first element in the Panel Vector as the current subPanel. */ currentPanel = 0; subPanel = (JPanel) vSubPanel.elementAt(currentPanel); /** Allocate sliders to the sub-panels. */ for (i = 0; i < COMPONENTS; i++) { PSlider slider = (PSlider) vSlider.elementAt(i); if (slider.getResideValue() == 'n') { currentPanel += 1; subPanel = (JPanel) vSubPanel.elementAt(currentPanel); } subPanel.add((PSlider) vSlider.elementAt(i)); } /** Set and view the source code on the frame */ textPane.setEditable(false); textPane.setContentType("text/html; charset=EUC-JP"); subPanel2.setLayout(new GridLayout(0, 2)); subPanel2.add(firstBox); subPanel2.add(secondBox); subPanel3.setLayout(new GridLayout(0, 3)); subPanel3.add(exeButton); exeButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { doExeCommand(); } }); subPanel3.add(resetButton); resetButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { doResetCommand(); } }); subPanel3.add(exitButton); exitButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { doExitCommand(); } }); /** Run the illustrated program */ try { pid = program.exec(cmd); if (isWindows == false) { Process pid2 = null; pid2 = program.exec("getpid " + cmd.substring(4)); } } catch (IOException ie) { System.err.println("Couldn't run " + ie); // System.exit(-1);; } /** Set the initial status for the window */ addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { File fp = new File(dataFile); doResetCommand(); boolean delete = fp.delete(); pid.destroy(); } }); doExeCommand(); setSize(WIDTH, HEIGHT); setLocation(500, 0); setVisible(true); }
public void createGUI() { setLayout(new BorderLayout()); toolBar = new JToolBar("options", JToolBar.HORIZONTAL); toolBar.setFloatable(false); toolBar.setOpaque(true); toolBar.setBackground(new Color(154, 12, 12)); toolBar.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); selectAllCB = new JCheckBox("Select All"); selectAllCB.setVisible(false); selectAllCB.setForeground(Color.white); selectAllCB.addActionListener(this); refreshBut = new JButton(new ImageIcon(this.getClass().getResource("/images/reloadIcon.png"))); refreshBut.setVisible(false); refreshBut.setToolTipText("Refresh"); refreshBut.setForeground(new Color(20, 88, 49)); refreshBut.addActionListener(this); backBut = new JButton(new ImageIcon(this.getClass().getResource("/images/backIcon.png"))); backBut.setVisible(false); backBut.setToolTipText("Back"); backBut.setForeground(new Color(20, 88, 49)); backBut.addActionListener(this); deleteBut = new JButton(new ImageIcon(this.getClass().getResource("/images/trashIcon.png"))); deleteBut.setToolTipText("Delete"); deleteBut.setForeground(Color.red); deleteBut.setVisible(false); deleteBut.addActionListener(this); deleteBut.setBackground(Color.red); restoreBut = new JButton(new ImageIcon(this.getClass().getResource("/images/restoreIcon.png"))); restoreBut.setToolTipText("Restore"); restoreBut.setForeground(Color.blue); restoreBut.setVisible(false); restoreBut.addActionListener(this); toolBar.addSeparator(new Dimension(10, 5)); toolBar.add(selectAllCB); toolBar.add(backBut); toolBar.add(refreshBut); toolBar.add(deleteBut); toolBar.add(restoreBut); add(toolBar, "North"); JPanel centPan = new JPanel(new GridBagLayout()); centPan.setBackground(new Color(52, 86, 70)); JLabel label = new JLabel("Select A Category From Left Pane"); label.setFont(new Font("arial", Font.BOLD, 35)); label.setForeground(Color.yellow); centPan.add(label); contentPan = new JScrollPane(centPan); contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); add(contentPan, "Center"); contentPan.repaint(); db = new Database(); // inboxSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id // desc"); // sentmailSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id // desc"); // draftSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id // desc"); // outboxSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id // desc"); // trashSet = db.getData("SELECT * FROM messages,trash WHERE messages.tag='trash' and // messages.msg_id=trash.msg_id ORDER BY deleted_at desc"); }
public BoxOnTable() { super(windowTitle); int i; Runtime program = Runtime.getRuntime(); Container content = getContentPane(); /** Get current OS of the system. */ if (System.getProperty("os.name").startsWith("Windows")) isWindows = true; else isWindows = false; /** Set interactive buttons for the user interface */ JButton exitButton = new JButton("Exit"); exitButton.setToolTipText("Exit the Program"); JPanel mainPanel = new JPanel(); content.add(mainPanel, BorderLayout.SOUTH); mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); content.add(scrollPane, BorderLayout.CENTER); scrollPane.setBorder(BorderFactory.createLoweredBevelBorder()); scrollPane.getViewport().add(textPane); mainPanel.add(exitButton, BorderLayout.CENTER); /** Set and view the source code on the frame */ textPane.setEditable(false); textPane.setContentType("text/html; charset=EUC-JP"); try { URL url = new URL("file:" + exampleSource); textPane.setPage(url); } catch (IOException ie) { System.err.println("Error in opening html source file " + ie); System.exit(-1); } exitButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { doExitCommand(); } }); /** Run the illustrated program */ try { pid = program.exec(cmd); } catch (IOException ie) { System.err.println("Couldn't run " + ie); System.exit(-1); } /** Set the initial status for the window */ addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { pid.destroy(); } }); setSize(WIDTH, HEIGHT); setLocation(500, 0); setVisible(true); }
public static void main() { // Main frame = new JFrame("Java Playground"); frame.setSize(640, 480); // Make sure the divider is properly resized frame.addComponentListener( new ComponentAdapter() { public void componentResized(ComponentEvent c) { splitter.setDividerLocation(.8); } }); // Make sure the JVM is reset on close frame.addWindowListener( new WindowAdapter() { public void windowClosed(WindowEvent w) { new FrameAction().kill(); } }); // Setting up the keybinding // Ctrl+k or Cmd+k -> compile bind(KeyEvent.VK_K); // Ctrl+e or Cmd+e -> console bind(KeyEvent.VK_E); // Save, New file, Open file, Print. // Currently UNUSED until I figure out how normal java files and playground files will // interface. bind(KeyEvent.VK_S); bind(KeyEvent.VK_N); bind(KeyEvent.VK_O); bind(KeyEvent.VK_P); // Binds the keys to the action defined in the FrameAction class. frame.getRootPane().getActionMap().put("console", new FrameAction()); // The main panel for typing code in. text = new JTextPane(); textScroll = new JScrollPane(text); textScroll.setBorder(null); textScroll.setPreferredSize(new Dimension(640, 480)); // Document with syntax highlighting. Currently unfinished. doc = text.getStyledDocument(); doc.addDocumentListener( new DocumentListener() { public void changedUpdate(DocumentEvent d) {} public void insertUpdate(DocumentEvent d) {} public void removeUpdate(DocumentEvent d) {} }); ((AbstractDocument) doc).setDocumentFilter(new NewLineFilter()); // The output log; a combination compiler warning/error/runtime error/output log. outputText = new JTextPane(); outputScroll = new JScrollPane(outputText); outputScroll.setBorder(null); // "Constant" for the error font error = new SimpleAttributeSet(); error.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.TRUE); error.addAttribute(StyleConstants.Foreground, Color.RED); // "Constant" for the warning message font warning = new SimpleAttributeSet(); warning.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.TRUE); warning.addAttribute(StyleConstants.Foreground, Color.PINK); // "Constant" for the debugger error font progErr = new SimpleAttributeSet(); progErr.addAttribute(StyleConstants.Foreground, Color.BLUE); // Print streams to redirect System.out and System.err. out = new TextOutputStream(outputText, null); err = new TextOutputStream(outputText, error); System.setOut(new PrintStream(out)); System.setErr(new PrintStream(err)); // Sets up the output log outputText.setEditable(false); outputScroll.setVisible(true); // File input/output setup chooser = new JFileChooser(); // Setting up miscellaneous stuff compiler = ToolProvider.getSystemJavaCompiler(); JVMrunning = false; redirectErr = null; redirectOut = null; redirectIn = null; // Sets up the splitter pane and opens the program up splitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT, textScroll, outputScroll); consoleDisplayed = false; splitter.remove(outputScroll); // Initially hides terminal until it is needed splitter.setOneTouchExpandable(true); frame.add(splitter); frame.setVisible(true); // Sets the divider to the proper one, for debugging // splitter.setDividerLocation(.8); }
void jbInit() throws Exception { titledBorder1 = new TitledBorder( BorderFactory.createLineBorder(new Color(153, 153, 153), 2), "Assembler messages"); this.getContentPane().setLayout(borderLayout1); this.setIconifiable(true); this.setMaximizable(true); this.setResizable(true); this.setTitle("EDIT"); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); splitPane.setDividerLocation(470); sourceArea.setFont(new java.awt.Font("Monospaced", 0, 12)); controlPanel.setLayout(gridBagLayout1); controlPanel.setBorder(BorderFactory.createLoweredBevelBorder()); positionPanel.setLayout(gridBagLayout2); fileLabel.setText("Source file:"); fileText.setEditable(false); browseButton.setSelected(false); browseButton.setText("Browse ..."); assembleButton.setEnabled(false); assembleButton.setText("Assemble file"); saveButton.setEnabled(false); saveButton.setText("Save file"); lineLabel.setText("Line:"); lineText.setMinimumSize(new Dimension(50, 20)); lineText.setPreferredSize(new Dimension(50, 20)); lineText.setEditable(false); columnLabel.setText("Column:"); columnText.setMinimumSize(new Dimension(41, 20)); columnText.setPreferredSize(new Dimension(41, 20)); columnText.setEditable(false); columnText.setText(""); messageScrollPane.setBorder(titledBorder1); messageScrollPane.setMinimumSize(new Dimension(33, 61)); messageScrollPane.setPreferredSize(new Dimension(60, 90)); optionsButton.setEnabled(false); optionsButton.setText("Assembler options ..."); messageScrollPane.getViewport().add(messageList, null); messageList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); this.getContentPane().add(splitPane, BorderLayout.CENTER); splitPane.add(textScrollPane, JSplitPane.TOP); splitPane.add(controlPanel, JSplitPane.BOTTOM); textScrollPane.getViewport().add(sourceArea, null); controlPanel.add( fileLabel, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); controlPanel.add( fileText, new GridBagConstraints( 1, 0, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 0), 0, 0)); controlPanel.add( browseButton, new GridBagConstraints( 4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); controlPanel.add( optionsButton, new GridBagConstraints( 2, 1, 1, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); controlPanel.add( assembleButton, new GridBagConstraints( 3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); controlPanel.add( saveButton, new GridBagConstraints( 4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); controlPanel.add( positionPanel, new GridBagConstraints( 0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); positionPanel.add( lineLabel, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); positionPanel.add( lineText, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0)); positionPanel.add( columnLabel, new GridBagConstraints( 2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0)); positionPanel.add( columnText, new GridBagConstraints( 3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0)); controlPanel.add( messageScrollPane, new GridBagConstraints( 0, 2, 5, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); }
/** Create the window UI. */ private void buildUI() { Container cPane = getContentPane(); cPane.setLayout(new GridBagLayout()); GridBagConstraints c; JLabel label; String msg; JTextField field; int row = 0; label = new JLabel(sTimeStampFormat.format(mInvite.getTimestamp())); label.setFont(new Font("SansSerif", Font.PLAIN, 9)); c = new GridBagConstraints(); c.gridx = 0; c.gridy = row++; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.EAST; c.insets = new Insets(SPACING, MARGIN, 0, MARGIN); cPane.add(label, c); msg = mInvite.getPlayerJID(); msg = StringUtils.parseBareAddress(msg); field = new JTextField(msg); field.setEditable(false); field.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4)); c = new GridBagConstraints(); c.gridx = 0; c.gridy = row++; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(SPACING, MARGIN, 0, MARGIN); cPane.add(field, c); String gamename = mInvite.getGameName(); if (gamename != null) gamename = gamename.trim(); if (gamename != null && !gamename.equals("")) msg = " " + localize("MessageInvitedOf"); else msg = " " + localize("MessageInvited"); label = new JLabel(msg); c = new GridBagConstraints(); c.gridx = 0; c.gridy = row++; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(SPACING, MARGIN, 0, MARGIN); cPane.add(label, c); if (gamename != null && !gamename.equals("")) { field = new JTextField(gamename); field.setEditable(false); field.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4)); c = new GridBagConstraints(); c.gridx = 0; c.gridy = row++; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(SPACING, MARGIN, 0, MARGIN); cPane.add(field, c); } String message = mInvite.getMessage(); if (message != null) message = message.trim(); if (message != null && !message.equals("")) { JTextArea textarea = new JTextArea(); textarea.setEditable(false); textarea.setRows(4); textarea.setLineWrap(true); textarea.setWrapStyleWord(true); textarea.setText(message); c = new GridBagConstraints(); c.gridx = 0; c.gridy = row++; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(GAP, MARGIN, 0, MARGIN); JScrollPane scroller = new JScrollPane(textarea); scroller.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4)); cPane.add(scroller, c); } label = new JLabel(localize("LabelNickname")); c = new GridBagConstraints(); c.gridx = 0; c.gridy = row; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(GAP, MARGIN, 0, MARGIN); cPane.add(label, c); mNicknameField = new JTextField(20); c = new GridBagConstraints(); c.gridx = 1; c.gridy = row++; c.weightx = 1; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(GAP, SPACING, 0, MARGIN); cPane.add(mNicknameField, c); // Add panel with Cancel and Create buttons JPanel buttonPanel = new JPanel(new GridBagLayout()); c = new GridBagConstraints(); c.gridx = 0; c.gridy = row++; c.gridwidth = GridBagConstraints.REMAINDER; c.insets = new Insets(GAP, MARGIN, MARGIN, MARGIN); c.anchor = GridBagConstraints.EAST; c.weightx = 1; cPane.add(buttonPanel, c); mAcceptButton = new JButton(localize("ButtonAccept")); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 0; c.insets = new Insets(0, 0, 0, 0); c.anchor = GridBagConstraints.EAST; buttonPanel.add(mAcceptButton, c); mChatButton = new JButton(localize("ButtonDeclineChat")); c = new GridBagConstraints(); c.gridx = 1; c.gridy = 0; c.insets = new Insets(0, SPACING, 0, 0); c.anchor = GridBagConstraints.EAST; buttonPanel.add(mChatButton, c); mDeclineButton = new JButton(localize("ButtonDecline")); c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.insets = new Insets(0, SPACING, 0, 0); c.anchor = GridBagConstraints.EAST; buttonPanel.add(mDeclineButton, c); }
/** Display a frame for browsing issues. */ private JPanel constructView() { // sort the original issues list final SortedList<Issue> issuesSortedList = new SortedList<Issue>(issuesEventList, null); // filter the sorted issues FilterList<Issue> filteredIssues = new FilterList<Issue>(issuesSortedList, filterPanel.getMatcherEditor()); SeparatorList<Issue> separatedIssues = new SeparatorList<Issue>( filteredIssues, GlazedLists.beanPropertyComparator(Issue.class, "subcomponent"), 0, Integer.MAX_VALUE); EventList<Issue> separatedIssuesProxyList = GlazedListsSwing.swingThreadProxyList(separatedIssues); // build the issues table issuesTableModel = GlazedListsSwing.eventTableModel(separatedIssuesProxyList, new IssueTableFormat()); final TableColumnModel issuesTableColumnModel = new EventTableColumnModel<TableColumn>(new BasicEventList<TableColumn>()); JSeparatorTable issuesJTable = new JSeparatorTable(issuesTableModel, issuesTableColumnModel); issuesJTable.setAutoCreateColumnsFromModel(true); issuesJTable.setSeparatorRenderer(new IssueSeparatorTableCell(separatedIssues)); issuesJTable.setSeparatorEditor(new IssueSeparatorTableCell(separatedIssues)); issuesSelectionModel = GlazedListsSwing.eventSelectionModel(separatedIssuesProxyList); issuesSelectionModel.setSelectionMode( ListSelection .MULTIPLE_INTERVAL_SELECTION_DEFENSIVE); // multi-selection best demos our awesome // selection management issuesSelectionModel.addListSelectionListener(new IssuesSelectionListener()); issuesJTable.setSelectionModel(issuesSelectionModel); issuesJTable.getColumnModel().getColumn(0).setPreferredWidth(150); issuesJTable.getColumnModel().getColumn(1).setPreferredWidth(400); issuesJTable.getColumnModel().getColumn(2).setPreferredWidth(300); issuesJTable.getColumnModel().getColumn(3).setPreferredWidth(300); issuesJTable.getColumnModel().getColumn(4).setPreferredWidth(250); issuesJTable.getColumnModel().getColumn(5).setPreferredWidth(300); issuesJTable.getColumnModel().getColumn(6).setPreferredWidth(300); issuesJTable.getColumnModel().getColumn(7).setPreferredWidth(1000); // turn off cell focus painting issuesJTable.setDefaultRenderer( String.class, new NoFocusRenderer(issuesJTable.getDefaultRenderer(String.class))); issuesJTable.setDefaultRenderer( Integer.class, new NoFocusRenderer(issuesJTable.getDefaultRenderer(Integer.class))); issuesJTable.setDefaultRenderer( Priority.class, new NoFocusRenderer(new PriorityTableCellRenderer())); LookAndFeelTweaks.tweakTable(issuesJTable); TableComparatorChooser.install( issuesJTable, issuesSortedList, TableComparatorChooser.MULTIPLE_COLUMN_KEYBOARD); JScrollPane issuesTableScrollPane = new JScrollPane( issuesJTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); issuesTableScrollPane.getViewport().setBackground(UIManager.getColor("EditorPane.background")); issuesTableScrollPane.setBorder(BorderFactory.createEmptyBorder()); issueDetails = new IssueDetailsComponent(filteredIssues); // projects EventList<Project> projects = Project.getProjects(); TransformedList<Project, Project> projectsProxyList = GlazedListsSwing.swingThreadProxyList(projects); // project select combobox DefaultEventComboBoxModel projectsComboModel = new DefaultEventComboBoxModel<Project>(projectsProxyList); JComboBox projectsCombo = new JComboBox(projectsComboModel); projectsCombo.setEditable(false); projectsCombo.setOpaque(false); projectsCombo.addItemListener(new ProjectChangeListener()); projectsComboModel.setSelectedItem(new Project(null, "Select a Java.net project...")); // build a label to display the number of issues in the issue table issueCounter = new IssueCounterLabel(filteredIssues); issueCounter.setHorizontalAlignment(SwingConstants.CENTER); issueCounter.setForeground(Color.WHITE); // throbber throbber = new JLabel(THROBBER_STATIC); throbber.setHorizontalAlignment(SwingConstants.RIGHT); // header bar JPanel iconBar = new GradientPanel(GLAZED_LISTS_MEDIUM_BROWN, GLAZED_LISTS_DARK_BROWN, true); iconBar.setLayout(new GridLayout(1, 3)); iconBar.add(projectsCombo); iconBar.add(issueCounter); iconBar.add(throbber); iconBar.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); // assemble all data components on a common panel JPanel dataPanel = new JPanel(); JComponent issueDetailsComponent = issueDetails; dataPanel.setLayout(new GridLayout(2, 1)); dataPanel.add(issuesTableScrollPane); dataPanel.add(issueDetailsComponent); // draw lines between components JComponent filtersPanel = filterPanel.getComponent(); filtersPanel.setBorder(BorderFactory.createEmptyBorder()); // filtersPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, // IssuesBrowser.GLAZED_LISTS_DARK_BROWN)); issueDetailsComponent.setBorder( BorderFactory.createMatteBorder(1, 0, 0, 0, GLAZED_LISTS_DARK_BROWN)); // the outermost panel to layout the icon bar with the other panels final JPanel mainPanel = new JPanel(new GridBagLayout()); mainPanel.add( iconBar, new GridBagConstraints( 0, 0, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mainPanel.add( filtersPanel, new GridBagConstraints( 0, 1, 1, 1, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mainPanel.add( Box.createHorizontalStrut(240), new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mainPanel.add( dataPanel, new GridBagConstraints( 1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); return mainPanel; }
public InterpreterFrame() { super("Simple Lisp Interpreter"); // Create the menu menubar = buildMenuBar(); setJMenuBar(menubar); // Create the toolbar toolbar = buildToolBar(); // disable cut and copy actions cutAction.setEnabled(false); copyAction.setEnabled(false); // Setup text area for editing source code // and setup document listener so interpreter // is notified when current file modified and // when the cursor is moved. textView = buildEditor(); textView.getDocument().addDocumentListener(this); textView.addCaretListener(this); // set default key bindings bindKeyToCommand("ctrl C", "(buffer-copy)"); bindKeyToCommand("ctrl X", "(buffer-cut)"); bindKeyToCommand("ctrl V", "(buffer-paste)"); bindKeyToCommand("ctrl E", "(buffer-eval)"); bindKeyToCommand("ctrl O", "(file-open)"); bindKeyToCommand("ctrl S", "(file-save)"); bindKeyToCommand("ctrl Q", "(exit)"); // Give text view scrolling capability Border border = BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(3, 3, 3, 3), BorderFactory.createLineBorder(Color.gray)); JScrollPane topSplit = addScrollers(textView); topSplit.setBorder(border); // Create tabbed pane for console/problems consoleView = makeConsoleArea(10, 50, true); problemsView = makeConsoleArea(10, 50, false); tabbedPane = buildProblemsConsole(); // Plug the editor and problems/console together // using a split pane. This allows one to change // their relative size using the split-bar in // between them. splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topSplit, tabbedPane); // Create status bar statusView = new JLabel(" Status"); lineNumberView = new JLabel("0:0"); statusbar = buildStatusBar(); // Now, create the outer panel which holds // everything together outerpanel = new JPanel(); outerpanel.setLayout(new BorderLayout()); outerpanel.add(toolbar, BorderLayout.PAGE_START); outerpanel.add(splitPane, BorderLayout.CENTER); outerpanel.add(statusbar, BorderLayout.SOUTH); getContentPane().add(outerpanel); // tell frame to fire a WindowsListener event // but not to close when "x" button clicked. setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(this); // set minimised icon to use setIconImage(makeImageIcon("spi.png").getImage()); // setup additional internal functions InternalFunctions.setup_internals(interpreter, this); // set default window size Component top = splitPane.getTopComponent(); Component bottom = splitPane.getBottomComponent(); top.setPreferredSize(new Dimension(100, 400)); bottom.setPreferredSize(new Dimension(100, 200)); pack(); // load + run user configuration file (if there is one) String homedir = System.getProperty("user.home"); try { interpreter.load(homedir + "/.simplelisp"); } catch (FileNotFoundException e) { // do nothing if file does not exist! System.out.println("Didn't find \"" + homedir + "/.simplelisp\""); } textView.grabFocus(); setVisible(true); // redirect all I/O to problems/console redirectIO(); // start highlighter thread highlighter = new DisplayThread(250); highlighter.setDaemon(true); highlighter.start(); }
public void setContent(String cat) { cat = cat.trim(); selectAllCB.setVisible(false); selectAllCB.setSelected(false); deleteBut.setVisible(false); restoreBut.setVisible(false); refreshBut.setVisible(true); Object columns[] = null; int count = 0; switch (cat) { case "Inbox": columns = new Object[] {"", "From", "Date", "Subject", "Content"}; count = Database.getCount("Inbox"); workingSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id desc"); ; break; case "SentMail": columns = new Object[] {"", "To", "Date", "Subject", "Content"}; count = Database.getCount("Sentmail"); workingSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id desc"); break; case "Draft": columns = new Object[] {"", "To", "Date", "Subject", "Content"}; count = Database.getCount("Draft"); workingSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id desc"); break; case "Outbox": columns = new Object[] {"", "To", "Date", "Subject", "Content"}; count = Database.getCount("Outbox"); workingSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id desc"); break; case "Trash": // restoreBut.setVisible(true); columns = new Object[] {"", "To/From", "Date", "Subject", "Content"}; count = Database.getCount("Trash"); workingSet = db.getData( "SELECT * FROM messages,trash WHERE messages.tag='trash' and messages.msg_id=trash.msg_id ORDER BY deleted_at desc"); break; default: System.out.println("in default case"); } if (count > 0) { selectAllCB.setVisible(true); rows = new Object[count][]; msgID = new int[count]; try { workingSet.beforeFirst(); for (int i = 0; i < count && workingSet.next(); i++) { msgID[i] = workingSet.getInt(1); rows[i] = new Object[] { false, workingSet.getString(2), workingSet.getDate(3), workingSet.getString(4), workingSet.getString(5) }; } } catch (SQLException sqlExc) { JOptionPane.showMessageDialog(null, sqlExc, "EXCEPTION", JOptionPane.ERROR_MESSAGE); sqlExc.printStackTrace(); } tableModel = new MyDefaultTableModel(rows, columns); table = new JTable(tableModel); table.getSelectionModel().addListSelectionListener(this); table.addMouseListener(this); table.getTableHeader().setOpaque(true); table.getTableHeader().setReorderingAllowed(false); // table.getTableHeader().setBackground(Color.blue); table.getTableHeader().setForeground(Color.blue); // table.setRowSelectionAllowed(false); // table.setColumnSelectionAllowed(false); table.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 14)); table.setRowHeight(20); table.setFillsViewportHeight(true); TableColumn column = null; for (int i = 0; i < 5; i++) { column = table.getColumnModel().getColumn(i); if (i == 0) { column.setPreferredWidth(6); } else if (i == 3) { column.setPreferredWidth(250); } else if (i == 4) { column.setPreferredWidth(450); } else { column.setPreferredWidth(40); } } table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); remove(contentPan); contentPan = new JScrollPane(table); contentPan.setBackground(Color.orange); contentPan.setOpaque(true); contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); add(contentPan, "Center"); Home.home.homeFrame.setVisible(true); } else { JPanel centPan = new JPanel(new GridBagLayout()); centPan.setBackground(new Color(52, 86, 70)); JLabel label = new JLabel("No Messages In This Category"); label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 22)); label.setForeground(Color.orange); centPan.add(label); remove(contentPan); contentPan = new JScrollPane(centPan); contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); add(contentPan, "Center"); contentPan.repaint(); } }
// initializes the internal component of the translator protected void jbInit() { this.getContentPane().setLayout(new GridBagLayout()); loadButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { loadButton_actionPerformed(e); } }); loadButton.setMaximumSize(new Dimension(39, 39)); loadButton.setMinimumSize(new Dimension(39, 39)); loadButton.setPreferredSize(new Dimension(39, 39)); loadButton.setSize(new Dimension(39, 39)); loadButton.setToolTipText("Load Source File"); loadButton.setIcon(loadIcon); saveButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { saveButton_actionPerformed(e); } }); saveButton.setMaximumSize(new Dimension(39, 39)); saveButton.setMinimumSize(new Dimension(39, 39)); saveButton.setPreferredSize(new Dimension(39, 39)); saveButton.setSize(new Dimension(39, 39)); saveButton.setToolTipText("Save Destination File"); saveButton.setIcon(saveIcon); singleStepButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { singleStepButton_actionPerformed(e); } }); singleStepButton.setMaximumSize(new Dimension(39, 39)); singleStepButton.setMinimumSize(new Dimension(39, 39)); singleStepButton.setPreferredSize(new Dimension(39, 39)); singleStepButton.setSize(new Dimension(39, 39)); singleStepButton.setToolTipText("Single Step"); singleStepButton.setIcon(singleStepIcon); ffwdButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { ffwdButton_actionPerformed(e); } }); ffwdButton.setMaximumSize(new Dimension(39, 39)); ffwdButton.setMinimumSize(new Dimension(39, 39)); ffwdButton.setPreferredSize(new Dimension(39, 39)); ffwdButton.setSize(new Dimension(39, 39)); ffwdButton.setToolTipText("Fast Forward"); ffwdButton.setIcon(ffwdIcon); rewindButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { rewindButton_actionPerformed(e); } }); rewindButton.setMaximumSize(new Dimension(39, 39)); rewindButton.setMinimumSize(new Dimension(39, 39)); rewindButton.setPreferredSize(new Dimension(39, 39)); rewindButton.setSize(new Dimension(39, 39)); rewindButton.setToolTipText("Rewind"); rewindButton.setIcon(rewindIcon); stopButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { stopButton_actionPerformed(e); } }); stopButton.setMaximumSize(new Dimension(39, 39)); stopButton.setMinimumSize(new Dimension(39, 39)); stopButton.setPreferredSize(new Dimension(39, 39)); stopButton.setSize(new Dimension(39, 39)); stopButton.setToolTipText("Stop"); stopButton.setIcon(stopIcon); fullTranslationButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { fullTranslationButton_actionPerformed(e); } }); fullTranslationButton.setMaximumSize(new Dimension(39, 39)); fullTranslationButton.setMinimumSize(new Dimension(39, 39)); fullTranslationButton.setPreferredSize(new Dimension(39, 39)); fullTranslationButton.setSize(new Dimension(39, 39)); fullTranslationButton.setToolTipText("Fast Translation"); fullTranslationButton.setIcon(fullTranslationIcon); messageLbl.setFont(Utilities.statusLineFont); messageLbl.setLineWrap(true); messageLbl.setEditable(false); messageLbl.setCursor(null); messageLbl.setOpaque(false); messageLbl.setFocusable(false); messageLblPane.setBorder(BorderFactory.createLoweredBevelBorder()); // messageLblPane.setBounds(new Rectangle(0, 672, TRANSLATOR_WIDTH - 8, 20)); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.ipadx = 0; c.ipady = 0; c.weightx = 1; c.weighty = 0; c.gridwidth = 3; c.anchor = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 2; this.getContentPane().add(messageLblPane, c); // arrowLabel.setBounds(new Rectangle(290, 324, 88, 71)); arrowLabel.setIcon(arrowIcon); // source.setVisibleRows(31); // destination.setVisibleRows(31); // source.setBounds(new Rectangle(35,100,source.getWidth(),source.getHeight())); // destination.setBounds(new Rectangle(375,100,destination.getWidth(),destination.getHeight())); c.fill = GridBagConstraints.BOTH; c.ipadx = 0; c.ipady = 0; c.weightx = 1; c.weighty = 1; c.gridwidth = 1; c.anchor = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 1; this.getContentPane().add(source, c); c.fill = GridBagConstraints.NONE; c.ipadx = 0; c.ipady = 0; c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.anchor = GridBagConstraints.CENTER; c.gridx = 1; c.gridy = 1; this.getContentPane().add(arrowLabel, c); c.fill = GridBagConstraints.BOTH; c.ipadx = 0; c.ipady = 0; c.weightx = 1; c.weighty = 1; c.gridwidth = 1; c.anchor = GridBagConstraints.CENTER; c.gridx = 2; c.gridy = 1; this.getContentPane().add(destination, c); // Adding the tool bar to this container. toolBar.setFloatable(false); toolBar.setLocation(0, 0); toolBar.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0)); toolBar.setBorder(BorderFactory.createEtchedBorder()); arrangeToolBar(); c.fill = GridBagConstraints.HORIZONTAL; c.ipadx = 0; c.ipady = 0; c.weightx = 1; c.weighty = 0; c.gridwidth = 3; c.anchor = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 0; this.getContentPane().add(toolBar, c); toolBar.revalidate(); toolBar.repaint(); repaint(); // Creating the menu bar arrangeMenu(); setJMenuBar(menuBar); // initializing the window size and visibility setDefaultCloseOperation(3); setSize(new Dimension(TRANSLATOR_WIDTH, TRANSLATOR_HEIGHT)); setVisible(true); }
public DOMTreeView(Document dom) { super("TreeWalkerView "); document = dom; // jtree UI setup jtree = new DOMTreeFull((Node) document); jtree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); // Listen for when the selection changes, call nodeSelected(node) jtree.addTreeSelectionListener( new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { TreePath path = (TreePath) e.getPath(); TreeNode treeNode = (TreeNode) path.getLastPathComponent(); if (jtree.getSelectionModel().isPathSelected(path)) nodeSelected(treeNode); } }); treeScroll = new JScrollPane(jtree); treeScroll.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("DOM Tree View"), BorderFactory.createEmptyBorder(4, 4, 4, 4))); JPanel urlPanel = new JPanel(); JLabel urlLabel = new JLabel("URL:"); urlTextField = new JTextField(50); urlTextField.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { Object source = evt.getSource(); if (source == urlTextField) { reloadJTree(urlTextField.getText()); } } }); urlPanel.add(urlLabel); urlPanel.add(urlTextField); JPanel selectedXPathPanel = new JPanel(); JLabel xpathLabel = new JLabel("XPath: "); selectedXPathTextField = new JTextField(50); selectedXPathTextField.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { Object source = evt.getSource(); if (source == selectedXPathTextField) { lookupByXPath(selectedXPathTextField.getText()); } } }); selectedXPathPanel.add(xpathLabel); selectedXPathPanel.add(selectedXPathTextField); JPanel lookupPanel = new JPanel(); JLabel lookupLabel = new JLabel("look up:"); lookupTextField = new JTextField(20); lookupTextField.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { Object source = evt.getSource(); if (source == lookupTextField) { lookup(lookupTextField.getText()); } } }); foundList = new JList(); foundList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); foundList.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { Object source = evt.getSource(); if (source == foundList) { FoundItem fi = (FoundItem) foundList.getSelectedValue(); if (fi == null) return; jtree.setSelectionPath(fi.treePath); jtree.scrollPathToVisible(fi.treePath); } } }); JScrollPane foundScroll = new JScrollPane(foundList); foundScroll.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Nodes found"), BorderFactory.createEmptyBorder(4, 4, 4, 4))); // foundScroll.set JPanel queryPanel = new JPanel(); queryPanel.add(lookupLabel); queryPanel.add(lookupTextField); lookupPanel.setLayout(new BorderLayout()); lookupPanel.add(queryPanel, BorderLayout.NORTH); lookupPanel.add(foundScroll, BorderLayout.CENTER); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treeScroll, lookupPanel); splitPane.setContinuousLayout(true); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(400); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); mainPanel.add(urlPanel, BorderLayout.NORTH); mainPanel.add(selectedXPathPanel, BorderLayout.SOUTH); mainPanel.add(splitPane, BorderLayout.CENTER); // mainPanel.add(treeScroll, BorderLayout.CENTER); // mainPanel.add(lookupPanel, BorderLayout.EAST); getContentPane().add(mainPanel); }
public DocumentationComponent( final DocumentationManager manager, final AnAction[] additionalActions) { myManager = manager; myIsEmpty = true; myIsShown = false; myEditorPane = new JEditorPane(UIUtil.HTML_MIME, "") { @Override public Dimension getPreferredScrollableViewportSize() { if (getWidth() == 0 || getHeight() == 0) { setSize(MAX_WIDTH, MAX_HEIGHT); } Insets ins = myEditorPane.getInsets(); View rootView = myEditorPane.getUI().getRootView(myEditorPane); rootView.setSize( MAX_WIDTH, MAX_HEIGHT); // Necessary! Without this line, size will not increase then you go // from small page to bigger one int prefHeight = (int) rootView.getPreferredSpan(View.Y_AXIS); prefHeight += ins.bottom + ins.top + myScrollPane.getHorizontalScrollBar().getMaximumSize().height; return new Dimension(MAX_WIDTH, Math.max(MIN_HEIGHT, Math.min(MAX_HEIGHT, prefHeight))); } { enableEvents(AWTEvent.KEY_EVENT_MASK); } @Override protected void processKeyEvent(KeyEvent e) { KeyStroke keyStroke = KeyStroke.getKeyStrokeForEvent(e); ActionListener listener = myKeyboardActions.get(keyStroke); if (listener != null) { listener.actionPerformed(new ActionEvent(DocumentationComponent.this, 0, "")); e.consume(); return; } super.processKeyEvent(e); } @Override protected void paintComponent(Graphics g) { GraphicsUtil.setupAntialiasing(g); super.paintComponent(g); } }; DataProvider helpDataProvider = new DataProvider() { @Override public Object getData(@NonNls String dataId) { return PlatformDataKeys.HELP_ID.is(dataId) ? DOCUMENTATION_TOPIC_ID : null; } }; myEditorPane.putClientProperty(DataManager.CLIENT_PROPERTY_DATA_PROVIDER, helpDataProvider); myText = ""; myEditorPane.setEditable(false); myEditorPane.setBackground(HintUtil.INFORMATION_COLOR); myEditorPane.setEditorKit(UIUtil.getHTMLEditorKit()); myScrollPane = new JBScrollPane(myEditorPane) { @Override protected void processMouseWheelEvent(MouseWheelEvent e) { if (!EditorSettingsExternalizable.getInstance().isWheelFontChangeEnabled() || !EditorUtil.isChangeFontSize(e)) { super.processMouseWheelEvent(e); return; } int change = Math.abs(e.getWheelRotation()); boolean increase = e.getWheelRotation() <= 0; EditorColorsManager colorsManager = EditorColorsManager.getInstance(); EditorColorsScheme scheme = colorsManager.getGlobalScheme(); FontSize newFontSize = scheme.getQuickDocFontSize(); for (; change > 0; change--) { if (increase) { newFontSize = newFontSize.larger(); } else { newFontSize = newFontSize.smaller(); } } if (newFontSize == scheme.getQuickDocFontSize()) { return; } scheme.setQuickDocFontSize(newFontSize); applyFontSize(); setFontSizeSliderSize(newFontSize); } }; myScrollPane.setBorder(null); myScrollPane.putClientProperty(DataManager.CLIENT_PROPERTY_DATA_PROVIDER, helpDataProvider); final MouseAdapter mouseAdapter = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { myManager.requestFocus(); myShowSettingsButton.hideSettings(); } }; myEditorPane.addMouseListener(mouseAdapter); Disposer.register( this, new Disposable() { @Override public void dispose() { myEditorPane.removeMouseListener(mouseAdapter); } }); final FocusAdapter focusAdapter = new FocusAdapter() { @Override public void focusLost(FocusEvent e) { Component previouslyFocused = WindowManagerEx.getInstanceEx() .getFocusedComponent(manager.getProject(getElement())); if (!(previouslyFocused == myEditorPane)) { if (myHint != null && !myHint.isDisposed()) myHint.cancel(); } } }; myEditorPane.addFocusListener(focusAdapter); Disposer.register( this, new Disposable() { @Override public void dispose() { myEditorPane.removeFocusListener(focusAdapter); } }); setLayout(new BorderLayout()); JLayeredPane layeredPane = new JBLayeredPane() { @Override public void doLayout() { final Rectangle r = getBounds(); for (Component component : getComponents()) { if (component instanceof JScrollPane) { component.setBounds(0, 0, r.width, r.height); } else { int insets = 2; Dimension d = component.getPreferredSize(); component.setBounds(r.width - d.width - insets, insets, d.width, d.height); } } } @Override public Dimension getPreferredSize() { Dimension editorPaneSize = myEditorPane.getPreferredScrollableViewportSize(); Dimension controlPanelSize = myControlPanel.getPreferredSize(); return new Dimension( Math.max(editorPaneSize.width, controlPanelSize.width), editorPaneSize.height + controlPanelSize.height); } }; layeredPane.add(myScrollPane); layeredPane.setLayer(myScrollPane, 0); mySettingsPanel = createSettingsPanel(); layeredPane.add(mySettingsPanel); layeredPane.setLayer(mySettingsPanel, JLayeredPane.POPUP_LAYER); add(layeredPane, BorderLayout.CENTER); setOpaque(true); myScrollPane.setViewportBorder(JBScrollPane.createIndentBorder()); final DefaultActionGroup actions = new DefaultActionGroup(); final BackAction back = new BackAction(); final ForwardAction forward = new ForwardAction(); actions.add(back); actions.add(forward); actions.add(myExternalDocAction = new ExternalDocAction()); back.registerCustomShortcutSet(CustomShortcutSet.fromString("LEFT"), this); forward.registerCustomShortcutSet(CustomShortcutSet.fromString("RIGHT"), this); myExternalDocAction.registerCustomShortcutSet(CustomShortcutSet.fromString("UP"), this); if (additionalActions != null) { for (final AnAction action : additionalActions) { actions.add(action); } } myToolBar = ActionManager.getInstance() .createActionToolbar(ActionPlaces.JAVADOC_TOOLBAR, actions, true); myControlPanel = new JPanel(); myControlPanel.setLayout(new BorderLayout()); myControlPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM)); JPanel dummyPanel = new JPanel(); myElementLabel = new JLabel(); dummyPanel.setLayout(new BorderLayout()); dummyPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); dummyPanel.add(myElementLabel, BorderLayout.EAST); myControlPanel.add(myToolBar.getComponent(), BorderLayout.WEST); myControlPanel.add(dummyPanel, BorderLayout.CENTER); myControlPanel.add(myShowSettingsButton = new MyShowSettingsButton(), BorderLayout.EAST); myControlPanelVisible = false; final HyperlinkListener hyperlinkListener = new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { HyperlinkEvent.EventType type = e.getEventType(); if (type == HyperlinkEvent.EventType.ACTIVATED) { manager.navigateByLink(DocumentationComponent.this, e.getDescription()); } } }; myEditorPane.addHyperlinkListener(hyperlinkListener); Disposer.register( this, new Disposable() { @Override public void dispose() { myEditorPane.removeHyperlinkListener(hyperlinkListener); } }); registerActions(); updateControlState(); }
private void makePanel(Dimension size) { JPanel buttonPanel = new JPanel(new GridLayout(1, 2, 5, 5)); newButton = new JButton("New"); newButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { lineBuilder.clear(); lineBuilder.setArmed(true); pauseButton.setText("Pause"); pauseButton.setEnabled(true); endButton.setEnabled(true); newButton.setEnabled(false); ((Component) wwd).setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); } }); buttonPanel.add(newButton); newButton.setEnabled(true); pauseButton = new JButton("Pause"); pauseButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { lineBuilder.setArmed(!lineBuilder.isArmed()); pauseButton.setText(!lineBuilder.isArmed() ? "Resume" : "Pause"); ((Component) wwd).setCursor(Cursor.getDefaultCursor()); } }); buttonPanel.add(pauseButton); pauseButton.setEnabled(false); endButton = new JButton("End"); endButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { lineBuilder.setArmed(false); newButton.setEnabled(true); pauseButton.setEnabled(false); pauseButton.setText("Pause"); endButton.setEnabled(false); ((Component) wwd).setCursor(Cursor.getDefaultCursor()); } }); buttonPanel.add(endButton); endButton.setEnabled(false); JPanel pointPanel = new JPanel(new GridLayout(0, 1, 0, 10)); pointPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); this.pointLabels = new JLabel[20]; for (int i = 0; i < this.pointLabels.length; i++) { this.pointLabels[i] = new JLabel(""); pointPanel.add(this.pointLabels[i]); } // Put the point panel in a container to prevent scroll panel from stretching the vertical // spacing. JPanel dummyPanel = new JPanel(new BorderLayout()); dummyPanel.add(pointPanel, BorderLayout.NORTH); // Put the point panel in a scroll bar. JScrollPane scrollPane = new JScrollPane(dummyPanel); scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); if (size != null) scrollPane.setPreferredSize(size); // Add the buttons, scroll bar and inner panel to a titled panel that will resize with the // main window. JPanel outerPanel = new JPanel(new BorderLayout()); outerPanel.setBorder( new CompoundBorder( BorderFactory.createEmptyBorder(9, 9, 9, 9), new TitledBorder("Line"))); outerPanel.setToolTipText("Line control and info"); outerPanel.add(buttonPanel, BorderLayout.NORTH); outerPanel.add(scrollPane, BorderLayout.CENTER); this.add(outerPanel, BorderLayout.CENTER); }