K
keinereg
Gast
Java:
import java.awt.*;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.text.FlowView.FlowStrategy;
public class CodecGUI extends JFrame{
Würfel würfel1 = new Würfel();
Würfel würfel2 = new Würfel();
public CodecGUI(){
//Komponenten aufbauen
JTextArea klartext = new JTextArea();
//JTextArea Klartext einstellen
JTextArea geheimtext = new JTextArea();
//JTextArea Geheimtext einstellen
JTextField codewort1 = new JTextField();
JTextField codewort2 = new JTextField();
JButton encode = new JButton();
encode.setText("Verschlüsseln");
JButton decode = new JButton();
decode.setText("Entschlüsseln");
JLabel klartextlabel = new JLabel("Klartext eingeben:");
JLabel geheimtextlabel = new JLabel("Geheimtext eingeben:");
JLabel codewort1label = new JLabel ("Erstes Codewort eingeben");
JLabel codewort2label = new JLabel ("Zweites Codewort eingeben");
//Panel erstellen
JPanel c = new JPanel();
c.setLayout(new BorderLayout());
//Setzen der Werte fürs JFrame von CodecGUI
this.add(c);
this.setTitle("Doppelwürfelprogramm");
this.setSize(600,300);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Unterpanel
JPanel wPanel = new JPanel(new FlowLayout());
JPanel wPanel2 = new JPanel(new FlowLayout());
JPanel wPanel3 = new JPanel (new FlowLayout());
JPanel cPanel = new JPanel(new FlowLayout());
JPanel ePanel = new JPanel(new FlowLayout());
JPanel cPanel2 = new JPanel(new FlowLayout());
JPanel cPanel3 = new JPanel(new FlowLayout());
//Panels hinzufügen
c.add(wPanel,BorderLayout.BEFORE_LINE_BEGINS);
wPanel.add(wPanel2);
wPanel.add(wPanel3);
c.add(cPanel,BorderLayout.CENTER);
cPanel.add(cPanel2);
cPanel.add(cPanel3);
c.add(ePanel,BorderLayout.AFTER_LAST_LINE);
//Hinzufügen der Komponenten
wPanel2.add(klartextlabel);
wPanel2.add(klartext);
wPanel3.add(geheimtextlabel);
wPanel3.add(geheimtext);
cPanel2.add(codewort1label);
cPanel2.add(codewort1);
cPanel3.add(codewort2label);
cPanel3.add(codewort2);
ePanel.add(encode);
ePanel.add(decode);
}
}