List of usage examples for javax.swing JScrollPane setVerticalScrollBarPolicy
@BeanProperty(preferred = true, enumerationValues = { "ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED", "ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER", "ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS" }, description = "The scrollpane vertical scrollbar policy") public void setVerticalScrollBarPolicy(int policy)
From source file:TreeExpandEventDemo2.java
public TreeExpandEventDemo2() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0;//www . jav a 2 s .co m c.weighty = 1.0; c.insets = new Insets(1, 1, 1, 1); demoArea = new DemoArea(); gridbag.setConstraints(demoArea, c); add(demoArea); c.insets = new Insets(0, 0, 0, 0); textArea = new JTextArea(); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.setPreferredSize(new Dimension(200, 75)); gridbag.setConstraints(scrollPane, c); add(scrollPane); setPreferredSize(new Dimension(450, 450)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:MainClass.java
public static JScrollPane createPagingScrollPaneForTable(JTable jt) { JScrollPane jsp = new JScrollPane(jt); TableModel tmodel = jt.getModel(); if (!(tmodel instanceof PagingModel)) { return jsp; }/* ww w . j a v a 2s . c om*/ final PagingModel model = (PagingModel) tmodel; final JButton upButton = new JButton("UP"); upButton.setEnabled(false); final JButton downButton = new JButton("DOWN"); if (model.getPageCount() <= 1) { downButton.setEnabled(false); } upButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { model.pageUp(); if (model.getPageOffset() == 0) { upButton.setEnabled(false); } downButton.setEnabled(true); } }); downButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { model.pageDown(); if (model.getPageOffset() == (model.getPageCount() - 1)) { downButton.setEnabled(false); } upButton.setEnabled(true); } }); jsp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); jsp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); jsp.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, upButton); jsp.setCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER, downButton); return jsp; }
From source file:com.sshtools.sshterm.SshTermCommandTab.java
/** * Creates a new SshToolsConnectionCommandTab object. *///from www . j a v a2 s . co m public SshTermCommandTab() { super(); JPanel main = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTH; gbc.insets = new Insets(0, 2, 2, 2); Insets ins2 = new Insets(2, 24, 2, 2); gbc.weightx = 1.0; requestPseudoTerminal.getModel().setSelected(false); disconnectOnSessionClose.getModel().setSelected(true); UIUtil.jGridBagAdd(main, requestPseudoTerminal, gbc, GridBagConstraints.REMAINDER); UIUtil.jGridBagAdd(main, disconnectOnSessionClose, gbc, GridBagConstraints.REMAINDER); UIUtil.jGridBagAdd(main, new JSeparator(JSeparator.HORIZONTAL), gbc, GridBagConstraints.REMAINDER); UIUtil.jGridBagAdd(main, onceAuthenticated, gbc, GridBagConstraints.REMAINDER); group.add(doNothing); group.add(startShell); group.add(executeCommands); startShell.setSelected(true); UIUtil.jGridBagAdd(main, doNothing, gbc, GridBagConstraints.REMAINDER); UIUtil.jGridBagAdd(main, startShell, gbc, GridBagConstraints.REMAINDER); UIUtil.jGridBagAdd(main, executeCommands, gbc, GridBagConstraints.REMAINDER); gbc.fill = GridBagConstraints.BOTH; gbc.insets = ins2; gbc.weighty = 1.0; //commands.setLineWrap(true); commands.setBorder(BorderFactory.createEtchedBorder()); JScrollPane scroll = new JScrollPane(commands); scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); UIUtil.jGridBagAdd(main, scroll, gbc, GridBagConstraints.REMAINDER); IconWrapperPanel iconProxyDetailsPanel = new IconWrapperPanel(new ResourceIcon(COMMANDS_ICON), main); commands.setRows(8); // This panel setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTH; gbc.insets = new Insets(2, 2, 2, 2); gbc.weightx = 1.0; add(iconProxyDetailsPanel, BorderLayout.NORTH); }
From source file:com.emental.mindraider.ui.outline.OutlineSorterJPanel.java
public OutlineSorterJPanel() { setLayout(new BorderLayout()); // table with archived concepts (title) // let table model to load discarded concepts itself tableModel = new SorterTableModel(); table = new JTable(tableModel); table.getSelectionModel().addListSelectionListener(new SorterListSelectionListener(table, tableModel)); table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setFillsViewportHeight(true);/*w w w .ja v a 2 s. c o m*/ table.setShowHorizontalLines(false); table.setShowVerticalLines(false); table.getColumnModel().getColumn(COLUMN_NAME).setPreferredWidth(150); table.getColumnModel().getColumn(COLUMN_ANNOTATION).setPreferredWidth(220); table.getColumnModel().getColumn(COLUMN_CREATED).setPreferredWidth(60); table.getColumnModel().getColumn(COLUMN_MODIFIED).setPreferredWidth(60); table.getColumnModel().getColumn(COLUMN_REVISION).setPreferredWidth(35); TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(table.getModel()); table.setRowSorter(sorter); sorter.setComparator(COLUMN_REVISION, new Comparator<Long>() { @Override public int compare(Long o1, Long o2) { return o2.intValue() - o1.intValue(); } }); final Comparator<String> timestampComparator = new Comparator<String>() { @Override public int compare(String o1, String o2) { if (OutlineTreeInstance.getCreatedTimestampFromHtml(o2) > OutlineTreeInstance .getCreatedTimestampFromHtml(o1)) { return 1; } else { if (OutlineTreeInstance.getCreatedTimestampFromHtml(o2) == OutlineTreeInstance .getCreatedTimestampFromHtml(o1)) { return 0; } else { return -1; } } } }; sorter.setComparator(COLUMN_MODIFIED, timestampComparator); sorter.setComparator(COLUMN_CREATED, timestampComparator); JScrollPane scroll = new JScrollPane(table); scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); add(scroll, BorderLayout.CENTER); }
From source file:dk.dma.epd.common.prototype.notification.StrategicRouteNotificationDetailPanelCommon.java
/** * {@inheritDoc}// www .j a v a 2 s . c o m */ @Override protected void buildGUI() { setLayout(new GridBagLayout()); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); // Create the transaction and status labels Insets insets5 = new Insets(5, 5, 5, 5); add(bold(new JLabel("Transaction ID:")), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); add(transactionTxt, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0)); add(bold(new JLabel("Latest status:")), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); add(statusTxt, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0)); // Create the info panel JPanel infoPanel = createInfoPanel(); add(infoPanel, new GridBagConstraints(0, 2, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0)); // Create the messages panel JScrollPane scrollPane = new JScrollPane(messagesPanel); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBorder(new MatteBorder(1, 1, 1, 1, UIManager.getColor("Separator.shadow"))); messagesPanel.setBackground(UIManager.getColor("List.background")); add(scrollPane, new GridBagConstraints(0, 3, 2, 1, 1.0, 1.0, WEST, BOTH, insets5, 0, 0)); }
From source file:org.drugis.addis.gui.builder.SMAAView.java
public JComponent buildCentralWeightsPart() { JScrollPane cpane = new JScrollPane(createWaiter(new CentralWeightsBuilder())); cpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); cpane.setViewportBorder(null);/*from ww w. j a v a 2 s . c o m*/ return cpane; }
From source file:org.drugis.addis.gui.builder.SMAAView.java
public JComponent buildRankAcceptabilitiesPart() { JScrollPane rankpane = new JScrollPane(createWaiter(new RankAcceptabilitiesBuilder())); rankpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); rankpane.setViewportBorder(null);//from w ww. j ava 2 s.c o m return rankpane; }
From source file:kenh.xscript.elements.Debug.java
private void initial(Container c) { c.setLayout(new BorderLayout()); // Add variable list DefaultListModel<String> model = new DefaultListModel(); if (this.getEnvironment() != null) { java.util.Set<String> keys = this.getEnvironment().getVariables().keySet(); for (String key : keys) { model.addElement(key);// www .ja v a 2 s .c om } } else { for (int i = 1; i < 10; i++) { model.addElement("Variable " + i); } model.addElement("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); } JList list = new JList(model); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane listPane = new JScrollPane(); listPane.setViewportView(list); listPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); c.add(listPane, BorderLayout.EAST); list.setPreferredSize(new Dimension(150, list.getPreferredSize().height)); // JTextField quote = new JTextField(); quote.requestFocus(); //JButton button = new JButton(">>"); JPanel quotePanel = new JPanel(); quotePanel.setLayout(new BorderLayout()); quotePanel.add(quote, BorderLayout.CENTER); //quotePanel.add(button, BorderLayout.EAST); JTextArea result = new JTextArea(); result.setEditable(false); JScrollPane resultPane = new JScrollPane(); resultPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); resultPane.setViewportView(result); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(quotePanel, BorderLayout.NORTH); panel.add(resultPane, BorderLayout.CENTER); c.add(panel, BorderLayout.CENTER); list.addListSelectionListener(this); //button.addActionListener(this); quote.addKeyListener(this); this.result = result; }
From source file:com.mindcognition.mindraider.ui.swing.concept.annotation.renderer.AbstractTextAnnotationRenderer.java
private JScrollPane encapsulateToScroll(Component what, String title) { JScrollPane editorScroll = new JScrollPane(what); editorScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); editorScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); // TODO bundle editorScroll.setBorder(new TitledBorder(title)); return editorScroll; }
From source file:com.mirth.connect.plugins.imageviewer.ImageViewer.java
public void viewAttachments(String channelId, Long messageId, String attachmentId) { JFrame frame = new JFrame("Image Viewer"); try {/*from ww w.j a v a2s. com*/ Attachment attachment = parent.mirthClient.getAttachment(channelId, messageId, attachmentId); byte[] rawData = attachment.getContent(); ByteArrayInputStream bis = new ByteArrayInputStream(rawData); image = ImageIO.read(new Base64InputStream(bis)); JScrollPane pictureScrollPane = new JScrollPane(new JLabel(new ImageIcon(image))); pictureScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); pictureScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); frame.add(pictureScrollPane); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { e.getWindow().dispose(); } }); frame.pack(); int imageWidth = image.getWidth(); int imageHeight = image.getHeight(); // Resize the frame so that it fits and scrolls images larger than // 800x600 properly. if (imageWidth > 800 || imageHeight > 600) { int width = imageWidth; int height = imageHeight; if (imageWidth > 800) { width = 800; } if (imageHeight > 600) { height = 600; } // Also add the scrollbars to the window width if necessary. Integer scrollBarWidth = (Integer) UIManager.get("ScrollBar.width"); int verticalScrollBar = 0; int horizontalScrollBar = 0; if (width == 800) { horizontalScrollBar = scrollBarWidth.intValue(); } if (height == 600) { verticalScrollBar = scrollBarWidth.intValue(); } // Also add the window borders to the width. width = width + frame.getInsets().left + frame.getInsets().right + verticalScrollBar; height = height + frame.getInsets().top + frame.getInsets().bottom + horizontalScrollBar; frame.setSize(width, height); } Dimension dlgSize = frame.getSize(); Dimension frmSize = parent.getSize(); Point loc = parent.getLocation(); if ((frmSize.width == 0 && frmSize.height == 0) || (loc.x == 0 && loc.y == 0)) { frame.setLocationRelativeTo(null); } else { frame.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); } frame.setVisible(true); } catch (Exception e) { parent.alertThrowable(parent, e); } }