使用JScrollPane的问题,纵向的滚动条出不来?
import javax.swing.*;
import java.awt.*;
public class TestFlowLayout
extends JFrame {
JScrollPane jScrollPane1 = new JScrollPane();
JPanel jPanel1 = new JPanel();
FlowLayout flowLayout1 = new FlowLayout();
BorderLayout borderLayout1 = new BorderLayout();
public TestFlowLayout() {
try {
this.setSize(400, 300);
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.getContentPane().setLayout(borderLayout1);
jPanel1.setLayout(flowLayout1);
flowLayout1.setAlignment(FlowLayout.LEFT);
for (int i = 9; i < 69; i++) {
jPanel1.add(new JButton("JButton" + (i + 1)), null);
}
jPanel1.setPreferredSize(new Dimension(380, -1));
this.getContentPane().add(jScrollPane1, BorderLayout.CENTER);
jScrollPane1.getViewport().add(jPanel1, null);
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e) {
e.printStackTrace();
}
TestFlowLayout frame = new TestFlowLayout();
frame.setVisible(true);
}
}
import java.awt.*;
public class TestFlowLayout
extends JFrame {
JScrollPane jScrollPane1 = new JScrollPane();
JPanel jPanel1 = new JPanel();
FlowLayout flowLayout1 = new FlowLayout();
BorderLayout borderLayout1 = new BorderLayout();
public TestFlowLayout() {
try {
this.setSize(400, 300);
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.getContentPane().setLayout(borderLayout1);
jPanel1.setLayout(flowLayout1);
flowLayout1.setAlignment(FlowLayout.LEFT);
for (int i = 9; i < 69; i++) {
jPanel1.add(new JButton("JButton" + (i + 1)), null);
}
jPanel1.setPreferredSize(new Dimension(380, -1));
this.getContentPane().add(jScrollPane1, BorderLayout.CENTER);
jScrollPane1.getViewport().add(jPanel1, null);
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e) {
e.printStackTrace();
}
TestFlowLayout frame = new TestFlowLayout();
frame.setVisible(true);
}
}
...全文
相关推荐
swing组件JScrollPane滚动条实例代码
主要介绍了swing组件JScrollPane滚动条实例代码,分享了两个相关代码示例,小编觉得还是挺不错的,具有一定借鉴价值,需要的朋友可以参考下
jquery滚动条插件jScrollPane的使用介绍
jScrollPane想必大家都不陌生吧它就是所谓的jquery滚动条插件,下面为大家介绍下其具体的使用,感兴趣的朋友不要错过
JScrollPane 滚动条 例子
JScrollPane 滚动条 例子
jQuery滚动条插件 jScrollPane
jScrollPane这个jQuery插件可以让你通过简单的CSS设置就能够替换所有分块元素在浏览器中默认的垂直滚动条样式。
Java常用面板之JScrollPane滚动面板实例详解
主要介绍了Java常用面板JScrollPane的简单介绍和一个相关实例,,需要的朋友可以参考下。


Java SE
