codice:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class AttractorsPanel extends JPanel{
Environment env=new Environment(0,0,0,0);
Methods funz=new Methods();
JPanel attPanel=new JPanel(new GridLayout(9,1));
JPanel flow1=new JPanel();
JPanel flow2=new JPanel();
JPanel flow3=new JPanel();
JPanel flow4=new JPanel();
JButton addAttWall=new JButton("Attrai verso muro");
JButton addAttPoint=new JButton("Attrai verso punto");
ButtonGroup attgroup=new ButtonGroup();
JRadioButton singleball=new JRadioButton("Singola", true);
JRadioButton doubleball=new JRadioButton("Doppia");
JRadioButton breakerball=new JRadioButton("Dirompente");
JRadioButton allball=new JRadioButton("Tutte");
ButtonGroup attwalls=new ButtonGroup();
JRadioButton north=new JRadioButton("Sopra", true);
JRadioButton south=new JRadioButton("Sotto");
JRadioButton west=new JRadioButton("Sinistra");
JRadioButton east=new JRadioButton("Destra");
JLabel attperlab=new JLabel("% di attrazione:");
JLabel xlab=new JLabel("X:");
JLabel ylab=new JLabel("Y:");
JTextField attper=new JTextField("20", 3);
JTextField xfield=new JTextField("0", 4);
JTextField yfield=new JTextField("0", 4);
public AttractorsPanel(EnvironmentPanel env){
attgroup.add(singleball);
attgroup.add(doubleball);
attgroup.add(breakerball);
attgroup.add(allball);
attwalls.add(north);
attwalls.add(south);
attwalls.add(west);
attwalls.add(east);
flow1.add(singleball);
flow1.add(doubleball);
flow1.add(breakerball);
flow1.add(allball);
flow2.add(attperlab);
flow2.add(attper);
flow3.add(addAttWall);
addAttWall.addActionListener(atl);
flow3.add(north);
flow3.add(south);
flow3.add(east);
flow3.add(west);
flow4.add(addAttPoint);
addAttPoint.addActionListener(atl);
flow4.add(xlab);
flow4.add(xfield);
flow4.add(ylab);
flow4.add(yfield);
attPanel.add(flow1);
attPanel.add(flow2);
attPanel.add(flow3);
attPanel.add(flow4);
add(attPanel);
setVisible(true);
}
public class attListener implements ActionListener{
public void actionPerformed(ActionEvent e){
int perc=Integer.parseInt(attper.getText());
int wall=funz.controllaRadioB1(north, south, west, east);
int type=funz.controllaRadioB1(singleball, doubleball, breakerball, allball);
PairOfDouble coord=null;
coord.x=Integer.parseInt(xfield.getText());
coord.y=Integer.parseInt(yfield.getText());
if(e.getSource()==addAttWall && type!=3){
env.attract(wall, perc, type);
}
else if(e.getSource()==addAttWall && type==3){
env.attract(wall, perc);
}
else if(e.getSource()==addAttPoint && type!=3){
env.attract(coord, perc, type);
}
else if(e.getSource()==addAttPoint && type==3){
env.attract(coord, perc);
}
}
}
attListener atl=new attListener();
}
L'errore me lo genera:
codice:
AttractorsPanel attP=new AttractorsPanel(plancia);