• Post Reply Bookmark Topic Watch Topic
  • New Topic

Updating jfree BarChart using click event  RSS feed

 
Nirmit Dalal
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a bar chart which i want to update it ....i tried the revalidate and repaint method but with no success ....HELP !!


 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're attaching the MouseListener only to the JButton - is that intentional?
 
Nirmit Dalal
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i didnt get what you meant ....


i attached mouselistener to only Jbutton so that it will trigger the event of popping JOptionpanes so that i can take values from the user to update the graph ..
do i even have to add
chartPanel.addMouseListener(this);
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should add a MouseListener to whatever component you want to listen to mouse events. It's very unusual to add one to a button, though, since buttons are normally handled by ActionListeners. It seems that that's what you want to do, since you're handling only the MouseClicked event.
 
Nirmit Dalal
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in my original program i am trying to do the same thing but instead of JButton i am using JLabel so thats why MOuseListener
i even tried chartPanel.addMouseListener(this) ...but still no change ...
 
Nirmit Dalal
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
op3.g.gData.clear();
op3.g.gData.setValue(v1,"What you saved","");
op3.g.gData.setValue(v1,"What you paid","");
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You do not need to revalidate() or repaint() . Presumably behind the scenes you use a CatagoryDataset (I can't tell since you don't provide the code). You just need to ensure that the CatagoryDataset fires a DatasetChangeEvent when you update it. If you use a DefaultCatagoryDataset then by using one of the setValue() methods this event will be fired automatically.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!