0
どうすればJTextArea
をスクロール可能にすることができますか? keysDisplay
にはスクロールバーがあり、これを使ってテキスト領域をスクロールすることができます。私はjFramePrint()
の未定のコードをスキップしました。SwingでJTextAreaをスクロール可能にする
public class ApplicationViewer extends JFrame {
private JTabbedPane tabs = new JTabbedPane();
private JTextArea keyGenDisplay = new JTextArea();
private JTextArea keysDisplay = new JTextArea();
private JPanel controlPanel = new JPanel();
private JButton addNumber = new JButton("Add Number");
private JButton addLetter = new JButton("Add Letter");
private JButton addHyphen = new JButton("Add Hyphen");
private JButton calculateButton = new JButton("Calculate Key");
private JTextField amountField = new JTextField("", 6);
private JLabel amountLabel = new JLabel(" Amount of Keys : ");
private JScrollPane scroll = new JScrollPane(keysDisplay);
public void jFramePrint() {
this.setLayout(new BorderLayout());
this.add(controlPanel, BorderLayout.SOUTH);
controlPanel.add(addNumber);
controlPanel.add(addLetter);
controlPanel.add(addHyphen);
controlPanel.add(amountLabel);
controlPanel.add(amountField);
controlPanel.add(calculateButton);
this.add(scroll);
this.setSize(1400, 900);
this.setTitle("Key Generator");
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
keyGenDisplay.append("Key Format: ");
keysDisplay.append("Keys Here: ");
tabs.add("Key Generator", keyGenDisplay);
tabs.add("Keys", keysDisplay);
this.add(tabs);
this.setVisible(true);
}
}
この投稿をチェックしてください:http://stackoverflow.com/questions/1052473/scrollbars-in-jtextarea –
コードを投稿するときに適切な書式を使用してください。1,2,3のスペースが使用されています。各行の字下げのために、これはコードを読みにくいものにしてくれます。 – camickr