|
-
Apr 21st, 2002, 03:21 PM
#1
JScroll
How can I add a Jscroll in a jTextArea if my layout is NULL?
Thx you
-
Apr 21st, 2002, 06:10 PM
#2
I just want to add a scroll bar to a jTextArea. Any suggestion if my layout is null?
-
Apr 21st, 2002, 07:34 PM
#3
Dazed Member
This is how it is normally done....
Code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Example{
public static void main(String[] args){
JScrollPane jsp = new JScrollPane(new JTextArea());
JFrame jf = new JFrame();
jf.addWindowListener(new WindowAdapter(){
public void WindowClosing(WindowEvent we){
System.exit(0);
}
});
Container c = jf.getContentPane();
c.add(jsp);
jf.setSize(200,150);
jf.setVisible(true);
}
}
But in order to position a component without the help of a layout manager you would have to use absoulte positioning. Normally you would want to use the setBounds() method which takes either a rectangle or x,y,width and height. I guess this could be good if you want the scroll bar wider then it normally is. You could also use setLocation() which takes a Point or x,y coordinates.
-
Apr 22nd, 2002, 04:36 PM
#4
thx you, !!! I mixed up the jscroll pane and the jtextarea
that what I had:
JTextArea text1 = new JTextArea(new JScrollPane);
and like you have gaven to me :
JScrollPane jsp = new JScrollPane(new JTextArea());
You see my error now 
Thx you Dilenger4
-
Apr 23rd, 2002, 01:18 PM
#5
Dazed Member
Your welcome.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|