Note that there are some explanatory texts on larger screens.

plurals
  1. POI have a JLabel that doesn't want to update
    primarykey
    data
    text
    <p>I've looked at other JLabel threads and though similar, a few just don't seem to apply to what I'm experiencing. First, I want to say I am a novice when it comes to Java. Next, I am trying to follow tutorials and demos at the docs.oracle.com site. Now, I can update the label when I type something into a JTextField and there is an ActionListener on that...</p> <p>But I also have a Menu, and when I select a Menu Item, that Action does not want to update the label.</p> <p>Questions - </p> <ol> <li>How do I have action listeners on both JTextFields and JMenuItems? Are there two ActionEvent methods or do I use one method and somehow identify each type of action?</li> <li>If I use the same basic code in the JTextField ActionEvent and JMenuItem ActionEvent, the JLabel updates correctly with the JTextField event but not JMenuItem event. They both use the messageField.setText property. Could the JMenuItem action be doing something to block the setText?</li> </ol> <p>I can easily copy code in here, but it's pretty spaghetti-like at the moment, so if you want to see anything, let me know specifically and I'll post it.</p> <p>I would appreciate any assistance that anyone would be able to provide.</p> <p>---edit--- Wow!! Thanks for all of the comments and suggestions.</p> <p>1 - I know it has to be my code. As I mentioned, I am really just cobbling stuff together from demos and tutorials, and trying to learn Java along the way. I've just never gotten the hang of object oriented.... 2 - I do know the individual Listeners are working. I'm using System.out.println to validate, as well as inspecting those labels in debug mode to see they have indeed changed.<br> 3 - I will look at the various links and code posted here and see if I can figure out what's wrong with my code.</p> <p>Really, thanks again!</p> <p>---edit---</p> <p>Here is what I originally had in my createAndShowGUI method....</p> <pre class="lang-java prettyprint-override"><code>private static void createAndShowGUI() { JFrame frame = new JFrame("Create XML for Photo Gallery"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); CreateGalleryXML window = new CreateGalleryXML(); frame.setJMenuBar(window.createMenuBar()); frame.add(new CreateGalleryXML()); frame.pack(); frame.setVisible(true); } </code></pre>
    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