Seperating Graphics from code on Swing application

1)I want to draw simple graphics like rectangles, curves, lines, images etc on top of my swing application. I would like to separate the graphic representation from the code to an external file like XML,XAML , SVG etc.. All these graphics should be editable(i.e. scaling, translating the position, changing font, color etc) . Please let me know the possible technologies?
2)Also is it possible to use HTML5 canvas component oj java swing.
JButton button = new JButton("<html><canvas>...</canvas></html>")
is this possible?.It is not working for me, if it is possible am i missing out something?

Hi,
Thanks for your reply!
I went through the link you provided. This is exactly how my application draws graphics now. But my problem is one of my shape will be a rectagle with circle, another will be rectangle with image.So i have to write seperate classes to draw each of these shapes. My idea is to avoid creating seperate classes but an external file will define all the graphics components and library should be smart enough to identify the drawings required and paint it on my swing components. I am in search for a library or a java feature that can do this. Please help!
Regards,
Anjana

Similar Messages

  • Accelarate the Linux ATI Graphics card  for java Swing application

    Hi All,
    I am using a ATI Radeon 9550 Graphic card in LFS (Linux from the scratch) environment. I want to enable the OpenGL-based pipeline for Java Swing application. I tried the -Dsun.java2d.opengl=true . But the Java swing application getting very slow.
    How to overcome this problem?
    Any one give the procedure to Accelerate ATI graphics card for Java Swing Application
    How to verify Java swing use ATI graphics card ?
    Thanks in advance..
    Prabhu.S

    Hi All,
    I am using a ATI Radeon 9550 Graphic card in LFS (Linux from the scratch) environment. I want to enable the OpenGL-based pipeline for Java Swing application. I tried the -Dsun.java2d.opengl=true . But the Java swing application getting very slow.
    How to overcome this problem?
    Any one give the procedure to Accelerate ATI graphics card for Java Swing Application
    How to verify Java swing use ATI graphics card ?
    Thanks in advance..
    Prabhu.S

  • Invoke an awt event from outside the swing application

    Is it possible to invoke an awt event triggered from outside the swing app? I am trying to implement a use case where i have to open a new tab in an already running swing app when a user clicks on a browser link.

    I have a desktop application that was invoked via webstart. The java webstart process started when the user clicked on a link that downloaded the swing application and now it runs in the clients JVM. Each browser click downloades and launches the application that performs a certain function. Now lets say, the user clicks on another link, then i don't want another java application to be launched. I want the same application that executes the function in lets say a new tab.
    Its kind of like you click on a link that somebody sent you in an outlook email. When you click on it and if firefox is already running, the link opens up in a new tab on an already running firefox browser. If firefox was not running, it starts a new firefox process.
    Hope this makes sense

  • Can not launch swing application from Java Web Start 1.6.0_37

    I have a dynamic generated jnlp file from a serlvet. When I used Java Web Start to start the swing application, it failed. The exception showed
    com.sun.deploy.net.FailedDownloadException: Unable to load resource: http://xxxx.xx.com:9080/dilpipweb/Test-1.0-SNAPSHOT.jar
         at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
         at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown Source)
         at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
         at java.util.concurrent.FutureTask.run(Unknown Source)
         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    I used janela to validate the generated jnlp file. It was valid. I also checked the tomcat access log, it showed that the Test-1.0-SNAPSHOT.jar file was accessed correctly (with a 200 return code).
    Can anyone help me what was the problem?
    Thanks,

    Hi.
    I got a different problem. My Corba application works in JRE 1.6, but doesn't works in JRE 1.5.X. I got an unexpected error and my console shows:
    getSubjectX500Principal NoSuchMethodError: java.lang NoSuchMethodError
    #### Java Web Start Error:
    #### null
    Can you help me?

  • Problem in Opening HTML Page in Internet Explorer from my Swing Application

    Hi,
    I am opening a HTML file in Internet Explorer from my swing application.I am using the code given below
    private final static String WIN_FLAG = "url.dll,FileProtocolHandler";
    private final static String WIN_PATH = "rundll32";
    String cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
    // url is HTML file Path
    Process p = Runtime.getRuntime().exec( cmd );
    Here there are two things i need to address ...
    1)The HTML file is opening up,but it always opens behind the swing application,that makes me every time to maximize the HTML file after it being opened up.I want to open it in front of the Swing Application.I need to implement "Always On Top" functionality for the html page.
    2)Whenever i trigger action to open different HTML page,it opens in new Internet Explorer window.
    I need to open it in same IE window.
    how to solve out these problems ??? any help would be greatly appreciated .Thanks in advance.
    - Manikandan

    any idea about this ????

  • Help Needed in opening a HTML File from swing application

    Hi,
    I am opening a HTML file in Internet Explorer from my swing application.
    I am using the code given below
    private final static String WIN_FLAG = "url.dll,FileProtocolHandler";
    private final static String WIN_PATH = "rundll32";
    String cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
    // url is HTML file Path
    Process p = Runtime.getRuntime().exec( cmd );
    The HTML file is opening up,but it always opens behind the swing application,that makes me every time to maximize the HTML file after it being opened up.
    I want to open it in front of the Swing Application.
    Any Help Please ?
    - Manikandan

    Check your Application's JFrame properties (may be ur Frame is set to be in top position ,always),and also check running your application in some other OS.

  • Launching Adobe Viewer from a Swing application

    How do I launch Adobe Viewer (or Reader) from my Swing application. I have a help menu item that needs to open the viewer with the PDF help manual. Since the application is cross-platform, do I need different versions of Adobe with my install package? Thanks for any help.

    Thanks. I tried the adobe bean and it seems to work fine until I select the "Print" icon. It crashes the Viewer and my application as well. I get the following:
    Any suggestions?
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : 11 occurred at PC=0xff2c614c
    Function name=realloc
    Library=/lib/libc.so.1
    Current Java thread:
    at sun.awt.motif.MTextFieldPeer.create(Native Method)
    at sun.awt.motif.MComponentPeer.init(MComponentPeer.java:169)
    at sun.awt.motif.MComponentPeer.<init>(MComponentPeer.java:179)
    at sun.awt.motif.MTextFieldPeer.<init>(MTextFieldPeer.java:68)
    at sun.awt.motif.MToolkit.createTextField(MToolkit.java:85)
    at java.awt.TextField.addNotify(TextField.java:194)
    at java.awt.Container.addNotify(Container.java:1579)
    at java.awt.Panel.addNotify(Panel.java:74)
    at java.awt.Container.addNotify(Container.java:1579)
    at java.awt.Window.addNotify(Window.java:349)
    at java.awt.Dialog.addNotify(Dialog.java:247)
    at java.awt.Window.pack(Window.java:367)
    at com.adobe.acrobat.gui.PDFPrint$PageRangeDialog.<init>(PDFPrint.java:144)
    at com.adobe.acrobat.gui.PDFPrint.<init>(PDFPrint.java:18)
    at com.adobe.acrobat.gui.PrintUI.printPages(PrintUI.java:183)
    at com.adobe.acrobat.gui.PrintUIVerb$PrintTransactor.printFileWithUI(PrintUI.java:591)
    at com.adobe.acrobat.gui.PrintUIVerb$PrintTransactor.buildChanges(PrintUI.java:556)
    at com.adobe.pe.notify.Transactor.commit(Transactor.java:44)
    at com.adobe.pe.awt.UIVerb$1.buildChanges(UIVerb.java:151)
    at com.adobe.pe.notify.Transactor.commit(Transactor.java:70)
    at com.adobe.pe.awt.UIVerb.invoke(UIVerb.java:51)
    at com.adobe.pe.awt.ToolBar.mouseReleased(ToolBar.java:419)
    at java.awt.Component.processMouseEvent(Component.java:3715)
    at java.awt.Component.processEvent(Component.java:3544)
    at java.awt.Component.dispatchEventImpl(Component.java:2593)
    at java.awt.Component.dispatchEvent(Component.java:2497)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
    at java.awt.Container.dispatchEventImpl(Container.java:1200)
    at java.awt.Component.dispatchEvent(Component.java:2497)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:339)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
    Dynamic libraries:
    0x10000 /shared/j2sdk1_3_1/bin/../bin/sparc/native_threads/java
    0xff360000 /lib/libthread.so.1
    0xff3a0000 /lib/libdl.so.1
    0xff280000 /lib/libc.so.1
    0xff260000 /usr/platform/SUNW,Ultra-4/lib/libc_psr.so.1
    0xfe480000 /local/j2sdk1_3_1/jre/lib/sparc/client/libjvm.so
    0xff210000 /lib/libCrun.so.1
    0xff1f0000 /lib/libsocket.so.1
    0xff100000 /lib/libnsl.so.1
    0xff1c0000 /lib/libm.so.1
    0xff240000 /lib/libw.so.1
    0xff0e0000 /lib/libmp.so.2
    0xff0a0000 /local/j2sdk1_3_1/jre/lib/sparc/native_threads/libhpi.so
    0xff070000 /local/j2sdk1_3_1/jre/lib/sparc/libverify.so
    0xff030000 /local/j2sdk1_3_1/jre/lib/sparc/libjava.so
    0xfe450000 /local/j2sdk1_3_1/jre/lib/sparc/libzip.so
    0xfd060000 /local/j2sdk1_3_1/jre/lib/sparc/libawt.so
    0xf4880000 /local/j2sdk1_3_1/jre/lib/sparc/motif21/libmawt.so
    0xfd010000 /shared/j2sdk1_3_1/bin/../jre/lib/sparc/libmlib_image.so
    0xf4600000 /lib/libXm.so.4
    0xf4580000 /lib/libXt.so.4
    0xfafd0000 /lib/libXext.so.0
    0xfafa0000 /usr/openwin/lib/libXtst.so.1
    0xf4480000 /lib/libX11.so.4
    0xfac60000 /lib/libSM.so.6
    0xfac30000 /lib/libICE.so.6
    0xf4380000 /local/j2sdk1_3_1/jre/lib/sparc/libfontmanager.so
    0xf4ba0000 /usr/openwin/lib/libdps.so.5
    0xf4860000 /shared/j2sdk1_3_1/bin/../jre/lib/sparc/libsunwjdga.so
    0xf4830000 /usr/openwin/lib/libdga.so.1
    0xf4560000 /shared/j2sdk1_3_1/bin/../jre/lib/sparc/libxinerama.so

  • To exit from swing application(reply soon )

    hi guys,
    what to do to exit from swing application using button or menuitem.
    i have extendd frame.
    i wrote]
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);but it didn't worked.
    thanx.

    hi guys,
    what to do to exit from swing application using
    button or menuitem.
    i have extendd frame.
    i wrote]
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);[
    code]What does that code do? Check the API for JFrame.
    but it didn't worked.No it would not. How do you add a action to a menuitem? (Check the tutorials).
    How do exit the JVM (check the tutorials, and/or the API for System)

  • How to invoke a JAR from Java Swing application?

    Hi,
    I am trying to start a jar file from the swings application.
    I am trying the following code,
    String cmd[] = new String[]{"cmd", "java -jar TestJFreeChart.jar"};
    try
           Process run = Runtime.getRuntime().exec(cmd);
    catch(Exception e)
    {}Is anything wrong in the usage?

    First try:
    "cmd /c java -jar app.jar" or cmd start, because it can't jsut run java.exe, it needs to be
    passed to the cmd interpretor witch further calls java.exe, etc
    Also read what stevejluke suggested. Its important to know if .waitFor or not.
    You wont understand these until you read the tutorial.

  • How to Call Crystal Reports from Swing Application

    Hi All,
    I have a requirement for calling Crystal Report from Swing Application. Please let me know how can I do that, and also provide the Source code for calling the crystal report.
    Thanks in advance.
    Chandra

    hi
    this is the code that i am using in my application which is similar to urs. but i am working with CR XI so make all the neccessary changes.
        import java.awt.*;
        import javax.swing.*;
        import com.crystaldecisions.ReportViewer.*;
        import com.crystaldecisions.reports.sdk.*;
        import com.crystaldecisions.sdk.occa.report.reportsource.*;
       public class HelloSwing
            public static void createAndShowGUI()
                try
                    //Make sure we have nice window decorations.
                    JFrame.setDefaultLookAndFeelDecorated(true);
                    //Create and set up the window.
                    JFrame frame = new JFrame("HelloWorldSwing");
                    frame.setTitle( "Testing Reports");
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   ReportViewerBean viewer = new ReportViewerBean();
                    viewer.init( new String[0], null, null, null);
                  ReportClientDocument rpt = new ReportClientDocument();
                    rpt.open( "report path", 1 );
                    IReportSource rptSource = rpt.getReportSource();
                    viewer.setReportSource( rptSource );
                    frame.getContentPane().add( viewer, BorderLayout.CENTER );
                    frame.setSize( 700, 500 );
                    frame.setVisible(true);
                    viewer.start();
                catch ( Exception exception )
                    System.out.println( exception.toString() );
            public static void main(String[] args)
                javax.swing.SwingUtilities.invokeLater(new Runnable()
                    public void run()
                        createAndShowGUI();
       there are 23 jar files that u need to import into ur package. but remember that ReportViewerBean should be the first jar file in the list & it should be followed by jrcerom.jar
    specify the key in the CRConfig.xml file (which also has to be imported in the package)
    u can find these jar files in the common objects folder in your program files.
    hope it helps. best of luck

  • Problems After shifting swing application from jdk1.3 to 1.4

    hi,
    i have shifted my Swing application from jdk1.3 to 1.4, some component settings changed in j2se1.4. are listed below
    1). i have added JComboBox to JPanel using BoxLayout, in jdk1.3 it is normal where as in 1.4 comboBox height is increased to panel height.
    Sample code
    (in a Panel)
         setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    add(getYearComboBox());
         add(getMonthNameComboBox());
         add(getDayOfMonthComboBox());
    2). in jdk1.3 the icon which is set to JFrame is visible in the JOptioPane.showConfirmationDialog() also, but in 1.4 the icon is not visible in conformation dialog box.
    Sample Code
    in a JFrame's constructor
    public OptionPaneTest()
    ImageIcon icon = new ImageIcon("icon.gif");
    setIconImage(icon.getImage());     
    setSize(250,100);
    addWindowListener(new java.awt.event.WindowAdapter() {
    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
    setVisible(true);
    JOptionPane.showMessageDialog(this,"hai", "Hai",JOptionPane.WARNING_MESSAGE);
    3). the Labels added to the panel or frame are displaying in light blue color with jdk1.3 and the same label displaying in black with j2se1.3
    Sample Code
    in a JPanel
    setLayout(new BorderLayout(20, 20));
    add(new JLabel("Testing Label Color"), BorderLayout.CENTER);
    please send solution to any or all.
    thanks in advance,
    Pavan.DV

    Thanks for your sugession.
    You realized me by showing the fact that there are no many classes
    Keep suggesting like this.
    I don't even know how to see the API documentation Before you told me.
    Don't take any issue as simple thing and never give foolish suggessions like this.
    If you know the Answer then share it or else musukoni kurcho ra

  • Launching Browser From Swing Application - Help Needed

    Hi,
    I am opening a HTML file in Internet Explorer from my swing application.
    I am using the code given below
    private final static String WIN_FLAG = "url.dll,FileProtocolHandler";
    private final static String WIN_PATH = "rundll32";
    String cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
    // url is HTML file Path
    Process p = Runtime.getRuntime().exec( cmd );
    The HTML file is opening up,but it always opens behind the swing application,that makes me every time to maximize the HTML file after it being opened up.
    I want to open it in front of the Swing Application.
    Any Help Please ?
    - Manikandan

    Browser Utility - Class to launch a URL in a web browser in
    a platform independent manner. Includes an optional swing
    GUI allowing user customization. [Open Source - GPL]
    http://ostermiller.org/utils/Browser.html
    BrowserLauncher - Open the system web browser with
    particular attention paid to various Macintosh systems.
    (Freeware)
    http://browserlauncher.sourceforge.net/
    Java World - With a little platform-specific Java code, you
    can easily use your system's default browser to display any
    URL in Windows or Unix.
    http://www.javaworld.com/javaworld/javatips/jw-javatip66.html
    JConfig - Class Libraries that allow a URL to be launched in
    a browser on Windows, Unix, or Macintosh. [Commercial]
    http://www.tolstoy.com/samizdat/jconfig.html
    Apple - MRJFileUtils.openURL() not implemented in Mac OS X.
    http://developer.apple.com/techpubs/macosx/ReleaseNotes/JavaGMWebReleaseNotes.html#MRJToolkit
    Apple - How one would open a URL in a web browser on a
    Macintosh.
    http://developer.apple.com/qa/java/java12.html

  • Viewing and printing a PDF file from Java Swing Application

    Hello,
    I need to view and print PDF files from Java Swing Application.How do I do that?I appreciate your help.
    Thank you
    Sumana Somareddy

    If you have a link to the URL pointing to the PDF file, you can allow the browser to open it. Then use the print function of the browser to print the PDF document.
    Regards,
    Tak.

  • Debug the swing application from eclipse

    Hi
    I had a swing application, to create a exe file i build the application using using build.xml. To run the application we need to open the exe file.
    I want to debug this swing application from eclipse. Can anybody please tell me how to debug this application.
    Note: I can able to debug simple swing application. But i can't able to debug this application.
    Thanks
    mindus

    If it's an actual .exe--that is, if you've compiled it to a native Windows executable--then you can't debug it using a Java debugger (such as the one in Eclipse).
    If, on the other hand, you just have a .jar file or a bunch of .class files, then you can debug this app the same way you debugged the other one.
    If you don't provide more details about what you actually did and what exact problems you're having ("I can't do it" contains no useful information whatsoever), then it's impossible to provide any more detailed advice than this.

  • Why we extend JFrame in java swings? how is it different from code not ...?

    how is it different from code nt extending JFrame?
    please explain the role of contentpane in both cases?
    thanx

    Search the net for examples and/or explanations of "inheritance vs composition.
    For the role of a contentPane, read the API for interface RootPaneContainer and class JRootPane. The second named API also has a link to the Swing tutorial on How to Use Root Panes.
    db

Maybe you are looking for