Menu

ThinkJava. The Professional Java IDE / ThinkJava Tutorials: Recent posts

How to make a Notepad app in ThinkJava

How to make a Notepad app in ThinkJava
Hi! Today, me, the founder and dev of ThinkJava, Zean, here to teach you how to make a Notepad app that you recognize in your PC.
Want to make one? Follow me and I will guide you on this adventure on to make notepad.

1. Prepare a new project
I know you already know how to make a new project. Let's name this new shiny project Notepad in Java
Then, make a class called Notepad.
2. Write the code
From now, in the class we have to write this line. We are going to use javax.swing so head to Window > Marketplace then go to Packages then download and install Java Framework Tools. Now you can start writing this line of code.
We need to make sure to import all the javax by writing this line of code.

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.datatransfer.*;
import java.io.*;
import javax.swing.undo.*;
import javax.swing.text.DefaultHighlighter;
import javax.swing.text.Highlighter;
import javax.swing.text.Highlighter.HighlightPainter;

Okay now we have initialized the damn stuffs, let's get to the real coding.
Write these statements inside the class.
Don't forget to write these statements next to the public class Notepad

public class Notepad extends JFrame

Next, we write these statements inside the class.
~~~
String filename;
JTextPane tx;
Clipboard clip = getToolkit().getSystemClipboard();
JColorChooser chooser = new JColorChooser(Color.WHITE);
UndoManager manager = new UndoManager();
Action undoAction = new UndoAction(manager);
Action redoAction = new RedoAction(manager);
JDialog finddiag;
JTextField getfindword;
HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(Color.orange);... read more

Posted by Zean 2021-02-26
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.