HEy ich und ein paar Freunde wollen Risiko und java programmieren und haben Probleme dabei die Buttons Tauschen und Start im Borderlayout Bereich south zu verschieben
danke für jede Hilfe
danke für jede Hilfe
Java:
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Gui extends JFrame implements ActionListener {
Dimension screensize = java.awt.Toolkit.getDefaultToolkit().getScreenSize ();
Image Spielfeld = new ImageIcon(this.getClass().getResource("risk_pic.png")).getImage();
JButton BMenu;
JButton BStart;
JButton BTauschen;
JList Cardlist;
JList LandA;
JList LandDef;
JLabel Karten;
Image WürfelList;
JFrame Game;
Gui(){
}
public void Display () {
BMenu=new JButton("Menu");
BTauschen=new JButton("Tauschen");
BStart=new JButton("Start");
String[]Karten= {"\n", " North Europe", " - \n" ," Cavalier","--------------------------", "\n"," North Europe", " - \n" ," Cavalier","--------------------------", "\n"," North Europe", " - \n" ," Cavalier","--------------------------", "\n"," North Europe", " - \n" ," Cavalier","--------------------------", "\n"," North Europe", " - \n" ," Cavalier","--------------------------", };
Cardlist = new JList(Karten);
JMenuBar menubar = new JMenuBar();
JMenuItem fileRes = new JMenuItem("Menu");
menubar.add(fileRes);
JPanel Unten = new JPanel(); // Panel Unten
Unten.add(BTauschen);
Unten.add(BStart);
Unten.add(new JLabel(" Einheiten zu Setzen: "+"6"+" Einheiten Gesamt: "+"10"));
JPanel Oben = new JPanel(); // Panel Oben
Oben.setLayout(new BoxLayout(Oben,BoxLayout.Y_AXIS));
JLabel la = new JLabel("Spieler 1");
la.setAlignmentX(CENTER_ALIGNMENT);
Oben.add(menubar);
Oben.add(la);
Oben.setBackground(Color.RED);
JPanel Links = new JPanel(); // Panel Links
Links.setLayout(new BoxLayout(Links,BoxLayout.Y_AXIS));
Links.add(Cardlist);
BTauschen.setAlignmentY(BOTTOM_ALIGNMENT);
JPanel Map = new JPanel(){
public void paint(Graphics g2d) { // Alles was gezeichnet wird ---> hier rein
g2d.drawImage(Spielfeld, 0, 0, getWidth(), getHeight(), this);
}};
JFrame frame = new JFrame();
frame.add(BorderLayout.NORTH,Oben);
frame.add(BorderLayout.WEST,Links);
frame.add(BorderLayout.SOUTH,Unten);
frame.add(BorderLayout.CENTER,Map);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize((int)screensize.getWidth(),(int)screensize.getHeight()-30);
frame.setVisible(true);
}
public void setUnits(){}
public void attack(){}
public void dice (){}
public void changeUnits(){}
public void actionPerformed(ActionEvent arg0) { // kommt man wohl nicht drumrum , zumindest für testläufe
repaint();
}
}