Skip to content

Commit d52a740

Browse files
committed
Added scroll pane to text area
Reason: So we can work with larger text. Also remove redundant try comment.
1 parent 15032ad commit d52a740

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/simplejavatexteditor/UI.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public UI() {
9696
try {
9797
ImageIcon image = new ImageIcon("icons/ste.png");
9898
super.setIconImage(image.getImage());
99-
} // try
99+
}
100100
catch (Exception ex) {
101101
ex.printStackTrace();
102102
}
@@ -132,9 +132,14 @@ public void keyPressed(KeyEvent ke) {
132132
}
133133
});
134134

135-
// This is why we didn't have to worry about the size of the TextArea!
135+
136+
JScrollPane scrollPane = new JScrollPane(textArea);
137+
textArea.setWrapStyleWord(true);
138+
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
136139
getContentPane().setLayout(new BorderLayout()); // the BorderLayout bit makes it fill it automatically
137-
getContentPane().add(textArea);
140+
JPanel panel = new JPanel(new BorderLayout());
141+
panel.add(scrollPane);
142+
getContentPane().add(panel);
138143

139144
// Set the Menus
140145
menuFile = new JMenu("File");

0 commit comments

Comments
 (0)