Witam. Potrzebuje pomocy z AffineTransform i RMI. Na zaliczenie mam oddać kółko i krzyżyk, z możliwością obrotu planszy w 3D i z multiplayerem po lanie. Nie mam na tyle wiedzy żeby zaimplementować to w swoim programie. O to jego kod:
public class plansza extends JFrame implements ActionListener{
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JPanel plan = null;
private JLabel jLabel = null;
private JButton restart = null;
private JButton[][] przycisk=new JButton[10][10];
private int XxY=3;
String kolej="O"; // @jve:decl-index=0:
private JLabel kolejka = null;
private JButton dodaj = null;
private JButton odejmij = null;
private JPanel getplan() {
if (plan == null) {
plan = new JPanel();
plan.setLayout(null);
plan.setBounds(new Rectangle(10, 10, 500, 500));
rozmiarPola(XxY);
}
return plan;
}
protected void rozmiarPola(int R)
{
plan.removeAll();
kolej="O";
for(int i=0;i<R;i++)
{
for(int ii=0;ii<R;ii++)
{
przycisk[i][ii]=new JButton("");
przycisk[i][ii].setBounds((ii*50), (i*50), 50, 50);
plan.add(przycisk[i][ii]);
przycisk[i][ii].addActionListener(this);
}
}
}
/**
* This method initializes restart
*
* @return javax.swing.JButton
*/
private JButton getRestart() {
if (restart == null) {
restart = new JButton();
restart.setBounds(new Rectangle(631, 30, 95, 32));
restart.setText("Nowa gra");
restart.addActionListener(this);
}
return restart;
}
/**
* This method initializes dodaj
*
* @return javax.swing.JButton
*/
private JButton getDodaj() {
if (dodaj == null) {
dodaj = new JButton();
dodaj.setBounds(new Rectangle(520, 30, 45, 45));
dodaj.setText("+");
dodaj.addActionListener(this);
}
return dodaj;
}
/**
* This method initializes odejmij
*
* @return javax.swing.JButton
*/
private JButton getOdejmij() {
if (odejmij == null) {
odejmij = new JButton();
odejmij.setBounds(new Rectangle(520, 75, 45, 45));
odejmij.setText("-");
odejmij.addActionListener(this);
}
return odejmij;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SwingUtilities.invokeLater(new Runnable() {
public void run() {
plansza thisClass = new plansza();
thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
thisClass.setVisible(true);
}
});
}
/**
* This is the default constructor
*/
public plansza() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(800, 600);
this.setContentPane(getJContentPane());
this.setTitle("OX");
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
kolejka = new JLabel();
kolejka.setBounds(new Rectangle(630, 10, 78, 16));
kolejka.setText("Teraz kolej: O");
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(519, 9, 79, 16));
jLabel.setText("Rozmiar pola");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getplan(), null);
jContentPane.add(jLabel, null);
jContentPane.add(getRestart(), null);
jContentPane.add(kolejka, null);
jContentPane.add(getDodaj(), null);
jContentPane.add(getOdejmij(), null);
}
return jContentPane;
}
@SuppressWarnings("deprecation")
public void actionPerformed(ActionEvent e){
if(e.getSource()==restart)
{
rozmiarPola(XxY);
plan.repaint();
}
if(e.getSource()==dodaj)
{
if(XxY<10)
{
XxY++;
rozmiarPola(XxY);
plan.repaint();
}
}
if(e.getSource()==odejmij)
{
if(XxY>3)
{
XxY--;
rozmiarPola(XxY);
plan.repaint();
}
}
if(((JButton)e.getSource()).getText()=="")
{
int raz=0;
if(kolej=="X")
{
((JButton)e.getSource()).setText(kolej);
kolej="O";
kolejka.setText("Teraz kolej: "+kolej);
raz=1;
}
if(kolej=="O" && raz==0)
{
((JButton)e.getSource()).setText(kolej);
kolej="X";
kolejka.setText("Teraz kolej: "+kolej);
}
for(int i=0, lx=0, ly=0;i<XxY;i++,lx=ly=0)
{
for(int ii=0;ii<XxY;ii++)
{
if(przycisk[i][ii].getText()=="X")
{
lx++;
if(lx==XxY)
JOptionPane.showMessageDialog(null, "Wygrały X");
}
if(przycisk[i][ii].getText()=="O")
{
ly++;
if(ly==XxY)
JOptionPane.showMessageDialog(null, "Wygrały O");
}
}
}
for(int i=0, lx=0, ly=0;i<XxY;i++,lx=ly=0)
{
for(int ii=0;ii<XxY;ii++)
{
if(przycisk[ii][i].getText()=="X")
{
lx++;
if(lx==XxY)
JOptionPane.showMessageDialog(null, "Wygrały X");
}
if(przycisk[ii][i].getText()=="O")
{
ly++;
if(ly==XxY)
JOptionPane.showMessageDialog(null, "Wygrały O");
}
}
}
for(int i=0, lx=0, ly=0;i<XxY;i++)
{
if(przycisk[i][i].getText()=="X")
{
lx++;
if(lx==XxY)
JOptionPane.showMessageDialog(null, "Wygrały X");
}
if(przycisk[i][i].getText()=="O")
{
ly++;
if(ly==XxY)
JOptionPane.showMessageDialog(null, "Wygrały O");
}
}
for(int i=0, lx=0, ly=0;i<XxY;i++)
{
if(przycisk[XxY-i-1][i].getText()=="X")
{
lx++;
if(lx==XxY)
JOptionPane.showMessageDialog(null, "Wygrały X");
}
if(przycisk[XxY-i-1][i].getText()=="O")
{
ly++;
if(ly==XxY)
JOptionPane.showMessageDialog(null, "Wygrały O");
}
}
}
}
}