U
Userer
Gast
Bräuchte irgendein leichtes GUI Programm.
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Main {
public static void main(String[] argv) throws Exception{
JFrame frame = new JFrame();
frame.add(new JLabel("Hallo Welt"));
frame.pack();
frame.setSize(200, 200);
frame.setVisible(true);
}
}
Anonymous hat gesagt.:Code:import javax.swing.JFrame; import javax.swing.JLabel; public class Main { public static void main(String[] argv) throws Exception{ JFrame frame = new JFrame(); frame.add(new JLabel("Hallo Welt")); frame.pack(); frame.setSize(200, 200); frame.setVisible(true); } }
:autsch: :autsch: :autsch:
package ping;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class Rechner implements ActionListener{
JTextField eingabe,eingabe2,ausgabe;
JButton button;
public Rechner(){
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new GridLayout(5,1));
eingabe = new JTextField();
eingabe2 = new JTextField();
ausgabe = new JTextField();
JLabel plus = new JLabel("+");
button = new JButton("=");
button.addActionListener(this);
frame.add(eingabe);
frame.add(plus);
frame.add(eingabe2);
frame.add(button);
frame.add(ausgabe);
frame.pack();
frame.setSize(250, 200);
frame.setVisible(true);
}
public static void main(String[] args) {
new Rechner();
}
public void actionPerformed(ActionEvent e){
if(e.getSource().equals(button)){
ausgabe.setText(String.valueOf(Integer.parseInt(eingabe.getText()) + Integer.parseInt(eingabe2.getText())));
}
}
}