Thread View: borland.public.jbuilder.java.swing
2 messages
2 total messages
Started by tom
Tue, 14 Feb 2006 22:31
What's wrong with this code?
Author: tom
Date: Tue, 14 Feb 2006 22:31
Date: Tue, 14 Feb 2006 22:31
70 lines
2778 bytes
2778 bytes
Hi,
Could someone please tell me what's wrong with the following code?
I tried to run the splash screen on a seperate thread, but it will only show
up after the main thread is finished.
Is there a way to allow the two thread starting at the same time?
Any suggestion will be appreciated.
Thanks,
Tom
here is my code snip.
....
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception exception) {
exception.printStackTrace();
}
Runnable runner = new Runnable() {
public void run() {
try {
Thread.sleep(1000);
}catch (InterruptedException e){}
validate_users();
String status = "Loading... Please wait...";
JDialog jwin = new JDialog();
JLabel l = new JLabel();
JPanel jpanel = new JPanel();
l.setText("Now Loading...");
l.setIcon(image3);
l.setVisible(true);
jpanel.add(
new JLabel("Now Loading...",
SwingConstants.CENTER));
jpanel.setVisible(true);
jwin.getContentPane().add(jpanel, BorderLayout.CENTER);
jwin.setTitle(status);
jwin.setResizable(false);
//jwin.setModal(true);
jwin.setBackground(Color.lightGray);
jwin.setBounds(400, 400, 250, 150);
jwin.setVisible(true);
jwin.repaint();
}
};
EventQueue.invokeLater(runner);
new Appilcation();
}
});
}
Re: What's wrong with this code?
Author: Lori M Olson [TeamB]
Date: Tue, 14 Feb 2006 23:56
Date: Tue, 14 Feb 2006 23:56
99 lines
3732 bytes
3732 bytes
tom wrote:
> Hi,
>
> Could someone please tell me what's wrong with the following code?
> I tried to run the splash screen on a seperate thread, but it will only show
> up after the main thread is finished.
> Is there a way to allow the two thread starting at the same time?
>
> Any suggestion will be appreciated.
>
> Thanks,
>
> Tom
>
> here is my code snip.
>
> ....
> public static void main(String[] args) {
>
> SwingUtilities.invokeLater(new Runnable() {
> public void run() {
> try {
> UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
> }
> catch (Exception exception) {
> exception.printStackTrace();
> }
>
> Runnable runner = new Runnable() {
> public void run() {
> try {
> Thread.sleep(1000);
> }catch (InterruptedException e){}
>
> validate_users();
>
> String status = "Loading... Please wait...";
> JDialog jwin = new JDialog();
>
> JLabel l = new JLabel();
> JPanel jpanel = new JPanel();
>
> l.setText("Now Loading...");
> l.setIcon(image3);
> l.setVisible(true);
> jpanel.add(
> new JLabel("Now Loading...",
> SwingConstants.CENTER));
>
> jpanel.setVisible(true);
> jwin.getContentPane().add(jpanel, BorderLayout.CENTER);
>
> jwin.setTitle(status);
> jwin.setResizable(false);
> //jwin.setModal(true);
> jwin.setBackground(Color.lightGray);
> jwin.setBounds(400, 400, 250, 150);
> jwin.setVisible(true);
> jwin.repaint();
>
> }
>
> };
> EventQueue.invokeLater(runner);
>
> new Appilcation();
> }
>
> });
>
> }
>
>
Googling for - swing splash thread
Yields:
http://www.javaworld.com/javaworld/javatips/jw-javatip104.html
--
Regards,
Lori Olson [TeamB]
------------
Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.
Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
http://www.visi.com/~gyles19/fom-serve/cache/1.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads