Skip to content

Commit

Permalink
Added about project dialog
Browse files Browse the repository at this point in the history
SQL driver code optimization
Throw error message in a message dialog
About project window
Removed unfinished JDialog
  • Loading branch information
shreyask21 committed Apr 10, 2020
1 parent dfc4b98 commit ad597c3
Show file tree
Hide file tree
Showing 13 changed files with 183 additions and 73 deletions.
1 change: 1 addition & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="img"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-13">
<attributes>
<attribute name="module" value="true"/>
Expand Down
Binary file modified bin/Test_package/Main.class
Binary file not shown.
Binary file modified bin/db_driver/assetdb.class
Binary file not shown.
Binary file modified export/asset_management.jar
Binary file not shown.
53 changes: 53 additions & 0 deletions src/GUI/about.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package GUI;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.net.URL;

public class about extends JDialog {
private static final long serialVersionUID = 5381052862136001506L;

public about() {
setModalityType(ModalityType.APPLICATION_MODAL);
setResizable(false);
setTitle("About Project");
setBackground(Color.WHITE);
getContentPane().setBackground(Color.WHITE);
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
int x = (int) ((dimension.getWidth() - getWidth()) / 2);
int y = (int) ((dimension.getHeight() - getHeight()) / 2);
setBounds(x, y, 516, 600);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setAlwaysOnTop(true);
getContentPane().setLayout(null);
JLabel L = new JLabel(new ImageIcon(this.getClass().getClassLoader().getResource("resources/about.png")));
L.setHorizontalAlignment(SwingConstants.CENTER);
L.setBounds(0, 0, 500, 500);
getContentPane().add(L);

JButton gitbtn = new JButton(new ImageIcon(this.getClass().getClassLoader().getResource("resources/git.png")));
gitbtn.setBackground(Color.WHITE);
gitbtn.setBounds(208, 511, 100, 40);
getContentPane().add(gitbtn);
gitbtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(new URL("https://github.com/shreyask21/assetmgmt/").toURI());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
});

}

public void display() {
this.setVisible(true);
}

}
40 changes: 0 additions & 40 deletions src/GUI/addentry_dialog.java

This file was deleted.

10 changes: 9 additions & 1 deletion src/GUI/createdb_dialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import java.awt.Font;
import java.awt.Toolkit;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.ButtonGroup;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.awt.event.ActionEvent;
import java.awt.Color;
import java.awt.Dimension;

/*Shows the database creation option dialog*/
public class createdb_dialog extends JDialog implements ActionListener {
Expand All @@ -36,7 +39,12 @@ public createdb_dialog() throws SQLException {
this.setModal(true);
this.setTitle("Choose What To Do...");
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
int x = (int) ((dimension.getWidth() - getWidth()) / 2);
int y = (int) ((dimension.getHeight() - getHeight()) / 2);
setBounds(400, 300, 400, 300);
setLocation(x, y);
setLocationRelativeTo(null);
getContentPane().setLayout(new BorderLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
Expand All @@ -52,7 +60,7 @@ public createdb_dialog() throws SQLException {

JRadioButton radio_olddb = new JRadioButton("Use Existing database");
radio_olddb.setFont(new Font("Tahoma", Font.PLAIN, 13));
radio_olddb.setBounds(210, 20, 147, 21);
radio_olddb.setBounds(210, 20, 168, 21);
contentPanel.add(radio_olddb);
radio_olddb.setActionCommand("old");

Expand Down
9 changes: 9 additions & 0 deletions src/GUI/error_dialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package GUI;

import javax.swing.JOptionPane;

public class error_dialog {
public static void showError(String error) {
JOptionPane.showMessageDialog (null, error, "Something went Wrong", JOptionPane.ERROR_MESSAGE);
}
}
26 changes: 25 additions & 1 deletion src/GUI/login_dialog.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package GUI;

import db_driver.assetdb;
import GUI.about;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JTextField;
Expand All @@ -9,10 +10,12 @@
import javax.swing.JOptionPane;
import javax.swing.SwingConstants;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.ActionEvent;
import java.awt.Color;
import java.awt.Dimension;

/*Shows the login dialog*/
public class login_dialog extends JDialog {
Expand All @@ -23,15 +26,23 @@ public class login_dialog extends JDialog {
private JLabel lblNewLabel;
private JLabel lblNewLabel_1;
private JLabel lblNewLabel_2;
private JButton aboutbtn;

/* Generates layout */
public login_dialog() {
/* Create layout */
this.setModal(true);
setModalityType(ModalityType.APPLICATION_MODAL);
setResizable(false);
this.setTitle("Login Prompt");
this.setAlwaysOnTop(false);
setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
assetdb db = new assetdb();
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
int x = (int) ((dimension.getWidth() - getWidth()) / 2);
int y = (int) ((dimension.getHeight() - getHeight()) / 2);
setBounds(400, 300, 400, 300);
setLocation(x, y);
setLocationRelativeTo(null);
getContentPane().setLayout(null);
textbox_username = new JTextField();
textbox_username.setBounds(140, 89, 120, 25);
Expand Down Expand Up @@ -85,6 +96,19 @@ public void actionPerformed(ActionEvent e) {
});
exitbtn.setBounds(140, 194, 120, 25);
getContentPane().add(exitbtn);

aboutbtn = new JButton("About");
aboutbtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
about info = new about();
info.display();
}
});
aboutbtn.setForeground(Color.DARK_GRAY);
aboutbtn.setBackground(Color.WHITE);
aboutbtn.setFont(new Font("Tahoma", Font.PLAIN, 10));
aboutbtn.setBounds(316, 238, 68, 23);
getContentPane().add(aboutbtn);

}

Expand Down
Loading

0 comments on commit ad597c3

Please sign in to comment.