2013年10月5日星期六

JButton is displayed with images and text , ask you to help look

private JButton getLoginButton () {
if (loginButton == null) {
img = new ImageIcon (getClass (). getResource ("/ image/18.png"));
loginButton = new JButton (" login ", img);
loginButton.setBounds (new Rectangle (109, 114, 68, 25));
loginButton.setMargin (new Insets (2,2,2,2));

/ / add a listener
loginButton.addActionListener (new ActionListener () {

public void actionPerformed (ActionEvent arg0) {
/ / TODO Auto-generated method stub
JOptionPane.showMessageDialog (null, " Login successful ." ) ;
}
});
}
return loginButton;
}


only show pictures , you can not display text
------ Solution ---------------------------- ----------------
delete the following two lines can be displayed . Margins should be the size of the problem
loginButton.setBounds (new Rectangle (109, 114, 68, 25));
loginButton.setMargin (new Insets (2,2,2,2));
------ For reference only ---------------- -----------------------
can show ah, just pictures and text arranged display
------ For reference only - -------------------------------------


arranged to give an example of how
------ For reference only --------------------------- ------------
I have the same problem

没有评论:

发表评论