Example usage for javax.swing JScrollPane setBorder

List of usage examples for javax.swing JScrollPane setBorder

Introduction

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

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.")
public void setBorder(Border border) 

Source Link

Document

Sets the border of this component.

Usage

From source file:Main.java

/**
 * Returns a new JScrollPane with the specified component and with an empty border.
 *
 * @param component the component to add to the scroll pane.
 * @return a new scroll pane./*from  w  w w.  j  a v  a  2  s . c  o  m*/
 */
public static JScrollPane borderlessScrollPane(final Component component) {
    JScrollPane pane = new JScrollPane(component);
    pane.setBorder(BorderFactory.createEmptyBorder());
    return pane;
}

From source file:Main.java

public static <T extends JComponent> JScrollPane wrap(final T component, final String title) {

    final JScrollPane scrollPane = new JScrollPane(component);
    scrollPane.setBorder(BorderFactory.createTitledBorder(scrollPane.getBorder(), title));
    return scrollPane;
}

From source file:Main.java

/**
 * @param scrollPane/*from   w  w  w .  j a  va 2  s  .  co m*/
 * @return
 */
public static GridBagConstraints initScrollPane(JScrollPane scrollPane) {
    scrollPane.setLayout(new ScrollPaneLayout());
    scrollPane.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    GridBagConstraints gb = new GridBagConstraints();
    gb.gridx = 0;
    gb.gridy = 0;
    gb.insets = new Insets(2, 2, 2, 2);
    return gb;
}

From source file:Main.java

/**
 * Creates a new <code>JScrollPane</code> object with the given properties.
 *
 * @param component The component of the scroll pane
 * @param bounds The dimension of the component
 * @param backgroundColor The color of the background
 * @param noBorder if true then the scroll pane is without border otherwise
 * the scroll pane will have also a border
 * @param visible if true then the scroll pane will be visible otherwise the
 * scroll pane will be invisible// w w  w  .  j av a 2 s .c  o  m
 * @return A <code>JScrollPane</code> object
 */
public static JScrollPane createJScrollPane(Component component, Rectangle bounds, Color backgroundColor,
        boolean noBorder, boolean visible) {
    JScrollPane pane = new JScrollPane();
    if (bounds != null) {
        pane.setBounds(bounds);
    }
    pane.setBackground(backgroundColor);
    pane.setViewportView(component);
    if (noBorder) {
        pane.setBorder(null);
    }
    if (!visible) {
        pane.setVisible(false);
    }
    return pane;
}

From source file:edu.ku.brc.specify.config.init.secwiz.DatabasePanel.java

/**
 * @param bgColor//from   w  ww . j a va 2s.co m
 * @param htmlFileName
 * @return
 */
public static JComponent createHelpPanel(final Color bgColor, final String htmlFileName) {
    Locale currLocale = Locale.getDefault();

    String helpMasterPath = (new File(".")).getAbsolutePath() + File.separator + "../" + "help/securitywiz/"
            + htmlFileName;
    String fullHelpMasterPath = UIHelper.createLocaleName(currLocale, helpMasterPath, "html");

    JEditorPane htmlPane = null;
    try {
        File file = new File(fullHelpMasterPath);
        if (!file.exists()) // for testing
        {
            helpMasterPath = (new File(".")).getAbsolutePath() + File.separator + "help/securitywiz/"
                    + htmlFileName;
            fullHelpMasterPath = UIHelper.createLocaleName(currLocale, helpMasterPath, "html");
            file = new File(fullHelpMasterPath);
            System.out.println(file.getCanonicalPath());
        }
        URI url = file.toURI();

        htmlPane = new JEditorPane(url.toURL()); //$NON-NLS-1$
        htmlPane.setEditable(false);
        htmlPane.setBackground(bgColor);

    } catch (IOException ex) {
        File file = new File(fullHelpMasterPath);
        String htmlDesc = "";
        try {
            htmlDesc = "Error loading help: " + file.getCanonicalPath();
        } catch (IOException e) {
            e.printStackTrace();
        }
        htmlPane = new JEditorPane("text/plain", htmlDesc); //$NON-NLS-1$
    }

    JScrollPane scrollPane = UIHelper.createScrollPane(htmlPane, true);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    scrollPane.getViewport().setPreferredSize(new Dimension(400, 400));

    return scrollPane;
}

