java中为JList添加滚动条,显示有问题
importjavax.swing.*;importjavax.swing.border.*;importjava.awt.*;publicclassUserSortex...
import javax.swing.*;import javax.swing.border.*;import java.awt.*;
public class UserSort extends JFrame {
private JPanel contentPane; static String[] names={"asfdsa","asdfa","sdaf","eqasdfasf","xc32","2sdafd"," ","x","abc","aac","ABC","dsfd","dabc"};
/** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { UserSort frame = new UserSort(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
/** * Create the frame. */ public UserSort() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 450, 300); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JList list = new JList(names); list.setBounds(10, 10, 302, 217); contentPane.add(list); contentPane.add(new JScrollPane(list));
}
}
大部分是使用eclipse的插件builder做的,最后只显示了一个空白的框框,哪位大神帮忙看看如何改,最好说说哪里出了问题 展开
public class UserSort extends JFrame {
private JPanel contentPane; static String[] names={"asfdsa","asdfa","sdaf","eqasdfasf","xc32","2sdafd"," ","x","abc","aac","ABC","dsfd","dabc"};
/** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { UserSort frame = new UserSort(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
/** * Create the frame. */ public UserSort() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 450, 300); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JList list = new JList(names); list.setBounds(10, 10, 302, 217); contentPane.add(list); contentPane.add(new JScrollPane(list));
}
}
大部分是使用eclipse的插件builder做的,最后只显示了一个空白的框框,哪位大神帮忙看看如何改,最好说说哪里出了问题 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询