Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a Notepad Application developed using java libraries. #187

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Programs/NotePadAppllication/Format.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import java.awt.*;

public class Format {
GUI gui;
String SELECTEDString;


Font arial ,ComicSansMS,timeNewRoman;
Format(GUI gui){
this.gui=gui;
}

public void wrapword(){

if (gui.wordwrapOn==false){
gui.wordwrapOn=true;
gui.textArea.setLineWrap(true);
gui.textArea.setWrapStyleWord(true);
gui.iWrap.setText("Wrap Word:On");

}
else if (gui.wordwrapOn==true){
gui.wordwrapOn=false;
gui.textArea.setLineWrap(false);
gui.textArea.setWrapStyleWord(false);
gui.iWrap.setText("Wrap Word:Off");
}

}

public void createFont(int fontSize){

arial=new Font("Arial",Font.PLAIN,fontSize);
ComicSansMS=new Font("ComicSansMS",Font.PLAIN,fontSize);
timeNewRoman=new Font("TimeNewRoman",Font.PLAIN,fontSize);
selectfont(SELECTEDString);

}
public void selectfont(String font){
SELECTEDString=font;
switch(SELECTEDString){
case "Time Of New Roman":gui.textArea.setFont(timeNewRoman); break;
case "Comic Sans MS":gui.textArea.setFont(ComicSansMS); break;
case "Arial":gui.textArea.setFont(arial);
}
}

}
31 changes: 31 additions & 0 deletions Programs/NotePadAppllication/Function_Color.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import java.awt.*;

public class Function_Color {
GUI gui;

Function_Color(GUI gui){
this.gui=gui;
}

public void changeColor(String color){
switch (color){
case "White":
gui.window.getContentPane().setBackground(Color.WHITE);
gui.textArea.setBackground(Color.WHITE);
gui.textArea.setForeground(Color.BLACK);
break;
case "Black":
gui.window.setBackground(Color.BLACK);
gui.textArea.setBackground(Color.BLACK);
gui.textArea.setForeground(Color.white);
break;
case "Red":
gui.window.setBackground(Color.red);
gui.textArea.setBackground(Color.red);
gui.textArea.setForeground(Color.WHITE);
break;

}

}
}
13 changes: 13 additions & 0 deletions Programs/NotePadAppllication/Function_Edit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class Function_Edit {
GUI gui;
Function_Edit(GUI gui){
this.gui=gui;
}

public void undo(){
gui.um.undo();
}
public void redo(){
gui.um.redo();
}
}
80 changes: 80 additions & 0 deletions Programs/NotePadAppllication/Function_File.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import java.awt.*;
import java.io.*;

public class Function_File {
GUI gui;
String fileName;
String fileAddress;
Function_File( GUI gui){
this.gui=gui;

}
public void newFile(){
gui.textArea.setText("");
gui.window.setTitle("New");
fileName=null;
fileAddress=null;
}
public void open(){
FileDialog fileDialog=new FileDialog(gui.window,"Open",FileDialog.LOAD);
fileDialog.setVisible(true);

if (fileDialog.getFile()!=null){
fileName= fileDialog.getFile();
fileAddress=fileDialog.getDirectory();
gui.window.setTitle(fileName);

try{
BufferedReader br= new BufferedReader(new FileReader(fileAddress+fileName));
gui.textArea.setText("");
String line=null;
while((line= br.readLine())!=null){
gui.textArea.append(line+"\n");
}
br.close();

}catch (Exception e){
System.out.println("File not found");
}

}
}
public void save(){
if (fileName==null){
SaveAs();
}
else {
try{
FileWriter fileWriter= new FileWriter(fileAddress+fileName);
fileWriter.write(gui.textArea.getText());
fileWriter.close();
}catch (Exception e){
System.out.println("Something Went Wrong");
}
}

}
public void SaveAs(){
FileDialog fileDialog = new FileDialog(gui.window,"SAVE",FileDialog.SAVE);
fileDialog.setVisible(true);
if(fileDialog.getFile()!=null){
fileName=fileDialog.getFile();
fileAddress=fileDialog.getDirectory();
gui.window.setTitle(fileName);
}
try{
FileWriter fileWriter= new FileWriter(fileAddress+fileName);
fileWriter.write(gui.textArea.getText());
fileWriter.close();
}catch (Exception e){
System.out.println("Something Went Wrong");
}
}
public void exit(){
System.exit(0);
}

public static void main(String[] args) {

}
}
Loading