Reputation: 4239
I have made a frame in which i have put two jTextfield boxes where the user can see the path of the loaded file. Problem is that if the path is too long , the textfield expands to accomodate the full path which again leads to display problems. I would like to keep the textfield's length constant and instead , display the full path of file as a tooltip instead.
How can this be done?
Code for layout manager of jinternal Frame:
javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
Upvotes: 1
Views: 1146
Reputation: 4239
I solved my problem: Anybody having the same problem can set the Property Columns using Netbeans. The default is 0, so the textfield cannot accomodate the full text. Use some value like 3 to achieve it.
Upvotes: 0
Reputation: 324078
I never use an IDE so I don't know how the GroupLayout works.
But when using the other layout managers I always use:
JTextField textField = new JTextField(10); // or whatever size your want
This will give the text field a preferred size and the layout manager can use that information when laying out the component.
Upvotes: 2
Reputation: 572
you need to choose a layout manager to manage the proportions of your JComponents. Try to put your textfiels on a JPanel so you can select a layout useful for you
Later you can use JTextField. setToolTip("full path") to set a tool tip
Upvotes: 0
Reputation: 23629
Code the GUI by hand instead. You will avoid problems like this and it will be much easier to make changes to your code.
Upvotes: 1