How to register created fonts in Java 5?

Java 6 provides the registerFont(Font) method in GraphicsEnvironment to register fonts created using Font's createFont(int, InputStream) method. However, I need my application to work using Java 5.
I looked in the Java 6 source code hoping to find the solution. In Java 6, GraphicsEnvironment's registerFont(Font) method calls a static method also entitled registerFont(Font) on the platform class sun.font.FontManager. Based on the code in sun.font.FontManager, I created a class for use in my application which only contains the variables and methods necessary for the registerFont(Font) method.
There is only one problem: the registerFont(Font) method in sun.font.FontManager relies on the use of a native+ method to derive a Font2D object from the created font. The method is: public static native Font2D getFont2D(Font). Although my program compiles, I get the following error message at runtime:
Exception in thread "Thread-3" java.lang.UnsatisfiedLinkError: getFont2D
     at MyFontManager.getFont2D(Native Method)
     at MyFontManager.registerFont(MyFontManager.java:105)
     at java.lang.Thread.run(Unknown Source)
How do I derive a Font2D object from a Font object?
OR
Using Java 5, how do I register a created font such that I can reference that font via its family name, as in the following lines of code (the Java 6 solution is crossed out)?
this.simpleAttributeSet = new SimpleAttributeSet();
try {
InputStream inputStream = getClass().getResource("fonts/FONT.TTF").openStream();
Font font = Font.createFont(Font.TRUETYPE_FONT, inputStream).deriveFont(Font.PLAIN, 25);
inputStream.close();
GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(font);
MyFontManager.registerFont(font);
StyleConstants.setFontFamily(this.simpleAttributeSet, font.getFamily());
} catch (Exception exception) {
System.err.println(exception);
}

Sure.
My strategy was to create a class for use in my application which would only contain all the variables and methods necessary to execute the registerFont(Font) method in the Java 6 version of sun.font.FontManager. The registerFont(Font) method calls two static, native methods: isCreatedFont and getFont2D. Originally, I made the mistake of including these methods in the class I created. The solution: call these methods on sun.font.FontManager.
The Java 5 version of sun.font.FontManager fortunately supports getFont2D, but does not support isCreatedFont. However, it is not necessary for my program to determine whether or not the font is a created font. Therefore, I replaced all instances of calls to isCreatedFont with the value true.
NOTE: The solution works, but my font ended up looking worse than it did using Java 6 and I'm interested in learning why.

