Note that there are some explanatory texts on larger screens.

plurals
  1. POAccessing a Button from another Object
    primarykey
    data
    text
    <p>I am busy doing a school project and hoped some awesome people out there could help me. I currently have a Main, a Log in GUI and a Search frame (designed with Netbeans Gui dev).</p> <p>I have an <code>actionPerformed(ActionEvent e)</code> method, where I am struggling is to access the Log in button that is on my Log in GUI. Currently I am doing this.</p> <p>In my constructor: Declare the Frame. <code>LogInFrame x = new LogInFrame();</code></p> <p>In </p> <pre><code>public actionPerformed(ActionEvent eve) { if(eve.getSource()==x.LogInBtn()) { x.setVisible(false); } } </code></pre> <p>At the moment the button isn't responding, so I was wondering if I was doing anything wrong.</p> <p>The current Frame is just a standard frame. Really simple</p> <pre><code>public static void main (String[] args) { JFrame LogInFrame = new JFrame ("Log in"); LogInFrame.setSize (300, 300); JButton close = new JButton ("Hid frame"); LogInFrame.getContentPane ().add (close); } } </code></pre> <p>Thats about everything that is needed. The problem does not lie with the GUI itself as I can run the GUI in netbeans fine. I can use the auto generated actionPerformed method of the button by double clicking on it. But i want to be able to access my GUI's compenents in my main.(tell the button what to do from my main). I have made sure that the button is public and can be accessed. I dont get any physical "coding" errors, the code just doesnt seem to be working (the button isnt responding if I add events from my main)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload