List of usage examples for javax.swing JScrollPane JScrollPane
public JScrollPane(Component view)
JScrollPane
that displays the contents of the specified component, where both horizontal and vertical scrollbars appear whenever the component's contents are larger than the view. From source file:Main.java
public static void main(final String args[]) { String labels[] = { "A", "B", "C", "D", "E" }; JFrame frame = new JFrame("Sizing Samples"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList jlist1 = new JList(labels); jlist1.setVisibleRowCount(4);/*from www.j a va 2s .co m*/ JScrollPane scrollPane1 = new JScrollPane(jlist1); frame.add(scrollPane1, BorderLayout.NORTH); jlist1.setValueIsAdjusting(false); frame.setSize(300, 350); frame.setVisible(true); }
From source file:AddingToJScrollPane.java
public static void main(String args[]) { JFrame frame = new JFrame("Tabbed Pane Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("Label"); label.setPreferredSize(new Dimension(1000, 1000)); JScrollPane jScrollPane = new JScrollPane(label); frame.add(jScrollPane, BorderLayout.CENTER); frame.setSize(400, 150);/* ww w . j a va2 s. c o m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Navigation Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextArea textArea = new JTextArea(); JScrollPane scrollPane = new JScrollPane(textArea); frame.add(scrollPane, BorderLayout.CENTER); NavigationFilter filter = new NavigationFilter() { public void setDot(NavigationFilter.FilterBypass fb, int dot, Position.Bias bias) { System.out.println("Setting: " + dot); fb.setDot(dot, bias);// ww w .j a v a 2 s.c om } public void moveDot(NavigationFilter.FilterBypass fb, int dot, Position.Bias bias) { System.out.println("Moving: " + dot); fb.setDot(dot, bias); } }; textArea.setNavigationFilter(filter); frame.setSize(250, 150); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("Caret Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextArea textArea = new JTextArea(); JScrollPane scrollPane = new JScrollPane(textArea); frame.add(scrollPane, BorderLayout.CENTER); CaretListener listener = new CaretListener() { public void caretUpdate(CaretEvent caretEvent) { System.out.println("dot:" + caretEvent.getDot()); System.out.println("mark" + caretEvent.getMark()); }// w w w . j a va 2s . co m }; textArea.addCaretListener(listener); frame.setSize(250, 150); frame.setVisible(true); }
From source file:TreeDISCONTIGUOUSSelection.java
public static void main(String[] argv) { JTree tree = new JTree(); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); JFrame frame = new JFrame("tree DISCONTIGUOUS selection"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setSize(380, 320);//from w w w. j a v a 2 s . c o m frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:FlowLayoutExample.java
public static void main(String[] args) { JPanel panel = new JPanel(); JTextArea area = new JTextArea("text area"); area.setPreferredSize(new Dimension(100, 100)); JButton button = new JButton("button"); panel.add(button);// w ww. j av a 2s . c o m panel.add(new JScrollPane(area)); JFrame f = new JFrame(); f.add(panel); f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame(); f.setLayout(new FlowLayout()); f.setSize(240, 250);//from w w w . j av a 2 s . co m f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JScrollPane jscrlpLabel = new JScrollPane( new JLabel("<html>A<br>B<br>C<br>D<br>E<br>F<br>G<br>H<br></html>.")); jscrlpLabel.setPreferredSize(new Dimension(200, 100)); JLabel label = new JLabel("Option"); JCheckBox a = new JCheckBox("A"); JCheckBox b = new JCheckBox("B"); JCheckBox c = new JCheckBox("C"); JCheckBox d = new JCheckBox("D"); JCheckBox e = new JCheckBox("E"); Box box = Box.createVerticalBox(); box.add(label); box.add(a); box.add(b); box.add(c); box.add(d); box.add(e); JScrollPane jscrlpBox = new JScrollPane(box); jscrlpBox.setPreferredSize(new Dimension(140, 90)); f.add(jscrlpLabel); f.add(jscrlpBox); f.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { String labels[] = { "A", "B", "C", "D", "E" }; JFrame frame = new JFrame("Sizing Samples"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList jlist1 = new JList(labels); jlist1.setVisibleRowCount(4);//from w ww.j a v a 2 s. c o m JScrollPane scrollPane1 = new JScrollPane(jlist1); frame.add(scrollPane1, BorderLayout.NORTH); jlist1.setSelectedIndices(new int[] { 1, 2 }); frame.setSize(300, 350); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { String labels[] = { "A", "B", "C", "D", "E" }; JFrame frame = new JFrame("Sizing Samples"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList jlist1 = new JList(labels); jlist1.setVisibleRowCount(4);/*from w w w . j a v a 2 s . c om*/ JScrollPane scrollPane1 = new JScrollPane(jlist1); frame.add(scrollPane1, BorderLayout.NORTH); jlist1.setSelectionForeground(Color.RED); frame.setSize(300, 350); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { String labels[] = { "A", "B", "C", "D", "E" }; JFrame frame = new JFrame("Sizing Samples"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList jlist1 = new JList(labels); jlist1.setVisibleRowCount(4);//from ww w . j a v a 2s .c om JScrollPane scrollPane1 = new JScrollPane(jlist1); frame.add(scrollPane1, BorderLayout.NORTH); jlist1.setSelectedIndex(1); frame.setSize(300, 350); frame.setVisible(true); }