R
Russell
Can someone please point out my error and tell me why this JTextArea will
not activate the JScrollPane !!
====================================================
CODE BELOW
====================================================
import java.awt.*;
import javax.swing.*;
public class testing extends JFrame{
JTabbedPane Tabbed = new JTabbedPane();
JScrollPane Scroller = new JScrollPane();
JTextArea textArea = new JTextArea();
JPanel tab1Pan = new JPanel();
JPanel tab2Pan = new JPanel();
public testing() {
jbInit();
}
private void jbInit() {
setSize(800, 600);
textArea.setPreferredSize(new Dimension(760, 520));
textArea.setWrapStyleWord(true);
Scroller.setHorizontalScrollBarPolicy(
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
Scroller.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
Scroller.getViewport().add(textArea, null);
tab1Pan.add(Scroller);
Tabbed.addTab("TAB 2", tab1Pan);
Tabbed.addTab("TAB 2", tab2Pan);
getContentPane().add(Tabbed);
}
public static void main(String[] args) {
testing frame = new testing();
JFrame.setDefaultLookAndFeelDecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
not activate the JScrollPane !!
====================================================
CODE BELOW
====================================================
import java.awt.*;
import javax.swing.*;
public class testing extends JFrame{
JTabbedPane Tabbed = new JTabbedPane();
JScrollPane Scroller = new JScrollPane();
JTextArea textArea = new JTextArea();
JPanel tab1Pan = new JPanel();
JPanel tab2Pan = new JPanel();
public testing() {
jbInit();
}
private void jbInit() {
setSize(800, 600);
textArea.setPreferredSize(new Dimension(760, 520));
textArea.setWrapStyleWord(true);
Scroller.setHorizontalScrollBarPolicy(
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
Scroller.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
Scroller.getViewport().add(textArea, null);
tab1Pan.add(Scroller);
Tabbed.addTab("TAB 2", tab1Pan);
Tabbed.addTab("TAB 2", tab2Pan);
getContentPane().add(Tabbed);
}
public static void main(String[] args) {
testing frame = new testing();
JFrame.setDefaultLookAndFeelDecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}