Deprecation warning for getFontMetrics(java.awt.Font) in java.awt.Toolkit

Hi all,
When I use the following code
JComponent c;
FontMetrics metrics = getToolkit().getFontMetrics(c.getFont());
I get this following warning during compilation:-
warning: getFontMetrics(java.awt.Font) in java.awt.Toolkit has been deprecated
JDK suggests to use getLineMetrics() of the Font class.
But there's an issue with that: if I use getLineMetrics(), there is no API method that I can use to get the width of a string as opposed to FontMetrics which provides stringWidth(String str) method for that purpose. In fact all the methods in FontMetrics are not mapped into LineMetrics.
Could anyone please help or provide me at least some pointers on how to tackle this issue so that I can get rid of the deprecated method along with the existing methods mapped to equivalent APIs? The bottomline is that I should be able to maintain the existing functinality of my application for those part of code that uses getToolkit().getFontMetrics().
Thank you for your help in advance.
-Sanjoy Das

Use Graphics.getFontMetrics(font) instead.
After creation your frame and calling frame.show();
You can access it like that
frame.show();
frame.getGraphics().getFontMetrics(new Font("Arial",0,10));
before showing graphics is null.
Or just create a BufferedImage and ask it for graphics.
BufferedImage img=new BufferedImage(...);
img.getGraphics().getFontMetrics(font);
regards
Stas

