mirror of
https://github.com/xfarrow/guify.git
synced 2025-02-20 05:50:36 +01:00
Notepad is now responsive
Version 1.0.4
This commit is contained in:
parent
2050c061db
commit
52e4de968f
@ -4,8 +4,8 @@ import java.awt.Color;
|
|||||||
|
|
||||||
public class Constants {
|
public class Constants {
|
||||||
public static final String APP_NAME = "Guify";
|
public static final String APP_NAME = "Guify";
|
||||||
public static final String VERSION = "1.0.3";
|
public static final String VERSION = "1.0.4";
|
||||||
public static final int VERSION_PROGRESSIVE = 3;
|
public static final int VERSION_PROGRESSIVE = 4;
|
||||||
|
|
||||||
public static class Constants_FSOperations{
|
public static class Constants_FSOperations{
|
||||||
public static final int NONE = 0;
|
public static final int NONE = 0;
|
||||||
|
@ -3,6 +3,7 @@ package controllers;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
import code.Constants;
|
||||||
import code.SshEngine;
|
import code.SshEngine;
|
||||||
import code.GuiAbstractions.Implementations.JFrameFactory;
|
import code.GuiAbstractions.Implementations.JFrameFactory;
|
||||||
import code.GuiAbstractions.Interfaces.IFrameFactory;
|
import code.GuiAbstractions.Interfaces.IFrameFactory;
|
||||||
@ -59,6 +60,10 @@ public class LoginController {
|
|||||||
frame.setVisible(show);
|
frame.setVisible(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return Constants.APP_NAME + " " + Constants.VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
public static class LoginCredentials{
|
public static class LoginCredentials{
|
||||||
public static String host;
|
public static String host;
|
||||||
public static String username;
|
public static String username;
|
||||||
|
@ -3,12 +3,9 @@ package views;
|
|||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
import code.Constants;
|
|
||||||
import code.Constants.GuifyColors;
|
import code.Constants.GuifyColors;
|
||||||
import controllers.LoginController;
|
import controllers.LoginController;
|
||||||
import views.interfaces.ILoginFrame;
|
import views.interfaces.ILoginFrame;
|
||||||
|
|
||||||
import javax.swing.JPasswordField;
|
import javax.swing.JPasswordField;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
@ -31,9 +28,10 @@ public class Login extends JFrame implements ILoginFrame {
|
|||||||
public Login(Object controller) {
|
public Login(Object controller) {
|
||||||
this.controller = (LoginController) controller;
|
this.controller = (LoginController) controller;
|
||||||
|
|
||||||
setTitle(Constants.APP_NAME);
|
setTitle(this.controller.getTitle());
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
setBounds(100, 100, 312, 400);
|
setResizable(false);
|
||||||
|
setBounds(100, 100, 300, 400);
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
contentPane.setForeground(Color.WHITE);
|
contentPane.setForeground(Color.WHITE);
|
||||||
contentPane.setBackground(Color.WHITE);
|
contentPane.setBackground(Color.WHITE);
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package views;
|
package views;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.Box;
|
import javax.swing.Box;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
@ -11,11 +13,9 @@ import javax.swing.JToolBar;
|
|||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentEvent;
|
||||||
import javax.swing.event.DocumentListener;
|
import javax.swing.event.DocumentListener;
|
||||||
|
|
||||||
import code.GuiAbstractions.Implementations.JGenericTextArea;
|
import code.GuiAbstractions.Implementations.JGenericTextArea;
|
||||||
import controllers.NotepadController;
|
import controllers.NotepadController;
|
||||||
import views.interfaces.INotepadFrame;
|
import views.interfaces.INotepadFrame;
|
||||||
|
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
@ -24,11 +24,12 @@ import java.awt.event.WindowAdapter;
|
|||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
public class Notepad extends JFrame implements INotepadFrame {
|
public class Notepad extends JFrame implements INotepadFrame {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private NotepadController controller;
|
private NotepadController controller;
|
||||||
private boolean jtextAreaShouldListenForChanges = true;
|
|
||||||
private JTextArea textArea;
|
private JTextArea textArea;
|
||||||
|
|
||||||
public Notepad(Object controller) {
|
public Notepad(Object controller) {
|
||||||
@ -36,12 +37,12 @@ public class Notepad extends JFrame implements INotepadFrame {
|
|||||||
setTitle(this.controller.getFilePath());
|
setTitle(this.controller.getFilePath());
|
||||||
setBounds(100, 100, 800, 600);
|
setBounds(100, 100, 800, 600);
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
getContentPane().setLayout(null);
|
getContentPane().setLayout(new BorderLayout());
|
||||||
|
JPanel contentPanel = new JPanel(new BorderLayout());
|
||||||
JScrollPane scrollPane = new JScrollPane();
|
JScrollPane scrollPane = new JScrollPane(textArea);
|
||||||
scrollPane.setBounds(10, 38, 764, 512);
|
contentPanel.add(scrollPane, BorderLayout.CENTER);
|
||||||
getContentPane().add(scrollPane);
|
contentPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); // We want to create a spaced JPanel
|
||||||
|
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||||
textArea = new JTextArea();
|
textArea = new JTextArea();
|
||||||
scrollPane.setViewportView(textArea);
|
scrollPane.setViewportView(textArea);
|
||||||
textArea.setTabSize(4);
|
textArea.setTabSize(4);
|
||||||
@ -68,18 +69,13 @@ public class Notepad extends JFrame implements INotepadFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleTextChange() {
|
private void handleTextChange() {
|
||||||
if(!((NotepadController)controller).isUnsaved() && jtextAreaShouldListenForChanges) {
|
if(!((NotepadController)controller).isUnsaved()) {
|
||||||
((NotepadController)controller).setUnsaved(true);
|
((NotepadController)controller).setUnsaved(true);
|
||||||
setTitle(((NotepadController)controller).getTitle());
|
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();
|
JButton saveBtn = new JButton();
|
||||||
saveBtn.setBorderPainted(false);
|
saveBtn.setBorderPainted(false);
|
||||||
saveBtn.setBorder(new EmptyBorder(0, 0, 0, 0)); // Set empty border
|
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(saveBtn);
|
||||||
toolBar.add(Box.createHorizontalStrut(15));
|
toolBar.add(Box.createHorizontalStrut(15));
|
||||||
toolBar.add(searchBtn);
|
toolBar.add(searchBtn);
|
||||||
|
|
||||||
getContentPane().add(toolBar);
|
getContentPane().add(toolBarPanel, BorderLayout.NORTH);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close "Find and Replace" if this window
|
* Close "Find and Replace" if this window
|
||||||
|
Loading…
x
Reference in New Issue
Block a user