Notepad is now responsive

Version 1.0.4
This commit is contained in:
xfarrow 2023-08-07 09:29:11 +02:00
parent 2050c061db
commit 52e4de968f
4 changed files with 28 additions and 23 deletions

View File

@ -4,8 +4,8 @@ import java.awt.Color;
public class Constants {
public static final String APP_NAME = "Guify";
public static final String VERSION = "1.0.3";
public static final int VERSION_PROGRESSIVE = 3;
public static final String VERSION = "1.0.4";
public static final int VERSION_PROGRESSIVE = 4;
public static class Constants_FSOperations{
public static final int NONE = 0;

View File

@ -3,6 +3,7 @@ package controllers;
import java.net.InetAddress;
import java.net.UnknownHostException;
import code.Constants;
import code.SshEngine;
import code.GuiAbstractions.Implementations.JFrameFactory;
import code.GuiAbstractions.Interfaces.IFrameFactory;
@ -59,6 +60,10 @@ public class LoginController {
frame.setVisible(show);
}
public String getTitle() {
return Constants.APP_NAME + " " + Constants.VERSION;
}
public static class LoginCredentials{
public static String host;
public static String username;

View File

@ -3,12 +3,9 @@ package views;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import code.Constants;
import code.Constants.GuifyColors;
import controllers.LoginController;
import views.interfaces.ILoginFrame;
import javax.swing.JPasswordField;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
@ -31,9 +28,10 @@ public class Login extends JFrame implements ILoginFrame {
public Login(Object controller) {
this.controller = (LoginController) controller;
setTitle(Constants.APP_NAME);
setTitle(this.controller.getTitle());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 312, 400);
setResizable(false);
setBounds(100, 100, 300, 400);
contentPane = new JPanel();
contentPane.setForeground(Color.WHITE);
contentPane.setBackground(Color.WHITE);

View File

@ -1,7 +1,9 @@
package views;
import java.awt.BorderLayout;
import java.awt.Color;
import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JButton;
@ -11,11 +13,9 @@ import javax.swing.JToolBar;
import javax.swing.border.EmptyBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import code.GuiAbstractions.Implementations.JGenericTextArea;
import controllers.NotepadController;
import views.interfaces.INotepadFrame;
import java.awt.Font;
import java.awt.Image;
import java.awt.event.MouseAdapter;
@ -24,11 +24,12 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import javax.swing.JScrollPane;
import javax.swing.JPanel;
public class Notepad extends JFrame implements INotepadFrame {
private static final long serialVersionUID = 1L;
private NotepadController controller;
private boolean jtextAreaShouldListenForChanges = true;
private JTextArea textArea;
public Notepad(Object controller) {
@ -36,12 +37,12 @@ public class Notepad extends JFrame implements INotepadFrame {
setTitle(this.controller.getFilePath());
setBounds(100, 100, 800, 600);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
getContentPane().setLayout(null);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 38, 764, 512);
getContentPane().add(scrollPane);
getContentPane().setLayout(new BorderLayout());
JPanel contentPanel = new JPanel(new BorderLayout());
JScrollPane scrollPane = new JScrollPane(textArea);
contentPanel.add(scrollPane, BorderLayout.CENTER);
contentPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); // We want to create a spaced JPanel
getContentPane().add(contentPanel, BorderLayout.CENTER);
textArea = new JTextArea();
scrollPane.setViewportView(textArea);
textArea.setTabSize(4);
@ -68,18 +69,13 @@ public class Notepad extends JFrame implements INotepadFrame {
}
private void handleTextChange() {
if(!((NotepadController)controller).isUnsaved() && jtextAreaShouldListenForChanges) {
if(!((NotepadController)controller).isUnsaved()) {
((NotepadController)controller).setUnsaved(true);
setTitle(((NotepadController)controller).getTitle());
}
}
});
JToolBar toolBar = new JToolBar();
toolBar.setFloatable(false);
toolBar.setBounds(10, 0, 614, 37);
toolBar.setBackground(new Color(240, 240, 240));
JButton saveBtn = new JButton();
saveBtn.setBorderPainted(false);
saveBtn.setBorder(new EmptyBorder(0, 0, 0, 0)); // Set empty border
@ -146,11 +142,17 @@ public class Notepad extends JFrame implements INotepadFrame {
}
});
JToolBar toolBar = new JToolBar();
toolBar.setFloatable(false);
JPanel toolBarPanel = new JPanel(new BorderLayout());
toolBarPanel.setBorder(BorderFactory.createEmptyBorder(0, 7, 0, 0));
toolBarPanel.add(toolBar, BorderLayout.LINE_START);
toolBar.setBackground(new Color(240, 240, 240));
toolBar.add(saveBtn);
toolBar.add(Box.createHorizontalStrut(15));
toolBar.add(searchBtn);
getContentPane().add(toolBar);
getContentPane().add(toolBarPanel, BorderLayout.NORTH);
/**
* Close "Find and Replace" if this window