• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

text alignment for Jtextfield

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,

How to align text in jtextfield to top.

My problem is here I am taking rgb values from jtextfield but because of text alignment in middle there is lot of white spaces in my rgba array in top and bottom .
can You please suggest how to get text exactly without getting white space top and bottom,

i need where i need to start in order to get correct text.

code:

Insets in=new Insets(0,0,0,0);
jTextField1.setMargin(in);
Dimension bounds = jTextField1.getPreferredSize();
final BufferedImage image = new BufferedImage(bounds.width, bounds.height,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = image.createGraphics();
SwingUtilities.paintComponent(g2d, jTextField1, new Container(),
0, 0, bounds.width, bounds.height);
jTextField1.paint(g2d);
g2d.dispose();
image.getRgb(0,0,bounds.width,bounds.height,null,bounds.width);

also i tried with this code

image.getRgb(0,40,bounds.width,bounds.height,null,bounds.width); it is giving me error

please help me

Thanks in Advance
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
'quest for knowledge' as a nic would indicate your willingness to comply with rules and requests.

the simple solution may be supplied when you comply.
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michael Dunn wrote:'quest for knowledge' as a nic would indicate your willingness to comply with rules and requests.

the simple solution may be supplied when you comply.

Thank you for noticing, Michael.

Member 178781, back to your private messages please.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic