java - Why wont my custom JButton display its name? -


hi working on project , having trouble adding jbuttons. reason, wont print name.

this class supposed add custom buttons

import java.awt.*; import javax.swing.jpanel;  public class fightpanel extends jpanel {  public static final int width = 600; public static final int height = 600;  public fightpanel() {     setpreferredsize(new dimension(width, height));     setlayout(new borderlayout());      fightbutton test = new fightbutton("test");     add(test); } } 

this class custom button class

import javax.swing.jbutton;  public class fightbutton extends jbutton {  private string name;  public fightbutton(string name) {     this.name = name;     setname(name); } 

}

the setname() method not control text displayed on button. used application code identify component.

the settext(...) used set text displayed in button.

did know have use super constructor that.

you don't have easiest way want since passing text parameter class.

if want change text after component has been created use settext() method.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -