Forum Stats

  • 3,838,062 Users
  • 2,262,325 Discussions
  • 7,900,486 Comments

Discussions

Applet and css

870573
870573 Member Posts: 3
edited Jun 23, 2011 1:02PM in JavaFX 2.0 and Later
In an applet, StyleManager.loadStylesheet(final String fname) causes a null exception .

The code below evade this :

StyleManager styleManager= StyleManager.getInstance();
URL url=getURL("/indicateurs/charts.css", Main.class);

try {
Stylesheet stylesheet = CSSParser.getInstance().parse(url);
styleManager.setUserAgentStylesheet(stylesheet);

} catch (IOException ex) {
System.out.println("exception:"+e);

}

In the css file indicateurs.charts.css , i add first the source of : sun.javafx.scene.control.skin.caspian.caspian.css (as the setUserAgentStylesheet erase the others stylesheet !!!)


Will there be a more simple way to deal with the css in an applet ?

thanks

Edited by: 867570 on 22 juin 2011 02:16

Answers

  • 793415
    793415 Member Posts: 7,279 Bronze Badge
    867570 wrote:
    In an applet, StyleManager.loadStylesheet(final String fname) causes a null exception .
    What's a <tt>StyleManager</tt>? I don't see it in the Java 6 JavaDocs.
    The code below evade this :

    StyleManager styleManager= StyleManager.getInstance();
    URL url=getURL("/indicateurs/charts.css", Main.class);
    What <tt>URL</tt> constructor takes a <tt>String</tt> and ..what is that, a <tt>Class</tt>?
    } catch (IOException ex) {
    System.out.println("exception:"+e);
    Don't throw away exception information. Call <tt>e.printStackTrace()</tt>. Even if you choose to dump part of the message to output, <tt>System.err</tt> rather than <tt>System.out</tt> should be used.
    Will there be a more simple way to deal with the css in an applet ?
    Can you:
    <li>Use the code formatting tags as described on the sticky post at the top of the forum thread listing?
    <li>Ask a smart question? The current code & text reads like nonsense.
  • 870573
    870573 Member Posts: 3
    it is in the javafx general Question :
    StyleManager is from the package : com.sun.javafx.css
  • aidreamer
    aidreamer Member Posts: 242
    edited Jun 22, 2011 11:38AM
    Packages in com.sun are usually intended as implementation or experimentation. Using them in your own projects is not recommended. As for using CSS in an applet, you should be able to do that without having to resort to those packages. The tutorial on CSS is right here: http://download.oracle.com/javafx/2.0/css_tutorial/jfxpub-css_tutorial.htm
  • I am interested in knowing what the traceback of the NPE is so I can see if it is a bug in the code. Thanks.
  • darrylburke
    darrylburke Member Posts: 18,007
    I would guess it's just a result of the security manager preventing the applet from accessing files on the local filesystem.

    db
  • 870573
    870573 Member Posts: 3
    when the code is :
    Scene scene = new Scene(root);
    scene.getStylesheets().addAll("/indicateurs/charts.css");


    the message from the console java is :
    WARNING: com.sun.javafx.css.StyleManager$2 run Resource "null" not found.

    SEVERE: javafx.scene.control.Control impl_processCSS The -fx-skin property has not been defined in CSS for [email protected][styleClass=sample-tile]

    SEVERE: javafx.scene.control.Control impl_processCSS The -fx-skin property has not been defined in CSS for [email protected][styleClass=sample-tile]



    thanks for your help
This discussion has been closed.