Hello everyone,
i implemented an ActionListener in a GUI and want to access an attribute of the main class object instance from within method public void actionPerformed(ActionEvent e).
The trouble is that the method does not recognize the object instance which was created in the main().
Please tell me how to handle this.
Here piece of the code:
public class GUI extends Frame implements ActionListener{
public GUI()
{...
JRadioButton byteSelected = new JRadioButton("Byteorientiert",false);
byteSelected.addActionListener(this);
...}
public static void main (String args[])
{
GUI frame = new GUI();
...}
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
String buttonClicked = e.getActionCommand();
if ((source == this().byteSelected) && (buttonClicked.equals("Text speichern"
))
{
saveByte(this().input.getText());
this().input.setText(""
;
}
}
I shall be grateful if somebody gives me advice about it.
Thanks,
Maria
i implemented an ActionListener in a GUI and want to access an attribute of the main class object instance from within method public void actionPerformed(ActionEvent e).
The trouble is that the method does not recognize the object instance which was created in the main().
Please tell me how to handle this.
Here piece of the code:
public class GUI extends Frame implements ActionListener{
public GUI()
{...
JRadioButton byteSelected = new JRadioButton("Byteorientiert",false);
byteSelected.addActionListener(this);
...}
public static void main (String args[])
{
GUI frame = new GUI();
...}
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
String buttonClicked = e.getActionCommand();
if ((source == this().byteSelected) && (buttonClicked.equals("Text speichern"
{
saveByte(this().input.getText());
this().input.setText(""
}
}
I shall be grateful if somebody gives me advice about it.
Thanks,
Maria