【发布时间】:2016-01-06 06:06:23
【问题描述】:
我有一个滚动窗格,我想在其中添加多个 jlabel。
这是代码..
JPanel panelEast = new JPanel();
panelEast.setBorder(new TitledBorder(null, "Notifiche", TitledBorder.LEADING, TitledBorder.TOP, null, null));
panelEast.setPreferredSize(new Dimension(250,120));
panelEast.setLayout(null);
JLabel lblNewLabel_3 = new JLabel("label1");
lblNewLabel_3.setIcon(new ImageIcon(Home.class.getResource("/it/polimi/icon/contact.png")));
lblNewLabel_3.setBounds(10, 81, 240, 52);
panelEast.add(lblNewLabel_3);
JLabel label_3 = new JLabel("label2");
label_3.setIcon(new ImageIcon(Home.class.getResource("/it/polimi/icon/verified.png")));
label_3.setBounds(new Rectangle(4, 0, 0, 0));
label_3.setAlignmentY(Component.TOP_ALIGNMENT);
label_3.setBounds(10, 30, 240, 52);
panelEast.add(label_3);
JLabel label_4 = new JLabel("label3");
label_4.setIcon(new ImageIcon(Home.class.getResource("/it/polimi/icon/verified.png")));
label_4.setBounds(new Rectangle(4, 0, 0, 0));
label_4.setAlignmentY(Component.TOP_ALIGNMENT);
label_4.setBounds(10, 131, 240, 52);
panelEast.add(label_4);
JScrollPane scrollPane = new JScrollPane(panelEast,JScrollPane.VERTICAL_SCROLLBAR_NEVER,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
pan2.add(scrollPane,BorderLayout.CENTER);
而且不起作用,有什么建议吗?
【问题讨论】: