gpt4 book ai didi

java - Netbeans 属性表 导航器窗口中容器中的 Swing 控件

转载 作者:太空宇宙 更新时间:2023-11-04 08:08:51 25 4
gpt4 key购买 nike

虽然 JButton 在属性表中具有布局类别,但其他组件却没有。具体来说,JList 是 JScrollPane 的一部分,显然,它是不可点击的。

如何选择 JScrollPane 来编辑其方向属性?

在 Netbeans GUI 构建器中,以下代码是自动生成的且不可编辑:

/**
* 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

最佳答案

选择要修改的面板,在 PropertySheet 中,向下滚动到 Layout 类别。从那里,修改 direction 属性。

关于java - Netbeans 属性表 导航器窗口中容器中的 Swing 控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11604731/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com