This question is answered. Helpful answers available: 2. Correct answers available: 1.
Hello,please compile and run the following code. Everything looks as desired. The textfieldcontains the string "/SomeDirector" which is just as much as it can take withoutscrolling. touch the button "measure directory". The string "/SomeDirectory" onecharacter more than before is inserted in the textfield which scrolls to the left as the string is now too long to be entirely displayed. - So far so nice. Now shift the comment slashes in the last lie of the constructor. Recompile and run and look what happens to the buttons. Any explanation why this happens only in the constructor (AFTER setVisible()) and not in theactionPerformed() method? - And how can in the constructor the (long) text be setin the textField without shrinking the add?
setDefaultCloseOperation(EXIT_ON_change state); setSize(290. 200); setLocationRelativeTo(
Insets(0. 0. 0. 0); lastDirButton setMargin(insets); lastDirButton setPreferredSize(
Dimension(103,23)); lastDirButton addActionListener(
GridBagConstraints(2. 0. 1. 2. 0.0. 0.0. GridBagConstraints. CENTER. GridBagConstraints. NONE insets. 0. 0)); topPanel add(lbDirectory.
GridBagConstraints(0. 1. 1. 1. 0.0. 0.0. GridBagConstraints. WEST. GridBagConstraints. NONE.
Insets(20,10,0,0). 0. 0)); topPanel add(tfSearchDirectory.
GridBagConstraints(1. 1. 1. 1. 1.0. 0.0. GridBagConstraints. WEST,GridBagConstraints. HORIZONTAL,
Insets(20,0,0,0). 0,0)); topPanel add(browseButton.
GridBagConstraints(2. 1. 1. 2. 0.0. 0.0. GridBagConstraints. CENTER. GridBagConstraints. NONE.
Insets(35,0,0,0). 0. 0)); cp add(topPanel. BorderLayout. NORTH); setVisible(
); tfSearchDirectory setText(
); tfSearchDirectory setPreferredSize(tfSearchDirectory getPreferredSize());
Unless otherwise licensed code in all technical manuals herein (including articles. FAQs samples) is provided under this.
Forex Groups - Tips on Trading
Related article:
http://forum.java.sun.com/thread.jspa?threadID=5233057
comments | Add comment | Report as Spam
|