Snippets Collections
import java.awt.Dimension;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class LeftSide
{
public LeftSide()
{
JFrame frame = new JFrame("Button");
JPanel panel = new JPanel();
JButton button = new JButton("Submit");
button.setPreferredSize(new Dimension(200, 30));
button.setIcon(new ImageIcon(this.getClass().getResource("submit.gif")));
panel.add(button);
frame.add(panel);
frame.setVisible(true);
}

public static void main(String[] args)
{
new LeftSide();
}
star

Sun Dec 04 2022 10:46:19 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/36011010/how-to-make-icon-and-text-align-left-side-on-jbutton

#java #swing

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension