选取框选择不适用于 Jgraphx
Marquee selection does not works on Jgraphx
我正在使用 Jgraphx 编写一个程序,并且多个 selection 运行良好(我可以 select 一个节点,按 ctrl 并单击另一个节点并 selected然后),但我无法使选取框 selection 起作用(我单击并拖动鼠标但没有矩形出现在 select 节点上)。我做错了什么?
要添加此功能,请创建一个新的 mxRubberband。这将为您完成所有工作。
示例:
public class HelloWorld extends JFrame
{
private static final long serialVersionUID = -2707712944901661771L;
public HelloWorld()
{
super("Hello, World!");
mxGraph graph = new mxGraph();
Object parent = graph.getDefaultParent();
graph.getModel().beginUpdate();
try
{
String s1 = "Hello";
String s2 = "World!";
Object v1 = graph.insertVertex(parent, "ID1", s1, 20, 20, 80,
30);
//graph.insertVertex(parent, null, v1, 20, 280, 80, 30);
Object v2 = graph.insertVertex(parent, "ID2", s2, 240, 150,
80, 30);
mxCell edge = (mxCell) graph.insertEdge(parent, "ID3", "TEST", v1, v2);
}
finally
{
graph.getModel().endUpdate();
}
Object o = graph.getDefaultParent();
mxGraphComponent graphComponent = new mxGraphComponent(graph);
new mxRubberband(graphComponent); // Adds support for marquee selection
getContentPane().add(graphComponent);
}
public static void main(String[] args)
{
HelloWorld frame = new HelloWorld();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 320);
frame.setVisible(true);
}
}
我正在使用 Jgraphx 编写一个程序,并且多个 selection 运行良好(我可以 select 一个节点,按 ctrl 并单击另一个节点并 selected然后),但我无法使选取框 selection 起作用(我单击并拖动鼠标但没有矩形出现在 select 节点上)。我做错了什么?
要添加此功能,请创建一个新的 mxRubberband。这将为您完成所有工作。 示例:
public class HelloWorld extends JFrame
{
private static final long serialVersionUID = -2707712944901661771L;
public HelloWorld()
{
super("Hello, World!");
mxGraph graph = new mxGraph();
Object parent = graph.getDefaultParent();
graph.getModel().beginUpdate();
try
{
String s1 = "Hello";
String s2 = "World!";
Object v1 = graph.insertVertex(parent, "ID1", s1, 20, 20, 80,
30);
//graph.insertVertex(parent, null, v1, 20, 280, 80, 30);
Object v2 = graph.insertVertex(parent, "ID2", s2, 240, 150,
80, 30);
mxCell edge = (mxCell) graph.insertEdge(parent, "ID3", "TEST", v1, v2);
}
finally
{
graph.getModel().endUpdate();
}
Object o = graph.getDefaultParent();
mxGraphComponent graphComponent = new mxGraphComponent(graph);
new mxRubberband(graphComponent); // Adds support for marquee selection
getContentPane().add(graphComponent);
}
public static void main(String[] args)
{
HelloWorld frame = new HelloWorld();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 320);
frame.setVisible(true);
}
}