Search code examples
javaswinglayoutnetbeansborder-layout

Netbeans property sheet Swing control in a container from Navigator window


While the JButton has a Layout category from the Properties sheet, the other components do not. Specifically, the JList is part of a JScrollPane which is, apparently, unclickable.

How do I select the JScrollPane to edit its direction property?

In the Netbeans GUI builder, the following code is auto-generated and isn't editable:

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jButton1 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jScrollPane2 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList();
jScrollPane3 = new javax.swing.JScrollPane();
jList2 = new javax.swing.JList();
jScrollPane4 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();

setLayout(new java.awt.BorderLayout());

jButton1.setText("jButton1");
add(jButton1, java.awt.BorderLayout.CENTER);

jScrollPane1.setViewportView(jTextPane1);

add(jScrollPane1, java.awt.BorderLayout.PAGE_START);

jList1.setModel(new javax.swing.AbstractListModel() {
    String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
    public int getSize() { return strings.length; }
    public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane2.setViewportView(jList1);

add(jScrollPane2, java.awt.BorderLayout.PAGE_END);

jList2.setModel(new javax.swing.AbstractListModel() {
    String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
    public int getSize() { return strings.length; }
    public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane3.setViewportView(jList2);

add(jScrollPane3, java.awt.BorderLayout.LINE_END);

jTable1.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {
        {null, null, null, null},
        {null, null, null, null},
        {null, null, null, null},
        {null, null, null, null}
    },
    new String [] {
        "Title 1", "Title 2", "Title 3", "Title 4"
    }
));
jScrollPane4.setViewportView(jTable1);

add(jScrollPane4, java.awt.BorderLayout.LINE_START);
}// </editor-fold>
// Variables declaration - do not modify

Solution

  • Select the panel you want to modify, in the PropertySheet, scroll down to the Layout category. From there, modify the direction property.