[This question is in relation to this question]
Setting: I have this home-crafted \"editable label\" component which looks like a label, but when you cl
In you editable label, when you start editing, use SwingUtilities.getRoot()
to get the root of your label, cast it to Container
. On the Container you can call getComponents()
. Iterate through this array and call setEnabled(false)
unless it is the label. Enable them when you're done editing.
One question: why do you need it? If you need dialog-like behavior, use JOptionPane
.
BTW, if you remove border from JTextField and setOpaque(false), it will be just as an editable label.