Swing添加纵向滚动条,求高手帮忙解决一下,小弟在线等,急急急!
privateJFrame_Frame=newJFrame();privateJPanel_productPanel=newJPanel();privatevoidini...
private JFrame _Frame = new JFrame();
private JPanel _productPanel = new JPanel();
private void initProductConfig() {
_Frame.setTitle("配置文件参数");
_Frame.setBounds(10, 10, 80, 50);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
tabbedPane.setBounds(10, 10, 77, 42);
_productPanel.setLayout(null);
tabbedPane.add(_productPanel,"商品配置");
int m = 10, n = 37;
int x1 = 10, x2 = 12, x3 = 23, x4 = 49, x5 = 55;
JLabel CILabel = new JLabel("配置项");
CILabel.setBounds(x1, m, 100, 20);
_productPanel.add(CILabel);
JLabel pageLabel = new JLabel("页面选择");
pageLabel.setBounds(x2, m, 100, 20);
_productPanel.add(pageLabel);
_Frame.getContentPane().add(tabbedPane);
}
这是我当前样式,但是滚动条没有出现
_productPanel.setLayout(null);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
tabbedPane.setBounds(10, 10, 824, 376);
_Frame.getContentPane().add(tabbedPane);
JScrollPane jsp = new JScrollPane(tabbedPane);
tabbedPane.add(_productPanel,"商品配置");
_Frame.getContentPane().add(jsp, BorderLayout.CENTER);
如果改为_productPanel.setLayout(new GridLayout(20, 20));就可以显示滚动条,但样式全变了 展开
private JPanel _productPanel = new JPanel();
private void initProductConfig() {
_Frame.setTitle("配置文件参数");
_Frame.setBounds(10, 10, 80, 50);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
tabbedPane.setBounds(10, 10, 77, 42);
_productPanel.setLayout(null);
tabbedPane.add(_productPanel,"商品配置");
int m = 10, n = 37;
int x1 = 10, x2 = 12, x3 = 23, x4 = 49, x5 = 55;
JLabel CILabel = new JLabel("配置项");
CILabel.setBounds(x1, m, 100, 20);
_productPanel.add(CILabel);
JLabel pageLabel = new JLabel("页面选择");
pageLabel.setBounds(x2, m, 100, 20);
_productPanel.add(pageLabel);
_Frame.getContentPane().add(tabbedPane);
}
这是我当前样式,但是滚动条没有出现
_productPanel.setLayout(null);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
tabbedPane.setBounds(10, 10, 824, 376);
_Frame.getContentPane().add(tabbedPane);
JScrollPane jsp = new JScrollPane(tabbedPane);
tabbedPane.add(_productPanel,"商品配置");
_Frame.getContentPane().add(jsp, BorderLayout.CENTER);
如果改为_productPanel.setLayout(new GridLayout(20, 20));就可以显示滚动条,但样式全变了 展开
若以下回答无法解决问题,邀请你更新回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询