我创建了一个具有以下序列的Swing Frame,JFrame> JPanel> JScrollPane> JTextArea中。 我使用卡片布局将JPanel加载到JFrame中。
我的问题是滚动条没有正确显示(如图所示)。
我的代码如下:
jTextArea1 = new javax.swing.JTextArea();
jScrollPane1 = new javax.swing.JScrollPane(jTextArea1);
jTextArea1.setColumns(15);
jTextArea1.setEditable(false);
jTextArea1.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
jTextArea1.setRows(3);
JScrollBar verticalScrollBar = jScrollPane1.getVerticalScrollBar();
verticalScrollBar.setValue(0);
jTextArea1.setCaretPosition(0);
jScrollPane1.setPreferredSize(new java.awt.Dimension(632, 425));
//Group Layout
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(
jPanelBottomPanel,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(
jLabelImageLogoSAGUpgradeUtility,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanelStartInstaller,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap()
)
.addGroup(
layout.createSequentialGroup()
.addGap(10, 10,
10)
.addComponent(
jCheckBox1)
.addGap(0,
0,
Short.MAX_VALUE))
.addGroup(
javax.swing.GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addContainerGap()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING,
false)
.addGroup(
layout.createSequentialGroup()
.addGap(0,
0,
0)
.addComponent(
jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
0,
Short.MAX_VALUE))
.addGap(5)
.addComponent(
jPanel5,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap())
);
layout.setVerticalGroup(layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(jLabelImageLogoSAGUpgradeUtility,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(8, 8, 8)
.addComponent(jPanel5,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 0, Short.MAX_VALUE)
.addComponent(jPanelStartInstaller,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jCheckBox1)
.addComponent(jPanelBottomPanel,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
));
答案 0 :(得分:0)
征求意见,
...如果是Nibus的外观和感觉,那么我需要改变我的代码的外观和感觉......
你需要这样的东西,
UIManager.setLookAndFeel ("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");