How can I make a Label or Icon clickable?
Hi I have 3 lables which have imageicons in them which keep changing from red to green to blue depending on the status of some server connection, Now I have a get info button right next to it which pops up a dialog box which gives more information about the server connection there like the IP PORT etc, I want to remove this get info button and have the user click the image icons to ger the same information?
I have a JPanel where I have all these compoents and this panel has a titled border, is it possible to make the border title clickable, any of the 2 solutions would be greatly appreciated.
Thanks a ton,
Ankur
Here's an example of some tweaks for cool-looking toolbar buttons, in Java 1.5.
import java.awt.*;
import java.net.*;
import javax.swing.*;
public class ButtonsExample {
public static void main(String[] args) throws MalformedURLException {
String prefix = "http://java.sun.com/developer/techDocs/hi/repository/graphicsRepository/toolbarButtonGraphics/media/";
String suffix = "24.gif";
String[] urls = {"Play", "Pause", "Stop", "FastForward", "Rewind", "StepBack", "StepForward", "Movie", "Volume"};
UIManager.put("Button.margin", new Insets(0,0,0,0));
JToolBar tb = new JToolBar();
for(int i=0; i<urls.length; ++i) {
JButton btn = new JButton(new ImageIcon(new URL(prefix + urls[i] + suffix)));
btn.setBorderPainted(false);
btn.setFocusPainted(false);
btn.setContentAreaFilled(true);
btn.setOpaque(false);
tb.add(btn);
}
JFrame f = new JFrame("ButtonsExample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(tb, BorderLayout.NORTH);
f.setSize(400,100);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
}
>