I have a weird issue... I'm a relatively new "enthusiast" Java programmer (I used to make my living hacking Perl, in a previous career), working on my first semi-real application. "Main-Class" is the MyApp
class, which creates a UserInputDialog
instance.
UserInputDialog
is a class I wrote that extend
s JFrame
, implements ActionListener
and KeyListener
, uses FlowLayout
, and presents the user with a JLabel
, JTextField
, and Cancel/OK JButton
s. When the JTextField
generates a KeyEvent
where keyReleased() == KeyEvent.VK_ENTER
, or when the "OK" JButton
generates an ActionEvent
, UserInputDialog
does some input validation, calls setVisible(false)
, and then calls MyApp.doSomething( JTextFieldInstance.getText() )
.
That all works perfectly. But now I'm trying to add a progress window to MyApp
, as doSomething()
can occasionally take a fair amount of time to complete.
I created the ProgressWindow
class, which extends JFrame
, uses BorderLayout
, and tosses a JProgressBar
in .NORTH
and a JScrollPane
(wrapping a JTextArea
) in .CENTER
. ProgressWindow
works perfectly when instantiated from ProgressWindowTester
and fed test data. It also works fine if I copy-and-paste the test for loops from ProgressWindowTester
into MyApp
and don't have MyApp
instantiate UserInputDialog
(i.e., there's nothing inherent in MyApp
that's causing this behavior; it seems to be some sort of interaction I'm not understanding, between UserInputDialog
and ProgressWindow
).
But when I try to use ProgressWindow
in MyApp
as intended, i.e., ProgressWindow
setVisible(true), I get a blank Swing window (of the proper size, and with the title bar set properly). The JProgressBar
and JScrollPane / JTextArea
components don't appear. The ProgressWindow
methods are being called by MyApp
properly (System.err.println()
messages show proper interaction), everything appears to be working fine, just, the components that should be visible in ProgressWindow
... aren't.
I can post code snippets, but it's kind of convoluted, and I'm probably just missing something obvious...
I'm familiar with the concept of separating UI and business logic generally (e.g., I used HTML::Template
and Class::DBI
and CGI::Application
when building Perl applications), but I'm not sure I'm "doing it right" in Java...
Thanks in advance!
Oh, I get exactly the same behavior on the two environments I've tried the code in: javac 1.6.0_29 on Mac OS X 10.6.8 ("Snow Leopard"); and javac 1.7.0_02[1] on the Fedora 15 Linux distribution, kernel 2.6.31.10-3, LXDE desktop environment.
[1] Downloaded directly from oracle.com; I;m not using OpenJDK (I know JDK 7 is based on OpenJDK) or gcj or anything like that