Example usage for javax.swing JScrollPane JScrollPane

List of usage examples for javax.swing JScrollPane JScrollPane

Introduction

In this page you can find the example usage for javax.swing JScrollPane JScrollPane.

Prototype

public JScrollPane(Component view) 

Source Link

Document

Creates a 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.

Usage

From source file:MainClass.java

public static void main(String args[]) {
    JFrame f = new JFrame("JTree Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JTree tree = new JTree();
    JScrollPane scrollPane = new JScrollPane(tree);
    f.add(scrollPane, BorderLayout.CENTER);
    f.setSize(300, 200);//w w  w .jav a 2  s.  c  o  m
    f.setVisible(true);
}

From source file:TreeRowHeight15.java

public static void main(String[] argv) {
    JTree tree = new JTree();

    tree.setRowHeight(15);//from  ww  w .  j ava2 s .  c o  m

    JFrame frame = new JFrame("Image");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new JScrollPane(tree));
    frame.setSize(380, 320);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    File f = new File("index.html");
    JEditorPane jep = new JEditorPane(f.toURI().toURL());

    JScrollPane sp = new JScrollPane(jep);
    sp.setPreferredSize(new Dimension(400, 200));

    JOptionPane.showMessageDialog(null, sp);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTextArea textArea = new JTextArea();
    JScrollPane pane = new JScrollPane(textArea);

    // Listen for value changes in the scroll pane's scrollbars
    AdjustmentListener listener = new MyAdjustmentListener();
    pane.getHorizontalScrollBar().addAdjustmentListener(listener);
    pane.getVerticalScrollBar().addAdjustmentListener(listener);
}

From source file:Main.java

public static void main(String[] argv) {
    int rows = 10;
    int cols = 5;
    JTable table = new JTable(rows, cols);
    JFrame f = new JFrame();
    f.setSize(300, 300);//from ww w.ja va 2s. c  o m
    f.add(new JScrollPane(table));
    f.setVisible(true);

}

From source file:Main.java

public static void main(String args[]) {
    JTable table = new JTable(22, 5);
    table.setPreferredScrollableViewportSize(new Dimension(400, 300));
    final JScrollPane scrollPane = new JScrollPane(table);
    JButton cornerButton = new JButton("#");
    scrollPane.setCorner(JScrollPane.UPPER_TRAILING_CORNER, cornerButton);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    JFrame frame = new JFrame();
    frame.add(scrollPane);/*from  w  ww .j a  v a 2s.  c  om*/
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    final JEditorPane editPane1 = new JEditorPane("text/html", "Try ty\tping some tabs");
    editPane1.setPreferredSize(new Dimension(400, 300));
    JOptionPane.showMessageDialog(null, new JScrollPane(editPane1));
    JOptionPane.showMessageDialog(null, new JScrollPane(new JEditorPane("text/html", editPane1.getText())));
}

From source file:Main.java

public static void main(String[] args) {
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            JScrollPane scrollpane = new JScrollPane(new ScrollPaneArtifacts());
            scrollpane.getViewport().setPreferredSize(new Dimension(400, 400));
            JFrame frame = new JFrame("ScrollPaneArtifacts");
            frame.getContentPane().add(scrollpane);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();//from ww w.  j a  v  a 2 s. c o m
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
}

From source file:TreeRowHeightCalculation.java

public static void main(String[] argv) {
    JTree tree = new JTree();

    tree.setRowHeight(0);/*  w w w .  jav a2 s. c  o m*/

    JFrame frame = new JFrame("tree row height calculation");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new JScrollPane(tree));
    frame.setSize(380, 320);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JTree tree = new JTree();
    for (int i = 0; i < tree.getRowCount(); i++) {
        tree.expandRow(i);/*ww  w .jav a  2s . c  o  m*/
    }
    f.add(new JScrollPane(tree));
    f.pack();
    f.setSize(200, 200);
    f.setVisible(true);
}