Hello guys! I'm learning about the library, actually I'm working with a swing example. I need that some button refresh my graph.. I try with:

\n

graphComponent.refresh();

\n

But it seems doesn't work.

\n

Sorry for my english :)

\n

Regards!

asked 21 Nov '11, 03:39

betens85's gravatar image

betens85
123
accept rate: 0%


What is your intention to do? If you want to draw some shapes like vertex or edges you have to surround this code with beginUpdate and endUpdate of the model class. It's like a database transaction: \n

graphComponent.getGraph().getModel().beginUpdate();\n...\n// insert or modify some shape\n...\ngraphComponent.getGraph().getModel().endUpdate();\ngraphComponent.refresh();\n
\nThat works fine for me. Maybe you can post some more code snippet?

link

answered 21 Nov '11, 22:21

Hardie82's gravatar image

Hardie82
76318
accept rate: 7%

Hi Hardie82, thanks for your answer. I'm trying to refresh a graph when I pressed some button. I have got:

\n

//method that build graph called buildGraph()\ngraphComponent.getGraph().getModel().beginUpdate();\n...\n// create nodes with their childs\n...\ngraphComponent.getGraph().getModel().endUpdate();

\n

//method binded with a button\nprivate void btnTestActionPerformed(ActionEvent e) {\n buildGraph("TEST", 2);\n}

\n

I need that method invoked from btnTestActionPerformed refresh a graph

\n

Thanks a lot! :)

link

answered 22 Nov '11, 03:29

betens85's gravatar image

betens85
123
accept rate: 0%

I've just done! It works... I add mxGraphComponent into a JPanel, then I invoke that method revalidate from instance to JPanel..\n ......\n graph.getModel().endUpdate();\n try{\n //build graph\n }\n finally {\n graph.getModel().endUpdate();\n }\nmxGraphComponent = new mxGraphComponent(graph);\nmiddlePanel.removeAll();\nmiddlePanel.add(mxGraphComponent);\nmiddlePanel.revalidate();\ngetContentPane().add(jPanelCentral, BorderLayout.CENTER);\n.....

\n

Regards

(22 Nov '11, 07:51) betens85
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×8
×6

Asked: 21 Nov '11, 03:39

Seen: 2,833 times

Last updated: 22 Nov '11, 07:51