• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Bar Chart

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm looking to create a Bar Chart applet,I did that by drawing
rectangles,but the problem is I need to create an event when I click on each bar,but the bars are not objects ,they are just shapes.
Any one please can help and tell me how to create a Bar Chart applet and when you click on each bar we popup a menu.
Thanks alot.
 
Trailboss
Posts: 23192
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest that you make lightweight components. Each component can inherit Canvas or Component. Set their size to be the size of the rectangle you want. Set their background color to the color you want. Then place them on a panel using the null layout manager (so you can get exact positioning). Now, each bar has it's own collection of events that it will generate!
 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not quite sure creating each comp. for every chart is that great idea, since it can slow the whole down a lot (depends on how many charts are there). Why just not check coordinates from the mouse clicks that are going to root component ?
From the other side, for the popup menu it can be more complicated, since if popup menu differes for every chart, then you'll need to remove/add items each time you click the popupTrigger button.

------------------
With best of best regards, Pawel S. Veselov ( aka Black Angel )
 
I carry this gun in case a vending machine doesn't give me my fritos. This gun and this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic