java,gui,怎么加滚动条?求解决啊

2025-01-26 07:58:39
推荐回答(1个)
回答1:

JScrollPane scroll = new JScrollPane();
JPanel contentPanel = new JPanel();
scroll.setViewport(contentPanel );
contentPanel.add(new JLabel("客户须知"), BorderLayout.NORTH);
contentPanel.add(new JTextArea("欢迎...", BorderLayout.CENTER);

JPanel radioPanel= new JPanel();
radioPanel.add(new JRadioButton("同意"));
radioPanel.add(new JRadioButton("不同意"));

contentPanel.add(radioPanel, BorderLayout.SOUTH);