[4473] in java-interest

home help back first fref pref prev next nref lref last post

Re: Alterning a list by removing scroll bar/s

daemon@ATHENA.MIT.EDU (Neil Bartlett)
Mon Jan 1 13:24:45 1996

Date: Mon, 1 Jan 1996 12:00:39 -0500
To: trk@wipsys.soft.net (RAMKUMAR.T)
From: Neil Bartlett <neilb@the-wire.com>
Cc: jug@solect.com, java-interest@java.sun.com

At 08:33 PM 1/1/96 -0500, TRK wrote:
>Neil Bartlett writes:
>> 
>> Out of interest, why do you want to remove the scrollbars? Maybe if you are
>> just wanting to display a body of static text to the use, you should
>> consider using a Label component. Label components support multi-line.
>> 
>> 
>Hi!
>
>I have a problem with Multi-Line Labels. I have MessageDialog
>class that extends Dialog, and it has a Label and a Button. I set 
>the Label's content by     
>
>	label.setText("***foo\n***goo\n");
>
>When I "show()" the MessageDialog object only "foo" is shown
>as the content. But if I getText from the label and print it using
>System.out.println, 
>***foo
>***goo
>is printed. Can someone tell me what is going wrong here?
>
>Is there any other way of getting Multi-line text displayed
>by a Label?
>
>
>Thanks in adv..
>
>Cheers
>TRK

Sorry I was being a trifle glib when I said about multi-line support. Labels
can be used to provide multi-line support. Here is a code snipet.

class MessageBox extends Dialog {

    public MessageBox(Frame parent, String s) {
	super(parent, "Message Dialog", true);
        StringTokenizer st = new StringTokenizer(s, "\n");
        Panel pl = new Panel();
        pl.setLayout( new GridLayout(st.countTokens(), 1) );
        while (st.hasMoreTokens()) {
	    pl.add(new Label(st.nextToken()));
        }
        add("Center", pl);
	Panel p = new Panel();
	add("South", p);
	p.add(new Button("OK"));
	resize(200, 175);
	setResizable(true);
    }

    public boolean action(Event e, Object arg) {
	hide();
	return true;
    }
}


Hope this helps.




Neil Bartlett     
Co-author of upcoming book, The Java Explorer
neilb@the-wire.com               416-769-1851

-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post