aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes how to fix the JLabel Text value in Swings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to fix the JLabel Text value in Swings" Watch "how to fix the JLabel Text value in Swings" New topic
Author

how to fix the JLabel Text value in Swings

elay Raja
Greenhorn

Joined: Jun 10, 2008
Posts: 27
I want to fix the length of the JLabel text in my application.

For example: JLabel test=new JLabel("Selected File Testing");

If i use the above string,then my design gets collapsed.

how to fix the length of the JLabel Text?

Please help me to resolve this issue...

here is my code...


getContentPane().setLayout(new GridBagLayout());
getContentPane().setBounds(500, 300, 500, 300);
getContentPane().setBackground(Color.decode("#C1CDAD"));
GridBagConstraints c = new GridBagConstraints();

c.anchor = GridBagConstraints.FIRST_LINE_START;
c.fill = GridBagConstraints.BOTH;
c.insets = new Insets(10, 10, 10, 0);
c.gridwidth = 1;
c.weightx=1.0f;
c.weighty=1.0f;
// c.gridx = 0;
c.gridy = 1;
getContentPane().add(fileSelectLabel, c);

c.anchor = GridBagConstraints.LINE_START;
c.fill = GridBagConstraints.BOTH;
c.insets = new Insets(10, 10, 10, 0);
c.gridwidth = 1;
c.gridx = 0;
c.gridy = 1;
getContentPane().add(statusLabel, c);

c.anchor = GridBagConstraints.PAGE_START;
c.fill = GridBagConstraints.BOTH;
c.insets = new Insets(10, 10, 10, 10);
c.gridwidth = 1;
c.gridx = 1;
c.gridy = 0;
getContentPane().add(pathField, c);
pathField.setEditable(false);
pathField.setBackground(Color.white);
pathField.setBorder(BorderFactory.createLineBorder(Color.decode("#98AFC7")));

c.anchor = GridBagConstraints.FIRST_LINE_END;
c.fill = GridBagConstraints.BOTH;
c.insets = new Insets(10, 10, 10, 10);
c.gridwidth = 1;
c.gridx = 2;
c.gridy = 0;
getContentPane().add(browseButton, c);

c.anchor = GridBagConstraints.LINE_END;
c.fill = GridBagConstraints.BOTH;
c.insets = new Insets(10, 10, 10, 10);
c.gridwidth = 1;
c.gridx = 2;
c.gridy = 1;
getContentPane().add(uploadButton, c);

c.anchor = GridBagConstraints.LINE_END;
c.fill = GridBagConstraints.BOTH;
c.insets = new Insets(10, 10, 10, 10);
c.gridwidth = 1;
c.gridheight = 1;
c.gridx = 2;
c.gridy = 2;
getContentPane().add(cancelButton, c);

c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.BOTH;
c.insets = new Insets(20, 10, 20, 10);
c.gridwidth = 3;
c.gridheight = 1;
c.gridx = 0;
c.gridy = 5;
getContentPane().add(uploadProgress, c);

c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.BOTH;
c.insets = new Insets(10, 10, 10, 10);
c.gridwidth = 1;
c.gridheight = 2;
c.gridx = 1;
c.gridy = 1;
getContentPane().add(statusArea, c);
statusArea.setEditable(false);
statusArea.setBorder(BorderFactory.createLineBorder(Color.decode("#98AFC7")));

c.anchor = GridBagConstraints.NORTH;
c.fill = GridBagConstraints.CENTER;
c.insets = new Insets(0, 5, 0, 5);
c.gridwidth = 1;
c.gridheight = 1;
c.gridx = 1;
c.gridy = 4;
getContentPane().add(bytesLabel, c);
bytesLabel.setVisible(false);

c.anchor = GridBagConstraints.WEST;
c.fill = GridBagConstraints.LAST_LINE_START;
c.insets = new Insets(0, 5, 0, 5);
c.gridwidth = 3;
c.gridheight = 1;
c.gridx = 0;
c.gridy = 6;
getContentPane().add(warningLabel, c);
warningLabel.setVisible(false);
warningLabel.setForeground(Color.red)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to fix the JLabel Text value in Swings
 
Similar Threads
GridBagLayout:: a few Qs
text box - GridBagLayout
JScrollPane Weight Shift In GridBagLayout
GridBagLayout...!
help automate code