Hi,
I am new to using GUI, and am trying to make a simple display box. However i ran into a problem. I don't know how to align the labels or buttons in the box. So now all the labels and buttons are centred and on the same line. How do align them to the left an on separate lines?
/** * A class that displays the weather * * @author Joel Potts * @version 1 * @last modified 22 september 2011 */ import java.awt.*; //Imports files needed for Dialog Windows import javax.swing.*; // Imports predefinded windows public class WeatherDisplay { public static void main (String args[]) { JFrame frame = new JFrame( "Heres Whats Happening In Your Neck of the Woods"); // Sets title for display window JLabel daysofWeek = new JLabel("Sunday Monday Tuesday Wednesday Thursday Friday Saturday ", JLabel.CENTER ); // Label for days of the week JLabel temperature = new JLabel("78 79 79 77 78 73 72", JLabel.LEFT); // Makes labelfor the temperatures frame.getContentPane().add(daysofWeek); frame.getContentPane().add(temperature); frame.setSize (400, 70); Container content = frame.getContentPane(); content.setBackground (Color.red); content.setLayout(new FlowLayout()); content.add(new JButton("Nothing Happens If You Click Me")); frame.setVisible (true); } }