package text;
/*
* TextAlignDemo.java
*/
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
public class TextAlignDemo extends JFrame {
private JTextPane textpane;
private JToolBar toolbar;
private JButton b5, b6, b7;
public TextAlignDemo() {
super("Text Align Demo");
setSize(400,300);
setLocationRelativeTo(null);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
textpane = new JTextPane();
toolbar = new JToolBar();
getContentPane().add(new JScrollPane(textpane), BorderLayout.CENTER);
getContentPane().add(toolbar, BorderLayout.NORTH);
b5 = new JButton(new StyledEditorKit.AlignmentAction("Left",StyleConstants.ALIGN_LEFT));
b5.setBackground(Color.white);
b5.setToolTipText("Left Align");
b6= new JButton(new StyledEditorKit.AlignmentAction("Center",StyleConstants.ALIGN_CENTER));
b6.setBackground(Color.white);
b6.setToolTipText("Center Align");
b7= new JButton(new StyledEditorKit.AlignmentAction("Right",StyleConstants.ALIGN_RIGHT));
b7.setBackground(Color.white);
b7.setToolTipText("Right Align");
toolbar.add(b5);
toolbar.add(b6);
toolbar.add(b7);
}
public static void main(final String args[]) {new TextAlignDemo().setVisible(true);}
}