posted 14 years ago
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