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(String[] args) { int bigNumber = 30001; String[] bigData = new String[bigNumber]; for (int ii = 0; ii < bigNumber; ii++) { bigData[ii] = "String " + (ii + 1); }// www .j a v a2 s. c om JList list = new JList(bigData); list.setVisibleRowCount(5); JOptionPane.showMessageDialog(null, new JScrollPane(list)); }
From source file:JListLocationToIndexSample.java
public static void main(String args[]) { String labels[] = { "A", "B", "C", "D", "E", "F", "G", "H" }; JFrame frame = new JFrame("Selecting JList"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList jlist = new JList(labels); JScrollPane scrollPane1 = new JScrollPane(jlist); frame.add(scrollPane1, BorderLayout.CENTER); System.out.println(jlist.indexToLocation(5)); frame.setSize(350, 200);//from w w w . j av a 2s.com frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextPane ta = new JTextPane(); ta.setContentType("text/html"); ta.setText("<HTML><BODY><CODE> import java.io.*; <br> public class MyIO{}</CODE><br></BODY></HTML>"); JScrollPane jsp = new JScrollPane(ta); f.getContentPane().add(jsp);//from w ww. j a va2 s . co m f.setSize(300, 200); f.setLocationRelativeTo(null); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); JTextArea textArea = new JTextArea(); f.add(new JScrollPane(textArea), BorderLayout.CENTER); Timer timer = new Timer(1000, new ActionListener() { @Override/*from www .ja v a2 s . co m*/ public void actionPerformed(ActionEvent e) { textArea.append("bla"); } }); timer.setRepeats(true); timer.start(); JButton button = new JButton("Click me"); button.addActionListener(e -> { System.out.println("Before option pane"); JOptionPane.showMessageDialog(f, "A message dialog"); System.out.println("After option pane"); }); f.add(button, BorderLayout.SOUTH); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { String subject[] = { "Math", " English", "SQL", " java", " c ", " c++ ", " cobol ", "this is a test" }; JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList<String> list = new JList<String>(subject); JScrollPane s = new JScrollPane(list); s.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); s.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); f.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG); f.add(s);/*from www .ja v a2 s. c om*/ f.setSize(300, 300); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.add(new JScrollPane(new Main())); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setVisible(true);/* w w w.ja va2 s.c om*/ }
From source file:Main.java
public static void main(String args[]) { 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()); }/*from w w w .j a va 2 s . co m*/ }; textArea.addCaretListener(listener); frame.setSize(250, 150); 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 a2s . co m JScrollPane scrollPane1 = new JScrollPane(jlist1); frame.add(scrollPane1, BorderLayout.NORTH); frame.setSize(300, 350); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table = new JTable(4, 5); // 4 rows & 5 columns table.setRowSelectionAllowed(false); table.setColumnSelectionAllowed(false); table.setCellSelectionEnabled(false); frame.add(new JScrollPane(table)); frame.setSize(300, 200);//w w w . ja va2 s. c o m frame.setVisible(true); }
From source file:TreeSingleSelection.java
public static void main(String[] argv) { JTree tree = new JTree(); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); JFrame frame = new JFrame("Tree single selection"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setSize(380, 320);/* ww w.jav a 2s . co m*/ frame.setLocationRelativeTo(null); frame.setVisible(true); }