?
Solved

Problem increasing size of a label

Posted on 2005-04-26
14
Medium Priority
?
194 Views
Last Modified: 2010-08-05
Hello,

I'm displaying data in a label but I cant seem to change the label size. Only part of the script gets shown..

Also after printing this information how do I make a  link to the stop method for the applet?
0
Comment
Question by:pigmentarts
  • 6
  • 6
  • 2
14 Comments
 
LVL 24

Expert Comment

by:sciuriware
ID: 13873364
A JEditorPane with/without JScrollPane is better for your purpose.
The applet should be stopped by the browser.
;JOOP!
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 13873503
I'm unsure how to use that.

Can't I just change the dimension of the label ?

Yes I want the browser to stop the applet, but how do I call it from a certain point in my code.

i want it to happen when some if else statements are called..
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 13873529
Of course you can:               myLabel.setPreferredSize(h, w);
but a JEditorPane (also JTextPane) grows dynamically as you add more text.
A JScrollPane takes care when the text grows over the frame size,
or when the user manually adjusts the size of the frame.

;JOOP!
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 12

Author Comment

by:pigmentarts
ID: 13873712
whats joop ??

are you saying I can place that at any point and it will stop current processes
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 13873720
and where do i stick the size of the label in :

label = new Label ("*");
0
 
LVL 24

Accepted Solution

by:
sciuriware earned 2000 total points
ID: 13873903
joop is my name ( ~ John/Jean/Johan/Sean ...).

Jlabel myLabel = new JLabel("Initial contents");
   myLabel.setPreferredSize(400, 100);      // Which is big ...

...... later perhaps:

   myLabel.setText(message);
   myLabel.setPreferredSize(300, 200);

Now, my advise is: the above is bad usage: for multi-line text the message
should be in HTML syntax, and how do you know the correct size?
Better is:

   JEditorPane myPane = new JEditorPane();
      myPane.setPreferredSize(300, 250);  // Later to choose a better size.
   JScrollPane sc = new JScrollPane(myPane);
   // Add the 'sc' to some pane of your frame.

   myPane.setText(message);

// 'myPane' will automatically grow, but the scrollpane will make
// it scrollable: the viewport will be of the size you gave above,
// but by scrolling you can see the whole picture.
// The text is now free: it folds on '\n' (newlines), although
you may still add HTML texts.

;JOOP!   (my signature)
0
 
LVL 92

Expert Comment

by:objects
ID: 13873916
The size of your label is controlled by the layout manager (if you are using one).
If you aren't you can use setSize() or setBounds() to set its size
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 13873943
pigmetarts, have a look at this:  http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html

that will tell you all you need to know about scrolpanes.

Objects is right, but you can still hold control
over the size of a label by:

   myLabel.setMaximumSize(h, w);

;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 13873945
Sorry, I misspelled:    pigmentarts.

;JOOP!
0
 
LVL 92

Expert Comment

by:objects
ID: 13873979
> but you can still hold control over the size of a label by:

does still depend on the layout manager being used and whether it takes min/max/preferred size into account
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 13874377
Until now a layoutmanager was not mentioned by the questioner.

pigmentarts, what frame do you use?

;JOOP!
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 13875008
just using a normal one :)
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 13875011
and don't worry I mispell my anme all the time

>>If you aren't you can use setSize() or setBounds() to set its size

Does set bounds only use the amount of space it needs?? but you can set as big a (h, w) as you want?
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 13875123
hey that jpane looks nice. lets see if I can mess up my coding :D
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month9 days, 4 hours left to enroll

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question