3
访问文本区域我将如何能够从运行这个功能我的主要()来构建GUI,然后使用代码从其他地方来处理按一下按钮,并从文本字段检索输入?能够从不同的类
package main;
import javax.swing.*;
import java.awt.*;
public class Gui {
public static void mainGUI() {
UIManager.put("swing.boldMetal", Boolean.FALSE);
java.net.URL imgApp = ClassLoader.getSystemResource("res/app.png");
JFrame mainWin = new JFrame("jIRC");
mainWin.setSize(1024, 720);
mainWin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainWin.setIconImage(new ImageIcon(imgApp).getImage());
Container panel = mainWin.getContentPane();
panel.setLayout(null);
JTextArea inputBox = new JTextArea();
inputBox.setSize(300, 100);
inputBox.setLocation(500, 250);
JButton sendButton = new JButton();
sendButton.setText("Send");
sendButton.setFont(new Font("Helvetica", Font.ITALIC, 16));
sendButton.setSize(72, 32);
sendButton.setLocation(500, 500);
panel.add(inputBox);
panel.add(sendButton);
mainWin.setVisible(true);
}
}
这里是我的类主要功能:
public class Run{
public static void main(String[] args) {
main.Debug.startupDebug();
main.Gui.mainGUI();
}
}
我将如何去把我的一些代码在非静态字段?
编辑成我的主要职务 – 2013-04-03 23:07:40
@DrZarreh:请将此代码为编辑张贴到你的问题,因为代码不会在评论格式化好。 – 2013-04-03 23:08:23
@DrZarreh:请参阅编辑。 – 2013-04-03 23:11:59