The java.awt.JButton.setAlignmentX() method sets the horizontal alignment of the text or icon in the JButton component. This method accepts a float value between 0.0 and 1.0, where 0.0 means left-aligned and 1.0 means right-aligned.
Example 1: Setting left alignment for a JButton component
JButton button = new JButton("Click me");
button.setAlignmentX(0.0f);
Example 2: Setting center alignment for a JButton component
JButton button = new JButton("Click me");
button.setAlignmentX(0.5f);
This method is a part of the java.awt package.
Java JButton.setAlignmentX - 17 examples found. These are the top rated real world Java examples of java.awt.JButton.setAlignmentX extracted from open source projects. You can rate examples to help us improve the quality of examples.