From source file:simulation.AureoZauleckAnsLab2.java

public static void DisplayTable(ArrayList<ArrayList> all, ArrayList percentages, String title) {
    JFrame frame = new JFrame();
    //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);                        
    JTable table = new JTable();
    table.setModel(new DefaultTableModel((int) (all.size() + 2), 2));

    table.setValueAt("VALUE LABELS", 0, 0);
    table.setValueAt("PERCENTAGE", 0, 1);

    table.setValueAt("TOTAL = 100%", (int) (all.size() + 1), 1);

    for (int i = 0; i < all.size(); i++) {
        table.setValueAt(all.get(i).get(0), i + 1, 0);

        table.setValueAt(new DecimalFormat("#.##").format(percentages.get(i)), i + 1, 1);

    }//w  ww.ja  v  a2 s.  c o m

    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.setBorder(BorderFactory.createTitledBorder(title));
    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:my.jabbr.app.ftpclient.ui.install.ProductLicenseInstallationPanel.java

private void initComponents() {
    try {// w  w  w. jav  a2  s . co m
        String licenseStr = FileUtils.readFileToString(new File(ConfigManager.GPL_LICENSE_FILE));
        licenseText = new JTextArea(licenseStr);
        licenseText.setColumns(20);
        licenseText.setRows(15);
        licenseText.setBorder(BorderFactory.createLineBorder(UIAccessories.BORDER_GRAY));
        licenseText.setBackground(UIAccessories.WHITE);
        licenseText.setEditable(false);

        JScrollPane scrollPane = new JScrollPane(licenseText);
        scrollPane.setBorder(null);
        scrollPane.setOpaque(false);
        scrollPane.getViewport().setOpaque(false);
        scrollPane.getViewport().setBorder(null);
        scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

        setLayout(new BorderLayout(20, 20));
        add(createTransparentFillerPanel(), BorderLayout.NORTH);
        add(scrollPane, BorderLayout.CENTER);
    } catch (IOException e) {
        e.printStackTrace();
    }

    this.setOpaque(false);
}

From source file:com.floreantpos.config.ui.OtherConfigurationView.java

public OtherConfigurationView() {
    setLayout(new BorderLayout());

    JPanel contentPanel = new JPanel();
    contentPanel.setLayout(new MigLayout("", "[][]", "[]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    tfMapApiKey = new FixedLengthTextField(); //$NON-NLS-1$
    tfMapApiKey.setLength(220);/*from   w ww  .j  av a 2 s  .  com*/
    contentPanel.add(new JLabel(Messages.getString("OtherConfigurationView.0"))); //$NON-NLS-1$
    contentPanel.add(tfMapApiKey); //$NON-NLS-1$

    JScrollPane scrollPane = new JScrollPane(contentPanel);
    scrollPane.setBorder(null);
    add(scrollPane);
}

From source file:SwingDnDTest.java

public SwingDnDFrame() {
    setTitle("SwingDnDTest");
    JTabbedPane tabbedPane = new JTabbedPane();

    JList list = SampleComponents.list();
    tabbedPane.addTab("List", list);
    JTable table = SampleComponents.table();
    tabbedPane.addTab("Table", table);
    JTree tree = SampleComponents.tree();
    tabbedPane.addTab("Tree", tree);
    JFileChooser fileChooser = new JFileChooser();
    tabbedPane.addTab("File Chooser", fileChooser);
    JColorChooser colorChooser = new JColorChooser();
    tabbedPane.addTab("Color Chooser", colorChooser);

    final JTextArea textArea = new JTextArea(4, 40);
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setBorder(new TitledBorder(new EtchedBorder(), "Drag text here"));

    JTextField textField = new JTextField("Drag color here");
    textField.setTransferHandler(new TransferHandler("background"));

    tabbedPane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            textArea.setText("");
        }/* w  w  w  . j av a2s. c o m*/
    });

    tree.setDragEnabled(true);
    table.setDragEnabled(true);
    list.setDragEnabled(true);
    fileChooser.setDragEnabled(true);
    colorChooser.setDragEnabled(true);
    textField.setDragEnabled(true);

    add(tabbedPane, BorderLayout.NORTH);
    add(scrollPane, BorderLayout.CENTER);
    add(textField, BorderLayout.SOUTH);
    pack();
}

