Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You will need to call update(Graphics g) on Panel after setEnabled(boolean) is called.</p> <p>check : <a href="http://download-llnw.oracle.com/javase/1.4.2/docs/api/java/awt/Container.html#update(java.awt.Graphics)" rel="nofollow noreferrer">http://download-llnw.oracle.com/javase/1.4.2/docs/api/java/awt/Container.html#update(java.awt.Graphics)</a></p> <p>I tried following code (built from code you provided), Its working fine.</p> <pre><code>import java.awt.Checkbox; import java.awt.Component; import java.awt.Dialog; import java.awt.Frame; import java.awt.Panel; import java.awt.TextField; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; public class CheckUI extends Dialog implements ItemListener { // The class that contains all of this is of type Window // Declaration of the components private Panel _inputPanel; private TextField min, max; private Checkbox cb; public CheckUI(Frame owner, boolean modal) { super(owner, modal); _inputPanel = new Panel(); this.add(_inputPanel); addMinMaxtextFields("min", "max"); } // This method adds to two text fields public void addMinMaxtextFields(String min, String max) { cb = new Checkbox(); cb.addItemListener(this); TextField minField = new TextField(min); TextField maxField = new TextField(max); this.min = minField; this.max = maxField; this.min.setEnabled(false); this.max.setEnabled(false); _inputPanel.add(minField); _inputPanel.add(maxField); _inputPanel.add(cb); } // listener for the checkbox public void itemStateChanged(ItemEvent e) { Component[] components = _inputPanel.getComponents(); min.setEnabled(!min.isEnabled()); min.setVisible(true); min.validate(); min.repaint(); _inputPanel.validate(); _inputPanel.repaint(); this.pack(); this.setSize(this.getWidth(), this.getHeight()); this.validate(); this.repaint(); /* do nothing */ } /** * @param args */ public static void main(String[] args) { Frame parent = new Frame(); parent.setVisible(true); parent.setExtendedState(Frame.MAXIMIZED_BOTH); parent.pack(); CheckUI ui = new CheckUI(parent, true); ui.pack(); ui.setVisible(true); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload