java - I want to make a dropdown menu -
help me void paint have imported , have imported graphics.
public class texttographicconverter { public static void main(string[] args) throws exception { bufferedimage image = new texttographicconverter().converttexttographic("my text", new font("arial", font.plain, 18)); //then want image } public bufferedimage converttexttographic(string text, font font) { bufferedimage img = new bufferedimage(1, 1, bufferedimage.type_int_argb); graphics2d g2d = img.creategraphics(); g2d.setfont(font); fontmetrics fm = g2d.getfontmetrics(); int width = fm.stringwidth(text); int height = fm.getheight(); g2d.dispose(); img = new bufferedimage(width, height, bufferedimage.type_int_argb); g2d = img.creategraphics(); g2d.setrenderinghint(renderinghints.key_alpha_interpolation, renderinghints.value_alpha_interpolation_quality); g2d.setrenderinghint(renderinghints.key_antialiasing, renderinghints.value_antialias_on); g2d.setrenderinghint(renderinghints.key_color_rendering, renderinghints.value_color_render_quality); g2d.setrenderinghint(renderinghints.key_dithering, renderinghints.value_dither_enable); g2d.setrenderinghint(renderinghints.key_fractionalmetrics, renderinghints.value_fractionalmetrics_on); g2d.setrenderinghint(renderinghints.key_interpolation, renderinghints.value_interpolation_bilinear); g2d.setrenderinghint(renderinghints.key_rendering, renderinghints.value_render_quality); g2d.setrenderinghint(renderinghints.key_stroke_control, renderinghints.value_stroke_pure); g2d.setfont(font); fm = g2d.getfontmetrics(); g2d.setcolor(color.black); g2d.drawstring(text, 0, fm.getascent()); g2d.dispose(); return img; } }
Comments
Post a Comment