I would like to know there is any way to focus on my I think that using the Thank you all and sorry for my bad english. To find someone on your label click , find out The code will work: JLabel . I have a series of labels and I want to know that I am selecting one of them.
MouseListener but do not know that the
JLabel is used to set the focus or in some mode Saying that I am selecting that label.
package com. Sandbox; Import javax.swing.boxLayout; Import javax.swing.JFrame; Import javax.swing.JLabel; Import javax.swing.JPanel; Import javax.swing.WindowConstants; Import java.awt.event.MouseAdapter; Import java.awt.event.MouseEvent; Public square swingsandbox {public static zero main (string [] args) {JFrame frame = buildFrame (); Zpean panel = new zpn (); Box layout layout = new box layout (panel, box layout.x_AXIS); Panel.setLayout (layout); . Frame.getContentPane () add (panel); Jlabel label = new jlabel ("click me and give me feedback"); Label.addMouseListener (New Mouse Adapter) {@Override Public Zero Mouse Lime (MouseEver E) {System.out.println ("Clicked!"}}}}); Panel.add (label); Panel.add (new JLabel ("This label will not react")); } Private Static JFrame buildFrame () {JFrame frame = new JFrame (); Frame.setDefaultCloseOperation (WindowConstants.EXIT_ON_CLOSE); Frame.setSize (200, 200); Frame.setVisible (true); Return frame; }}
No comments:
Post a Comment