Pb de saccadement avec un JScrollPane

ivanohe5 Messages postés 12 Date d'inscription mardi 15 juillet 2003 Statut Membre Dernière intervention 18 avril 2006 - 13 avril 2006 à 18:47
ivanohe5 Messages postés 12 Date d'inscription mardi 15 juillet 2003 Statut Membre Dernière intervention 18 avril 2006 - 18 avril 2006 à 11:11
Salut,

g une fenetre toute simple en swing avec JScrollPane au milieu avec un JPanel sur lequel je dessine.

Tout s'affiche bien au début, mais lorque je veux voir l'intégralité de mon dessin qui est plus grand que ma fenetre, là cé la boullie le JviewPort ne correspond plus du tout cé un mélange entre mon dessin des barres du composant ....

voici le code:

la fenetre:

public class affPrise extends JFrame{

JPanel pan1 = new JPanel();
BorderLayout master = new BorderLayout();
graphAffPrise graph;
JScrollPane jSp;// = new JScrollPane();

public affPrise(ArrayList<Requetes_obs> p) {

graph = new graphAffPrise(p);
graph.setPreferredSize(graph.getPreferredSize());
jSp = new JScrollPane(graph);
jSp.setPreferredSize(jSp.getPreferredSize());
pan1.setLayout(new BorderLayout());
pan1.setPreferredSize(pan1.getPreferredSize());
pan1.add(jSp);
//Size the frame.
//pack();
setSize(new Dimension(1000,800));

// Create components and put them in the frame.
//...create emptyLabel...
this.getContentPane().add(pan1);

setTitle("Affichage des entrées du sat");
//look
JFrame.setDefaultLookAndFeelDecorated(true);

//What happens when the frame closes?
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


// jSp.getViewport().add(graph);


setLocationRelativeTo(null);

//Show it.
this.setVisible(true);

}//fin cons

}//fin class

le dessin:

public class graphAffPrise extends JPanel{

ArrayList<Requetes_obs> prises = new ArrayList<Requetes_obs>();
int espace=0;
float x,y,lar,minVal;

public graphAffPrise(ArrayList<Requetes_obs> p) {

prises=p;
this.setPreferredSize(new Dimension(1200,1300));

}//fin cons

public void paint(Graphics g2){

Graphics2D g = (Graphics2D)g2;
g.setBackground(Color.WHITE);

g.setColor(Color.BLUE);
g.drawLine(50,50,1050,50);

double k =(1000/(double)(prises.get(prises.size()-1).getTdeb()-prises.get(0).getTdeb()));

for(int i=0; i<prises.size();i++){

x=prises.get(i).getTdeb();
y=50+espace;
lar=(prises.get(i).getTfin()-prises.get(i).getTdeb());

//dessine
g.drawRect((int)(k*x),(int)y,50+(int)(k*lar),10);
g.setFont(new Font("",Font.BOLD,10));
g.drawString(String.valueOf(prises.get(i).getPriorite()),25+(int)(k*x)+(int)(k*lar)/2,(int)y+9);

espace=espace+20;
}

}//fin graph

}//fin class

merci d'avance

2 réponses

ivanohe5 Messages postés 12 Date d'inscription mardi 15 juillet 2003 Statut Membre Dernière intervention 18 avril 2006
18 avril 2006 à 11:11
quand je bouje une barre du scroll pane le Jview devient tout saccadé
0
ivanohe5 Messages postés 12 Date d'inscription mardi 15 juillet 2003 Statut Membre Dernière intervention 18 avril 2006
18 avril 2006 à 11:11
quand je bouje une barre du scroll pane le Jview devient tout saccadé
0
Rejoignez-nous