-
Bug
-
Resolution: Fixed
-
P4
-
1.1.6, 1.2.0
-
beta
-
generic, x86
-
generic, windows_nt
Name: mf23781 Date: 07/20/98
*Symptoms:
The bug appears when a JScrollPane, containing a JTextArea, is added to a
JTabbedPane.
When text that requires a scroll bar is added to the JTextArea while that
tab is not selected, no scroll
bar is created be the JScrollPane when the tab is viewed later. If long
text is added to the JTextArea
while its tab is selected, the JScrollPane will correctly create a scroll
bar.
The following is a short applet that demonstrates the problem. Run the
applet and press the message
button on the first tab. This adds a long piece of text to the JTextArea on
the next tab. Then switch
to the "text" tab. The message is there, but there is no scroll bar. Now
press the message button on
the "text" tab. The same long message is added and now the scroll bar
appears and the entire
message is viewable.
import com.sun.java.swing.*;
import java.awt.event.*;
import
java.awt.*;
public class TabTest extends JApplet implements ActionListener
{
JTabbedPane tabbedPane;
JButton msgButton1, msgButton2;
JTextArea textArea;
JScrollPane scrollPane;
JPanel buttonPanel, buttonAndTextPanel;
public void init()
{
textArea = new JTextArea();
buttonPanel = new JPanel( new BorderLayout() );
buttonAndTextPanel = new JPanel( new BorderLayout() );
// button1 adds text that does not cause JScrollPane to add a scroll
bar
// button2 causes a scroll bar to be created
msgButton1 = new JButton( "Add Message" );
msgButton2 = new JButton( "Add Message" );
scrollPane = new JScrollPane( textArea );
buttonPanel.add( msgButton1, BorderLayout.CENTER );
buttonAndTextPanel.add( msgButton2, BorderLayout.NORTH );
buttonAndTextPanel.add( scrollPane, BorderLayout.CENTER );
tabbedPane = new JTabbedPane();
tabbedPane.add( "Button", buttonPanel );
tabbedPane.add( "Text", buttonAndTextPanel );
getContentPane().add(tabbedPane);
msgButton1.addActionListener( this );
msgButton2.addActionListener( this );
}
public void actionPerformed( ActionEvent event )
{
if ( event.getSource() instanceof JButton )
{
String msgString = new String("This message is longer than the
Panel");
textArea.append( msgString + msgString + msgString + "\n");
}
}
}
======================================================================
- duplicates
-
JDK-4176153 JScrollArea not updating scrollbars for JTextPane
-
- Closed
-