From source file:simulation.AureoZauleckAnsLab2.java

public static void DisplayTables(double k, ArrayList<Double> cl, ArrayList<Double> cl2, ArrayList<Double> tlcl,
        ArrayList<Double> tucl, ArrayList<Double> midList, ArrayList<ArrayList<Double>> freq,
        ArrayList<Double> freqPercent, ArrayList<Double> cfs, ArrayList<Double> cps, String title) {

    JFrame frame = new JFrame();
    //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);                        
    JTable table = new JTable();
    table.setModel(new DefaultTableModel((int) (k + 2), 7));

    table.setValueAt("CLASS LIMITS", 0, 0);
    table.setValueAt("TRUE CLASS LIMITS", 0, 1);
    table.setValueAt("MIDPOINTS", 0, 2);
    table.setValueAt("FREQUENCY", 0, 3);
    table.setValueAt("%", 0, 4);
    table.setValueAt("CF", 0, 5);
    table.setValueAt("C%", 0, 6);
    table.setValueAt("n = " + N, (int) (k + 1), 3);
    table.setValueAt("TOTAL = 100%", (int) (k + 1), 4);

    for (int i = 0; i < k; i++) {
        table.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0);
        table.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1);
        table.setValueAt(midList.get(i), i + 1, 2);
        table.setValueAt(freq.get(i).size(), i + 1, 3);
        table.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4);
        table.setValueAt(cfs.get(i), i + 1, 5);
        table.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6);
    }/*from  www . j a v a  2s  .co m*/

    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.setBorder(BorderFactory.createTitledBorder(title));
    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);

    Scanner sc = new Scanner(System.in);

    int type = 0, testT = 0;
    String typeTest = "";
    do {

        System.out.println();
        System.out.println("COLLAPSE CLASS LIMITS?");
        System.out.println("[1] COLLAPSE LOWER CLASS LIMIT");
        System.out.println("[2] COLLAPSE UPPPER CLASS LIMIT");
        System.out.println("[3] COLLAPSE BOTH");
        System.out.println("[4] DON'T COLLAPSE");

        System.out.println();
        System.out.println("Please pick a number from the choices above.");

        typeTest = sc.next();

        if (IsNumber(typeTest)) {
            testT = Convert(typeTest);
        } else {
            do {
                System.out.println("Please enter a number only.");
                typeTest = sc.next();
            } while (!IsNumber(typeTest));

            testT = Convert(typeTest);
        }
        type = testT;
    } while (type < 1 || type > 4);

    if (type == 1) {

        JFrame frame2 = new JFrame();
        //frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);                        
        JTable table2 = new JTable();
        table2.setModel(new DefaultTableModel((int) (k + 2), 7));

        table2.setValueAt("CLASS LIMITS", 0, 0);
        table2.setValueAt("TRUE CLASS LIMITS", 0, 1);
        table2.setValueAt("MIDPOINTS", 0, 2);
        table2.setValueAt("FREQUENCY", 0, 3);
        table2.setValueAt("%", 0, 4);
        table2.setValueAt("CF", 0, 5);
        table2.setValueAt("C%", 0, 6);
        table2.setValueAt("n = " + N, (int) (k + 1), 3);
        table2.setValueAt("TOTAL = 100%", (int) (k + 1), 4);

        for (int i = 0; i < k; i++) {
            table2.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0);
            table2.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1);
            table2.setValueAt(midList.get(i), i + 1, 2);
            table2.setValueAt(freq.get(i).size(), i + 1, 3);
            table2.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4);
            table2.setValueAt(cfs.get(i), i + 1, 5);
            table2.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6);
        }
        table2.setValueAt("below " + cl2.get(0), 1, 0);
        table2.setValueAt(" - ", 1, 1);
        table2.setValueAt(" - ", 1, 2);

        JScrollPane scrollPane2 = new JScrollPane(table2);

        scrollPane2.setBorder(BorderFactory.createTitledBorder(title));
        frame2.add(scrollPane2, BorderLayout.CENTER);
        frame2.setSize(300, 150);
        frame2.setVisible(true);

    } else if (type == 2) {

        JFrame frame3 = new JFrame();
        //frame3.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);                        
        JTable table3 = new JTable();
        table3.setModel(new DefaultTableModel((int) (k + 2), 7));

        table3.setValueAt("CLASS LIMITS", 0, 0);
        table3.setValueAt("TRUE CLASS LIMITS", 0, 1);
        table3.setValueAt("MIDPOINTS", 0, 2);
        table3.setValueAt("FREQUENCY", 0, 3);
        table3.setValueAt("%", 0, 4);
        table3.setValueAt("CF", 0, 5);
        table3.setValueAt("C%", 0, 6);
        table3.setValueAt("n = " + N, (int) (k + 1), 3);
        table3.setValueAt("TOTAL = 100%", (int) (k + 1), 4);
        int a = (int) k;

        for (int i = 0; i < k; i++) {
            table3.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0);
            table3.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1);
            table3.setValueAt(midList.get(i), i + 1, 2);
            table3.setValueAt(freq.get(i).size(), i + 1, 3);
            table3.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4);
            table3.setValueAt(cfs.get(i), i + 1, 5);
            table3.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6);
        }
        table3.setValueAt(cl.get(a - 1) + " above", a, 0);
        table3.setValueAt(" - ", a, 1);
        table3.setValueAt(" - ", a, 2);

        JScrollPane scrollPane3 = new JScrollPane(table3);
        scrollPane3.setBorder(BorderFactory.createTitledBorder(title));
        frame3.add(scrollPane3, BorderLayout.CENTER);

        frame3.setSize(300, 150);
        frame3.setVisible(true);
    }

    else if (type == 3) {
        JFrame frame4 = new JFrame();
        //frame4.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);                        
        JTable table4 = new JTable();
        table4.setModel(new DefaultTableModel((int) (k + 2), 7));
        table4.setValueAt("CLASS LIMITS", 0, 0);
        table4.setValueAt("TRUE CLASS LIMITS", 0, 1);
        table4.setValueAt("MIDPOINTS", 0, 2);
        table4.setValueAt("FREQUENCY", 0, 3);
        table4.setValueAt("%", 0, 4);
        table4.setValueAt("CF", 0, 5);
        table4.setValueAt("C%", 0, 6);
        table4.setValueAt("n = " + N, (int) (k + 1), 3);
        table4.setValueAt("TOTAL = 100%", (int) (k + 1), 4);

        int a = (int) k;

        for (int i = 0; i < k; i++) {
            table4.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0);
            table4.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1);
            table4.setValueAt(midList.get(i), i + 1, 2);
            table4.setValueAt(freq.get(i).size(), i + 1, 3);
            table4.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4);
            table4.setValueAt(cfs.get(i), i + 1, 5);
            table4.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6);
        }
        table4.setValueAt("below " + cl2.get(0), 1, 0);
        table4.setValueAt(cl.get(a - 1) + " above", a, 0);
        table4.setValueAt(" - ", 1, 1);
        table4.setValueAt(" - ", 1, 2);
        table4.setValueAt(" - ", a, 1);
        table4.setValueAt(" - ", a, 2);

        JScrollPane scrollPane4 = new JScrollPane(table4);
        scrollPane4.setBorder(BorderFactory.createTitledBorder(title));
        frame4.add(scrollPane4, BorderLayout.CENTER);

        frame4.setSize(300, 150);
        frame4.setVisible(true);
    } else {

    }
}