• Post Reply Bookmark Topic Watch Topic
  • New Topic

custom component design  RSS feed

 
Shyam Purkayastha
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to design a custom component of
LDC\LED digit display in the seven segment form.
Can anybody hel
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you designed so far?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shyam,
Are you using AWT or swing? Do you want the component to be event driven or method driven? You need to answer these and some other basic questions before you start coding. There are countless ways to do what you want to do, you just have to figure out which way you want to go.
Hope this helps,
Michael Morris
 
Shyam Purkayastha
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually i havent designed anything uptill now.I will use swing for it .As I am quite new to GUI programming I dont know how to approach it.
However I have thought of the following options for it
1) Images of the LCD digit states will be stored in image files in the disk.Thease image files will be loaded to the system at runtime as an image array any displayed according to the need
2) Each segment of the LCD digit will be painted using drawPoly()method during initialization.At runtime the segments constituing a digit will be repainted using fillPoly() method.
Please tell me which of the options is better in terms of performance.Do you have anyother approach in mind.
A few more questions regarding this are
1) where is the painting done .In the paint() or the paint Graphics() method.
2)How do I automatically scale the component?
Thanks in advance for your suggestions
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are going to be using Images anyway, and since you had planned on using SWING, I would suggest this.
Create Images of Digits 0 - 9. Then, create an ImageIcon using those images and place on a Jlabel, JButton, JPanel, whatever component you wish to use, and then just add those components to your Window, Dialog, JFrame, what have you. To change the numbers, just remove(Component) and add(Component) again. Simple.
 
Shyam Purkayastha
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Gregg
Thanks for the tip
Can you suggest some precautions for automatic resizing of the components in case the main wondow is resized.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That may be a little more difficult to implement. Even if you use a layout manager, that will not resize the images for you. So you are probably going to have to do some actual image scaling. I have scaled an image down before, but not back and forth according to the size of a component, so I am afraid I will not be much help with that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!