I want to edit my text alignment to the center. I already know you can do: intro.setHorizontalAlignment(JLabel.CENTER); to make it centered. But I want to do it so that it is like in microsoft word when you do that icon. This is my program so far:
import javax.swing.*;
import javax.swing.JLabel;
public class FrameStuff
{
public static void main(String[] args)
{
// Creating and setting up a regular frame
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Setting up frame characteristics
frame.setSize(800, 600);
frame.setTitle("FrameStuff");
// Making it visible
frame.setVisible(true);
//Making and assigning a new string
String textintro = new String("<html>This is my program <br/>I am having loads of fun <br/>Thanks for helping me!</html>");
// Made a new label (just happened to call it intro
JLabel intro = new JLabel(textintro );
// Set some sort of alignment within the frame
intro.setHorizontalAlignment(JLabel.CENTER);
//Add the dang label to the frame.
frame.add(intro);
}
}
My first time using this and a newbie at programming.