Cosmetic changes to most panels
parent
d803f6df2a
commit
316222e8b5
|
@ -6,11 +6,14 @@ import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
|
||||||
public class Main extends JFrame {
|
public class Main extends JFrame {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -24,18 +27,20 @@ public class Main extends JFrame {
|
||||||
|
|
||||||
//Wird in mehreren Labels benutzt (reg und log)
|
//Wird in mehreren Labels benutzt (reg und log)
|
||||||
private JPanel errorMessage; // mal gucken, vllt auch nicht
|
private JPanel errorMessage; // mal gucken, vllt auch nicht
|
||||||
private JPanel profile; //wird nach registrieren oder login kreiert
|
|
||||||
|
|
||||||
|
private JLabel mainMenuLabel;
|
||||||
private JPanel logRegScreen;
|
private JPanel logRegScreen;
|
||||||
private JButton loginButton;
|
private JButton loginButton;
|
||||||
private JButton registerButton;
|
private JButton registerButton;
|
||||||
|
|
||||||
|
private JLabel loginLabel;
|
||||||
private JPanel loginScreen;
|
private JPanel loginScreen;
|
||||||
private JPanel loginName;
|
private JPanel loginName;
|
||||||
private JPanel loginPassword;
|
private JPanel loginPassword;
|
||||||
private JButton loginConfirmButton;
|
private JButton loginConfirmButton;
|
||||||
private JButton loginZurückButton;
|
private JButton loginZurückButton;
|
||||||
|
|
||||||
|
private JLabel registerLabel;
|
||||||
private JPanel registerScreen; // Backend muss PLZ und Ort prüfen, sonst kann die Entfernung in Zukunft nicht berechnet werden
|
private JPanel registerScreen; // Backend muss PLZ und Ort prüfen, sonst kann die Entfernung in Zukunft nicht berechnet werden
|
||||||
private JPanel registerName;
|
private JPanel registerName;
|
||||||
private JPanel registerPassword;
|
private JPanel registerPassword;
|
||||||
|
@ -48,12 +53,13 @@ public class Main extends JFrame {
|
||||||
private JButton registerConfirmButton;
|
private JButton registerConfirmButton;
|
||||||
private JButton registerZurückButton;
|
private JButton registerZurückButton;
|
||||||
|
|
||||||
|
private JLabel menuLabel;
|
||||||
private JPanel menu;
|
private JPanel menu;
|
||||||
private JPanel searchPLZ;
|
private JPanel searchPLZ_ORT;
|
||||||
private JPanel searchOrt;
|
|
||||||
private JButton searchConfirmButton;
|
private JButton searchConfirmButton;
|
||||||
private JButton randDestinationsCarButton;
|
private JButton randDestinationsCarButton;
|
||||||
private JButton randDestinationsBikeButton;
|
private JButton randDestinationsBikeButton;
|
||||||
|
private JPanel profile;
|
||||||
private JButton logOutButton;
|
private JButton logOutButton;
|
||||||
|
|
||||||
public Main(String api_key) {
|
public Main(String api_key) {
|
||||||
|
@ -71,23 +77,30 @@ public class Main extends JFrame {
|
||||||
errorMessageCreate();//wahrscheinlich muss individuell angepasst werden
|
errorMessageCreate();//wahrscheinlich muss individuell angepasst werden
|
||||||
|
|
||||||
logRegScreen = new JPanel(new FlowLayout());
|
logRegScreen = new JPanel(new FlowLayout());
|
||||||
|
mainMenuLabel = new JLabel(" Hauptmenü ");
|
||||||
|
mainMenuLabel.setFont(new Font("Arial", Font.PLAIN, 24));
|
||||||
loginButtonCreate();
|
loginButtonCreate();
|
||||||
registerButtonCreate();
|
registerButtonCreate();
|
||||||
|
logRegScreen.add(mainMenuLabel);
|
||||||
logRegScreen.add(loginButton, BorderLayout.WEST);
|
logRegScreen.add(loginButton, BorderLayout.WEST);
|
||||||
logRegScreen.add(registerButton, BorderLayout.EAST);
|
logRegScreen.add(registerButton, BorderLayout.EAST);
|
||||||
|
|
||||||
loginScreen = new JPanel(new FlowLayout());
|
loginScreen = new JPanel(new FlowLayout());
|
||||||
|
loginLabel = new JLabel(" Einloggen ");
|
||||||
|
loginLabel.setFont(new Font("Arial", Font.PLAIN, 24));
|
||||||
loginNameCreate();
|
loginNameCreate();
|
||||||
loginPasswordCreate();
|
loginPasswordCreate();
|
||||||
loginConfirmButtonCreate();
|
loginConfirmButtonCreate();
|
||||||
loginZurückButtonCreate();
|
loginZurückButtonCreate();
|
||||||
|
loginScreen.add(loginLabel);
|
||||||
loginScreen.add(loginName);
|
loginScreen.add(loginName);
|
||||||
loginScreen.add(loginPassword);
|
loginScreen.add(loginPassword);
|
||||||
loginScreen.add(loginConfirmButton);
|
loginScreen.add(loginConfirmButton);
|
||||||
loginScreen.add(loginZurückButton);
|
loginScreen.add(loginZurückButton);
|
||||||
loginScreen.add(loginZurückButton);
|
|
||||||
|
|
||||||
registerScreen = new JPanel(new FlowLayout()); // flowLayout muss angepasst werden, um nicht scheiße auszusehen
|
registerScreen = new JPanel(new FlowLayout()); // flowLayout muss angepasst werden, um nicht scheiße auszusehen
|
||||||
|
registerLabel = new JLabel("Registrieren");
|
||||||
|
registerLabel.setFont(new Font("Arial", Font.PLAIN, 24));
|
||||||
registerNameCreate();
|
registerNameCreate();
|
||||||
registerPasswordCreate();
|
registerPasswordCreate();
|
||||||
registerOrtCreate();
|
registerOrtCreate();
|
||||||
|
@ -98,31 +111,34 @@ public class Main extends JFrame {
|
||||||
registerBikeSpeedCreate();
|
registerBikeSpeedCreate();
|
||||||
registerConfirmButtonCreate();
|
registerConfirmButtonCreate();
|
||||||
registerZurückButtonCreate();
|
registerZurückButtonCreate();
|
||||||
|
registerScreen.add(registerLabel);
|
||||||
registerScreen.add(registerName);
|
registerScreen.add(registerName);
|
||||||
registerScreen.add(registerPassword);
|
registerScreen.add(registerPassword);
|
||||||
registerScreen.add(registerOrt);
|
registerScreen.add(registerOrt);
|
||||||
registerScreen.add(registerPLZ);
|
registerScreen.add(registerPLZ);
|
||||||
|
registerScreen.add(registerCarName);
|
||||||
registerScreen.add(registerCarSpeed);
|
registerScreen.add(registerCarSpeed);
|
||||||
|
registerScreen.add(registerCarCO2);
|
||||||
registerScreen.add(registerBikeSpeed);
|
registerScreen.add(registerBikeSpeed);
|
||||||
registerScreen.add(registerConfirmButton);
|
registerScreen.add(registerConfirmButton);
|
||||||
registerScreen.add(registerZurückButton);
|
registerScreen.add(registerZurückButton);
|
||||||
registerScreen.add(registerZurückButton);
|
|
||||||
|
|
||||||
menu = new JPanel(null);
|
menu = new JPanel(null);
|
||||||
searchPLZCreate();
|
menuLabel = new JLabel("Gugl Maps");
|
||||||
searchOrtCreate();
|
menuLabel.setFont(new Font("Arial", Font.PLAIN, 24));
|
||||||
|
searchPLZ_ORTCreate();
|
||||||
searchConfirmButtonCreate();
|
searchConfirmButtonCreate();
|
||||||
randDestinationsCarButtonCreate();
|
randDestinationsCarButtonCreate();
|
||||||
randDestinationsBikeButtonCreate();
|
randDestinationsBikeButtonCreate();
|
||||||
logOutButtonCreate();
|
logOutButtonCreate();
|
||||||
searchPLZ.setBounds(160, 0, 200, 200);
|
menuLabel.setBounds(180, -125, 300, 300);
|
||||||
searchOrt.setBounds(0, 0, 200, 200);
|
searchPLZ_ORT.setBounds(20, 50, 300, 100);
|
||||||
searchConfirmButton.setBounds(360, 5, 90, 20);
|
searchConfirmButton.setBounds(346, 70, 110, 30);
|
||||||
randDestinationsCarButton.setBounds(360, 40, 90, 20);
|
randDestinationsCarButton.setBounds(346, 115, 110, 30);
|
||||||
randDestinationsBikeButton.setBounds(360, 75, 90, 20);
|
randDestinationsBikeButton.setBounds(346, 160, 110, 30);
|
||||||
logOutButton.setBounds(380, 420, 90, 30);
|
logOutButton.setBounds(346, 420, 110, 30);
|
||||||
menu.add(searchPLZ);
|
menu.add(menuLabel);
|
||||||
menu.add(searchOrt);
|
menu.add(searchPLZ_ORT);
|
||||||
menu.add(searchConfirmButton);
|
menu.add(searchConfirmButton);
|
||||||
menu.add(randDestinationsCarButton);
|
menu.add(randDestinationsCarButton);
|
||||||
menu.add(randDestinationsBikeButton);
|
menu.add(randDestinationsBikeButton);
|
||||||
|
@ -135,18 +151,11 @@ public class Main extends JFrame {
|
||||||
cardLayout.show(panelLayout, "1");
|
cardLayout.show(panelLayout, "1");
|
||||||
jframe.add(panelLayout);
|
jframe.add(panelLayout);
|
||||||
jframe.setResizable(false);
|
jframe.setResizable(false);
|
||||||
jframe.setSize(450, 140);
|
jframe.setSize(450, 160);
|
||||||
jframe.setLocationRelativeTo(null);
|
jframe.setLocationRelativeTo(null);
|
||||||
jframe.setVisible(true);
|
jframe.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void profileCreate() {
|
|
||||||
profile = new JPanel();
|
|
||||||
JLabel jl = new JLabel("Profil");
|
|
||||||
searchOrt.add(jl);
|
|
||||||
//Backend soll DatenLiefern
|
|
||||||
}
|
|
||||||
|
|
||||||
private void errorMessageCreate() {
|
private void errorMessageCreate() {
|
||||||
errorMessage = new JPanel();
|
errorMessage = new JPanel();
|
||||||
JLabel jl = new JLabel("Daten sind falsch oder unvollständig!");
|
JLabel jl = new JLabel("Daten sind falsch oder unvollständig!");
|
||||||
|
@ -162,7 +171,7 @@ public class Main extends JFrame {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
cardLayout.show(panelLayout, "2");
|
cardLayout.show(panelLayout, "2");
|
||||||
jframe.setSize(new Dimension(500, 180));
|
jframe.setSize(new Dimension(400, 150));
|
||||||
// implementiere einlesen der textfelder des Panels
|
// implementiere einlesen der textfelder des Panels
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -177,7 +186,7 @@ public class Main extends JFrame {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
cardLayout.show(panelLayout, "3");
|
cardLayout.show(panelLayout, "3");
|
||||||
jframe.setSize(new Dimension(520, 180));
|
jframe.setSize(new Dimension(260, 390));
|
||||||
// implementiere einlesen der textfelder des Panles
|
// implementiere einlesen der textfelder des Panles
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -266,7 +275,7 @@ public class Main extends JFrame {
|
||||||
|
|
||||||
private void registerCarNameCreate() {
|
private void registerCarNameCreate() {
|
||||||
registerCarName = new JPanel();
|
registerCarName = new JPanel();
|
||||||
JLabel jl = new JLabel("Auto km/h");
|
JLabel jl = new JLabel(" Auto Name");
|
||||||
JTextField tf = new JTextField(10);
|
JTextField tf = new JTextField(10);
|
||||||
tf.setName("registerCarNameText");
|
tf.setName("registerCarNameText");
|
||||||
registerCarName.add(jl);
|
registerCarName.add(jl);
|
||||||
|
@ -284,7 +293,7 @@ public class Main extends JFrame {
|
||||||
|
|
||||||
private void registerCarCO2Create() {
|
private void registerCarCO2Create() {
|
||||||
registerCarCO2 = new JPanel();
|
registerCarCO2 = new JPanel();
|
||||||
JLabel jl = new JLabel("Auto km/h");
|
JLabel jl = new JLabel("Verbrauch/100km");
|
||||||
JTextField tf = new JTextField(10);
|
JTextField tf = new JTextField(10);
|
||||||
tf.setName("registerCarCO2Text");
|
tf.setName("registerCarCO2Text");
|
||||||
registerCarCO2.add(jl);
|
registerCarCO2.add(jl);
|
||||||
|
@ -328,28 +337,25 @@ public class Main extends JFrame {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void searchPLZCreate() {
|
private void searchPLZ_ORTCreate() {
|
||||||
searchPLZ = new JPanel();
|
searchPLZ_ORT = new JPanel();
|
||||||
JLabel jl = new JLabel("PLZ");
|
JLabel jl = new JLabel("Plz oder Ort");
|
||||||
JTextField tf = new JTextField(10);
|
JTextField tf = new JTextField(28);
|
||||||
tf.setName("plzSuche");
|
|
||||||
searchPLZ.add(jl);
|
|
||||||
searchPLZ.add(tf);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void searchOrtCreate() {
|
|
||||||
searchOrt = new JPanel();
|
|
||||||
JLabel jl = new JLabel("Ort");
|
|
||||||
JTextField tf = new JTextField(10);
|
|
||||||
tf.setName("ortSuche");
|
tf.setName("ortSuche");
|
||||||
searchOrt.add(jl);
|
searchPLZ_ORT.add(jl);
|
||||||
searchOrt.add(tf);
|
searchPLZ_ORT.add(tf);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void searchConfirmButtonCreate() {
|
private void searchConfirmButtonCreate() {
|
||||||
searchConfirmButton = new JButton("Suche");
|
searchConfirmButton = new JButton();
|
||||||
searchConfirmButton.setPreferredSize(new Dimension(150, 50));
|
searchConfirmButton.setPreferredSize(new Dimension(150, 80));
|
||||||
searchConfirmButton.setFocusable(false);
|
searchConfirmButton.setFocusable(false);
|
||||||
|
|
||||||
|
ImageIcon icon = png("lupe.png", 20, 20);
|
||||||
|
searchConfirmButton.setIcon(icon);
|
||||||
|
searchConfirmButton.setText(" Suche");
|
||||||
|
searchConfirmButton.setIconTextGap(3);
|
||||||
|
|
||||||
searchConfirmButton.addActionListener(new ActionListener() {
|
searchConfirmButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
@ -359,9 +365,15 @@ public class Main extends JFrame {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void randDestinationsCarButtonCreate() { //Auto Icon hinzufügen
|
private void randDestinationsCarButtonCreate() { //Auto Icon hinzufügen
|
||||||
randDestinationsCarButton = new JButton("Kurztrip");
|
randDestinationsCarButton = new JButton();
|
||||||
randDestinationsCarButton.setPreferredSize(new Dimension(150, 50));
|
randDestinationsCarButton.setPreferredSize(new Dimension(150, 80));
|
||||||
randDestinationsCarButton.setFocusable(false);
|
randDestinationsCarButton.setFocusable(false);
|
||||||
|
|
||||||
|
ImageIcon icon = png("auto.png", 20, 20);
|
||||||
|
randDestinationsCarButton.setIcon(icon);
|
||||||
|
randDestinationsCarButton.setText("Kurztrip");
|
||||||
|
randDestinationsCarButton.setIconTextGap(3);
|
||||||
|
|
||||||
randDestinationsCarButton.addActionListener(new ActionListener() {
|
randDestinationsCarButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
@ -371,9 +383,15 @@ public class Main extends JFrame {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void randDestinationsBikeButtonCreate() { //Fahrrad Icon hinzufügen
|
private void randDestinationsBikeButtonCreate() { //Fahrrad Icon hinzufügen
|
||||||
randDestinationsBikeButton = new JButton("Kurztrip");
|
randDestinationsBikeButton = new JButton();
|
||||||
randDestinationsBikeButton.setPreferredSize(new Dimension(150, 50));
|
randDestinationsBikeButton.setPreferredSize(new Dimension(150, 80));
|
||||||
randDestinationsBikeButton.setFocusable(false);
|
randDestinationsBikeButton.setFocusable(false);
|
||||||
|
|
||||||
|
ImageIcon icon = png("fahrrad.png", 20, 20);
|
||||||
|
randDestinationsBikeButton.setIcon(icon);
|
||||||
|
randDestinationsBikeButton.setText("Kurztrip");
|
||||||
|
randDestinationsBikeButton.setIconTextGap(3);
|
||||||
|
|
||||||
randDestinationsBikeButton.addActionListener(new ActionListener() {
|
randDestinationsBikeButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
@ -396,4 +414,12 @@ public class Main extends JFrame {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ImageIcon png(String path, int sizeX, int sizeY) { // umständlich und png nicht transparent
|
||||||
|
ImageIcon icon = new ImageIcon(getClass().getResource(path)); // Path des PNGs muss angegeben werden
|
||||||
|
Image img = icon.getImage();
|
||||||
|
Image newimg = img.getScaledInstance(sizeX, sizeY, java.awt.Image.SCALE_SMOOTH); // wähle Größe des PNGs
|
||||||
|
ImageIcon iconTwo = new ImageIcon(newimg);
|
||||||
|
return iconTwo;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue