• Post Reply Bookmark Topic Watch Topic
  • New Topic

Images in Swing

 
Muralidhar Krishnamoorthy
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Im workin on a project that involves the coding of a calculator like object. I would like to use LED like display panels for the display of the results..But how would one do that ??
Please tell me asap
Reg
Muralidhar
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the easiest thing to do would be to make images of the numerals 0 - 9 that look like what you want. Then just do some parsing of the number that you want to display to display the appropriate graphics. Make sure that all the numeral graphics are the same size. Then, load them up as ImageIcons in your program... Have a series of JPanels or something in your program to display each numeral.

HTH,
-Nate
 
Muralidhar Krishnamoorthy
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Thanx for replyin...This is the very same idea ive thought of but the trouble is there is some gap between two image icons whenever i tried to display the numbers...Is there any method to make them look as a single panel?
Reg
Muralidhar
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using GridLayout to display them? The default hGap and vGap spacing give a few pixels of space between components... and even if you set hGap and vGap to 0, there is still a little space between components. So set hGap and vGap to negative values! I was suprised... but it works! Try a value around -2 and your components will have no space between them...

-Nate
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!