Skip to content
Open
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
69 changes: 67 additions & 2 deletions src/simpleUi/SimpleEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import javax.swing.*;
import javax.swing.text.*;

//ui improvements needed, drop down menu

/*
* Concrete implementation of the Editor interface,
Expand Down Expand Up @@ -36,7 +37,7 @@ public SimpleEditor(String title) {
* @return none
*/
private void init() {
area.setLineWrap(true);
area.setLineWrap(true);
area.setWrapStyleWord(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Expand Down Expand Up @@ -78,7 +79,71 @@ private String getNumbers() {
content1.add(buttonRow, BorderLayout.SOUTH);

frame.setContentPane(content1);
}

//adding drop down menu

// 1. Create the Menu Bar
JMenuBar menuBar = new JMenuBar();

// 2. Create a Menu (e.g., File)
JMenu fileMenu = new JMenu("File");
JMenu editMenu = new JMenu("Edit");
JMenu searchMenu = new JMenu("Search");
JMenu helpMenu = new JMenu("Info");

// 3. Create Menu Items
JMenuItem newItem = new JMenuItem("New");
JMenuItem openItem = new JMenuItem("Open");
JMenuItem saveItem = new JMenuItem("Save");
JMenuItem exitItem = new JMenuItem("Exit");

// 4. Add items to the file menu
fileMenu.add(newItem);
fileMenu.add(saveItem);
fileMenu.add(openItem);
fileMenu.addSeparator(); // Adds a visual line
fileMenu.add(exitItem);

editMenu.add(new JMenuItem("Undo"));
editMenu.add(new JMenuItem("Redo"));
editMenu.add(new JMenuItem("Clear"));

searchMenu.add(new JMenuItem("Find"));
searchMenu.add(new JMenuItem("Replace"));
searchMenu.add(new JMenuItem("Highlight Matches"));


// 5. Add menu to the bar, and bar to the frame
menuBar.add(fileMenu);
menuBar.add(editMenu);
menuBar.add(searchMenu);
menuBar.add(helpMenu);
frame.setJMenuBar(menuBar);


JMenuItem helpItem = new JMenuItem("Help");

helpItem.addActionListener(e -> {
JOptionPane.showMessageDialog(
frame,
"Welcome to the our Text Editor!\n\n"
+ "File:\nOpen and save text and java files.\n\n"
+ "Edit:\nUndo, redo, and clear text.\n\n"
+ "Search:\nFind words and replace text.\n\n"
+ "Use the buttons or menus to perform actions.\n\n"
+ "Brought to you by: Matthew Biegel, Robert Conti, \nMichael McGrath, Rui Li, Luke Padilla \n 2026",
"Help",
JOptionPane.INFORMATION_MESSAGE
);
});

helpMenu.add(helpItem);
menuBar.add(helpMenu);

// 6. Add logic to the items (optional but recommended)
exitItem.addActionListener(e -> System.exit(0));
}

@Override
protected void uiShow() {
SwingUtilities.invokeLater(() -> frame.setVisible(true));
Expand Down