I'm pretty new to java and I've read some documentation on Layout specifically BoxLayout. I'm not hung up on BoxLayout but it seemed to do what I need. Problem is that label (status) is not left aligned and I can't seem to force it to the left. It will move left if I set the text to a really long line of text. Here is the code:
package tests;
import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
public class TestLayout extends JPanel {
private JFrame frame;
private JPanel view;
private JLabel status;
TestLayout(JFrame iframe) {
frame = iframe;
setLayout(new BoxLayout(this,BoxLayout.PAGE_AXIS));
//setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
status = new JLabel("==> Hello");
status.setHorizontalAlignment(0);
//status.setAlignmentX(0.0f);
view = new JPanel();
view.setBackground(Color.white);
add(view);
add(status);
}
public static void main(String args[]) {
JFrame frame = new JFrame("Test Layout");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Display the window.
TestLayout tl = new TestLayout(frame);
frame.add(tl);
frame.pack();
frame.setSize(1100, 800);
frame.validate();
frame.setVisible(true);
}
}
Any suggestions would be appreciated.