Re: JTextField shrinking
To: comp.lang.java.gui
On Jun 13, 10:04 pm, Hendrik Maryns <gtw37b...@sneakemail.com> wrote:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class UIBuilder {
~ public UIBuilder() {
~ super();
...
~ }
}
Grateful for any comments, H.
Does 'comments' include questions?
Where did all the ~ characters come from?
<sscce>
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class UIBuilder {
public UIBuilder() {
super();
// Look-and-feel
try {
UIManager.setLookAndFeel(UIManager
.getSystemLookAndFeelClassName());
} catch (final Exception exc) {
// fall back to default
exc.printStackTrace();
}
final JFrame frame = new JFrame();
final JPanel np = new JPanel(true);
final JButton treebankButton = new JButton("Treebank");
treebankButton.setToolTipText("Choose a treebank.");
treebankButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
// some useful stuff
}
});
np.add(treebankButton);
final JTextField treebankField = new JTextField(
"Please choose a treebank.", 30);
treebankField.setToolTipText("The treebank being queried.");
treebankField.setName("Treebank");
treebankField.setEditable(false);
np.add(treebankField);
frame.getContentPane().add(np, "North"); //$NON-NLS-1$
frame.pack();
// not the answer to the wider question, but
// one way to solve it for the displayed UI
frame.setMinimumSize( frame.getPreferredSize() );
// please specify a close operation, before setting a PLAF!
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setVisible(true);
}
public static void main(final String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new UIBuilder();
}
});
}
}
</sscce>
--
Andrew T.
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24