List of usage examples for javax.swing JScrollPane setHorizontalScrollBarPolicy
@BeanProperty(preferred = true, enumerationValues = { "ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED", "ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER", "ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS" }, description = "The scrollpane scrollbar policy") public void setHorizontalScrollBarPolicy(int policy)
From source file:org.yccheok.jstock.gui.AjaxAutoCompleteJComboBox.java
private void adjustScrollBar() { final int max_search = 8; // i < max_search is just a safe guard when getAccessibleChildrenCount // returns an arbitary large number. 8 is magic number JPopupMenu popup = null;/*from ww w . j ava 2s.c o m*/ for (int i = 0, count = this.getUI().getAccessibleChildrenCount(this); i < count && i < max_search; i++) { Object o = this.getUI().getAccessibleChild(this, i); if (o instanceof JPopupMenu) { popup = (JPopupMenu) o; break; } } if (popup == null) { return; } JScrollPane scrollPane = null; for (int i = 0, count = popup.getComponentCount(); i < count && i < max_search; i++) { Component c = popup.getComponent(i); if (c instanceof JScrollPane) { scrollPane = (JScrollPane) c; break; } } if (scrollPane == null) { return; } scrollPane.setHorizontalScrollBar(new JScrollBar(JScrollBar.HORIZONTAL)); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); }
From source file:org.zaproxy.zap.extension.encoder2.EncodeDecodeDialog.java
private void addField(JPanel parent, int index, JComponent c, String title) { final java.awt.GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0;// ww w .j a va 2 s .co m gbc.gridy = index; gbc.insets = new java.awt.Insets(1, 1, 1, 1); gbc.anchor = java.awt.GridBagConstraints.NORTHWEST; gbc.fill = java.awt.GridBagConstraints.BOTH; gbc.weightx = 0.5D; gbc.weighty = 0.5D; final JScrollPane jsp = new JScrollPane(); jsp.setViewportView(c); jsp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jsp.setBorder(BorderFactory.createTitledBorder(null, title, TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, FontUtils.getFont(FontUtils.Size.standard), java.awt.Color.black)); parent.add(jsp, gbc); }
From source file:org.zaproxy.zap.extension.encoder2.EncodeDecodeDialog.java
/** * This method initializes jPanel/* w w w .j a va 2 s. c om*/ * * @return javax.swing.JPanel */ private JPanel getJTabbed() { if (jPanel == null) { /* jPanel = new JPanel(); jPanel.setPreferredSize(new java.awt.Dimension(800,600)); jPanel.setLayout(new GridBagLayout()); */ // jPanel is the outside one jPanel = new JPanel(); jPanel.setPreferredSize(new java.awt.Dimension(800, 600)); jPanel.setLayout(new GridBagLayout()); jTabbed = new JTabbedPane(); jTabbed.setPreferredSize(new java.awt.Dimension(800, 500)); final JPanel jPanel1 = new JPanel(); jPanel1.setLayout(new GridBagLayout()); final JPanel jPanel2 = new JPanel(); //jPanel2.setPreferredSize(new java.awt.Dimension(800,500)); jPanel2.setLayout(new GridBagLayout()); final JPanel jPanel3 = new JPanel(); //jPanel3.setPreferredSize(new java.awt.Dimension(800,500)); jPanel3.setLayout(new GridBagLayout()); final JPanel jPanel4 = new JPanel(); jPanel4.setLayout(new GridBagLayout()); // 3 tabs - Encode, Decode, Hash?? addField(jPanel1, 1, getBase64EncodeField(), Constant.messages.getString("enc2.label.b64Enc")); addField(jPanel1, 2, getUrlEncodeField(), Constant.messages.getString("enc2.label.urlEnc")); addField(jPanel1, 3, getAsciiHexEncodeField(), Constant.messages.getString("enc2.label.asciiEnc")); addField(jPanel1, 4, getHTMLEncodeField(), Constant.messages.getString("enc2.label.HTMLEnc")); addField(jPanel1, 5, getJavaScriptEncodeField(), Constant.messages.getString("enc2.label.JavaScriptEnc")); addField(jPanel2, 1, getBase64DecodeField(), Constant.messages.getString("enc2.label.b64Dec")); addField(jPanel2, 2, getUrlDecodeField(), Constant.messages.getString("enc2.label.urlDec")); addField(jPanel2, 3, getAsciiHexDecodeField(), Constant.messages.getString("enc2.label.asciiDec")); addField(jPanel2, 4, getHTMLDecodeField(), Constant.messages.getString("enc2.label.HTMLDec")); addField(jPanel2, 5, getJavaScriptDecodeField(), Constant.messages.getString("enc2.label.JavaScriptDec")); addField(jPanel3, 1, getSha1HashField(), Constant.messages.getString("enc2.label.sha1Hash")); addField(jPanel3, 2, getMd5HashField(), Constant.messages.getString("enc2.label.md5Hash")); addField(jPanel4, 1, getIllegalUTF82ByteField(), Constant.messages.getString("enc2.label.illegalUTF8.2byte")); addField(jPanel4, 2, getIllegalUTF83ByteField(), Constant.messages.getString("enc2.label.illegalUTF8.3byte")); addField(jPanel4, 3, getIllegalUTF84ByteField(), Constant.messages.getString("enc2.label.illegalUTF8.4byte")); jTabbed.addTab(Constant.messages.getString("enc2.tab.encode"), jPanel1); jTabbed.addTab(Constant.messages.getString("enc2.tab.decode"), jPanel2); jTabbed.addTab(Constant.messages.getString("enc2.tab.hash"), jPanel3); jTabbed.addTab(Constant.messages.getString("enc2.tab.illegalUTF8"), jPanel4); final java.awt.GridBagConstraints gbc1 = new GridBagConstraints(); gbc1.gridx = 0; gbc1.gridy = 1; gbc1.insets = new java.awt.Insets(1, 1, 1, 1); gbc1.anchor = java.awt.GridBagConstraints.NORTHWEST; gbc1.fill = java.awt.GridBagConstraints.BOTH; gbc1.weightx = 1.0D; gbc1.weighty = 0.25D; final java.awt.GridBagConstraints gbc2 = new GridBagConstraints(); gbc2.gridx = 0; gbc2.gridy = 2; gbc2.insets = new java.awt.Insets(1, 1, 1, 1); gbc2.anchor = java.awt.GridBagConstraints.NORTHWEST; gbc2.fill = java.awt.GridBagConstraints.BOTH; gbc2.weightx = 1.0D; gbc2.weighty = 1.0D; final JScrollPane jsp = new JScrollPane(); jsp.setViewportView(getInputField()); jsp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jsp.setBorder(BorderFactory.createTitledBorder(null, Constant.messages.getString("enc2.label.text"), TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, FontUtils.getFont(FontUtils.Size.standard), java.awt.Color.black)); //addField(jPanel, 1, getInputField(), "Text to be encoded/decoded/hashed"); //addField(jPanel, 2, jTabbed, "Text to be encoded/decoded/hashed"); jPanel.add(jsp, gbc1); jPanel.add(jTabbed, gbc2); jPanel2.requestFocus(); } return jPanel; }
From source file:org.zaproxy.zap.extension.quickstart.QuickStartPanel.java
private void initialize() { this.setIcon(new ImageIcon(BreakPanel.class.getResource("/resource/icon/16/147.png"))); // 'lightning' icon this.setDefaultAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | Event.SHIFT_MASK, false)); this.setMnemonic(Constant.messages.getChar("quickstart.panel.mnemonic")); this.setLayout(new BorderLayout()); JPanel panelContent = new JPanel(new GridBagLayout()); JScrollPane jScrollPane = new JScrollPane(); jScrollPane.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 11)); jScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); jScrollPane.setViewportView(panelContent); this.add(jScrollPane, BorderLayout.CENTER); panelContent.setBackground(Color.white); panelContent.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); /*/*ww w .j a va2s .c o m*/ * Layout: * Col 0 1 2 3 4 * Row+----------------------+----------------------+----------------------+----------------------+----------------------+ * 0 | Top welcome message | zap128x128.png | * 1 | URL: | [ Url field ] | | * 2 | | [ Attack button ] | [ Stop button ] | padding | | * 3 | Progress: | Progress details | | * | Bottom message | * | Show at start: | [x] | | | | * +----------------------+----------------------+----------------------+----------------------+----------------------+ */ panelContent.add(new JLabel(Constant.messages.getString("quickstart.panel.topmsg")), LayoutHelper.getGBC(0, 0, 4, 1.0D, new Insets(5, 5, 5, 5))); if (Constant.isDevBuild()) { panelContent.add( new JLabel(new ImageIcon(QuickStartPanel.class .getResource("/org/zaproxy/zap/extension/quickstart/resources/zap128x128dark.png"))), LayoutHelper.getGBC(4, 0, 1, 0.0D, 0.0D, GridBagConstraints.NORTH)); } else { panelContent.add( new JLabel(DisplayUtils.getScaledIcon( new ImageIcon(SearchPanel.class.getResource("/resource/zap128x128.png")))), LayoutHelper.getGBC(4, 0, 1, 0.0D, 0.0D, GridBagConstraints.NORTH)); } panelContent.add(new JLabel(Constant.messages.getString("quickstart.label.url")), LayoutHelper.getGBC(0, 1, 1, 0.0D, new Insets(5, 5, 5, 5))); JPanel urlSelectPanel = new JPanel(new GridBagLayout()); JButton selectButton = new JButton(Constant.messages.getString("all.button.select")); selectButton.setIcon( DisplayUtils.getScaledIcon(new ImageIcon(View.class.getResource("/resource/icon/16/094.png")))); // Globe icon selectButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { NodeSelectDialog nsd = new NodeSelectDialog(View.getSingleton().getMainFrame()); SiteNode node = null; try { node = Model.getSingleton().getSession().getSiteTree() .findNode(new URI(getUrlField().getText(), false)); } catch (Exception e2) { // Ignore } node = nsd.showDialog(node); if (node != null && node.getHistoryReference() != null) { try { getUrlField().setText(node.getHistoryReference().getURI().toString()); } catch (Exception e1) { // Ignore } } } }); urlSelectPanel.add(this.getUrlField(), LayoutHelper.getGBC(0, 0, 1, 1.0D)); urlSelectPanel.add(selectButton, LayoutHelper.getGBC(1, 0, 1, 0.0D)); panelContent.add(urlSelectPanel, LayoutHelper.getGBC(1, 1, 3, 0.25D)); panelContent.add(this.getAttackButton(), LayoutHelper.getGBC(1, 2, 1, 0.0D)); panelContent.add(this.getStopButton(), LayoutHelper.getGBC(2, 2, 1, 0.0D)); panelContent.add(new JLabel(""), LayoutHelper.getGBC(3, 2, 1, 0.75D, 0.0D)); // Padding to right of buttons progressLabel = new JLabel( Constant.messages.getString("quickstart.progress." + AttackThread.Progress.notstarted.name())); panelContent.add(new JLabel(Constant.messages.getString("quickstart.label.progress")), LayoutHelper.getGBC(0, 3, 1, 0.0D, new Insets(5, 5, 5, 5))); panelContent.add(this.progressLabel, LayoutHelper.getGBC(1, 3, 3, 0.0D)); panelContent.add(new JLabel(Constant.messages.getString("quickstart.panel.proxymsg")), LayoutHelper.getGBC(0, 4, 5, 1.0D, new Insets(5, 5, 5, 5))); if (Control.getSingleton().getExtensionLoader().getExtension("ExtensionPlugNHack") != null) { // Plug-n-Hack extension has been installed - this makes configuration much easier :) if (DesktopUtils.canOpenUrlInBrowser()) { panelContent.add(new JLabel(Constant.messages.getString("quickstart.label.mitm")), LayoutHelper.getGBC(0, 6, 1, 0.0D, new Insets(5, 5, 5, 5))); panelContent.add(this.getConfButton(), LayoutHelper.getGBC(1, 6, 1, 0.0D)); panelContent.add(new JLabel(Constant.messages.getString("quickstart.label.mitmalt")), LayoutHelper.getGBC(0, 7, 1, 0.0D, new Insets(5, 5, 5, 5))); } else { panelContent.add(new JLabel(Constant.messages.getString("quickstart.label.mitmurl")), LayoutHelper.getGBC(0, 7, 1, 0.0D, new Insets(5, 5, 5, 5))); } panelContent.add(this.getConfField(), LayoutHelper.getGBC(1, 7, 3, 0.25D)); } else { panelContent.add(new JLabel(Constant.messages.getString("quickstart.panel.helpmsg")), LayoutHelper.getGBC(0, 5, 5, 1.0D, new Insets(5, 5, 5, 5))); } panelContent.add(new JLabel(""), LayoutHelper.getGBC(0, 10, 4, 1.D, 1.0D)); // Padding at bottom this.setMode(Control.getSingleton().getMode()); }
From source file:org.zaproxy.zap.extension.tlsdebug.TlsDebugPanel.java
@SuppressWarnings("deprecation") private void initialize() { this.setIcon(TLSDEBUG_ICON); this.setDefaultAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, // TODO Remove warn suppression and use View.getMenuShortcutKeyStroke with // newer ZAP (or use getMenuShortcutKeyMaskEx() with Java 10+) Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | KeyEvent.ALT_DOWN_MASK, false)); this.setLayout(new BorderLayout()); JPanel panelContent = new JPanel(new GridBagLayout()); this.add(panelContent, BorderLayout.NORTH); panelContent.setBackground(Color.white); panelContent.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); panelContent.add(new JLabel(Constant.messages.getString("tlsdebug.label.url")), LayoutHelper.getGBC(0, 0, 1, 0.0D, new Insets(5, 5, 5, 5))); JPanel urlSelectPanel = new JPanel(new GridBagLayout()); JButton selectButton = new JButton(Constant.messages.getString("all.button.select")); selectButton.setIcon(/*from ww w. java2 s . com*/ DisplayUtils.getScaledIcon(new ImageIcon(View.class.getResource("/resource/icon/16/094.png")))); // Globe // icon selectButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { NodeSelectDialog nsd = new NodeSelectDialog(View.getSingleton().getMainFrame()); SiteNode node = null; try { node = Model.getSingleton().getSession().getSiteTree() .findNode(new URI(getUrlField().getText(), false)); } catch (Exception e2) { // Ignore } node = nsd.showDialog(node); if (node != null && node.getHistoryReference() != null) { try { getUrlField().setText(node.getHistoryReference().getURI().toString()); } catch (Exception e1) { // Ignore } } } }); urlSelectPanel.add(this.getUrlField(), LayoutHelper.getGBC(0, 0, 1, 1.0D)); urlSelectPanel.add(selectButton, LayoutHelper.getGBC(1, 0, 1, 0.0D)); panelContent.add(urlSelectPanel, LayoutHelper.getGBC(1, 0, 3, 0.25D)); panelContent.add(this.getCheckButton(), LayoutHelper.getGBC(0, 1, 1, 0.0D)); JPanel outputPanel = new JPanel(new BorderLayout()); outputPanel.add(new JLabel(Constant.messages.getString("tlsdebug.label.console")), BorderLayout.NORTH); JScrollPane jScrollPane = new JScrollPane(); jScrollPane.add(getOutputArea(), LayoutHelper.getGBC(0, 0, 4, 1.D, 1.0D)); // Padding // at // bottom jScrollPane.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 11)); jScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); jScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); jScrollPane.setViewportView(getOutputArea()); outputPanel.add(jScrollPane, BorderLayout.CENTER); this.add(outputPanel, BorderLayout.CENTER); }
From source file:pcgen.gui2.PCGenFrame.java
/** * Create a component to display the message within the bounds of the * screen. If the message is too big for the screen a suitably sized * scroll pane will be returned./* w w w . j a v a 2 s . c o m*/ * @param message The text of the message. * @return The component containing the text. */ private JComponent getComponentForMessage(String message) { JLabel jLabel = new JLabel(message); JScrollPane scroller = new JScrollPane(jLabel); Dimension size = jLabel.getPreferredSize(); final int decorationHeight = 80; final int decorationWidth = 70; Rectangle screenBounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); boolean scrollerNeeded = false; if (size.height > screenBounds.height - decorationHeight) { size.height = screenBounds.height - decorationHeight; scrollerNeeded = true; } if (size.width > screenBounds.width - decorationWidth) { size.width = screenBounds.width - decorationWidth; scrollerNeeded = true; } else if (scrollerNeeded) { scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); } scroller.setPreferredSize(size); return scrollerNeeded ? scroller : jLabel; }
From source file:pcgen.gui2.tabs.bio.CampaignHistoryInfoPane.java
private void initComponents() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); addButton.setText("Add Next Chronicle"); addButton.setActionCommand(ADD_COMMAND); allButton.setText("All"); allButton.setActionCommand(ALL_COMMAND); noneButton.setText("None"); noneButton.setActionCommand(NONE_COMMAND); Box hbox = Box.createHorizontalBox(); hbox.add(Box.createRigidArea(new Dimension(5, 0))); hbox.add(new JLabel("Check an item to include on your Character Sheet")); hbox.add(Box.createRigidArea(new Dimension(5, 0))); hbox.add(allButton);/*from w w w .j a va 2s . co m*/ hbox.add(Box.createRigidArea(new Dimension(3, 0))); hbox.add(noneButton); hbox.add(Box.createHorizontalGlue()); add(Box.createVerticalStrut(5)); add(hbox); add(Box.createVerticalStrut(10)); JScrollPane pane = new JScrollPane(chroniclesPane) { @Override public Dimension getMaximumSize() { Dimension size = getPreferredSize(); size.width = Integer.MAX_VALUE; return size; } @Override public boolean isValidateRoot() { return false; } }; pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); add(pane); add(Box.createVerticalStrut(10)); addButton.setAlignmentX(0.5f); add(addButton); add(Box.createVerticalStrut(5)); add(Box.createVerticalGlue()); }
From source file:picocash.components.AccountPanel.java
protected JScrollPane createTransactionScrollPane(ListModel listModel) { final JXList transactionList = new JXList(listModel); transactionList.setBackground(TRANSPARENT_LIST_BACKGROUND); transactionList.setCellRenderer(new DefaultListRenderer(new TransactionProvider())); transactionList.setRolloverEnabled(true); transactionList.addHighlighter(// w ww .j a v a2 s .c o m new TransactionPainterHighlighter(HighlightPredicate.ALWAYS, new MattePainter(Color.WHITE))); transactionList.addHighlighter( new TransactionPainterHighlighter(HighlightPredicate.ROLLOVER_ROW, new PinstripePainter())); final JScrollPane scrollPane = new JScrollPane(transactionList); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setViewportBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); transactionList.setOpaque(true); scrollPane.setOpaque(true); return scrollPane; }
From source file:pipeline.GUI_utils.ListOfPointsView.java
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override//from ww w . j a v a2 s .co m public void show() { if (frame != null) frame.toFront(); if (table == null) { spreadsheetEngine = new DependencyEngine(new BasicEngineProvider()); setupTableModel(points); silenceUpdates.incrementAndGet(); table = new JXTablePerColumnFiltering(tableModel); table.setRolloverEnabled(true); // table.setDragEnabled(true); table.setFillsViewportHeight(false); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table.setShowGrid(true); table.setShowHorizontalLines(true); table.setColumnSelectionAllowed(true); table.setRowSelectionAllowed(true); table.setColumnControlVisible(true); table.setHighlighters(new Highlighter[] { HighlighterFactory.createAlternateStriping() }); table.addPropertyChangeListener("horizontalScrollEnabled", new PropertyChangeListener() { JViewport viewPort, filteringViewPort, columnDescViewPort; int lastX; ChangeListener scrollListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (viewPort == null || filteringViewPort == null) { return; } Point position = viewPort.getViewPosition(); if (position.x == lastX) { return; } filteringViewPort.setViewPosition(position); columnDescViewPort.setViewPosition(position); lastX = position.x; } }; @Override public void propertyChange(PropertyChangeEvent evt) { if (viewPort != null) { viewPort.removeChangeListener(scrollListener); } if (evt.getNewValue().equals(true)) { viewPort = getTableViewPort(table); if (viewPort == null) { return; } table.filteringTable.setHorizontalScrollEnabled(true); table.tableForColumnDescriptions.setHorizontalScrollEnabled(true); table.updateFilteringTableSetup(); filteringViewPort = getTableViewPort(table.filteringTable); columnDescViewPort = getTableViewPort(table.tableForColumnDescriptions); viewPort.addChangeListener(scrollListener); scrollListener.stateChanged(null); } else { table.filteringTable.setHorizontalScrollEnabled(false); table.tableForColumnDescriptions.setHorizontalScrollEnabled(false); } } }); modelForColumnDescriptions = new dataModelAllEditable(1, tableModel.getColumnCount()); Vector<String> rowVector0 = (Vector<String>) modelForColumnDescriptions.getDataVector().get(0); for (int j = 0; j < tableModel.getColumnCount(); j++) { rowVector0.setElementAt(tableModel.getColumnName(j), j); } boolean done; do { done = true; for (TableColumn i : table.getColumns(true)) { TableColumnExt iCast = (TableColumnExt) i; if (iCast.getTitle().equals("Class") || iCast.getTitle().equals("c") || iCast.getTitle().equals("t") || iCast.getTitle().equals("clusterID") || iCast.getTitle().equals("userCell 2") || iCast.getTitle().equals("userCell 3")) { if (iCast.isVisible()) { iCast.setVisible(false); done = false; break; } } } } while (!done); SwingUtilities.invokeLater(modelForColumnDescriptions::fireTableDataChanged); JScrollPane scrollPane = new JScrollPane(table); scrollPane.setPreferredSize(new Dimension(2000, 2000)); updateColumnDescriptions(); silenceUpdates.decrementAndGet(); setSpreadsheetColumnEditorAndRenderer(); tableForColumnDescriptions = new JXTable(modelForColumnDescriptions); table.tableForColumnDescriptions = tableForColumnDescriptions; JScrollPane jScrollPaneForNames = new JScrollPane(tableForColumnDescriptions); jScrollPaneForNames.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); JPanel controlPanel = new JPanel(); controlPanel.setLayout(new FlowLayout()); JButton createScatterPlotButton = new JButton("Scatter plot from selected columns"); controlPanel.add(createScatterPlotButton); createScatterPlotButton.setActionCommand("Scatter plot from selected columns"); createScatterPlotButton.addActionListener(this); realTimeUpdateCheckbox = new JCheckBox("Update display in real time"); controlPanel.add(realTimeUpdateCheckbox); realTimeUpdateCheckbox.setActionCommand("Update display in real time"); realTimeUpdateCheckbox.addActionListener(this); JButton forceUpdate = new JButton("Force display update"); controlPanel.add(forceUpdate); forceUpdate.setActionCommand("Force display update"); forceUpdate.addActionListener(this); JButton extendFormula = new JButton("Extend formula to column"); controlPanel.add(extendFormula); extendFormula.setActionCommand("Extend formula to column"); extendFormula.addActionListener(this); JButton saveFormulas = new JButton("Save user formulas..."); saveFormulas.addActionListener(this); saveFormulas.setActionCommand("Save user formulas"); controlPanel.add(saveFormulas); JButton reloadFormulas = new JButton("Reload user formulas..."); reloadFormulas.addActionListener(this); reloadFormulas.setActionCommand("Reload user formulas"); controlPanel.add(reloadFormulas); controlPanel.add(new JLabel("Color with:")); coloringComboBox = new JComboBox(); controlPanel.add(coloringComboBox); DefaultComboBoxModel comboBoxModel = (DefaultComboBoxModel) coloringComboBox.getModel(); coloringComboBox.addActionListener(this); for (int i = 0; i < tableModel.getColumnCount(); i++) { comboBoxModel.addElement(tableModel.getColumnName(i)); } JButton saveTableToFile = new JButton("Save table to file"); controlPanel.add(saveTableToFile); saveTableToFile.setActionCommand("Save table to file"); saveTableToFile.addActionListener(this); /* final JCheckBox useCalibration = new JCheckBox("Use calibration"); useCalibration.addActionListener(e -> { if (points == null) return; boolean selected = useCalibration.isSelected(); if (selected && !(points instanceof PluginIOCalibrable)) { Utils.displayMessage("Type " + points.getClass().getName() + " does not have calibration", true, LogLevel.ERROR); return; } PluginIOCalibrable calibrable = (PluginIOCalibrable) points; if (selected && (calibrable.getCalibration() == null)) { Utils.displayMessage("Calibration information is not present in the segmentation; one " + "way of adding it is to give the source image (with calibration) as an input " + "to the active contour plugin", true, LogLevel.ERROR); return; } float xyCalibration = selected ? ((float) calibrable.getCalibration().pixelWidth) : 0; float zCalibration = selected ? ((float) calibrable.getCalibration().pixelDepth) : 0; updateCalibration(xyCalibration, zCalibration); }); PluginIOCalibrable calibrable = null; if (points instanceof PluginIOCalibrable) calibrable = (PluginIOCalibrable) points; boolean calibrationPresent = calibrable != null && calibrable.getCalibration() != null; useCalibration.setSelected(calibrationPresent); if (calibrationPresent) { updateCalibration((float) calibrable.getCalibration().pixelWidth, (float) calibrable.getCalibration().pixelDepth); } controlPanel.add(useCalibration); */ frame = new JFrame(points.getName()); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); listener = new WindowListenerWeakRef(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { close();// So all references to data are nulled, to ensure garbage collection } }); frame.addWindowListener(listener); frame.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = GridBagConstraints.RELATIVE; c.weighty = 0.75; c.weightx = 1.0; c.gridwidth = 1; c.gridheight = 1; frame.add(scrollPane, c); c.weighty = 0.0; JScrollPane scrollPane2 = new JScrollPane(table.filteringTable); scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane2.setMinimumSize(new Dimension(1, 250)); frame.add(scrollPane2, c); c.weighty = 0.0; jScrollPaneForNames.setMinimumSize(new Dimension(1, 40)); jScrollPaneForNames.setMaximumSize(new Dimension(9999999, 40)); frame.add(jScrollPaneForNames, c); c.weighty = 0.0; c.fill = GridBagConstraints.HORIZONTAL; controlPanel.setMinimumSize(new Dimension(1, 80)); frame.add(controlPanel, c); table.setHorizontalScrollEnabled(true); table.updateFilteringTableSetup(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int height = screenSize.height; int width = screenSize.width; frame.setSize((int) (0.67 * width), height / 2); frame.setLocation((int) (0.33 * width), height / 2); frame.setVisible(true); } if ((tableUpdateThread == null) || (!tableUpdateThread.isAlive())) { tableUpdateThread = new Thread(() -> { try { checkForDirtiness(); } catch (Exception e) { Utils.log("Exception in ListOfPointsView GUI update thread", LogLevel.ERROR); Utils.printStack(e); } }, "ListOfPointsView GUI update thread"); tableUpdateThread.start(); } }
From source file:psidev.psi.mi.filemakers.xmlMaker.gui.XsdTreePanelImpl.java
/** * create a new instance of XslTree The nodes will be automaticaly * duplicated if the schema specify that more than one element of this type * are mandatory//from w w w . jav a 2 s. c om */ public XsdTreePanelImpl(XsdTreeStructImpl xsdTree, JTextPane messagePane) { super(xsdTree); messagePane.setEditable(false); JScrollPane scrollpane = new JScrollPane(messagePane); scrollpane.setMaximumSize(new Dimension(Short.MAX_VALUE, 150)); scrollpane.setMinimumSize(new Dimension(200, 150)); scrollpane.setPreferredSize(new Dimension(200, 150)); scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollpane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); scrollpane.setBorder(new TitledBorder("Messages")); add(scrollpane, BorderLayout.SOUTH); add(getButtonPanel(), BorderLayout.EAST); MouseListener mouseListener = new TreeMouseAdapter(); xsdTree.tree.addMouseListener(mouseListener); }