Search code examples
javaswinghidden-fieldbeep

Java Swing: Audible sound when altering hidden UI element on unselected panel of JTabbedPane


I'm new to Java, so I'm having a hard time tracking down an answer to this on my own. I'm writing a Java application, and I'm using Swing. I'm not sure if it's relevant, but I'm using Netbeans as my IDE on a Mac.

I've been having this problem where an audible sound would be emitted whenever my Java program was launched. I tracked it down to a setText method call to a JTextField element that happens to be on an unselected panel of a JTabbedPane. If I comment that out, the sound doesn't occur.

The reason I want to do this is so that when that panel is selected, it will appear with the correct info, which I don't know until the program has started up.

Does anyone have an idea as to why this is happening and how to disable it?

Thanks!


Solution

  • Questioner's comment seems like it should be an answer, so here goes:

    It had nothing to do with being hidden. I was thoughtlessly doing this from a thread other than the event dispatch. I'm not sure why it beeped, but when I properly used invokeLater, the sound went away.