|
@@ -52,9 +52,17 @@ public class ServerFrame extends javax.swing.JInternalFrame {
|
52
|
52
|
*/
|
53
|
53
|
private Border myborder;
|
54
|
54
|
/**
|
55
|
|
- * The northframe used when the frame is not maximised
|
|
55
|
+ * The dimensions of the titlebar of the frame
|
56
|
56
|
**/
|
57
|
57
|
private Dimension titlebarSize;
|
|
58
|
+ /**
|
|
59
|
+ * whether to auto scroll the textarea when adding text
|
|
60
|
+ */
|
|
61
|
+ private boolean autoScroll = true;
|
|
62
|
+ /**
|
|
63
|
+ * holds the scrollbar for the frame
|
|
64
|
+ */
|
|
65
|
+ private JScrollBar scrollBar;
|
58
|
66
|
|
59
|
67
|
private ServerCommandParser commandParser;
|
60
|
68
|
|
|
@@ -70,6 +78,7 @@ public class ServerFrame extends javax.swing.JInternalFrame {
|
70
|
78
|
setResizable(true);
|
71
|
79
|
|
72
|
80
|
this.parent = parent;
|
|
81
|
+ scrollBar = jScrollPane1.getVerticalScrollBar();
|
73
|
82
|
|
74
|
83
|
commandParser = new ServerCommandParser(parent);
|
75
|
84
|
|
|
@@ -103,7 +112,7 @@ public class ServerFrame extends javax.swing.JInternalFrame {
|
103
|
112
|
|
104
|
113
|
/**
|
105
|
114
|
* Adds a line of text to the main text area, and scrolls the text pane
|
106
|
|
- * down so that it's visible
|
|
115
|
+ * down so that it's visible if the scrollbar is already at the bottom
|
107
|
116
|
* @param line text to add
|
108
|
117
|
*/
|
109
|
118
|
public void addLine(String line) {
|
|
@@ -114,9 +123,15 @@ public class ServerFrame extends javax.swing.JInternalFrame {
|
114
|
123
|
ex.printStackTrace();
|
115
|
124
|
}
|
116
|
125
|
|
117
|
|
- jScrollPane1.invalidate();
|
118
|
|
- JScrollBar bar = jScrollPane1.getVerticalScrollBar();
|
119
|
|
- bar.setValue(bar.getMaximum());
|
|
126
|
+ autoScroll = ((scrollBar.getValue() + scrollBar.getVisibleAmount())
|
|
127
|
+ != scrollBar.getMaximum());
|
|
128
|
+ System.out.println("Value: \t\t"+scrollBar.getValue()+
|
|
129
|
+ "\r\nVisible \t"+scrollBar.getVisibleAmount()+
|
|
130
|
+ "\r\nMax: \t\t"+scrollBar.getMaximum()+
|
|
131
|
+ "\r\nAutoScrolling: \t"+autoScroll);
|
|
132
|
+ if(autoScroll) {
|
|
133
|
+ jTextPane1.setCaretPosition(doc.getLength());
|
|
134
|
+ }
|
120
|
135
|
}
|
121
|
136
|
|
122
|
137
|
/** This method is called from within the constructor to
|