JGraph

JGraph - Java - Programmation

Marsh Posté le 03-04-2008 à 20:39:19    

bonjour,
mon problème et que j'ai crée class rectangle à l'aide de la bibliothèque JGraph.
import java.awt.*;
import java.awt.geom.Rectangle2D;
 
import javax.swing.*;
 
 
import org.jgraph.JGraph;
import org.jgraph.graph.DefaultEdge;
import org.jgraph.graph.DefaultGraphCell;
import org.jgraph.graph.DefaultGraphModel;
import org.jgraph.graph.GraphConstants;
import org.jgraph.graph.GraphModel;
 
public class rectangle {
public rectangle(){}
public static DefaultGraphCell attaque (String name, double x,
double y, double w, double h, Color bg, boolean raised ) {
 
// Create vertex with the given name
DefaultGraphCell cell = new DefaultGraphCell(name);
 
// Set bounds
GraphConstants.setBounds(cell.getAttributes(), new Rectangle2D.Double(
x, y, w, h));
 
// Set fill color
if (bg != null) {
GraphConstants.setGradientColor(cell.getAttributes(), bg);
GraphConstants.setOpaque(cell.getAttributes(), true);
}
 
// Set raised border
if (raised)
GraphConstants.setBorder(cell.getAttributes(), BorderFactory
.createRaisedBevelBorder());
else
// Set black border
GraphConstants.setBorderColor(cell.getAttributes(), Color.black);
 
// Add a Floating Port
cell.addPort();
 
return cell;
 
}
}
et je veux faire appel à elle dans class Attaque
*****claase Attaque*****
import java.awt.*;
import java.awt.geom.Rectangle2D;
 
import javax.swing.*;
 
 
import org.jgraph.JGraph;
import org.jgraph.graph.DefaultEdge;
import org.jgraph.graph.DefaultGraphCell;
import org.jgraph.graph.DefaultGraphModel;
import org.jgraph.graph.GraphConstants;
import org.jgraph.graph.GraphModel;
 
 
public class Attaque
 
{
public static void main (String args[])
{
 
// Construct Model and Graph
GraphModel model = new DefaultGraphModel();
JGraph graph = new JGraph(model);
 
// Control-drag should clone selection
graph.setCloneable(false);
 
// Enable edit without final RETURN keystroke
graph.setInvokesStopCellEditing(true);
 
// When over a cell, jump to its default port (we only have one, anyway)
graph.setJumpToDefaultPort(true);
 
// Insert all three cells in one call, so we need an array to store them
 
 
// Create Hello Vertex
rectangle c = new rectangle();
DefaultGraphCell cells = new DefaultGraphCell();
cells = c.attaque("Hello", 140, 140, 40, 140, Color.BLUE, false);
 
// Insert the cells via the cache, so they get selected
graph.getGraphLayoutCache().insert(cells);
 
// Show in Frame
JFrame frame = new JFrame();
frame.getContentPane().add(new JScrollPane(graph));
//frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
 
}
 
 
 
 
 
}
 
 
voila ce qu'ils affiche comme erreur
 
C:\Documents and Settings\bonbino\Bureau\toto>javac -classpath jgraph.jar Attaque.java
Attaque.java:38: cannot find symbol
symbol : class rectangle
location: class Attaque
rectangle c = new rectangle();
^
Attaque.java:38: cannot find symbol
symbol : class rectangle
location: class Attaque
rectangle c = new rectangle();
^
2 errors
 
je n'arrive pas à comprendre, ils sont dans le même dossier
je travaille avec Crimson Editor
pouvez vous recompilez peut être quellequ'un d'entre vous peu la détecter je serais reconnaissante :jap:

Reply

Marsh Posté le 03-04-2008 à 20:39:19   

Reply

Marsh Posté le 04-04-2008 à 09:17:21    

C'est une erreur fréquente quand on débute : tu n'as pas mis le répertoire courant dans le classpath.
Essaye avec : javac -classpath .;jgraph.jar Attaque.java
 
Sinon, pour plus de lisibilité et pour suivre les conventions, renomme ta classe rectangle en Rectangle (les classes commencent par une majuscule)

Reply

Marsh Posté le 04-04-2008 à 14:29:56    

Bidem a écrit :

C'est une erreur fréquente quand on débute : tu n'as pas mis le répertoire courant dans le classpath.
Essaye avec : javac -classpath .;jgraph.jar Attaque.java
 
Sinon, pour plus de lisibilité et pour suivre les conventions, renomme ta classe rectangle en Rectangle (les classes commencent par une majuscule)


 
bonjour,
 
merci bouceaup  

Reply

Marsh Posté le 04-04-2008 à 14:37:03    

Bidem a écrit :

C'est une erreur fréquente quand on débute : tu n'as pas mis le répertoire courant dans le classpath.
Essaye avec : javac -classpath .;jgraph.jar Attaque.java
 
Sinon, pour plus de lisibilité et pour suivre les conventions, renomme ta classe rectangle en Rectangle (les classes commencent par une majuscule)


 
 
bonjour, :jap:  
merci bidem vous m'avais vraiment régler un grand problème encore merci . :jap:  :jap:

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed