Hello World message disappeared?!
5 Message(s) by 3 Author(s) originally posted in java misc
| From: Geoff Cox |
Date: Friday, July 15, 2005
|
Hello,
I am trying out some of the
Sun JAVA
sample code and starting to learn
about swing gui etc.
I've added the slider
object and now the Hello World
message no
longewr appears. Why is this?
Thanks
Geoff
import JAVAx.swing.*;
public
class HelloWorldSwing {
/**
* Create the
GUI and show it. For
thread safety,
* this
method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI() {
//Make sure we've nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(true);
//Create and set up the window.
JFrame
frame = new JFrame("HelloWorldSwing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800, 600);
//Add the ubiquitous "Hello World" label.
JLabel label = new JLabel("Hello World");
frame.getContentPane().add(label);
//Add slider
JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 20, 1);
frame.getContentPane().add(slider);
//Display the window.
// frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a
job for the event-dispatching thread:
//creating and showing this application's GUI.
JAVAx.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
| From: Andrew Thompson |
Date: Friday, July 15, 2005
|
wrote in message:
I am trying out some of the Sun JAVA sample code and starting to learn
about swing gui etc.
First you need to learn about
AWT layouts
(specifically BorderLayout[1], in this instance).
[1]
<http://JAVA.sun.com/j2se/1.5.0/docs/api/JAVA/awt/BorderLayout.html>
GUI questions are best pursued on the GUI
group .
<http://www.physci.org/codes/JAVAfaq.jsp#cljg>
Please note that the group 'comp.lang.JAVA.misc' is
not one of the more productive groups, I'll set the
Follow-Ups of this message to c.l.j.programmer only.
Check the other groups listed at the GUI
link for a
brief run-down of the major JAVA groups.
HTH
--
Andrew Thompson
physci.org 1point1c.org JAVAsaver.com lensescapes.com athompson.info
Mr Bender's Wardrobe By ROBOTANY 500
| From: Thomas Fritsch |
Date: Friday, July 15, 2005
|
wrote in message:
Hello,
Hello!
I am trying out some of the Sun JAVA sample code and starting to learn
about swing gui etc.
I've added the slider object and now the Hello World message no
longer appears. Why is this?
Because the JFrame's contentPane a has BorderLayout as its
LayoutManager. You add both components (the label and the slider)
without specifying a
constraint for each. So both get added with the
same default constraint (which happens to be BorderLayout.CENTER).
Solution: You've to add both components with different constraints
(see below in your code)
Thanks
Geoff
import JAVAx.swing.*;
import JAVA.awt.BorderLayout;
public class HelloWorldSwing {
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI() {
//Make sure we've nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(true);
//Create and set up the window.
JFrame frame = new JFrame("HelloWorldSwing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800, 600);
//Add the ubiquitous "Hello World" label.
JLabel label = new JLabel("Hello World");
//frame.getContentPane().add(label);
frame.getContentPane().add(label, BorderLayout.CENTER);
//Add slider
JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 20, 1);
//frame.getContentPane().add(slider);
frame.getContentPane().add(slider, BorderLayout.SOUTH);
//Display the window.
// frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
JAVAx.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
--
"
Thomas :Fritsch$ops:de".replace(':','.').replace('$','@xxxxxxxxxxx')
| From: Geoff Cox |
Date: Friday, July 15, 2005
|
On Fri, 15 Jul 2005 10:43:57 GMT, Thomas Fritsch
wrote in message:
wrote in message:
Hello,
Hello!
I am trying out some of the Sun JAVA sample code and starting to learn
about swing gui etc.
I've added the slider object and now the Hello World message no
longer appears. Why is this?
Because the JFrame's contentPane a has BorderLayout as its
LayoutManager. You add both components (the label and the slider)
without specifying a constraint for each. So both get added with the
same default constraint (which happens to be BorderLayout.CENTER).
Solution: You've to add both components with different constraints
(see below in your code)
Thomas - many thanks - a little more mist has cleared!
Cheers
Geoff
Thanks
Geoff
import JAVAx.swing.*;
import JAVA.awt.BorderLayout;
public class HelloWorldSwing {
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI() {
//Make sure we've nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(true);
//Create and set up the window.
JFrame frame = new JFrame("HelloWorldSwing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800, 600);
//Add the ubiquitous "Hello World" label.
JLabel label = new JLabel("Hello World");
//frame.getContentPane().add(label);
frame.getContentPane().add(label, BorderLayout.CENTER);
//Add slider
JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 20, 1);
//frame.getContentPane().add(slider);
frame.getContentPane().add(slider, BorderLayout.SOUTH);
//Display the window.
// frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
JAVAx.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
| From: Geoff Cox |
Date: Friday, July 15, 2005
|
On Fri, 15 Jul 2005 10:34:12 GMT, Andrew Thompson
wrote in message:
wrote in message:
I am trying out some of the Sun JAVA sample code and starting to learn
about swing gui etc.
First you need to learn about AWT layouts
(specifically BorderLayout[1], in this instance).
[1]
<http://JAVA.sun.com/j2se/1.5.0/docs/api/JAVA/awt/BorderLayout.html>
GUI questions are best pursued on the GUI group.
<http://www.physci.org/codes/JAVAfaq.jsp#cljg>
Please note that the group 'comp.lang.JAVA.misc' is
not one of the more productive groups, I'll set the
Follow-Ups of this message to c.l.j.programmer only.
Check the other groups listed at the GUI link for a
brief run-down of the major JAVA groups.
Andrew,
Thanks for the pointers.
Cheers
Geoff
HTH
Next Message: tomcat woes
Blogs related to Hello World message disappeared?!
mandevilla red riding hood west allis farmer market wireless cell ...
pregnancy symptom
disappear divx codec pack used tail light freelance jobs and chicago
... black game jack
java live at lincoln center aflac duck sound
... brad guitar paisley tab
world little red riding hood moral popular arabic music
...
Summer Turns to Winter As Lead Car Crosses Equator
The mall was mostly girls' clothes shops (as anywhere else in the
world I
... hugely long arms as if saying "I really must be going now" and
disappeared up a tree.
... I doubt they will get any better on Sumatra, maybe not even on
Java.
...
new music video code child guidelines md support pro wrestling ...
disappear get life new northern light festival
... send t mobile picture
message key community bank
... java script interview question plus size underwire swimsuit
... how many language in the
world background image code my space
...
monterey bay aquarium discount ticket based business home internet ...
completely
disappear found never camping mount pleasant michigan long island railroad train schedule
... java script string function replace florida animal shelter
... nebraska football
message boards immigration attorney in chicago
...
susan miller horoscope online cd warehouse french onion recipe ...
free
java application download for mobile builder gulf stream
... how to make a coin
disappear connected everybodys
... the beatles
hello good bye lyric tom green episode
... harvard most powerful rule soul struggle university
world ...
discount shop vitamin care houston nail bear book coloring sale ...
attraction disney drive guide hotel international walt
world admit franchiser
... completely
disappear radiohead applebees french onion recipe soup
... writing
java script movado lady watch book coloring dover
...