私はGUIを作成しました。いくつかのボタンがあります。私はそれらの下にオブジェクトのようなコンソールを追加して、ユーザーがそれらを見ることができるようにメッセージを書くことができるようにしたいと思います。 私はどの要素/オブジェクト/クラスを使用すべきですか?私はそれが異なる行にメッセージを表示できるようにしたい。ここ は、GUIを作成するための私のコードです:GUIにウィンドウのような "コンソール"を追加するには?
public ssGUI() {
setLayout(new BorderLayout());
bRunNoAdj = new JButton("Run no adjustment");
bRunNoAdj.setVerticalTextPosition(AbstractButton.CENTER);
bRunNoAdj.setHorizontalTextPosition(AbstractButton.LEADING);
bRunNoAdj.setMnemonic(KeyEvent.VK_E);
bRunNoAdj.addActionListener(this);
bRunNoAdj.setEnabled(false);
bRunNoAdj.setBackground(Color.white);
bRunAdj = new JButton("Run adjustment");
bRunAdj.setVerticalTextPosition(AbstractButton.CENTER);
bRunAdj.setHorizontalTextPosition(AbstractButton.LEADING);
bRunAdj.setMnemonic(KeyEvent.VK_E);
bRunAdj.addActionListener(this);
bRunAdj.setEnabled(false);
bRunAdj.setBackground(Color.white);
bConnect = new JButton("Connect");
bConnect.setMnemonic(KeyEvent.VK_E);
bConnect.addActionListener(this);
bConnect.setEnabled(true);
bConnect.setBackground(Color.white);
bDisconnect = new JButton("Disconnect");
bDisconnect.setMnemonic(KeyEvent.VK_E);
bDisconnect.addActionListener(this);
bDisconnect.setEnabled(false);
bDisconnect.setBackground(Color.white);
bStationary = new JButton("Show Stationary");
bStationary.setMnemonic(KeyEvent.VK_E);
bStationary.addActionListener(this);
bStationary.setEnabled(false);
bStationary.setBackground(Color.white);
bMoving = new JButton("Show Moving");
bMoving.setMnemonic(KeyEvent.VK_E);
bMoving.addActionListener(this);
bMoving.setEnabled(false);
bMoving.setBackground(Color.white);
JPanel topPanel = new JPanel();
topPanel.add(bConnect);
topPanel.add(bDisconnect);
add(topPanel, BorderLayout.NORTH);
JPanel centerPanel = new JPanel();
centerPanel.add(bRunNoAdj);
centerPanel.add(bRunAdj);
add(centerPanel, BorderLayout.CENTER);
JPanel bottomPanel = new JPanel();
bottomPanel.add(bStationary);
bottomPanel.add(bMoving);
add(bottomPanel, BorderLayout.SOUTH);
}
任意の助けをいただければ幸いです、ありがとうございました。
だと思います。 – BadCash
なぜ私はそれを偽にするべきですか? –
@DanyLavrovこれをfalseに設定しないと、ユーザーは追加したメッセージを削除または変更できます。 – Roan