Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-18-2007, 05:09 PM
Member
 
Join Date: Nov 2007
Posts: 2
Dreen is on a distinguished road
Dialog typeface outside Java
Hello Java Community,

I am quite new to the Java language, however Im familiar with programming overall. I am in need to write an application that would use Java's Dialog typeface in image creation, but I do not know Java well enough to write it in this language.
I am looking for the Dialog typeface in TrueType, FreeType or some other format that I would be able to use outside the Java language. I have searched for this a lot but with no results.
I would greatly appreciate any help in finding this typeface.

~Dreen
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-19-2007, 08:35 AM
Member
 
Join Date: Nov 2007
Posts: 2
Dreen is on a distinguished road
I have decided searching is pointless, there is no Dialog outside Java.
Being however in need as I am, I have decided to try and write a Java program, which would do what I want which is:
* take 2 arguments in cmd line - label text and label name (label, labelName)
* create an image with black background and white text in Dialog size 11 saying exactly what was given in label text parameter
* save an image as labelName.png

So far this is what I was able to produce:
Code:
public class Main { /** * Installation folder */ static String pmDir = "/home/dreen/Makra/patmaker/"; /** * PATs folder */ static String patDir = "/home/dreen/Makra/";//matchItems/"; /** * Font size */ static int fSize = 11; /** * @param args the command line arguments */ public static void main(String[] args) { // there have to be 2 arguments: label text, label name. if (args.length < 2) { System.out.println("Too few arguments (2 required)."); System.exit(-1); } String label = args[0]; String labelName = args[1]; int imgH = fSize; int imgW = label.length() * 10; // how to get text size before initializing the image btw? // setup the image BufferedImage image = new BufferedImage(imgW, imgH, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = image.createGraphics(); g2d.setColor(Color.BLACK); g2d.drawRect(0,0,imgH,imgW); g2d.setColor(Color.WHITE); Font f = new Font("Dialog", Font.PLAIN, fSize); g2d.setFont(f); g2d.drawString(label, 0, 0); g2d.dispose(); // save the image File file = new File(patDir + labelName + ".png"); try { ImageIO.write(image,"png",file); } catch(IOException e) { handleException(e); } } /** * Handle errors */ public static void handleException (Exception e) { try { BufferedWriter errorLog = new BufferedWriter(new FileWriter(pmDir + "error.log")); errorLog.write("Afollowing error occured:\n\n"); errorLog.write ("====== Exception " + e.getMessage() + " ======"); errorLog.write(e.getStackTrace().toString()); System.err.println("An error occured, log file saved."); System.exit(-1); } catch(IOException ioe) { System.err.println("IOException"); System.exit(-1); } } }
This is a complete program for that purpose, which should work, but it doesn't. Can you please help me and tell me why?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Example of SWT Dialog Java Tip Java Tips 0 01-09-2008 01:01 PM
SWT Dialog JavaForums Java Blogs 0 12-31-2007 05:53 PM
I'm trying to add a separate dialog to a Java program... romina AWT / Swing 1 08-07-2007 06:26 AM
Dialog Box uncopywritable New To Java 2 07-30-2007 01:42 PM
Java Print Dialog Framework 1.7 levent Java Announcements 0 06-19-2007 06:07 PM


All times are GMT +3. The time now is 05:53 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org