Similar Messages

  • How can i create messenger with java tv API on STB

    deal all.
    how can i create messenger with java tv API on STB.
    how can Xlets communicate each other?
    how?
    i am interested in xlet communications with java tv.
    is it impossible or not?
    help all..

    You can create a messenger-style application using JavaTV fairly easily. JavaTV supports standard java.net, and so any IP-based connection is pretty easy to do. The hard part of the application will be text input, but people have been using cellphone keypads to send SMS messages for long enough that they're familiar with doing this. This doesn't work well for long messages, where you really need a decent keyboard, but for short SMS-type messages it's acceptable.
    The biggest problem that you need to work around is the return channel. Many receivers only have a dial-up connection, ties up the phone line and potentially costs people money if they don't get free local calls. Always-on return channels (e.g. ADSL or cable modem) are still pretty uncommon, so it's something that you nee to think about. Of course, if you do have an always-on connection then this problem just goes away.
    This is really one of those cases that's technically do-able, but the infrastructure may not be there to give users a good experience.
    Steve.

  • How to register remote client in java to a Corba server in C++

    Hi All,
    Although i know that it spossible for to have a Corba client in java and Corba server in C++.What am nto sure is whether i can have this client and server on 2 different machines.In a vwgue way i think it shoudl be possible but not sure.
    I have Server running in Corba in one machine, how to register java client on another machine to this server .??
    Thanks,
    Ranjitha

    Hi,
    You can do that by defining the DB link to use while you register the function.
    From the Administrator go to "Tools-> Register PL/SQL Functions..."
    Fill in the information of the function (name, display, owner ...)
    And in the "Database Link" choose your new DB link.
    Tamir

  • How to change the font of java application?

    Hie... I have created a simple java application. Now , i need to change the font to my native language (Nepali Unicode), ie, i want to change the font of the buttons and message box to Nepali? Can anyone help?

    Component.setFont(...)

  • How to register a created font in java 5?

    Java 6 provides the registerFont(Font) method in GraphicsEnvironment to register fonts created using Font's createFont(int, InputStream) method. However, I need my application to work using Java 5.
    I looked in the Java 6 source code hoping to find the solution. In Java 6, GraphicsEnvironment's registerFont(Font) method calls a static method also entitled registerFont(Font) on the platform class sun.font.FontManager. Based on the code in sun.font.FontManager, I created a class for use in my application which only contains the variables and methods necessary for the registerFont(Font) method.
    But It doesnt works.
    Hope someone suggests any solution..!!
    Thanks,
    shri

    Ujjal wrote:
    Hi All,
    Need your help...
    I have just started learning Java and JSP.
    I was trying to write a simple Shopping Cart program in JSP. I have created a directory under my root context directory. But while I am invoking the JSP, I am getting a error like this:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 18 in the jsp file: /JspSessionCart/build/carts.jspMaybe you should look at that JSP. It's incorrect, obviously.
    Look, here's a hint:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\mycontext\org\apache\jsp\JspSessionCart\build\carts_jsp.java:66: package sessions does not exist
    cart = (sessions.DummyCart) jspxpage_context.getAttribute("cart", PageContext.SESSION_SCOPE);Why isn't this a good enough guide?

  • How can I create a scheduled java application/task?

    Hi,
    Being a complete newbie to the Java language, I hope I am forgiven if the above is blindingly obvious.
    I have a java application which I have developed that when run from the command prompt (java xyz) selects a bunch of records from my database, then creates a text file with the results. Pretty simple stuff.
    My question is, how can I automate this process? I would like it to run every night at midnight. Will I have to create a batch file? If so, how? Help!!
    Any advice would be much appreciated :)
    Thanks, Chris

    Scheduling a task is a very Operating System dependent operation. It does not exist in some OS's without some kind of addin. Things of this sort are usually not done exclusively in Java, unless you want to have your application running all the time and simply perform some operation at a specific time (see Timer). Otherwise look on google.com for 'scheduler' and 'windows 98' for example.

  • How do I create a Dynamic java.sql.Date ArrayList or Collection?

    I Have a MySQL table with a Datetime field with many values inserted.
    I want to know which is the Best way to capture all the Inserted DB values inside a Dynamic Array.
    I get errors that state that I should use Matching data-types, and plus I don't know how to create or fill a Dynamic Date ArrayList/Collection.
    Please Help, I need this urgently...

    package pruebadedates;
    import java.sql.*;
    * @author J?s?
    public class ClaseDeDates {
        /** Creates a new instance of ClaseDeDates */
         * @param args the command line arguments
        public static void main(String[] args) {
            java.sql.Date aDate[] = null;       
            Connection con = null;
            Statement stmt = null;
            ResultSet rs = null;
            try{
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                con = DriverManager.getConnection("jdbc:mysql://localhost/pruebafechas", "root", "picardias");
                    if(!con.isClosed()){
                    stmt = con.createStatement();
                    stmt.executeQuery ("SELECT dates FROM datestable");
                    rs = stmt.getResultSet();
                        while (rs.next())
                        aDate[] = rs.getDate("dates");
            catch(Exception e)
               System.out.println(e);
            //System.out.println(aDate);     
    }Hi, There is my code and the errors that I get are:
    found : java.sql.Date
    required: java.sql.Date[]
    aDate = rs.getDate("dates");
    Actually I have No idea as How to get a Result set into an ArrayList or Collection. Please tell me how to do this Dynamically. I have like 25 records in that Database table, but they will grow, so I would really appreciate to know the code to do this. I suspect my problem is in the bolded part of my code.
    Thank you very much Sir.

  • How to register jdbc driver in java application

    Using Java Studio Enterprise:
    1. Add mssqlserver.jar to Libraries.
    2. jar contains package: com.microsoft.jdbc.sqlserver,
    package contains SQLServerDriver.class
    Trying to register this driver in program with:
    Class.forName("com.microsoft.jdbc.SQLServerDriver");
    raises exception ClassNotFoundException
    Maybe I should put mssqlserver.jar to specific folder?
    For web application using same driver works fine.

    hi,
    Class.forName("com.microsoft.jdbc.SQLServerDriver");
    raises exception ClassNotFoundExceptionFirst you check weather these jar files is in your lib <folder>
    msbase.jar,mssqlserver.jar,msutil.jar
    if no, copy that files and try it,

  • How to partially created files in java

    In my program i am monitering a folder to identify a particular file is created.
    this file created by another program. i don't have any control to that.
    i am using a while loop to moniter the file folder.
    i am using following codeing for that.
    while ((! found)&&(loopcount<99999)){
    files = file.listFiles(
    new FileFilter() {
    public boolean accept(File pathname) {
    if (pathname.isFile() &&
    pathname.getName().startsWith(awbNumber+"_") &&
    pathname.getName().endsWith(".pdf")) {
    return true;
    return false;
    problem is if the file is partially created also this code identifies the file is created.then the contents of the file are encoded. therefore sometimes the partially created file will be encoded. it doesnot prompt any exceptions.
    how can i idntify the file is fully created or partially created.is there a way to read file mode that is if the file is in read mode or not.
    i need to encode the fully created file.
    please help me
    thanks in advance

    have you tried re-nameing the file? if the file is still open by the other program renaming will fail and thus you know to wait.

  • How to use different fonts in java

    i want to use some other font,what should i do to use a different font??? thanks in advance

    Hi,
    Use the function below for the component you want to change the font.
    setFont
    public void setFont(Font f)
    Sets the Font of this object.
    Parameters:
    f - the new Font for the object
    Hope this helps
    Roopasri Vittal
    Developer Technical Support
    Sun Microsystems
    http://sun.com/developers/support

  • How to create reports in java or j2ee???

    I want to know how can we create reports in java or j2ee like we use crystal report in vb or .net.do we use jsp or servlet to generate the reports or is there any other tool to do the same?Members,please,do help me.

    Well, you can use JasperResports (http://www.jasperforge.org/) and Eclipse Birt (http://www.eclipse.org/birt/phoenix/)

  • How to create command line java client

    I have a java servlet FileClient.java and am invoking it thru POST method from the html file. How can I create command line java client so that I can execute this class file from windows command prompt.
    e.g. java FileClient <argument>
    TIA

    > .. there's also a "won't work".
    I could post a sample...I know that you can instantiate and call aservlet,
    or even write your own servlet container - butit's
    still a local instance. He can't invoke his remote
    servlet by calling its class on the client like he
    suggested.HttpURLConnection in main.Only if his Servlet has a main method. Which wouldn't really make it a servlet anymore.
    OP said he wants to invoke it from command-line using
    java -cp . TheServletClass
    He said he has a servlet called FileClient. And he can't invoke a servlet directly that way, without building a wrapper that starts it, making it more than a servlet, and it definitely won't execute on the server. That's my whole point. I never wanted to say you can't write a command-line program that invokes a servlet on a remote server. I do it myself after all.
    I guess I should have expressed myself more clearly.

  • How to install new fonts using code in java?

    Hi,
    How to install font in a system using java, provided i know the font file's address. Is there any specific class/method available for this purpose? Copying the file to windows/font directory will work for windows, but I think it wont be generic to all operating system. So is there anyway to install a font using code?
    I also want to know how to make the font available only until my application window is open, It must be available to all other external applications like photoshop, word etc., When I close my window it must un-install automatically or be made not available to other applications. Any suggestions? Please do help! Thanks in advance...

    I have already tried the above, But the font created using input stream is available only to my application* and is not viewable in photoshop.*. I realize this. Like I said, I know of no method that will register/deregister the font with the system. You'll have to create your own method that takes the operating system into account.
    String os = System.getPropery("os.name");
    if(os.equals("Windows Vista")) {
    }else if(os.equals("Windows XP")) {
    }else if(os.equals("Windows NT")) {
    }else if(os.equals("Solaris")) {
    AIX
    Digital Unix
    FreeBSD
    HP UX
    Irix
    Linux
    Mac OS
    Mac OS X
    MPE/iX
    Netware 4.11
    OS/2
    Solaris
    Windows 2000
    Windows 95
    Windows 98
    Windows NT
    Windows Vista
    Windows XPYou'll need the standard font directory for each system. I think all the window ones are C:\Windows\Font\ . Each OS probably has its own little quark (like having several font directories or throwing different security exceptions). Undoubtly it's going to require some research and a bit of trial and error. You can probably work some magic with Runtime.exec(...) as well.
    The alternative would be to google for some libraries that offer similar functionality, or promt the user for the system's font directory and save the location of the directory in a file somewhere for future use (so the user dosen't have to specify the font directory everytime he/she starts up the application).

  • How to register the recipient when create job by function

    I am now use JOB_OPEN , JOB_SUBMIT and JOB_CLOSE to create a job in the program. And need to post the result of the report to the person by email.
    Can you tell me how to register the recipient when create the job.
    ( in sm36, it is easily to do but how to do in coding? )
    regards,
    slam

    Hi
    I think in Back ground using the above fun modules you can't send a mail to the receipient.
    see the use of the above fun modules;
      IF p_bjob = 'X'.
        CONCATENATE sy-cprog sy-datum sy-uzeit
                    INTO jobname SEPARATED BY '_'.
        CALL FUNCTION 'JOB_OPEN'
          EXPORTING
            jobname          = jobname
          IMPORTING
            jobcount         = jobcount
          EXCEPTIONS
            cant_create_job  = 1
            invalid_job_data = 2
            jobname_missing  = 3
            OTHERS           = 4.
        CALL FUNCTION 'GET_PRINT_PARAMETERS'
          IMPORTING
            out_archive_parameters = arc_params
            out_parameters         = print_params
            valid                  = valid
          EXCEPTIONS
            archive_info_not_found = 1
            invalid_print_params   = 2
            invalid_archive_params = 3
            OTHERS                 = 4.
        IF valid = chk.
          SUBMIT ybrep
                          WITH < sel Screen>
                          AND RETURN
                          USER               sy-uname
                          VIA JOB            jobname
                          NUMBER             jobcount
                          TO SAP-SPOOL
                          SPOOL PARAMETERS   print_params
                          ARCHIVE PARAMETERS arc_params
                          WITHOUT SPOOL DYNPRO.
          CALL FUNCTION 'JOB_CLOSE'
            EXPORTING
              jobcount             = jobcount
              jobname              = jobname
              strtimmed            = 'X'
            EXCEPTIONS
              cant_start_immediate = 1
              invalid_startdate    = 2
              jobname_missing      = 3
              job_close_failed     = 4
              job_nosteps          = 5
              job_notex            = 6
              lock_failed          = 7
              invalid_target       = 8
              OTHERS               = 9.
          IF sy-subrc <> 0.
           MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ELSE.
            MESSAGE i029 WITH jobname.
          ENDIF.
        ELSE.
          MESSAGE s000 WITH text-003.
          STOP.
        ENDIF.
      ENDIF.
    Reward points if useful
    Regards
    Anji

  • How to save report in PersonalCategory  after creating it using java panel?

    Hi,
    Anybody knows How to save report in PersonalCategory  after creating it using java panel?
    I dont want to save it in public folder. I want to save report (webi) in user's personal category.
    can anybody send me source code?
    It will help me a lot.
    Thanks in advance
    Amol Mali

    Hi teda,
    i'm assuming that you have seen my post that i did successfuly save report in user's personal category.
    Actually the report is created in webi java panel using RE SDK and  is saved in Report Sample Folder then i'm saving it in user's personal category by following code
    string query = "Select SI_PERSONAL_CATEGORIES From CI_INFOOBJECTS Where "
                         + "SI_INSTANCE=0 And SI_ID=" + reportID;
                    InfoObjects infoObjects = infoStore.Query(query);
                    InfoObject infoObject = infoObjects[1];
                    Webi wreport = (Webi)infoObject;
                    ObjectRelativeIDs personalIDs = wreport.PersonalCategories;
                /personalIDs.Add(Convert.ToInt32(categoryID));
                   infoStore.Commit(infoObjects);
    But the report is presents in the Folder also and in user's personal category also.
    I dont want the report to be in the folder (Report Sample) if i saved it in user's personal category.
    How can i do that?
    any idea.
    Please help me.
    Thanks in advance
    Amol Mali
    Edited by: amol mali on Jan 9, 2009 7:55 PM

Maybe you are looking for

  • SALE ORDER COMPLETION DATE

    Hi all,            We are create one sale order in va01N after completion of all process we make a delivery entry in VL01N.We are creat morethan five deliveries.       Any standard report to see the sale orders completed date ie order closed date wis

  • Unable to see markups in Outlook 2010 attachment preview

    Hi, I am unable to see markup tags which were done in Word 2010 in the Outlook 2010 attachment preview window. The word file normally gets marked up and sent as an attachment. Most of the time the attachment preview will highlight the markup over the

  • Work Completion in the cProjects Dashboard is not working

    Hi All In my cProjects dashboard Work Completion is not reflecting the actial figures. It is always displaying as '000'. I have run the evaluation report for dashboard and all other fields are reflecting except this field. Can you guys let me know wh

  • Statspack with explain plan.

    The goal is to obtain the overall system statistics and explain plans for the entire system. 1. The only tool that I can think of is "StatsPack". 2. With AWR there are 2 issues:- a. It is not free b. It does not give Explain plan output. 3. We can us

  • Partial conversion of planned order for AFS material

    Hi, I cant able to convert partially the planned order in to production order for the AFS material. Has any one has faced this problem? Is there is anything i need to do in IMG? Regards / US