init commit

This commit is contained in:
2022-06-02 16:16:04 +02:00
commit afacff8476
17 changed files with 517 additions and 0 deletions

23
.idea/compiler.xml generated Normal file
View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

1
.idea/description.html generated Normal file
View File

@@ -0,0 +1 @@
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html>

6
.idea/encodings.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

9
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectKey">
<option name="state" value="project://63537948-39a4-48a0-9c97-34259a0fa913" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_3" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/HowToJava.iml" filepath="$PROJECT_DIR$/HowToJava.iml" />
</modules>
</component>
</project>

124
.idea/uiDesigner.xml generated Normal file
View File

@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

12
HowToJava.iml Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

30
src/Main2.java Normal file
View File

@@ -0,0 +1,30 @@
import com.rkcsd.apps.demo.gui.MainWindow;
public class Main2 {
public static void main(String[] args) {
MainWindow w = new MainWindow();
}
public static void main2(String[] args) {
MyApp abc = new MyApp("Hello World", 0);
abc.appVersion = 6;
abc.setAppName("Test");
System.out.println("MyStaticApp.getAppName()" + MyStaticApp.getAppName());
MyApp xyz = new MyApp("zweite App", 5);
xyz.setAppName("hkjhkjh");
System.out.println(abc.getAppName());
System.out.println(xyz.getAppName());
MyStaticApp.appVersion = 4;
//MyStaticApp.setAppName("static rulez!");
System.out.println("MyStaticApp.getAppName()" + MyStaticApp.getAppName());
}
}

18
src/MyApp.java Normal file
View File

@@ -0,0 +1,18 @@
public class MyApp {
private String appName = "Test";
public int appVersion = 6;
public MyApp(String appName, int appVersion) {
}
public void setAppName(String appName) {
MyStaticApp.setAppName(appName);
this.appName = appName + "!";
}
public String getAppName() {
return appName;
}
}

12
src/MyStaticApp.java Normal file
View File

@@ -0,0 +1,12 @@
public class MyStaticApp {
private static String appName = "Test";
public static int appVersion = 6;
public static void setAppName(String appName) {
MyStaticApp.appName = appName + "!";
}
public static String getAppName() {
return appName;
}
}

View 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());
}
}
}

View 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());
}
}
}

View 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);
}
}

View File

@@ -0,0 +1,32 @@
package com.rkcsd.apps.demo.main;
public class Calculator {
private double value1;
private double value2;
private double result;
public Calculator(double value1, double value2) {
setValue1(value1);
setValue2(value2);
}
public void setValue1(double value1) {
this.value1 = value1;
}
public void setValue2(double value2) {
this.value2 = value2;
}
public void doAdd() {
result = value1 + value2;
}
public void doSubtract(){
result = value1 - value2;
}
public double getResult() {
return result;
}
}

View File

@@ -0,0 +1,14 @@
package com.rkcsd.apps.demo.main;
import com.rkcsd.apps.demo.gui.MainWindow;
public class Main {
public static void main(String[] args) {
MainWindow w = new MainWindow();
}
}

View File

@@ -0,0 +1,22 @@
package com.rkcsd.apps.demo.main;
public class StringToNumberConverter {
private String s;
private double n;
private boolean error;
public StringToNumberConverter(String s) {
this.s = s;
}
public double doConversion() {
this.error = false;
try {
n = Double.parseDouble(s);
} catch (NumberFormatException e) {
this.error = true;
}
return n;
}
public boolean hasError() {
return error;
}
}