- Build a text editor using Java swing
- jEdit
- jEdit is a programmer’s text editor written in Java.
- Features
- Project Samples
- Project Activity
- Categories
- License
- Follow jEdit
- Saved searches
- Use saved searches to filter your results more quickly
- text-editor
- Here are 176 public repositories matching this topic.
- 1hakr / AnExplorer
- neoedmund / neoeedit
- pH-7 / Simple-Java-Text-Editor
- lltvcn / FreeText
- Cypher-Notepad / Cypher-Notepad
- cristianzsh / JCEditor
- TomerAberbach / mano-simulator
- massivemadness / EditorKit
- RohitAwate / Ballad
- TS-Code-Editor / Android-Code-Editor
- iamareebjamal / Kodis
- manoj5047 / QUOTZY
- Eadgyth / Programming-Editor
- abrandell / JavaFX-TextEditor
- Saved searches
- Use saved searches to filter your results more quickly
- License
- pH-7/Simple-Java-Text-Editor
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
Build a text editor using Java swing
Hi, we are learning how to build a text editor using Java or we can say a simple notepad. Java swing components are lightweight as compared to other GUI components of Java. It is also platform-independent.
So let’s discuss how to build this project using Java swing. First, let’s discuss the components required to build this project are Text area require to writing or reading the text, then we require some menu items like file, edit, and info file contains options like open, save, new and exit whereas edit contains cut, copy, paste, undo and redo and finally on info contains information about developer and text editor. Now we require a scroll bar that scrolls the page according to the requirement of the user. Now we need to add functionality to each menu item to cut, copy, and past we require only one line of code as given below respectively.
textArea.cut(); textArea.copy(); textArea.paste();
Where textArea is the object of the JTextArea which is used for the Text Area component. Now we require to add undo and redo functionality so we require to create an object of UndoManager class and then attach this object with textArea.
UndoManager undo = new UndoManager(); textArea.getDocument().addUndoableEditListener(undo);
Now use this object and add undo and redo functionality to the menu items by writing a single line of code for each one.
Next, we require to add functionality to new, open, save and exit menu items. Let’s being with new for it we just need to clear the text in the teaxtArea component so for that, we need to set the empty string in it.
Now it time to save and open both of them the code require to add functionality in them is similar. First, we will code for the functionality to save a file.
JFileChooser filechooser = new JFileChooser("f:"); int temp = filechooser.showSaveDialog(null); if (temp == JFileChooser.APPROVE_OPTION) < File file = new File(filechooser.getSelectedFile().getAbsolutePath()); try < FileWriter filewriter = new FileWriter(file, false); BufferedWriter bufferwr = new BufferedWriter(filewriter); bufferwr.write(textRegion.getText()); bufferwr.flush(); bufferwr.close(); >catch (Exception ex) < JOptionPane.showMessageDialog(frmTextEditor, ex.getMessage()); >>
Now we will code for opening a file in the text editor.
JFileChooser filechooser = new JFileChooser("f:"); int temp = filechooser.showOpenDialog(null); if (temp == JFileChooser.APPROVE_OPTION) < File file = new File(filechooser.getSelectedFile().getAbsolutePath()); try < String str="",str1=""; FileReader fileread = new FileReader(file); BufferedReader bufferrd = new BufferedReader(fileread); str1=bufferrd.readLine(); while((str=bufferrd.readLine())!=null) < str1=str1+"\n"+str; >textRegion.setText(str1); > catch(Exception ex) < JOptionPane.showMessageDialog(frmTextEditor, ex.getMessage()); >>
Now finally we will code for exiting from the text editor through the exit menu item.
frmTextEditor.dispatchEvent(new WindowEvent(frmTextEditor, WindowEvent.WINDOW_CLOSING));
finally, we discuss the major and some minor parts of the code of the project so to completely deploy or build this project we require complete code which is attached below just copy it and build your own text editor.
import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JMenuBar; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JRadioButtonMenuItem; import javax.swing.JLabel; import javax.swing.JSeparator; import javax.swing.JEditorPane; import javax.swing.JFileChooser; import java.awt.CardLayout; import javax.swing.JTextArea; import javax.swing.SpringLayout; import javax.swing.undo.UndoManager; import java.awt.event.ActionListener; import java.awt.event.WindowEvent; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.awt.event.ActionEvent; import javax.swing.BoxLayout; import java.awt.BorderLayout; import javax.swing.JScrollBar; import javax.swing.JScrollPane; public class text_editor < private JFrame frmTextEditor; /** * Launch the application. */ public static void main(String[] args) < EventQueue.invokeLater(new Runnable() < public void run() < try < text_editor window = new text_editor(); window.frmTextEditor.setVisible(true); >catch (Exception e) < e.printStackTrace(); >> >); > /** * Create the application. */ public text_editor() < initialize(); >/** * Initialize the contents of the frame. */ private void initialize() < frmTextEditor = new JFrame(); frmTextEditor.setTitle("Text Editor"); frmTextEditor.setBounds(100, 100, 505, 490); frmTextEditor.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frmTextEditor.getContentPane().setLayout(new BorderLayout(0, 0)); JTextArea textRegion = new JTextArea(); frmTextEditor.getContentPane().add(textRegion, BorderLayout.CENTER); JMenuBar menuBar = new JMenuBar(); frmTextEditor.setJMenuBar(menuBar); UndoManager undo = new UndoManager(); textRegion.getDocument().addUndoableEditListener(undo); JMenu mnFile = new JMenu("File"); menuBar.add(mnFile); JMenuItem mntmNew = new JMenuItem("New"); mntmNew.addActionListener(new ActionListener() < public void actionPerformed(ActionEvent arg0) < textRegion.setText(""); >>); mnFile.add(mntmNew); JMenuItem mntmSave = new JMenuItem("Save"); mntmSave.addActionListener(new ActionListener() < public void actionPerformed(ActionEvent e) < JFileChooser filechooser = new JFileChooser("f:"); int temp = filechooser.showSaveDialog(null); if (temp == JFileChooser.APPROVE_OPTION) < File file = new File(filechooser.getSelectedFile().getAbsolutePath()); try < FileWriter filewriter = new FileWriter(file, false); BufferedWriter bufferwr = new BufferedWriter(filewriter); bufferwr.write(textRegion.getText()); bufferwr.flush(); bufferwr.close(); >catch (Exception ex) < JOptionPane.showMessageDialog(frmTextEditor, ex.getMessage()); >> > >); mnFile.add(mntmSave); JMenuItem mntmOpen = new JMenuItem("Open"); mntmOpen.addActionListener(new ActionListener() < public void actionPerformed(ActionEvent e) < JFileChooser filechooser = new JFileChooser("f:"); int temp = filechooser.showOpenDialog(null); if (temp == JFileChooser.APPROVE_OPTION) < File file = new File(filechooser.getSelectedFile().getAbsolutePath()); try < String str="",str1=""; FileReader fileread = new FileReader(file); BufferedReader bufferrd = new BufferedReader(fileread); str1=bufferrd.readLine(); while((str=bufferrd.readLine())!=null) < str1=str1+"\n"+str; >textRegion.setText(str1); > catch(Exception ex) < JOptionPane.showMessageDialog(frmTextEditor, ex.getMessage()); >> > >); mnFile.add(mntmOpen); JMenuItem mntmExit = new JMenuItem("Exit"); mntmExit.addActionListener(new ActionListener() < public void actionPerformed(ActionEvent e) < frmTextEditor.dispatchEvent(new WindowEvent(frmTextEditor, WindowEvent.WINDOW_CLOSING)); >>); mnFile.add(mntmExit); JMenu mnEdit = new JMenu("Edit"); menuBar.add(mnEdit); JMenuItem mntmCut = new JMenuItem("Cut"); mntmCut.addActionListener(new ActionListener() < public void actionPerformed(ActionEvent e) < textRegion.cut(); >>); mnEdit.add(mntmCut); JMenuItem mntmCopy = new JMenuItem("Copy"); mntmCopy.addActionListener(new ActionListener() < public void actionPerformed(ActionEvent e) < textRegion.copy(); >>); mnEdit.add(mntmCopy); JMenuItem mntmExi = new JMenuItem("Paste"); mntmExi.addActionListener(new ActionListener() < public void actionPerformed(ActionEvent e) < textRegion.paste(); >>); mnEdit.add(mntmExi); JMenuItem mntmUndo = new JMenuItem("Undo"); mntmUndo.addActionListener(new ActionListener() < public void actionPerformed(ActionEvent e) < undo.undo(); >>); mnEdit.add(mntmUndo); JMenuItem mntmRedo = new JMenuItem("Redo"); mntmRedo.addActionListener(new ActionListener() < public void actionPerformed(ActionEvent e) < undo.redo(); >>); mnEdit.add(mntmRedo); JMenu mnInfo = new JMenu("Info"); menuBar.add(mnInfo); JLabel lblThisEditorIs = new JLabel("This Editor is designed in Java Swing"); mnInfo.add(lblThisEditorIs); JSeparator separator = new JSeparator(); mnInfo.add(separator); JLabel lblDevelopedByYashika = new JLabel("& Developed By Yashika Jain"); mnInfo.add(lblDevelopedByYashika); JScrollPane scrollabletextRegion = new JScrollPane(textRegion); scrollabletextRegion.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); scrollabletextRegion.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); frmTextEditor.getContentPane().add(scrollabletextRegion); > >
Thank you for reading this Blog.
jEdit
jEdit is a programmer’s text editor written in Java.
jEdit is a programmer’s text editor written in Java. It uses the Swing toolkit for the GUI and can be configured as a rather powerful IDE through the use of its plugin architecture.
Features
- Written in Java, so it runs on Mac OS X, Unix, VMS and Windows.
- Built-in macro language; extensible plugin architecture.
- Hundreds of plugins can be downloaded and installed from within jEdit using the plugin manager feature.
- Auto indent, and syntax highlighting for more than 200 languages.
- Supports a large number of character encodings including UTF8 and Unicode.
- Folding for selectively hiding regions of text.
- Word wrap.
- Highly configurable and customizable.
- See http://www.jedit.org/?page=features for more .
Project Samples
Project Activity
Categories
License
Follow jEdit
For Family Offices, Fund Administrators, Hedge Funds, Wealth Management and Private Equity Firms, Funds of Funds, and other investment professionals
FundCount is a partnership accounting and analytical software solution that tracks, analyzes and reports the value of complex investments. Suitable for fund administrators, family offices, hedge funds, and private equity firms, FundCount offers an integrated multicurrency general ledger and automated workflow tools to bring a higher level of efficency to daily processes. It also comes with flexible, effortlesss reporting tools to enable firms to quickly produce and deliver consolidated reports tailored to each client’s unique requirements. FundCount has been voted as the Best Fund Accounting and Reporting Systems Firm by Hedgeweek.
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
text-editor
Here are 176 public repositories matching this topic.
1hakr / AnExplorer
📁 Another Android Explorer ( File Manager ) is an All-in-One Open source file manager. AnExplorer File Manager (File Explorer) is designed for all android devices including Phones, Phablets, Tablets, Chromecast, Wear OS, Android TV and Chromebooks. It’s a fully designed with Material guidelines by Google.
neoedmund / neoeedit
neoeedit — a smart, light, powerful text editor.
pH-7 / Simple-Java-Text-Editor
📝 PHNotepad is a simple Java text/code editor (notepad) written in Java. It has also nice features such as Search tool, Find/Replace text/code, Auto-completion, Nice Image Buttons for better UX, etc.
lltvcn / FreeText
Cypher-Notepad / Cypher-Notepad
The user-friendly, plain-text editor with Hybrid Encryption.
cristianzsh / JCEditor
📝 Text editor created in Java
TomerAberbach / mano-simulator
🖥️ An assembler and hardware simulator for the Mano Basic Computer, a 16 bit computer.
massivemadness / EditorKit
🖊 EditorKit is a multi-language code editor library for Android
RohitAwate / Ballad
A simple, beautiful text editor made using JavaFX.
TS-Code-Editor / Android-Code-Editor
iamareebjamal / Kodis
Kodis is an Android based Code Text Editor
manoj5047 / QUOTZY
Repositry for powerful android Text editor with tons of features.
Eadgyth / Programming-Editor
A text and code editor using Java. Run code in Java, C#, Perl, Python, R or HTML.
abrandell / JavaFX-TextEditor
Text editor built in JavaFX.
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
📝 PHNotepad is a simple Java text/code editor (notepad) written in Java. It has also nice features such as Search tool, Find/Replace text/code, Auto-completion, Nice Image Buttons for better UX, etc.
License
pH-7/Simple-Java-Text-Editor
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
PH NotePad is a simple and light text editor (notepad) written in Java.
- Search tool (to search text/keywords easily in the code) + highlighting the code found.
- Find/Replace text/code.
- 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.
- Drag and Drop (drag files into the text area and they get loaded).
- Nice image buttons for better UX.
- Pierre-Henry Soria: hi [AT] ph7 [D0T] me
- Achintha Gunasekara: contact [AT] achinthagunasekara [D0T] com
Download the Jar file and double click to run
Or run java -jar SimpleJavaTextEditor.jar from the command line
You can also generate easily a new jar file with the following command when you are in src/ directory jar cmvf ../manifest.mf ../SimpleJavaTextEditor.jar simplejavatexteditor/*.class
Icons directory and its files must be present on the path when running the application (so you will have to move «icons/» into «src/» directory)
Apache License, Version 2.0 or later; See the license.txt file in the notepad folder.
About
📝 PHNotepad is a simple Java text/code editor (notepad) written in Java. It has also nice features such as Search tool, Find/Replace text/code, Auto-completion, Nice Image Buttons for better UX, etc.