Reputation:
here is my code:
bbtn = new JButton("Brightness");
bbtn.setLayout(new BoxLayout(bbtn, BoxLayout.LINE_AXIS));
bbtn.setBorderPainted(false);
bbtn.setAlignmentX(LEFT_ALIGNMENT);
bbtn.setAlignmentY(TOP_ALIGNMENT);
bbtn.setBackground(Color.white);
ImageIcon img = new ImageIcon("C:\\Documents and Settings\\omi\\My Documents\\NetBeansProjects\\JavaApplicationEditor\\src\\utilities_brightness.png");
bbtn.setIcon(img);
mpanel.add(bbtn);
setAlignement
lines are not working i've also try the setBounds
but still not working
Upvotes: 0
Views: 58
Reputation: 1092
You should put your JButton on a Container, and sets the layout manager of your container to feat the left alignment. This is a example maybe inspire you :
JPanel thePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
JButton theButton = new JButton("Britness");
thePanel.add(theButton);
Hope that helps, Salam
Upvotes: 1