我有两个clases GUI(这renderes我的主要的JFrame)和打印类(即由JButton的调用上GUI类)。现在,在我的GUI类,我有JTextArea中和的方法:静态方法来分配非静态变量
void setOutput(String data)
{
// output is JTextArea
output.setText(data);
}
但是数据提供了打印的JFrame在那里我有一个JButton用行动听众:
sizOpt.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent event)
{
// textfield is a JTextField component
String data = textfield.getText();
// My problem is here i need to invoke the setOutput
// method in GUI to output the string however i cant call that method in
// any way but making it static or calling new GUI which will create a new
// Instance of GUI class
GUI.setOutput(data);
}
});
那么......这个问题是怎么回事?很好很抱歉看到它,但是真的不应该把你的实际问题放在代码示例中的注释中。 –
对不起,这是上午5点,我的眼睛正在放血,我的思想即将临近突破点。 –