init commit
This commit is contained in:
94
src/com/rkcsd/apps/demo/gui/MainWindow.java
Normal file
94
src/com/rkcsd/apps/demo/gui/MainWindow.java
Normal file
@@ -0,0 +1,94 @@
|
||||
package com.rkcsd.apps.demo.gui;
|
||||
|
||||
import com.rkcsd.apps.demo.main.Calculator;
|
||||
import com.rkcsd.apps.demo.main.Main;
|
||||
import com.rkcsd.apps.demo.main.StringToNumberConverter;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
public class MainWindow extends JFrame {
|
||||
|
||||
private JTextField input1;
|
||||
private JTextField input2;
|
||||
|
||||
private JLabel text;
|
||||
|
||||
private JButton btnPrinterList;
|
||||
private JButton btnAdminPanel;
|
||||
private JButton btnExit;
|
||||
|
||||
private JComboBox cbx;
|
||||
|
||||
public MainWindow() {
|
||||
super("Meine Anwendung");
|
||||
this.setSize(1000, 500);
|
||||
|
||||
this.setLayout(null);
|
||||
|
||||
btnPrinterList = new JButton("DL Anzeigen");
|
||||
btnPrinterList.setBounds(10, 210, 500, 20);
|
||||
btnPrinterList.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
PrinterListWindow secondWindow = new PrinterListWindow(MainWindow.this);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
this.add(btnPrinterList);
|
||||
|
||||
btnAdminPanel = new JButton("Admin Panel öffnen");
|
||||
btnAdminPanel.setBounds(10, 105, 500, 20);
|
||||
btnAdminPanel.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
MainWindow second = new MainWindow();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
this.add(btnAdminPanel);
|
||||
|
||||
btnExit = new JButton("Beenden");
|
||||
btnExit.setBounds(500, 315, 500, 20);
|
||||
btnExit.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
System.exit(0);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
this.add(btnExit);
|
||||
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
private void doAction() {
|
||||
StringToNumberConverter stnc1 = new StringToNumberConverter(input1.getText());
|
||||
StringToNumberConverter stnc2 = new StringToNumberConverter(input2.getText());
|
||||
|
||||
double d1 = stnc1.doConversion();
|
||||
double d2 = stnc2.doConversion();
|
||||
|
||||
if (stnc1.hasError() || stnc2.hasError()) {
|
||||
JOptionPane.showMessageDialog(MainWindow.this,
|
||||
"Da ging wohl was schief");
|
||||
} else {
|
||||
Calculator calc = new Calculator(d1, d2);
|
||||
if (cbx.getSelectedItem().equals("+")) {
|
||||
calc.doAdd();
|
||||
} else if (cbx.getSelectedItem().equals("-")) {
|
||||
calc.doSubtract();
|
||||
}
|
||||
JOptionPane.showMessageDialog(MainWindow.this,
|
||||
"Das Ergebnis lautet: " + calc.getResult());
|
||||
}
|
||||
}
|
||||
}
|
||||
87
src/com/rkcsd/apps/demo/gui/MainWindowOld.java
Normal file
87
src/com/rkcsd/apps/demo/gui/MainWindowOld.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package com.rkcsd.apps.demo.gui;
|
||||
|
||||
import com.rkcsd.apps.demo.main.Calculator;
|
||||
import com.rkcsd.apps.demo.main.StringToNumberConverter;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
public class MainWindowOld extends JFrame {
|
||||
|
||||
private JTextField input1;
|
||||
private JTextField input2;
|
||||
|
||||
private JLabel text;
|
||||
|
||||
private JButton action;
|
||||
|
||||
private JComboBox cbx;
|
||||
|
||||
public MainWindowOld() {
|
||||
super("Meine Anwendung");
|
||||
this.setSize(1000, 500);
|
||||
|
||||
this.setLayout(null);
|
||||
|
||||
text = new JLabel("Bitte geben Sie etwas ein:");
|
||||
text.setBounds(10, 10, 500, 20);
|
||||
this.add(text);
|
||||
|
||||
input1 = new JTextField();
|
||||
input1.setBounds(10, 60, 500, 20);
|
||||
this.add(input1);
|
||||
|
||||
input2 = new JTextField();
|
||||
input2.setBounds(10, 110, 500, 20);
|
||||
this.add(input2);
|
||||
|
||||
cbx = new JComboBox();
|
||||
cbx.setBounds(10, 160, 500, 20);
|
||||
cbx.addItem("+");
|
||||
cbx.addItem("-");
|
||||
this.add(cbx);
|
||||
|
||||
action = new JButton("Beschriftung");
|
||||
action.setBounds(10, 210, 500, 20);
|
||||
action.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
MainWindowOld.this.doAction();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
this.add(action);
|
||||
|
||||
|
||||
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
private void doAction() {
|
||||
StringToNumberConverter stnc1 = new StringToNumberConverter(input1.getText());
|
||||
StringToNumberConverter stnc2 = new StringToNumberConverter(input2.getText());
|
||||
|
||||
double d1 = stnc1.doConversion();
|
||||
double d2 = stnc2.doConversion();
|
||||
|
||||
if (stnc1.hasError() || stnc2.hasError()) {
|
||||
JOptionPane.showMessageDialog(MainWindowOld.this,
|
||||
"Da ging wohl was schief");
|
||||
} else {
|
||||
Calculator calc = new Calculator(d1, d2);
|
||||
if (cbx.getSelectedItem().equals("+")) {
|
||||
calc.doAdd();
|
||||
} else if (cbx.getSelectedItem().equals("-")) {
|
||||
calc.doSubtract();
|
||||
}
|
||||
JOptionPane.showMessageDialog(MainWindowOld.this,
|
||||
"Das Ergebnis lautet: " + calc.getResult());
|
||||
}
|
||||
}
|
||||
}
|
||||
19
src/com/rkcsd/apps/demo/gui/PrinterListWindow.java
Normal file
19
src/com/rkcsd/apps/demo/gui/PrinterListWindow.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.rkcsd.apps.demo.gui;
|
||||
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JTable;
|
||||
|
||||
public class PrinterListWindow extends JDialog {
|
||||
public PrinterListWindow(JFrame mainWindow) {
|
||||
super(mainWindow);
|
||||
setLayout(null);
|
||||
setSize(800, 600);
|
||||
|
||||
JTable t = new JTable();
|
||||
t.setBounds(10, 10, 700, 500);
|
||||
this.add(t);
|
||||
|
||||
setVisible(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user