-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormat.java
More file actions
50 lines (41 loc) · 1.42 KB
/
Format.java
File metadata and controls
50 lines (41 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.awt.Font;
public class Format {
GUI gui;
Font arial , comicSansMS , timesNewRoman;
String selectedFont;
public Format(GUI gui){
this.gui = gui;
}
public void wordWrap(){
if(!gui.wordWrapOn){
gui.wordWrapOn = true;
gui.textArea.setLineWrap(true);
gui.textArea.setWrapStyleWord(true);
gui.iWrap.setText("Word Wrap : ON");
}else{
gui.wordWrapOn = false;
gui.textArea.setLineWrap(false);
gui.textArea.setWrapStyleWord(false);
gui.iWrap.setText("Word Wrap : OFF");
}
}
public void createFont(int fontSize){
arial = new Font("Arial" , Font.PLAIN , fontSize);
comicSansMS = new Font("Comic Sans MS" , Font.PLAIN , fontSize);
timesNewRoman = new Font("Times New Roman" , Font.PLAIN , fontSize);
setFont(selectedFont);
}
public void setFont(String font){
selectedFont = font;
switch (selectedFont) {
case "Arial": gui.textArea.setFont(arial);
break;
case "Comic Sans MS" : gui.textArea.setFont(comicSansMS);
break;
case "Times New Roman" : gui.textArea.setFont(timesNewRoman);
break;
default:
break;
}
}
}