Skip to content

Commit 957d752

Browse files
committed
Merge branch 'master' of gitlab.com:pH-7/Simple-Java-Text-Editor
2 parents 99ea46e + 6594b58 commit 957d752

File tree

7 files changed

+57
-29
lines changed

7 files changed

+57
-29
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,41 @@
55
![Programming Java Text Editor](Screenshots/text-editor-writing-icon.svg)
66

77

8-
- Search tool (to search text/keywords easily in the code) + highlighting the code found
8+
* Search tool (to search text/keywords easily in the code) + highlighting the code found.
99

10-
- Find/Replace text/code
10+
* Find/Replace text/code.
1111

12-
- Auto completion for Java and C++ keywords (files need to be saved as *.java*/*.cpp*). It can be easily expanded to support pretty much any number of languages.
12+
* Auto completion for Java and C++ keywords (files need to be saved as *.java*/*.cpp*). It can be easily expanded to support pretty much any number of languages.
1313

14-
- Nice image buttons for better UX
14+
* Nice image buttons for better UX.
1515

1616

1717
![Example Java Text Editor](Screenshots/find-replace-word-in-java-text-editor.png)
1818

1919

2020
## AUTHOR
2121

22-
[Pierre-Henry Soria](https://github.com/pH-7)
22+
**[Pierre-Henry Soria](http://pierrehenry.be)**
2323

2424

25-
### Contributors
25+
### Contributors 🏅
2626

27-
- [Achintha Gunasekara](https://github.com/achinthagunasekara)
27+
* [Achintha Gunasekara](https://github.com/achinthagunasekara)
2828

29-
- [Patrick Slagle](https://github.com/patrick-slagle)
29+
* [Patrick Slagle](https://github.com/patrick-slagle)
3030

31-
- [Marcus Redgrave-Close](https://github.com/marcusjrc)
31+
* [Marcus Redgrave-Close](https://github.com/marcusjrc)
3232

33-
- [Ossi Laukkanen](https://github.com/Fitoh)
33+
* [Ossi Laukkanen](https://github.com/Fitoh)
3434

35-
- [Akashdeep Singh](https://github.com/akashdeepsingh9988)
35+
* [Akashdeep Singh](https://github.com/akashdeepsingh9988)
3636

3737

3838
## CONTACT
3939

40-
Pierre-Henry SORIA: pierrehenrysoria [AT] gmail [D0T] com
40+
* Pierre-Henry Soria: hi [AT] ph7 [D0T] me
4141

42-
Achintha Gunasekara: contact [AT] achinthagunasekara [D0T] com
42+
* Achintha Gunasekara: contact [AT] achinthagunasekara [D0T] com
4343

4444

4545
## DEMO

icons/bold.png

946 Bytes
Loading

icons/italic.png

514 Bytes
Loading

src/simplejavatexteditor/About.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @modifiedby Achintha Gunasekara
1515
* @modweb http://www.achinthagunasekara.com
1616
* @modemail [email protected]
17-
*
17+
*
1818
* @Modifiedby SidaDan
1919
* @modemail [email protected]
2020
* Bug fixed. If JTextArea txt not empty and the user will
@@ -42,15 +42,15 @@ public About(UI ui) {
4242
panel = new JPanel(new FlowLayout());
4343
panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
4444
frame = new JFrame();
45-
45+
4646
frame.addWindowListener(new WindowAdapter() {
4747
@Override
4848
public void windowClosing(WindowEvent e) {
4949
frame.dispose();
5050
}
5151
});
5252

53-
53+
5454
frame.setVisible(true);
5555
frame.setSize(500,300);
5656
frame.setLocationRelativeTo(ui);

src/simplejavatexteditor/Find.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @modifiedby Achintha Gunasekara
1515
* @modweb http://www.achinthagunasekara.com
1616
* @modemail [email protected]
17-
*
17+
*
1818
* @Modifiedby SidaDan
1919
* @modemail [email protected]
2020
* Center this JFrame to the JTextArea
@@ -23,7 +23,7 @@
2323
* is only hidden (still running). We need DISPOSE_ON_CLOSE for
2424
* this JFrame.
2525
* Tested with java 8.
26-
*
26+
*
2727
* @Modifiedby SidaDan
2828
* @modemail [email protected]
2929
* Removed unsused imports
@@ -45,7 +45,6 @@ public class Find extends JFrame implements ActionListener {
4545
JButton findBtn, findNext, replace, replaceAll, cancel;
4646
private JTextArea txt;
4747

48-
4948
public Find(JTextArea text) {
5049
this.txt = text;
5150

src/simplejavatexteditor/SimpleJavaTextEditor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
public class SimpleJavaTextEditor extends JTextPane {
2424

2525
private static final long serialVersionUID = 1L;
26-
public final static String AUTHOR_EMAIL = "[email protected]";
26+
public final static String AUTHOR_EMAIL = "[email protected]";
2727
public final static String NAME = "PHNotePad";
2828
public final static String EDITOR_EMAIL = "[email protected]";
2929
public final static double VERSION = 3.0;
@@ -35,4 +35,4 @@ public static void main(String[] args) {
3535
new UI().setVisible(true);
3636
}
3737

38-
}
38+
}

src/simplejavatexteditor/UI.java

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
* @modemail [email protected]
3232
* Removed unuse objects like container, Border emptyBorder
3333
* Removed unsused imports
34+
*
35+
* @Modifiedby Giorgos Pasentsis
36+
* @modemail [email protected]
3437
*/
3538
package simplejavatexteditor;
3639

@@ -55,9 +58,13 @@ public class UI extends JFrame implements ActionListener {
5558
private final JMenuItem newFile, openFile, saveFile, close, cut, copy, paste, clearFile, selectAll, quickFind,
5659
aboutMe, aboutSoftware, wordWrap;
5760
private final JToolBar mainToolbar;
58-
JButton newButton, openButton, saveButton, clearButton, quickButton, aboutMeButton, aboutButton, closeButton;
61+
JButton newButton, openButton, saveButton, clearButton, quickButton, aboutMeButton, aboutButton, closeButton, boldButton, italicButton;
5962
private final Action selectAllAction;
6063

64+
//setup icons - Bold and Italic
65+
private final ImageIcon boldIcon = new ImageIcon("icons/bold.png");
66+
private final ImageIcon italicIcon = new ImageIcon("icons/italic.png");
67+
6168
// setup icons - File Menu
6269
private final ImageIcon newIcon = new ImageIcon("icons/new.png");
6370
private final ImageIcon openIcon = new ImageIcon("icons/open.png");
@@ -86,9 +93,8 @@ public class UI extends JFrame implements ActionListener {
8693
private boolean edit = false;
8794

8895
public UI() {
89-
9096
// Set the initial size of the window
91-
setSize(700, 500);
97+
setSize(800, 500);
9298

9399
// Set the title of the window
94100
setTitle("Untitled | " + SimpleJavaTextEditor.NAME);
@@ -101,9 +107,9 @@ public UI() {
101107

102108
// Set a default font for the TextArea
103109
textArea = new JTextArea("", 0, 0);
104-
textArea.setFont(new Font("Century Gothic", Font.BOLD, 12));
110+
textArea.setFont(new Font("Century Gothic", Font.PLAIN, 12));
105111
textArea.setTabSize(2);
106-
textArea.setFont(new Font("Century Gothic", Font.BOLD, 12));
112+
textArea.setFont(new Font("Century Gothic", Font.PLAIN, 12));
107113
textArea.setTabSize(2);
108114

109115
/* SETTING BY DEFAULT WORD WRAP ENABLED OR TRUE */
@@ -312,6 +318,17 @@ public void actionPerformed(ActionEvent ev) {
312318
mainToolbar.add(closeButton);
313319
mainToolbar.addSeparator();
314320

321+
boldButton = new JButton(boldIcon);
322+
boldButton.setToolTipText("Bold");
323+
boldButton.addActionListener(this);
324+
mainToolbar.add(boldButton);
325+
mainToolbar.addSeparator();
326+
327+
italicButton = new JButton(italicIcon);
328+
italicButton.setToolTipText("Italic");
329+
italicButton.addActionListener(this);
330+
mainToolbar.add(italicButton);
331+
mainToolbar.addSeparator();
315332
/**
316333
* **************** FONT SETTINGS SECTION **********************
317334
*/
@@ -361,7 +378,6 @@ public void actionPerformed(ActionEvent ev) {
361378

362379
Font font1 = new Font(fontFamily, Font.PLAIN, sizeOfFont);
363380
textArea.setFont(font1);
364-
365381
}
366382
});
367383
//FONT SIZE SETTINGS SECTION END
@@ -485,8 +501,21 @@ else if (e.getSource() == openFile || e.getSource() == openButton) {
485501
} // If the source of the event was the "save" option
486502
else if (e.getSource() == saveFile || e.getSource() == saveButton) {
487503
saveFile();
504+
}// If the source of the event was the "Bold" button
505+
else if (e.getSource() == boldButton) {
506+
if (textArea.getFont().getStyle() == Font.BOLD){
507+
textArea.setFont(textArea.getFont().deriveFont(Font.PLAIN));
508+
} else {
509+
textArea.setFont(textArea.getFont().deriveFont(Font.BOLD));
510+
}
511+
}// If the source of the event was the "Italic" button
512+
else if (e.getSource() == italicButton) {
513+
if (textArea.getFont().getStyle() == Font.ITALIC){
514+
textArea.setFont(textArea.getFont().deriveFont(Font.PLAIN));
515+
} else {
516+
textArea.setFont(textArea.getFont().deriveFont(Font.ITALIC));
517+
}
488518
}
489-
490519
// Clear File (Code)
491520
if (e.getSource() == clearFile || e.getSource() == clearButton) {
492521

@@ -507,7 +536,6 @@ else if (e.getSource() == aboutMe || e.getSource() == aboutMeButton) {
507536
else if (e.getSource() == aboutSoftware || e.getSource() == aboutButton) {
508537
new About(this).software();
509538
}
510-
511539
}
512540

513541
class SelectAllAction extends AbstractAction {
@@ -555,4 +583,5 @@ private void saveFile() {
555583
}
556584
}
557585
}
586+
558587
}

0 commit comments

Comments
 (0)