@@ -22,24 +22,25 @@ public class SplitPaneDemo2 extends JFrame {
22
22
23
23
private AbstractDocument doc ;
24
24
25
- private JTextPane textPane ;
26
- private JTextArea changeLog ;
27
- private JLabel label ;
25
+ private JTextPane sqlTextPane ;
26
+ private JEditorPane lessonTextPane ;
27
+ private JTextArea changeLog ;
28
+ private JLabel label ;
28
29
29
30
public SplitPaneDemo2 () {
30
31
super ("SplitPaneDemo2" );
31
32
32
- textPane = new JTextPane ();
33
- textPane .setCaretPosition (0 );
34
- textPane .setMargin (new Insets (5 ,5 ,5 ,5 ));
35
- StyledDocument styledDoc = textPane .getStyledDocument ();
33
+ sqlTextPane = new JTextPane ();
34
+ sqlTextPane .setCaretPosition (0 );
35
+ sqlTextPane .setMargin (new Insets (5 ,5 ,5 ,5 ));
36
+ StyledDocument styledDoc = sqlTextPane .getStyledDocument ();
36
37
if (styledDoc instanceof AbstractDocument ) {
37
38
doc = (AbstractDocument )styledDoc ;
38
39
} else {
39
40
System .err .println ("Text pane's document isn't an AbstractDocument!" );
40
41
System .exit (-1 );
41
42
}
42
- JScrollPane scrollPane = new JScrollPane (textPane );
43
+ JScrollPane scrollPane = new JScrollPane (sqlTextPane );
43
44
scrollPane .setPreferredSize (new Dimension (200 , 200 ));
44
45
45
46
//Create the text area for the status log and configure it.
@@ -48,30 +49,32 @@ public SplitPaneDemo2() {
48
49
JScrollPane scrollPaneForLog = new JScrollPane (changeLog );
49
50
50
51
//Create a split pane for the change log and the text area.
51
- JSplitPane leftPane = new JSplitPane (JSplitPane .HORIZONTAL_SPLIT , scrollPane , scrollPaneForLog );
52
+ JSplitPane leftPane = new JSplitPane (JSplitPane .VERTICAL_SPLIT , scrollPane , scrollPaneForLog );
52
53
leftPane .setOneTouchExpandable (true );
53
54
54
-
55
+ //Provide minimum sizes for the two components in the split pane
56
+ leftPane .setMinimumSize (new Dimension (100 , 50 ));
55
57
56
58
//XXXX: Bug #4131528, borders on nested split panes accumulate.
57
59
//Workaround: Set the border on any split pane within
58
60
//another split pane to null. Components within nested split
59
61
//panes need to have their own border for this to work well.
60
62
leftPane .setBorder (null );
61
63
62
- //Create a regular old label
63
- label = new JLabel ("Click on an image name in the list." , JLabel .CENTER );
64
+ lessonTextPane = new JEditorPane ();
65
+ lessonTextPane .setEditable (false );
66
+ lessonTextPane .setCaretPosition (0 );
67
+ lessonTextPane .setMargin (new Insets (5 ,5 ,5 ,5 ));
68
+
69
+ JScrollPane scrollPaneForLesson = new JScrollPane (lessonTextPane );
70
+ scrollPaneForLesson .setPreferredSize (new Dimension (200 , 200 ));
64
71
65
72
//Create a split pane and put "top" (a split pane)
66
73
//and JLabel instance in it.
67
- JSplitPane splitPane = new JSplitPane (JSplitPane .VERTICAL_SPLIT , leftPane , label );
74
+ JSplitPane splitPane = new JSplitPane (JSplitPane .HORIZONTAL_SPLIT , leftPane , scrollPaneForLesson );
68
75
splitPane .setOneTouchExpandable (true );
69
76
splitPane .setDividerLocation (180 );
70
77
71
- //Provide minimum sizes for the two components in the split pane
72
- // leftPane.setMinimumSize(new Dimension(100, 50));
73
- label .setMinimumSize (new Dimension (100 , 30 ));
74
-
75
78
//Add the split pane to this frame
76
79
getContentPane ().add (splitPane );
77
80
}
0 commit comments