Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get acces to elements from another GUi?
    primarykey
    data
    text
    <p>First I have a GUI (gui1), when I press a button, a different GUI (gui2) is created. My question is: How I can get access to elements from gui2, using methods from gui1?</p> <p>Example: When I press a button from gui1, I want to <code>QuesHandText.setText(myVector[0]);</code> <code>QuesHandText</code> is a <code>JTextField</code> from gui1 and <code>myVector[0]</code> a var from gui2. The result error message: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException</p> <p>When I press Ok from Gui2 , I want to setText for the JTextField on Gui1 <a href="http://img72.imageshack.us/img72/2822/36185233.png" rel="nofollow">http://img72.imageshack.us/img72/2822/36185233.png</a></p> <pre><code> //imports public class Gui extends JFrame{ public JButton Simulate, Particular, Start, HandSelection; public JTextField QuesHandText, FlopTurnRiverText, RezultatText; public Gui g; public Gui() { QuesHandText = new JTextField(4); //instruct ClassParticular handler1 = new ClassParticular(); Particular.addActionListener(handler1); } public Gui(String t) { //instruct myVector[0]="some_string"; myVector[1]="some_string2"; } public class ClassParticular implements ActionListener{ public void actionPerformed(ActionEvent event){ //instruc HandSelection hs = new HandSelection(); HandSelection.addActionListener(hs); StartClass hndlr = new StartClass(); Start.addActionListener(hndlr); add(HandSelection); add(Start); } } public class HandSelection implements ActionListener{ public void actionPerformed(ActionEvent e){ g = new Gui("Hand selection"); g.setVisible(true); g.setSize(1135,535); g.setDefaultCloseOperation(HIDE_ON_CLOSE); g.setResizable(false); } } public class StartClass implements ActionListener{ public void actionPerformed(ActionEvent event){ QuesHandText.setText(myVector[0]); // THE PROBLEM IS HERE, I KNOW IT !! } } </code></pre> <p>}</p>
    singulars
    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.
 

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