[[jbutton]]
 
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        MyButton b = new MyButton ();
        b.setText ("Muj knoflik");
        b.addText ("...");
        b.addText ("???");
        b.removeText ("???");
        jToolBar1.add (b);
    }
package example;
 
import java.awt.Color;
import javax.swing.*;
 
public class MyButton extends JButton {
 
    public void addText (String s)
    {
        setForeground (Color.red);
        setText (getText () + s);
        // this.setText (this.getText () + s);
    }
 
    public void removeText (String s)
    {
        setForeground (Color.blue);
        String t = getText ();
        if (t.endsWith(s))
        {
           t = t.substring (0, t.length()-s.length());
           setText (t);
        }    
    }
 
}
 
jbutton.txt · Last modified: 2016/11/10 16:18 by 147.32.8.115
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki