Source Code : Active Label Sample
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Active Label Sample

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
public class ActiveSample {
private static final String LABEL_FACTORY = "LabelFactory";
public static void main(String args[]) {
JFrame frame = new JFrame("Active Example");
UIManager.put(LABEL_FACTORY, new ActiveLabel());
final JPanel panel = new JPanel();
JButton button = new JButton("Get");
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
JLabel label = (JLabel) UIManager.get(LABEL_FACTORY);
panel.add(label);
panel.revalidate();
}
};
button.addActionListener(actionListener);
Container contentPane = frame.getContentPane();
contentPane.add(panel, BorderLayout.CENTER);
contentPane.add(button, BorderLayout.SOUTH);
frame.setSize(200, 200);
frame.setVisible(true);
}
}
class ActiveLabel implements UIDefaults.ActiveValue {
private int counter = 0;
public Object createValue(UIDefaults defaults) {
JLabel label = new JLabel("" + counter++);
return label;
}
}
Thank with us