Similar Messages

  • [svn:fx-trunk] 12367: Added deprecation warning for the use of SVG.

    Revision: 12367
    Revision: 12367
    Author:   [email protected]
    Date:     2009-12-02 08:30:21 -0800 (Wed, 02 Dec 2009)
    Log Message:
    Added deprecation warning for the use of SVG.
    QE notes: None
    Doc notes: None
    Bugs: SDK-24392
    Reviewer: Paul
    Tests run: SVG test cases.
    Is noteworthy for integration: No
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-24392
    Modified Paths:
        flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/media/SVGTranscoder.java
        flex/sdk/trunk/modules/compiler/src/java/flex2/compiler_en.properties

  • Warning for users of older versions of Java thinking of upgrading to 10.6

    I'm a pediatric oncologist and I use a MacBook Pro at work for many aspects of patient care. We have web based system that allows us to look at radiology scans from any computer via a browser. This system requires Java 1.4.2 to work -- it will not work with newer versions of Java.
    In OS X 10.5, I would simply switch to Java 1.4.2 when needed and back when I was done. Unfortunately, Snow Leopard only installs Java 1.6. This leaves me completely unable to look at scans from my MacBook Pro.
    Off the top of my head, if there was a way to take the Java 1.4.2 package from OS X 10.5 and install it on OS X 10.6, and to use Java Preferences to switch between Java versions, that would be a great solution for me, even with the understanding that Java 1.4.2 is EOL'ed and that no updates would be expected.
    Today I contacted Apple Support, and the official word is that there is no way to install Java 1.4.2 under Snow Leopard, and that my only option at this point in time is to go back to OS X 10.5.
    Unless someone can figure out a way to hack Java 1.4.2 from OS X 10.5 into Snow Leopard, that is.

    I was able to get Java 1.4.2 working with Safari in Snow Leopard tonight. Here's how to do it.
    1. Install Java 1.4.2 as outlined in this link:
    http://wiki.oneswarm.org/index.php/OSX_10.6_SnowLeopard
    Alternatively, extract Java 1.4.2 from the Java For Mac OS X 10.5 Update 4 installation package, and install it in a similar manner:
    http://support.apple.com/downloads/Javafor_Mac_OS_X_10_5_Update4
    2. Make sure that Java 1.4.2 is the first 32-bit application in the list. Under Java Preferences, my list reads:
    Java SE 6 64-bit
    J2SE 1.4.2 32-bit
    Java SE 6 32-bit
    3. Open Safari in 32-bit mode via the Get Info window for Safari. This is where I was getting screwed up. It finally occurred to me that Java 1.4.2 is a 32-bit application, but if Safari was opening in 64-bit mode, it wouldn't use the 32-bit Java apps.
    Once I opened Safari in 32-bit mode, Safari was able to use Java 1.4.2.

  • Fonts in java apps for win and linux

    Hi everyone.
    i need to build an application mult-plataform, to run in windows and linux...
    but i don�t know waht font i must use...the default font that java takes doesn�t exist in linux (dialog)...
    waht font should i use in my app??
    thanx

    For going multi-platform it is easiest to stick to the logical fonts: Fonts named "Serif", "SansSerif", "Monospaced", "Dialog", and "DialogInput".
    These fonts are guaranteed to exist on any platform, although their implementations may be different. If you use others then you'll have to figure out how to deal with cross platform issues.
    Jeff

  • Using Type 1 fonts in Java 1.5

    I'm trying to use the Font.createFont() method to instantiate a Type 1 font. The second parameter to the createFont() method asks for a filename...but what kind of Type 1 file is needed? I've tried .pfa, .pfb, and .pfm files, and Java doesn't recognize any of them as proper Type 1 files.
    Can anyone who knows something about Type 1 fonts help? (I only know just enough to be completely confused about the different Type 1 filetypes.)
    Thanks.

    The exception I'm getting looks like this:
    java.awt.FontFormatException: Unrecognised Font Format
         at sun.font.FontManager.createFont2D(FontManager.java:1520)
         at java.awt.Font.<init>(Font.java:438)
         at java.awt.Font.createFont(Font.java:745)

  • Displaying Windows True Type fonts using Java 1.1.x

    Can anyone shed some light on why I cant just use the name of the fon't I want to display? Here is the code I'm using:
    Font font1 = new Font(sFontName, iStyle, iSize);
    this.setFont(font1);
    sFontName is the name of the font, and it works with the font names that are garaunteed by Java (i.e. Dialog, DialogInput, Monospaced, Serif, SansSerif, or Symbol), but if I try to use a true type font name such as "Tahoma" it just loads the default font instead. Is there a different method required to load system dependant fonts?
    Any ideas would be greatly appreciated. Thanks.

    If your font is properly installed (i.e. in the fonts folder and you've performed a restart) then it should work. I have code in the splash screen for an open source project like this:
    subTitleLbl.setFont (new java.awt.Font ("Lucida Blackletter", 0, 18));Which works if the font is properly installed. Otherwise, it simply grabs the system font, as you indicated.
    I've done some searching, and haven't found a way to load a font into java. Java won't do it because it's not platform independent.
    Fortunately, this code works even if the font is not present--it just won't have the font you want.

  • "RDLParser.java": java.io.StringBufferInputStream in java.io deprecated

    Hi I tried to compile a piece of Java code and received the below warning :
    "RDLParser.java": java.io.StringBufferInputStream in java.io has been deprecated at line 48, column 23
    The piece of code until the point of the warning is:
    package Parser;
    import java.io.*;
    public class RDLParser implements RDLParserConstants {
    static java.util.Stack paramStack = new java.util.Stack();
    static java.util.Stack opStack = new java.util.Stack();
    public static void main(String args[]) {
    RDLParser parser;
    ParseNode result;
    if (args.length == 1) {
    try {
    parser = new RDLParser(new java.io.FileInputStream(args[0]));
    } catch (java.io.FileNotFoundException e) {
    System.out.println("RDL Parser Version 0.1: File " + args[0] + " not found.");
    return;
    } else {
    System.out.println("RDL Parser Version 0.1: Usage is :");
    System.out.println(" java RDLParser inputfile");
    return;
    try {
    result = parser.tree_exp();
    System.out.println(result.toString());
    System.out.println("RDL Parser Version 0.1: parsed successfully.");
    } catch (ParseException e) {
    System.out.println("RDL Parser Version 0.1: Encountered errors during parse: " + e.toString());
    public static ParseNode parse (InputStream inStream)
    ParseNode result = null;
    RDLParser parser = new RDLParser( inStream );
    try {
    result = parser.tree_exp();
    //System.out.println("RDL Parser Version 0.1: parsed successfully.");
    } catch (ParseException e) {
    System.out.println("RDL Parser Version 0.1: Encountered errors during parse: " + e.toString());
    return result;
    public static ParseNode parse (String inString)
    return parse (new StringBufferInputStream(inString)); //WARNING
    Any ideas?

    Whenever I get a deprecation message, the first thing I do is look in the API docs for the class and method that is deprecated. If you look at the API docs, it will tell you why the class or method is deprecated and suggest other ways to accompish the same.

  • Useless code in java.awt.image.SampleModel.java?

    Hey there,
    i just looked up the sourcecode of java.awt.image.SampleModel.java in JDK 6
    I discovered two issues i'd like to discuss.
    1) on lines 736 to 739 this code is stated:
    if (iArray != null)
    pixels = iArray;
    else
    pixels = new int[numBands * w * h];
    I asked myself, why does this code exist? while the getPixels() method is overwritten twice by double[] getPixels() and float[] getPixels, it is impossible to reach the part of the java code that initializes the pixels-array. One could only step into that line if "null" is given for the i/d/fArray-parameter. but if one would do so, the Java parser couldn't determine, which method is to use. so this part of code is just useless IMHO.
    the java developers could get a little more performance out of this method if the if statement would be cut out - especially when reading a lot of very small rasters
    or, on the other hand, they could replace this piece of code by an explicit bounds check.
    When somebody touches this code, i would appreciate it if the errormessage "index out of bounds!" could be rewritten to be a little more verbose, like: Index out of bounds(x=123; y=456, maxX=100, maxY=400)!(numbers are just examples)
    I hope i didn't miss something very basic and could help improving this class a little bit.
    2) the local variable Offset(line 734) is coded against code conventions which say, variables shall start with a lowercase letter. Offset obviously doesn't fit that convention.
    best regards
    kdot

    One could only step into that line if "null" is given for the i/d/fArray-parameter. but if one would do so, the Java parser couldn't determine, which method is to use. so this part of code is just useless IMHO. You can have
    sampleModel.getPixels(x,y,w,h,(int[]) null, dataBuffer);No ambiguity on which method to use.
    the local variable Offset(line 734) is coded against code conventions which say, variables shall start with a lowercase letter. Offset obviously doesn't fit that convention. You're correct, offset is against coding conventions. So are many other examples scattered throughout the jdk source code. For example, Hashtable should be called HashTable. In some cases the coding conventions might not have been established when the original code was written. In other cases it might have been human error. In yet other cases the conventions were probably ignored. The person who wrote the SampleModel class did so some 10+ years ago (Java 1.2). Who knows what he/she was thinking at the time, and in all honesty - does it really matter in this case?
    Did you know there are some classes that declare unused local variables (ahem ColorConvertOp)? Some also have unused imports ( *** cough *** BufferedImage *** cough *** ). In essence, the jdk source code is not the epidemy of code correctness. But it's still pretty good.

  • Java.awt.Dialog in Java 1.6 has a memory leak

    When a modal Dialog opens a modal sub-dialog, the Dialog stays in memory after both the sub-dialog and the Dialog itself is disposed.
    The field that contains the leaked object is Dialog.modalDialogs (static). The methods which causes the leak are Dialog.modalHide and Dialog.modalShow.
    Whenever a modal Dialog is opened, Dialog.modalShow is called, and adds itself to Dialog.modalDialogs.
    When it closes, Dialog.modalHide is called and removes one copy of itself from Dialog.modalDialogs. Then Dialog.modalShow is called on all previously blocked modal dialogs. When the sub-dialog is opened and closed, Dialog.modalDialogs contains two references to the main Dialog, and only one of them is removed when Dialog.modalHide for that Dialog is called.
    To detect the leak, just put a break point in Dialog.modalHide, after modalDialogs.remove(this);. When opening a Dialog and closing it without opening a sub-dialog, the Dialog.modalDialogs field should be empty. When a sub-dialog was opened and closed before the main Dialog is closed, the Dialog.modalDialogs field contains a reference to the disposed main Dialog.
    This leak does not exist in 1.5.0_10 (no Dialog.modalDialogs field). I have searched the bug database, but I have not found this bug there. Could anyone confirm this?
    A simple code to reproduce the leak:
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowEvent;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    public class Test {
       public static void main(String[] args) {
          final JFrame frame = new JFrame() {
             protected void processWindowEvent(WindowEvent e) {
                super.processWindowEvent(e);
                if (e.getID() == WindowEvent.WINDOW_CLOSING) {
                   System.exit(0);
          JButton button = new JButton("Dialog");
          button.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent aE) {
                JButton subButton = new JButton("SubDialog");
                subButton.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent aE) {
                      JOptionPane.showMessageDialog(frame, "SubDialog");
                JOptionPane.showMessageDialog(frame, subButton);
          frame.getContentPane().add(button);
          frame.pack();
          // Center the window
          Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
          Dimension frameSize = frame.getSize();
          if (frameSize.height > screenSize.height) {
             frameSize.height = screenSize.height;
          if (frameSize.width > screenSize.width) {
             frameSize.width = screenSize.width;
          frame.setLocation((screenSize.width - frameSize.width) / 2,
                (screenSize.height - frameSize.height) / 2);
          frame.setVisible(true);
    }

    Sorry, I just found the bug in the bugdatabase (with google of course,):
    [http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6497929]

  • True Type Fonts in Java

    Hi all
    I searched through the forum and found some threads with the same problem but never a solution attached so here is my question:
    I'm currently trying to use a True Type Font in Java. I installed the font under windows and it works fine in e.g. Word, but when I try to use it in Java all I can see are "rectangles". I'm not sure if the problem lies in the font itself or if it is a problem of Java. The fonts are named "Fughetta" and "Toccata" and can be found here: http://www.efn.org/~bch/aboutfonts.html. He is a code snippet I'm using to test the font:
    public void setFonts(Graphics g)
            if (f != null) {
                return;
            f = new Font("Fughetta", Font.TRUETYPE_FONT, 26);
            System.out.println(f);
        public void paintComponent(Graphics g)
            super.paintComponent(g);
            setFonts(g);
            String s1 = "1234567890��!\"�$%&/(()=?`";
            String s2 = "qwertzuiop�+asdfghjkl��#yxcvbnm,.-<";
            String s3 = "QWERTZUIOP�*ASDFGHJKL��'YXCVBNM;:_>";
            String s4 = "1��{[]\\}@�~�|";
            g.setFont(f);
            g.drawString(s1, 10, 30);
            g.drawString(s2, 10, 70);
            g.drawString(s3, 10, 110);
            g.drawString(s4, 10, 150);
        }All help is appreciated ;)
    - marc

    Hy, Thanks for your sollution, but now I can't use this kind of approach.
    I need to show a Bar Code Font inside a JTable cell, so I created my CellRenderer, in which I tried to change the font to my "Code EAN13" True Type font.
    public Component getTableCellRendererComponent(JTable table,
                Object value, boolean isSelected, boolean hasFocus, int row, int column)  {
                 Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                 if (column == CollectInfoTableModel.CODBAREPRODUS_INDEX ) {
                         Font barCodeFont = new Font("Arial", Font.BOLD, 36);
                         c.setFont(barCodeFont);                 
    }This doesn't work, it just prints some strange characters.
    I tried your sollution, but when I make :
    Graphics2D g2D= (Graphics)c.getGraphics();i keep getting g2D = null.
    What can I do ?
    Is there a way to obtai a valid Grapics object on which to draw the glyphVector on ?

  • Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

    Hello everyone ... sorry for my English but I am an Italian boy with a problem that is not answered.
    I had to create a web application-service (created in Java with NetBeans 6.7) which is connected to a database postgresql (8.3.5) and for connection to the server using tomcat (3.2.4) through SOAP messages (2_2).
    OPERATING SYSTEM: WINXP
    I have created classes ... I created the database ... completed the project in NetBeans without any errors ... implemented the necessary libraries in the project (also ).... 8.3.604.jar jdbc tomcat configured and soap ... .. and set the environment variables (soap, mail, send in xerces )...... run the application on the NetBeans appears the login screen of my web service .....
    enter username and password (exactly!) and the NetBeans gives me an Exception:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at Intro.loginActionPerformed(Intro.java:522)
            at Intro.access$100(Intro.java:21)
            at Intro$2.actionPerformed(Intro.java:111)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
            at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
            at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
            at java.awt.Component.processMouseEvent(Component.java:6263)
            at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
            at java.awt.Component.processEvent(Component.java:6028)
            at java.awt.Container.processEvent(Container.java:2041)
            at java.awt.Component.dispatchEventImpl(Component.java:4630)
            at java.awt.Container.dispatchEventImpl(Container.java:2099)
            at java.awt.Component.dispatchEvent(Component.java:4460)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
            at java.awt.Container.dispatchEventImpl(Container.java:2085)
            at java.awt.Window.dispatchEventImpl(Window.java:2475)
            at java.awt.Component.dispatchEvent(Component.java:4460)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 31 seconds)  The line 522 Intro class is as follows:
    private void loginActionPerformed(java.awt.event.ActionEvent evt) {                                     
            try {
                URL address= new URL("http://"+ip+":8080/soap/servlet/rpcrouter");
                //Costruzione della chiamata
                Call chiamata = new Call();
                chiamata.setTargetObjectURI("urn:server");
                chiamata.setMethodName("controllaAgenzia");
                chiamata.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
                //creazione parametri che dovro' passare al soap
                Vector<Parameter> params = new Vector<Parameter>();
                String u = user.getText();
                String p = String.valueOf(password.getPassword());
                params.addElement(new Parameter("user", String.class, u, null));
                params.addElement(new Parameter("password", String.class, p, null));
                chiamata.setParams(params);//parametri passati al soap
                try {
                    //Invocazione RPC
                    Response respons = chiamata.invoke(address, "");
                    //qui ho la risposta inviata dal server
                    *Parameter par = respons.getReturnValue();*
                    Object value = par.getValue();
                    String REP = String.valueOf(value);
                    System.out.println(REP);
                    if (REP.equals("ACK_agenzia")) {
                        new MainAgenzia(ip);
                        this.dispose();
                    } else if (REP.equals("NACK_agenzia")) {
                        JOptionPane.showMessageDialog(null, "I dati inseriti non sono corretti", "Errore", JOptionPane.ERROR_MESSAGE);
                        password.setText("");
                        user.setText("");
                    } The strange thing is that this web service was running just finished the project.
    After 4-5 days of its operation has stopped, creandomi this problem.
    I think the answer is, the server that is not the case.
    I thought all I thought was jdbc, but I can connect to the database, so I do not know what to do and how to proceed.
    thanks to all, and thanks to my translator. :P

    Parameter par = respons.getReturnValue();There is only one possible reason, "respons" is null.

  • Custom Template for Third Party Balance Summary Report(Java type executable

    Hi Al,l we have a requirment to have a layout with some of the fields from
    Third Party Balance Summary Report( Which is a Java type executable and
    Data definition has Data Template attached(.xml)).
    I tried in below way.
    Coppied the Third Party Balance Summary Report program with same application and parameters
    with. Then defined a Datadefinition with my concurrent prog short name
    attached the same standard .xml file(Not sure what it is) and developed a custom template with
    a custom rtf(excel output type), and submitted the program
    the output is generated in excel but my custom .rtf layout is not getting applied
    rather it is showing same layout as in standard.
    Some thing I am missing here or else it is not the way of changing the
    template.
    If any one know how to do this please let me know.
    My client want only some files from the standard report(no need of new fileds)
    with output type xls.
    Thanks in Advance.
    The same content is posted in Custom Template for Third Party Balance Summary Report(Java type executable sorry for duplicating the thread, just for increase the visibility for my issue I did this.

    I gave up on using a different font or figuring out if I could use Times New Roman's built-in fractions visible in Font Book (as unicodes) and did a work-around based on Michael Wasley's tips in this discussion.
    https://discussions.apple.com/message/11622842#11622842
    I adapted it however and think it looks a little better.
    Font: Times New Roman 12 point
    I used the fraction bar in 12-point (Shift-Option-1) for automatic kerning.
    For the numerator, I changed the font style to superior (12-point).
    For the denominator, I changed the font style to subscript (Shift-Command-hyphen) and reduced the font size to half, or 6-point using the short-cut Shift-Command-<.
    When the fractions occured in my footnotes (9-point), I used 4-point in the denominator; 10- and 11-point, I used 5-point in the denominator. This seemed to produce the best result when printing.
    Thank you, Michael.
    -Dottie

  • Fonts in java

    Hello,
    I'm sorry if i post this topic here, but I can't find any solution for my problem. I have develope an application with NetBeans in Windows. I have make a standalone software. Label's font are "Tahoma". Now I wanna modify my application. Now I use NetBeans under Ubuntu. When I click on a label in NetBeans' gui-editor and I choose font, the list of font available are only: Courier, Default, Dialog, DialogInput, Lucida Bright, Lucida Sans, Luxi Mono, Luxi Sans, Luxi Serif, Monospaced, SansSerif and Serif. Tahoma there aren't, but in my Ubuntu Systems fonts are too many more, and Tahoma there are! If I run this application JVM can't visualize text with Tahoma fonts and this text are in other font.
    Can anyone help me?
    Thanks so much!!!

    Check out 2D FAQ:
    http://java.sun.com/products/java-media/2D/reference/faqs/index.html#Q_What_font_types_does_Java_2D_s
    And Text tutorial:
    http://java.sun.com/developer/onlineTraining/Media/2DText/

  • Java.lang.NullPointerException in apple.awt.CTextField

    Hi,
    an applet running for many years fine on a number of Java VMs, suffers a strange problem with the Apple VM. All single-line text fields appear disabled (greyed out). On the Java console, the following exception is recorded:
    Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
    at apple.awt.CTextField$1.run(CTextField.java:45)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:633)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:29 6)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:20 1)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    As you see, this stack trace is obviously related to the problem - I guess, some state-change calls to the TextField are translated into a asynchronous event, whose handler fails. Unfortunately, this trace gives no hint at all, how to work around this problem in the apple.awt.CTextField implementation!
    Can anybody give a hint what happens in line 45 of apples CTextField implementation? Can the applet be rewritten in a way to set attributes required by this event handler?
    Greetings,
    Andreas.

    {color:red}{size:20px}CROSS POSTED{size}{color}
    [http://forums.sun.com/thread.jspa?threadID=5333376]
    Cross posting is rude.
    db

  • Exception JComboox :Exception in thread "AWT-EventQueue-0" java.lang.NullPo

    Hi, I mapped a vector object to the JComboBox. I'm using the observer pattern to update the ComboBox box whenever there is an message receives.If an update is received I just add the data to the vector and to refresh the ComboBox bu calling the UpdateUI() method. When more updates received same time i'm getting the following exception.
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
         at javax.swing.plaf.basic.BasicComboBoxUI.paintCurrentValue(BasicComboBoxUI.java:1059)
         at javax.swing.plaf.basic.BasicComboBoxUI.paint(BasicComboBoxUI.java:850)
         at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
         at javax.swing.JComponent.paintComponent(JComponent.java:740)
         at javax.swing.JComponent.paint(JComponent.java:1003)
         at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4930)
         at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4883)
         at javax.swing.JComponent._paintImmediately(JComponent.java:4826)
         at javax.swing.JComponent.paintImmediately(JComponent.java:4633)
         at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
         at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    Please assist me in fixing this issue if anyone came across this issue.
    Thanks.

    I just add the data to the vector and to refresh the ComboBox bu calling the UpdateUI() methodYou should NOT be updating the vector.
    That is NOT what the updateUI() method is used for.
    The proper way to update a component is to udate the MODEL The model will then notify the VIEW so it can repaint itself. Also, make sure the code is executed on the EDT. Read the section from the Swing tutorial on Concurrency.

Maybe you are looking for