List of usage examples for javax.swing ScrollPaneConstants VERTICAL_SCROLLBAR_ALWAYS
int VERTICAL_SCROLLBAR_ALWAYS
To view the source code for javax.swing ScrollPaneConstants VERTICAL_SCROLLBAR_ALWAYS.
Click Source Link
From source file:com.googlecode.sarasvati.visual.jung.JungVisualizer.java
@SuppressWarnings("serial") public static void main(String[] args) throws Exception { TestSetup.init();/*from w ww.j a v a2 s .co m*/ Session session = TestSetup.openSession(); HibEngine engine = new HibEngine(session); JFrame frame = new JFrame("Workflow Visualizer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(800, 600)); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); frame.getContentPane().add(splitPane); DefaultListModel listModel = new DefaultListModel(); for (Graph g : engine.getRepository().getGraphs()) { listModel.addElement(g); } ListCellRenderer cellRenderer = new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); Graph g = (Graph) value; setText(g.getName() + "." + g.getVersion() + " "); return this; } }; final JList graphList = new JList(listModel); graphList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); graphList.setCellRenderer(cellRenderer); JScrollPane listScrollPane = new JScrollPane(graphList); listScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); listScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); splitPane.add(listScrollPane); //TreeLayout<NodeRef, Arc> layout = new TreeLayout<NodeRef, Arc>(); DirectedSparseMultigraph<Node, Arc> graph = new DirectedSparseMultigraph<Node, Arc>(); //final SpringLayout2<HibNodeRef, HibArc> layout = new SpringLayout2<HibNodeRef, HibArc>(graph); //final KKLayout<HibNodeRef, HibArc> layout = new KKLayout<HibNodeRef, HibArc>(graph); final TreeLayout layout = new TreeLayout(graph); final BasicVisualizationServer<Node, Arc> vs = new BasicVisualizationServer<Node, Arc>(layout); //vs.getRenderContext().setVertexLabelTransformer( new NodeLabeller() ); //vs.getRenderContext().setEdgeLabelTransformer( new ArcLabeller() ); vs.getRenderContext().setVertexShapeTransformer(new NodeShapeTransformer()); vs.getRenderContext().setVertexFillPaintTransformer(new NodeColorTransformer()); vs.getRenderContext().setLabelOffset(5); vs.getRenderContext().setVertexIconTransformer(new Transformer<Node, Icon>() { @Override public Icon transform(Node node) { return "task".equals(node.getType()) ? new TaskIcon(node) : null; } }); Transformer<Arc, Paint> edgeColorTrans = new Transformer<Arc, Paint>() { private Color darkRed = new Color(128, 0, 0); @Override public Paint transform(Arc arc) { return "reject".equals(arc.getName()) ? darkRed : Color.black; } }; vs.getRenderContext().setEdgeDrawPaintTransformer(edgeColorTrans); vs.getRenderContext().setArrowDrawPaintTransformer(edgeColorTrans); final JScrollPane scrollPane = new JScrollPane(vs); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); splitPane.add(scrollPane); scrollPane.setBackground(Color.white); graphList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } final Graph g = (Graph) graphList.getSelectedValue(); if ((g == null && currentGraph == null) || (g != null && g.equals(currentGraph))) { return; } currentGraph = g; DirectedSparseMultigraph<Node, Arc> jungGraph = new DirectedSparseMultigraph<Node, Arc>(); for (Node ref : currentGraph.getNodes()) { jungGraph.addVertex(ref); } for (Arc arc : currentGraph.getArcs()) { jungGraph.addEdge(arc, arc.getStartNode(), arc.getEndNode()); } GraphTree graphTree = new GraphTree(g); layout.setGraph(jungGraph); layout.setInitializer(new NodeLocationTransformer(graphTree)); scrollPane.repaint(); } }); frame.setVisible(true); }
From source file:Main.java
public Main() { super();//from ww w. j a v a 2 s. c o m this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); Container contentPane = this.getContentPane(); textArea = new JTextArea(); JScrollPane pane = new JScrollPane(textArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); contentPane.add(pane, BorderLayout.CENTER); }
From source file:com.clank.launcher.swing.MessageLog.java
private void initComponents() { if (colorEnabled) { JTextPane text = new JTextPane() { @Override//from w w w . ja va 2 s . co m public boolean getScrollableTracksViewportWidth() { return true; } }; this.textComponent = text; } else { JTextArea text = new JTextArea(); this.textComponent = text; text.setLineWrap(true); text.setWrapStyleWord(true); } textComponent.setFont(new JLabel().getFont()); textComponent.setEditable(false); textComponent.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE); DefaultCaret caret = (DefaultCaret) textComponent.getCaret(); caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE); document = textComponent.getDocument(); document.addDocumentListener(new LimitLinesDocumentListener(numLines, true)); JScrollPane scrollText = new JScrollPane(textComponent); scrollText.setBorder(null); scrollText.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollText.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); add(scrollText, BorderLayout.CENTER); }
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);/*w w w. ja v a 2 s .com*/ } } 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:eu.lp0.cursus.ui.AboutDialog.java
private void initialise() { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle(Messages.getString("about.title", Constants.APP_DESC)); //$NON-NLS-1$ DefaultUnitConverter duc = DefaultUnitConverter.getInstance(); FormLayout layout = new FormLayout("2dlu, pref, fill:pref:grow, max(30dlu;pref), 2dlu", //$NON-NLS-1$ "2dlu, max(15dlu;pref), 2dlu, max(15dlu;pref), 2dlu, fill:max(100dlu;pref):grow, 2dlu, max(16dlu;pref), 2dlu"); //$NON-NLS-1$ getContentPane().setLayout(layout);/*from w w w . java 2s .c o m*/ JLabel lblName = new JLabel(Constants.APP_NAME + ": " + Messages.getString("about.description")); //$NON-NLS-1$ //$NON-NLS-2$ getContentPane().add(lblName, "2, 2, 3, 1"); //$NON-NLS-1$ getContentPane().add(new LinkJButton(Constants.APP_URL), "2, 4"); //$NON-NLS-1$ JScrollPane scrCopying = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); getContentPane().add(scrCopying, "2, 6, 3, 1"); //$NON-NLS-1$ JTextArea txtCopying = new JTextArea(loadResources("COPYRIGHT", "LICENCE")); //$NON-NLS-1$ //$NON-NLS-2$ txtCopying.setFont(Font.decode(Font.MONOSPACED)); txtCopying.setEditable(false); scrCopying.setViewportView(txtCopying); scrCopying.setPreferredSize( new Dimension(scrCopying.getPreferredSize().width, duc.dialogUnitYAsPixel(100, scrCopying))); Action actClose = new CloseDialogAction(this); JButton btnClose = new JButton(actClose); getContentPane().add(btnClose, "4, 8"); //$NON-NLS-1$ getRootPane().setDefaultButton(btnClose); getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CloseDialogAction.class.getName()); getRootPane().getActionMap().put(CloseDialogAction.class.getName(), actClose); pack(); setMinimumSize(getSize()); setSize(getSize().width, getSize().height * 3 / 2); btnClose.requestFocusInWindow(); }
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; }// w ww .j a v a 2 s . com 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.filelocker.gui.Events.java
public void make() { // PrintStream oldOut = System.out; PrintStream printStream = new PrintStream(new OutputStream() { @Override//from w ww .j a v a 2s. c om public void write(byte[] buffer, int offset, int length) throws IOException { final String text = new String(buffer, offset, length); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { vNotificationArea.append(text); } }); } @Override public void write(int b) throws IOException { write(new byte[] { (byte) b }, 0, 1); } }); System.setOut(printStream); vPasswordField.setEchoChar('#'); vPasswordLabel.setFont(bigFont); vBrowseLabel.setFont(bigFont); vNotificationArea.setVisible(false); vNotificationArea.setEditable(false); vScroller.setVisible(false); vScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); vScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); vPanel = new JPanel(); vPanel.add(vLockButton); vPanel.add(vCloseButton); vFrame.getContentPane().add(BorderLayout.SOUTH, vPanel); vPanel = new JPanel(); vPanel.add(vPasswordLabel); vPanel.add(vPasswordField); vPanel.add(vBrowseLabel); vPanel.add(vBrowseField); vPanel.add(vBrowseButton); vPanel.add(vScroller); // vPanel.setLayout (new BoxLayout (vPanel, BoxLayout.Y_AXIS)); vFrame.getContentPane().add(BorderLayout.CENTER, vPanel); vLockButton.addActionListener(new vLockButton_Click()); vCloseButton.addActionListener(new vCloseButton_Click()); vBrowseButton.addActionListener(new vBrowseButton_Click()); }
From source file:events.ListSelectionDemo.java
public ListSelectionDemo() { super(new BorderLayout()); String[] listData = { "one", "two", "three", "four", "five", "six", "seven" }; String[] columnNames = { "French", "Spanish", "Italian" }; list = new JList(listData); listSelectionModel = list.getSelectionModel(); listSelectionModel.addListSelectionListener(new SharedListSelectionHandler()); JScrollPane listPane = new JScrollPane(list); JPanel controlPane = new JPanel(); String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" }; final JComboBox comboBox = new JComboBox(modes); comboBox.setSelectedIndex(2);/*w w w . j a va2 s. co m*/ comboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String newMode = (String) comboBox.getSelectedItem(); if (newMode.equals("SINGLE_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); } else { listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } output.append("----------" + "Mode: " + newMode + "----------" + newline); } }); controlPane.add(new JLabel("Selection mode:")); controlPane.add(comboBox); //Build output area. output = new JTextArea(1, 10); output.setEditable(false); JScrollPane outputPane = new JScrollPane(output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); //Do the layout. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); add(splitPane, BorderLayout.CENTER); JPanel topHalf = new JPanel(); topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS)); JPanel listContainer = new JPanel(new GridLayout(1, 1)); listContainer.setBorder(BorderFactory.createTitledBorder("List")); listContainer.add(listPane); topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); topHalf.add(listContainer); //topHalf.add(tableContainer); topHalf.setMinimumSize(new Dimension(100, 50)); topHalf.setPreferredSize(new Dimension(100, 110)); splitPane.add(topHalf); JPanel bottomHalf = new JPanel(new BorderLayout()); bottomHalf.add(controlPane, BorderLayout.PAGE_START); bottomHalf.add(outputPane, BorderLayout.CENTER); //XXX: next line needed if bottomHalf is a scroll pane: //bottomHalf.setMinimumSize(new Dimension(400, 50)); bottomHalf.setPreferredSize(new Dimension(450, 135)); splitPane.add(bottomHalf); }
From source file:dk.dma.epd.common.prototype.gui.voct.VOCTAdditionalInfoPanel.java
/** * Constructor/* w ww. j a va2 s.com*/ * * @param compactLayout * if false, there will be message type selectors in the panel */ public VOCTAdditionalInfoPanel(boolean compactLayout) { super(new BorderLayout()); EPD.getInstance().getVoctHandler().addVoctSarInfoListener(this); // Prepare the title header titleHeader.setBackground(getBackground().darker()); titleHeader.setOpaque(true); titleHeader.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); titleHeader.setHorizontalAlignment(SwingConstants.CENTER); add(titleHeader, BorderLayout.NORTH); // Add messages panel scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); messagesPanel.setBackground(UIManager.getColor("List.background")); messagesPanel.setOpaque(false); messagesPanel.setLayout(new GridBagLayout()); messagesPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(scrollPane, BorderLayout.CENTER); JPanel sendPanel = new JPanel(new GridBagLayout()); add(sendPanel, BorderLayout.SOUTH); Insets insets = new Insets(2, 2, 2, 2); // Add text area // if (false) { // messageText = new JTextField(); // ((JTextField) messageText).addActionListener(this); // sendPanel.add(messageText, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0)); // // } else { messageText = new JTextArea(); JScrollPane scrollPane2 = new JScrollPane(messageText); scrollPane2.setPreferredSize(new Dimension(100, 50)); scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); sendPanel.add(scrollPane2, new GridBagConstraints(0, 0, 1, 2, 1.0, 1.0, NORTH, BOTH, insets, 0, 0)); // } // Add buttons // ButtonGroup group = new ButtonGroup(); if (!compactLayout) { JToolBar msgTypePanel = new JToolBar(); msgTypePanel.setBorderPainted(false); msgTypePanel.setOpaque(true); msgTypePanel.setFloatable(false); sendPanel.add(msgTypePanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0)); } if (compactLayout) { addBtn = new JButton("Add to Log"); sendPanel.add(addBtn, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0)); } // addBtn.setEnabled(false); // messageText.setEditable(false); addBtn.addActionListener(this); }
From source file:com.k42b3.sacmis.Sacmis.java
public Sacmis(String path, String file, int exitCode, boolean writerStdIn) throws Exception { this.path = path; this.file = file; this.exitCode = exitCode; this.writerStdIn = writerStdIn; this.setTitle("sacmis (version: " + ver + ")"); this.setLocation(100, 100); this.setSize(600, 500); this.setMinimumSize(this.getSize()); // arguments/* w w w. j av a 2 s .c om*/ JPanel panelArgs = new JPanel(); panelArgs.setLayout(new BorderLayout()); panelArgs.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); this.args = new Args(); this.args.setText(file); panelArgs.add(this.args, BorderLayout.CENTER); this.add(panelArgs, BorderLayout.NORTH); // main panel JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT); this.in = new In(); JScrollPane scrIn = new JScrollPane(this.in); scrIn.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); scrIn.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrIn.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp.add(scrIn); this.out = new Out(); JScrollPane scrOut = new JScrollPane(this.out); scrOut.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); scrOut.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrOut.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp.add(scrOut); this.add(sp, BorderLayout.CENTER); // toolbar this.toolbar = new Toolbar(); this.toolbar.getRun().addActionListener(new runHandler()); this.toolbar.getReset().addActionListener(new resetHandler()); this.toolbar.getAbout().addActionListener(new aboutHandler()); this.toolbar.getExit().addActionListener(new exitHandler()); this.getContentPane().add(this.toolbar, BorderLayout.SOUTH); this.setVisible(true); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.loadFile(); }