wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes text alignment for Jtextfield Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "text alignment for Jtextfield" Watch "text alignment for Jtextfield" New topic
Author

text alignment for Jtextfield

satya saha
Greenhorn

Joined: Aug 08, 2008
Posts: 13
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
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
'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.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38045
    
  22
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: text alignment for Jtextfield
 
Similar Threads
GUI help
GUI help
GUI help
deal with text on window closing
my brand spanking new layout manager