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[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Object rowData[][] = { { "Row1-Column1", "Row1-Column2", "Row1-Column3" }, { "Row2-Column1", "Row2-Column2", "Row2-Column3" } }; Object columnNames[] = { "1", "2", "3" }; JTable table = new JTable(rowData, columnNames); JScrollPane scrollPane = new JScrollPane(table); table.setTableHeader(null);/*from www . j av a2 s . c om*/ frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) { JTree tree = new JTree() { protected void setExpandedState(TreePath path, boolean state) { if (state) { super.setExpandedState(path, state); }/*from ww w.ja v a2s . co m*/ } }; JFrame frame = new JFrame("Ignore all collapse requests"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setSize(380, 320); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:LookAndFeelMakeIcon.java
public static void main(String args[]) { JFrame frame = new JFrame("Lazy Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Object iconObject = LookAndFeel.makeIcon(LookAndFeelMakeIcon.class, "yourFile.gif"); UIManager.put("Tree.leafIcon", iconObject); JTree tree = new JTree(); JScrollPane scrollPane = new JScrollPane(tree); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(200, 200);/*from www.ja va 2 s .com*/ frame.setVisible(true); }
From source file:Main.java
public static final void main(String args[]) throws Exception { JFrame f = new JFrame(); DefaultListModel<String> dlm = new DefaultListModel<String>(); JList<String> list = new JList<>(dlm); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.add(new JScrollPane(list)); f.add(new JButton("Add") { {//from w w w . j av a2s .c o m addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dlm.addElement("A"); } }); } }, BorderLayout.SOUTH); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame("EditorPane Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); try {/*from w w w . ja va 2 s . c o m*/ JEditorPane editorPane = new JEditorPane("http://www.java2s.com"); editorPane.setEditable(false); EditorKit kit = editorPane.getEditorKit(); JScrollPane scrollPane = new JScrollPane(editorPane); frame.add(scrollPane); } catch (IOException e) { System.err.println("Unable to load: " + e); } frame.setSize(640, 480); frame.setVisible(true); }
From source file:EmptyColumnHeader.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Object rowData[][] = { { "Row1-Column1", "Row1-Column2", "Row1-Column3" }, { "Row2-Column1", "Row2-Column2", "Row2-Column3" } }; Object columnNames[] = { "", "", "" }; JTable table = new JTable(rowData, columnNames); JScrollPane scrollPane = new JScrollPane(table); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150);/* ww w .jav a2s . c o m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame("EditorPane Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); try {/*from w w w.jav a2s.com*/ JEditorPane editorPane = new JEditorPane("http://www.java2s.com"); editorPane.setEditable(false); String type = editorPane.getContentType(); JScrollPane scrollPane = new JScrollPane(editorPane); frame.add(scrollPane); } catch (IOException e) { System.err.println("Unable to load: " + e); } frame.setSize(640, 480); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("Shared Model"); JTextArea areaFiftyOne = new JTextArea(); JTextArea areaFiftyTwo = new JTextArea(); areaFiftyTwo.setDocument(areaFiftyOne.getDocument()); JTextArea areaFiftyThree = new JTextArea(); areaFiftyThree.setDocument(areaFiftyOne.getDocument()); frame.setLayout(new GridLayout(3, 1)); frame.add(new JScrollPane(areaFiftyOne)); frame.add(new JScrollPane(areaFiftyTwo)); frame.add(new JScrollPane(areaFiftyThree)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(300, 300);// w w w .j a v a 2s.c o m frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame("EditorPane Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); try {//from w w w. j a va2 s . c o m JEditorPane editorPane = new JEditorPane("http://www.java2s.com"); editorPane.setEditable(false); Dimension dimension = editorPane.getPreferredSize(); JScrollPane scrollPane = new JScrollPane(editorPane); frame.add(scrollPane); } catch (IOException e) { System.err.println("Unable to load: " + e); } frame.setSize(640, 480); frame.setVisible(true); }
From source file:ListenerSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Offset Example"); Container content = frame.getContentPane(); JTextArea textArea = new JTextArea(); JScrollPane scrollPane = new JScrollPane(textArea); final Document document = textArea.getDocument(); document.addDocumentListener(new MyListener()); content.add(scrollPane, BorderLayout.CENTER); frame.setSize(250, 150);/*from w w w . j a v a 2 s .c om*/ frame.setVisible(true); }