GUI

Status
Nicht offen für weitere Antworten.
G

Guest

Gast
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:
 
U

Userer

Gast
Ich brauche ein GUI Programm, das in Java geschrieben wurde.
 

The_S

Top Contributor
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:

Das wäre jetzt meine nächste Antwort gewesen :D :applaus:

[edit] @Userer siehe Code von Gast :)
 
G

Guest

Gast
Ich will ja mal nicht so sein:
Code:
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())));
		}
	}
}
 
Status
Nicht offen für weitere Antworten.

Neue Themen


Oben