Adding Applets to Web Applications

Is it possible to add other components to the same Java Server Page where the Applet is?
Thank You,
Manuel Braz

The problem with this is that I have not been able to get this to work when creating my own applets in JSC or NB5.5 (See my current post from today / yesterday). I am still hoping someone can help with a solution to the java class not found browser error.
There is a FAQ about this problem and it suggests creating a servlet to steam the java applet to the jsp page based on a relative path (as the .class file is stored in the WEB-INF folder and inaccessable to the jsp page) but does not go so far as to give an example how to do this... does anyone know how to do this?. (Please don't feel I am hijacking this thread - I do believe it is relevant to the original post).

Similar Messages

  • ClassNotFound error while running applet from Web application

    hi everyone,
    I have a web application deployed in Tomcat web server. I have HTML file at the level of WEB-INF. And all class files under WEB-INF/classes. But while ruuning the application it giving following error.
    load: class com.app.AppletTest not found.
    java.lang.ClassNotFoundException: com.app.AppletTest
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadCode(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.IOException: open HTTP connection failed.
         at sun.applet.AppletClassLoader.getBytes(Unknown Source)
         at sun.applet.AppletClassLoader.access$100(Unknown Source)
         at sun.applet.AppletClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         ... 10 more
    Here the HTML file applettest.html
    <html>
         <head>
              <title>Multiple Image Upload</title>
         </head>
         <body>
              <applet code="com.app.AppletTest" width="300" height="300">
              </applet>
         </body>
    </html>
    And Java applet file is
    package com.app;
    import java.applet.Applet;
    import java.awt.Color;
    import java.awt.Graphics;
    public class AppletTest extends Applet
         public void init()
              System.out.println("Init called");
              this.setBackground(new Color(180,200,250));
         public void start()
              System.out.println("Start called");
         public void paint(Graphics g)
              g.drawString("welcome Hello World",50,50);
              System.out.println("Paint called");
         public void stop()
              System.out.println("Stop called");
         public void destroy()
              System.out.println("Destroy called");
    Thanks.

    Hi,
    if u put ur com.app.AppletTest file @ WEB-INF Directry, then this problem will solve easily.
    you have to put applet package(com.app.AppletTest) @ WEB-INF Directry. Since
    Applet is using by html, u have to keep applet with html file.
    if applet class have interaction with other classes, u have to seperate all related class to applet to seperate package and put them @ WEB-INF folder.

  • Access Denied Web Application with Claims authentication NTLM only when using secondary URL

    I have a SharePoint 2010 server farm with 2 web front ends, an application server and a database server.  Both front ends are internal to
    our network and are not behind a load balancer.
    NOTE THAT I HAD TO SUBSTITUTE hzzp with hzzp so that I had no links in the body of this post since I am not verified
    I setup a new web application called "SharePoint 41171" with:
    Public URL:
    hzzp://testserver1:41171
    Claims authentication
    NTLM only: no forms auth
    No SSL
    New web site "SharePoint 41171"
    New app pool
    New content database
    I create a top level site collection and name mydomain\myusername as the primary site collection admin
    I am able to access this site as expected at
    hzzp://testserver1:41171 with the aforementioned site collection owner id: mydomain\myusername
    I add an alternate access mapping for a secondary URL for this web application in the Intranet zone:
    hzzp://iwatest.mydomain.com
    So my AAMs for the site read as:
    hzzp://testserver1:41171    
    Default     hzzp://testserver1:41171
    hzzp://iwatest.mydomain.com    
    Intranet     hzzp://iwatest.mydomain.com
    When I attempt to log on to
    hzzp://iwatest.mydomain.com with the same user name and password, I get "access denied".
    I can access this site using
    hzzp://iwatest.mydomain.com if I log in as the farm account.  This is the only account that seems to work.
    Side Note: If I create a separate web application without claims - just NTLM and create the same AAMs, I can login fine with the same secondary
    URL and the same user name
    IP address properly maps to this machine.
    I reviewed the ULS logs and find the following:
    10/30/2012 16:20:23.45              w3wp.exe (0x0E78)                      
                    0x1724       SharePoint Foundation              Monitoring                   
                    nasq                        Medium    Entering
    monitored scope (Request (GET:hzzp://iwatest.mydomain.com:80/_layouts/AccessDenied.aspx?Source=hzzp%3A%2F%2Fiwatest%2Emydomain%2Ecom))                
    10/30/2012 16:20:23.45              w3wp.exe (0x0E78)                      
                    0x1724       SharePoint Foundation              Logging Correlation Data     
          xmnv                        Medium    Name=Request (GET:hzzp://iwatest. mydomain.com:80/_layouts/AccessDenied.aspx?Source=hzzp%3A%2F%2Fiwatest%2Emydomain%2Ecom)      
    8f313b5e-8476-4dd4-9abe-0cb6dbe024b6
    10/30/2012 16:20:23.45              w3wp.exe (0x0E78)                      
                    0x1724       SharePoint Foundation              Logging Correlation Data     
          xmnv                        Medium    Site=/          8f313b5e-8476-4dd4-9abe-0cb6dbe024b6
    10/30/2012 16:20:23.45              w3wp.exe (0x0E78)                      
                    0x1724       SharePoint Foundation              General                      
                       8e2s                        Medium 
      Unknown SPRequest error occurred. More information: 0x80070005       8f313b5e-8476-4dd4-9abe-0cb6dbe024b6
    10/30/2012 16:20:23.45              w3wp.exe (0x0E78)                      
                    0x1724       SharePoint Foundation              Monitoring                   
                    b4ly                        Medium    Leaving
    Monitored Scope (Request (GET:hzzp://iwatest.mydomain.com:80/_layouts/AccessDenied.aspx?Source=hzzp%3A%2F%2Fiwatest%2Emydomain%2Ecom)). Execution Time=8.66003919492561   8f313b5e-8476-4dd4-9abe-0cb6dbe024b6
    Basically it tells me that access is denied.  I didnt see anything that stood out here.
    I found this article:
    hzzp://social.technet.microsoft.com/Forums/en-US/sharepointadminprevious/thread/ded9188b-ee03-4ef0-bb50-3ad138110e0c, which pointed me in the direction of ensuring that the portal
    super user and portal reader accounts were properly added to my web application.  I followed the every popular article on doing this:
    hzzp://technet.microsoft.com/en-us/library/ff758656.aspx, but still no luck.  As per the thread, I added the 2 domain accounts to the user policy with appropriate privilege
    and then set them as the super user and super reader accounts via powershell, and yes I did prefix those names with "i:0#.w|mydomain\".  To be exta sure, I repeated this for all web applications on this server with slightly different powershell steps
    depending on wether or not claims was enabled on the web application.
    The Claims to Windows Token Service is running.
    I saw some mention of ensuring that the secure token service is running with a proper application pool account, but we are not running that service
    and I cant imagine what that would have to do with my situation.
    I have deleted and readded the web application and repeated these steps to no better effect.
    I gave the mydomain\myusername full control for the web application through the user policy, ensured that it was indeed the primary site collection
    owner and added it to the default site owners group.  None of this helped.
    I changed the application pool account to the farm account.  No change in behavior.
    Rebooted IIS and the machines many times along the way.
    Further, when I attempt to sign in as a different user after being denied, I get "an unexpected error has occured message.  I found the following
    in ULS:
    10/30/2012 11:19:03.71 w3wp.exe (0x182C)                      
    0x1210  SharePoint Foundation                 Logging Correlation Data                     
    xmnv     Medium               Name=Request (GET:hzzp://iwatest.mydomain.com:80/_layouts/accessdenied.aspx?loginasanotheruser=true&Source=hzzp%3A%2F%2Fiwatest%2Emydomain%2Ecom)
    cc409ec2-4889-42fa-aa7d-9cc4535e4f0e
    10/30/2012 11:19:03.71 w3wp.exe (0x182C)                      
    0x1210  SharePoint Foundation                 Logging Correlation Data                     
    xmnv     Medium               Site=/    cc409ec2-4889-42fa-aa7d-9cc4535e4f0e
    10/30/2012 11:19:03.72 w3wp.exe (0x182C)                      
    0x1210  SharePoint Foundation                 General                      
             8e2s                Medium               Unknown SPRequest error occurred.
    More information: 0x80070005      cc409ec2-4889-42fa-aa7d-9cc4535e4f0e
    10/30/2012 11:19:03.72 w3wp.exe (0x182C)                      
    0x1210  SharePoint Foundation                 Runtime                      
            tkau                Unexpected       System.NullReferenceException: Object reference not set to an instance
    of an object.    at Microsoft.SharePoint.ApplicationPages.AccessDeniedPage.LogInAsAnotherUser()     at Microsoft.SharePoint.ApplicationPages.AccessDeniedPage.OnLoad(EventArgs e)     at System.Web.UI.Control.LoadRecursive()    
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)            cc409ec2-4889-42fa-aa7d-9cc4535e4f0e
    10/30/2012 11:19:03.74 w3wp.exe (0x182C)                      
    0x1210  SharePoint Foundation                 Monitoring                        
    b4ly                Medium               Leaving Monitored Scope (Request (GET:hzzp://iwatest.mydomain.com:80/_layouts/accessdenied.aspx?loginasanotheruser=true&Source=hzzp%3A%2F%2Fiwatest%2Emydomain%2Ecom)).
    Execution Time=22.5439266722447           cc409ec2-4889-42fa-aa7d-9cc4535e4f0e
    By the way, this occurs for the farm account also after a successful login and an attempt to sign in as a different user.
    Any help would be greatly appreciated

    Thanks spadminspadmin:
    I have, though I am not sure that what I've added there is correct:
    The URL that I am trying to use to access the web application's IIS site is hxxp://iwatest.mydomain.com.  I added a binding to the IIS site as follows:
    Type    Host name                      port        IP address
    http     iwatest.mydomain.com     41171     *
    Is that correct?

  • Deploy Web Application

    Dears,
    I developed a web application and it's time to deploy it,
    i know that i can host it on any web server (currently i am using Apache tomcat) and then type the url .
    but i want to see my web Application home page when i open start->All programs to click on the web page and open it directly
    Is there any tool that can enable me to do this...
    can any one help me in this issue?
    Best Regards,
    Marwa

    Web-start technology is for launching client side
    applications and applets, not web applications.
    For the types of forums that deal with J2EE, see here..
    http://forum.java.sun.com/category.jspa?categoryID=20

  • Accessing web application JAR files from applet

    I've got an applet which is part of a web application.
    All the web application JARs are in the webapps/myappl/WEB-INF/lib directory, and I
    can't seem to place anything in that directory on the archive attribute of <OBJECT> tag.
    I'm running into trouble because I'm sending objects from the servlet to the applet and keep getting classnot found during deserialization because I've missed some jar file on the archive attribute. I've had to copy lots of jar files up to where the codebase in the HTML file is to make this run. My question is this.
    Is it better to just change the tomcat security policy file (catalina.policy in tomcat conf directory) so that the JARs are directly accessible and I don't have to copy them from WEB-INF/lib???? Has anyone done this before? What would the line look like?
    I'm assuming that I have to follow the instructions (THAT I DON'T UNDERSTAND)
    at the bottom of the policy file. Can someone help me out here????
    should I have something like
    grant codeBase "file:${catalina.home}/webapps/myappl/WEB-INF/classes/-"
    { permission java.security.AllPermission; };
    grant codeBase "file:${catalina.home}/webapps/myappl/WEB-INF/lib/-"
    { permission java.security.AllPermission; };
    Will this allow me to place references to jar files (and the classes directory) in the archive attribute, such as
    <OBJECT .....  >
        <param name="archive" value="../WEB-INF/lib/applet.jar,../WEB-INF/lib/someapp.jar,../WEB-INF/classes" />trailer for catalina.policy is
    // You can assign additional permissions to particular web applications by
    // adding additional "grant" entries here, based on the code base for that
    // application, /WEB-INF/classes/, or /WEB-INF/lib/ jar files.
    // Different permissions can be granted to JSP pages, classes loaded from
    // the /WEB-INF/classes/ directory, all jar files in the /WEB-INF/lib/
    // directory, or even to individual jar files in the /WEB-INF/lib/ directory.
    // For instance, assume that the standard "examples" application
    // included a JDBC driver that needed to establish a network connection to the
    // corresponding database and used the scrape taglib to get the weather from
    // the NOAA web server.  You might create a "grant" entries like this:
    // The permissions granted to the context root directory apply to JSP pages.
    // grant codeBase "file:${catalina.home}/webapps/examples/-" {
    //   permission java.net.SocketPermission "dbhost.mycompany.com:5432", "connect";
    //   permission java.net.SocketPermission "*.noaa.gov:80", "connect";
    // The permissions granted to the context WEB-INF/classes directory
    // grant codeBase "file:${catalina.home}/webapps/examples/WEB-INF/classes/-" {
    // The permission granted to your JDBC driver
    // grant codeBase "file:${catalina.home}/webapps/examples/WEB-INF/lib/driver.jar" {
    //   permission java.net.SocketPermission "dbhost.mycompany.com:5432", "connect";
    // The permission granted to the scrape taglib
    // grant codeBase "file:${catalina.home}/webapps/examples/WEB-INF/lib/scrape.jar" {
    //   permission java.net.SocketPermission "*.noaa.gov:80", "connect";
    // };

    Thank you for your reply.
    As I mentioned in my first post I had seen a couple of posts mentioning ServletContext before, but dismissed them as I am not using any servlets of my own. However, since you showed me exactly how it was used I realised I could probably just use a dummy servlet to get this information.
    The following page suggests a couple of techniques for doing just this.
    http://www.jguru.com/forums/view.jsp?EID=1087411
    So I think that's me sorted, cheers.

  • Adding a secure, internal-only SharePoint Web application / Site collection in existing farm

    Hi,
    We are currently working on creating a new internal-only SharePoint site that will host sensitive information. We are planning the architecture to provide a secure environment to host this information in SharePoint. We will create the new web app on a separate
    database with encryption enabled TDE; we are also planning to encrypt the data through the SharePoint (Insert third-party vendor here) forms before it gets to the SP DB. And obviously, SharePoint permissions will be set accordingly.
    Additionally, we would like to have the site accessible
    only through our internal network and keep it off the DMZ.
    Our current SharePoint environment consists of two web-front end servers (load-balanced) externally exposed (DMZ), one application server and the SQL server both behind the DMZ (internal-only). Currently all of our SharePoint web apps are accessible externally
    through SSL.
    What is the best way to accomodate this new internal-only web application within our existing farm providing the security measures explained before?
    I am thinking  on adding an extra WFE server to the existing farm and put it behind the DMZ (internal-only) in a similar way as our application server is configured right now, but just serving exclusively this new internal site's content. I would then
    have the NEtwork guys to make the site accessible only to users logged-in internally in our network and through this new dedicated server only. My concern is that since all of our other web apps in the farm are exposed externally, and since the new server
    would be part of the same farm, that could be open doors for bad guys to access this information. Are there any other topology options I should consider? I have thought about creating a small (one-server only) new farm just for this purpose, but I am trying
    to avoid going that route.
    Any thoughts?
    Thank you,
    Rob

    You're mostly going down the right track.
    A new web application in dedicated SQL DB and web application policies to deny all external accounts access to the sites will go a long way. You can also make sure that the DNS does not resolve externally.
    If you want security you will probably be building the web application on https alone, which is my preference for any farms these days. That might negate the need for your encrypted infopath system.
    However you cannot add a WFE to a farm and dedicate a web app soley to that server. Any server with the SharePoint Foundation Web Application role will host all web applications. You can steer traffic to one
    server or another but that's not really doing much for security. If it's on one WFE it's on them all. For that reason I would say that the standalone farm is the best, most secure, solution.
    All of what you've been describing will help with security but you'll have to spend hours testing connections, securing files and testing testing testing.  Whilst the standalone will just work.
    No, i don't know why that turned into tiny print either.

  • Using Applets in ADF Web Application

    Hi,
    I'm building an ADF web application using JDeveloper 11. I would have to use applets which have to "communicate" with database (insert, update).
    What would be considered as "the best practice" for that "JDBC flavored applet"? Is it possible to reuse a database connection?
    Any suggestion would be appreciated.
    Thanks.

    Boris,
    You could still use ADF Business Components and access them remotely (from the applet).
    John

  • Web Application working correctly only with Everyone user added to user privilages

    Hello,
    I have an web application in Sharepoint 2013 which only works correctly with the Everyone (Read Only) user added to User Privileges in Central Admin. 
    If I remove Everyone user from user privileges, user domains, that are added to access groups in Site Permissions, are directed to Request Access page of the site. I cannot understand how is this happening, specially because I have other Web App on the same
    server which are working correctly.
    Could you please advice me how could I trace the problem and resolve it.
    Thank you!

    Hi Bogdan,
    According to your description, my understanding is that Everyone user cannot access the web application except adding the account to user policy of the web application in Central Administration.
    I recommend to check if the Super Reader account has been given the Full Read permission on the web application in Central Administration.
    If not, add the account to the User Policy of the web application and grant Full Read permission to the account.
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Will adding a second ADFS Web Application Proxy cause service disruption

    Today I have attempted to add a second ADFS WAP server to an existing (working) ADFS solution based on 2012 R2.
    I am able to install and configure the required role/services successfully but then I'm presented with the Remote Access Management console. This shows the two WAP servers but not the existing published application from the original WAP server and only seems
    to let me Publish a new application.
    I'm not sure if I should go ahead and run the Publish Application wizard again in case it impacts on the existing application and causes disruption to the service/users.
    Any suggestions would be much appreciated.
    Cheers for now
    Russell 

    the config for the Web Application Proxy is stored in the ADFS v3 configuration database.
    As soon as you add a new WAP to the farm it will get its config from the database
    WAP can be domain joined or not. The reason for having it be domain joined is if you need to manage the system centrally and you need to leverage Kerberos Constrained Delegation for Windows based apps
    If you have more than one WAP, you should use some kind of load balancing mechanism such as either Windows NLB or a hardware loadbalancer
    adding a new WAP should not impact, you just need to make sure it is actually used
    Cheers,
    Jorge de Almeida Pinto
    Principal Consultant | MVP Directory Services | IAM Technologies
    COMMUNITY...:
    DISCLAIMER: This post is provided "AS IS" with no warranties of any kind, either expressed or implied, and confers no rights! Always evaluate/test yourself before using/implementing this!

  • Added user as Farm Admin - still can't create a new Web Application

    What exactly does it take for someone (assuming through Central Admin) to be able to have enough permissions to create a new Web Application?
    I just added one of our developers as a Farm Admin, and the 'New' button is disabled for him, so he can't create a new Web Application.

    As I mentioned in my post.  To create a Web Application you need to be both a Farm Administrator and a local administrator on the server.  You said he was a farm admin.  Was he also a server admin on the server?
    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

  • Adding a WebService Client to a Web Application

    Hi, Everybody,
    I built a Bepl Module in which I had a ECHO WebService and the response parameter is a complex type.
    Then I built a Web application, and used the WSDL file to add a WebService Client to a this Web Application,
    but I found that the WebService Referrence dose not contain any method, so I could not add it in my jsp page.
    But when I changed the Response Message Part Type into a simple one, everything worked fine.
    *All the progress is the same as " [Using a Manually Created WSDL as a Web Service Client|https://open-esb.dev.java.net/kb/v2/javaeesetut.html] ", but change the simple type into complex type.*
    I want to know if the WebService Client Referrence dose not support generating java code which contains complex type or I had a wrong operation?
    thanks

    There are current limitations with the wsimport functionality and an issue has been logged.
    If you have a look at the blog entry from Andrew Hopkinson.....
    [http://blogs.sun.com/toxophily/entry/javacaps_tip_migrating_a_simple]
    ...you'll see part way down what the WSDL must look like to work with wsimport, i.e.....
    Message parts must be created using an Element rather than a specific type and the element must be defined in a local in-line schema.
    This in-line element can only contain a sequence with a single sub-element of a specific Complex Type.
    The name of the input element must be the same as the operation it will be used in.
    nillable element option should not be used because this will cause your strings to be returned as JAXBElements and not Strings.
    ...etc....
    Bit painful I know, but this is the only workaround until the bug is fixed.

  • Facing Problem while adding Azure Project to existing C# web application

    Hi,
    I have a web application with 5 projects under one Solution. I want to publish this web application on Windows Azure, for that I have tried to add Windows Azure Cloud Service Project but this option is not appear in option list. But when I create new web
    application add Windows Azure Cloud Service Project option appeared. I didn't understand why this happened. I have also tried to migrate old code to new project but having error
    " The type or namespace name 'DataAnnotations' does not exist in the namespace 'System.ComponentModel' (are you missing an assembly reference?)"
    If I add this dll then more than 18000 error occures like control not found(The name 'lnkbtnNew' does not exist in the current context).
    Please help me out, I am struggling since couple of days.
    Thanks in advance.

    Hi,
    Please try the following steps, see if it helps.
    1. create new azure cloud service project (it is better to choose the same version of .netframework with your web application );
    2. right click the solution, add your web application as Existing Project
    3. Right click on the “Roles” node in the Cloud Service project and select “Add | Web Role Project in solution…”
    Please try to set the “Copy Local” to “True” in order to avoid assembly missing issue, see more at:
    http://blogs.msdn.com/b/asiatech/archive/2013/01/09/how-to-resolve-the-could-not-load-file-or-assembly-issues-on-windows-azure-web-sites.aspx
    If this post doesn't give you help, please follow up with more detailed information.
    Best Regards,
    Jambor
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to Hide HTML code of web application (applet)?

    hi
    On web, while running application, if user open View\Source from browser, he can see all HTML code (base_jini.html). The problem is that we can't afford to show source code to client, because it has DB connection inf (username/password) as well. How this html code can be hide from client machine?
    I think, i convey my prblom. If not, please run any web application and try to see source code from browser view menu, U will see that all configuration details are visible including db password. I suppose there should be some way to hide these details to client.
    Please help in this regard, i will be very thankful
    regards
    Asif

    Forms Listener Servlet is just another way of setting up forms on the web. The main difference is instead of the client and the Forms runtime talking directly, they do so via the webserver. This means thay you only need to have one port opened in your firewalls (e.g. 80) instead of two (80 and 9000)
    Please read the paper I indicated and this will hopefully explain it all.
    As to the suggestion of using the LOGON built int - this would be a solution but you will have to consider if this is acceptable if you have more that one user since the person running the application would have to identify themselves in some way.
    The other option is do not add the username and password in teh HTML and the default logon dialog will appear.
    Regards
    Grant Ronald
    Forms Product Management

  • Help please! Java application and web application...

    Hi,
    I have a problem with inserting a java application (Main.java) in a web application(index.jsp).
    I found a source demo of a drag and drop application on the Internet, but now I want to
    have the drag and drop application work in a Jpanel/JFrame in a webapplication.
    The drag and drop application code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    public class Main {
        public static void main(final String[] args) {
            final ButtonGroup grp = new ButtonGroup();
            final JPanel palette = new JPanel(new FlowLayout(FlowLayout.LEFT));
            palette.setBorder(BorderFactory.createTitledBorder("Palette"));
            final MainPanel mainPanel = new MainPanel();
            mainPanel.setPalette(palette);
            for(int j=0; j<4; j++){
                final JToggleButton btn = new JToggleButton("Panel "+(j+1));
                palette.add(btn);
                grp.add(btn);
                btn.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        mainPanel.setAdding(btn.getText());
            final JFrame f = new JFrame("Drag and drop panels");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(palette, BorderLayout.WEST);
            f.getContentPane().add(mainPanel, BorderLayout.CENTER);
            f.setSize(800, 600);
            f.setVisible(true);
    class MainPanel extends JPanel implements MouseListener, MouseMotionListener {
        private JPanel palette;
        private String adding="";
        private SubPanel hitPanel;
        private int deltaX, deltaY, oldX, oldY;
        private final int TOL = 4;  //tolerance
        public MainPanel() {
            setLayout(null);
            addMouseListener(this);
            addMouseMotionListener(this);
        public void mousePressed(final MouseEvent e) {
            if( adding != "" ){
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                SubPanel sub = new SubPanel(adding);
                add(sub);
                sub.setSize(sub.getPreferredSize());
                sub.setLocation((int)e.getX(),(int)e.getY());
                revalidate();
                adding = "";
                return;
            Component c = getComponentAt(e.getPoint());
            if (c instanceof SubPanel) {
                hitPanel = (SubPanel) c;
                oldX = hitPanel.getX();
                oldY = hitPanel.getY();
                deltaX = e.getX() - oldX;
                deltaY = e.getY() - oldY;
                if( oldX < e.getX()-TOL ) oldX += hitPanel.getWidth();
                if( oldY < e.getY()-TOL ) oldY += hitPanel.getHeight();
        public void mouseDragged(final MouseEvent e) {
            if (hitPanel != null) {
                int xH = hitPanel.getX();
                int yH = hitPanel.getY();
                int xDiff = e.getX()-oldX;
                int yDiff = e.getY()-oldY;
                int cursorType = hitPanel.getCursor().getType();
                if( cursorType == Cursor.W_RESIZE_CURSOR){           //West resizing
                    hitPanel.setBounds( e.getX(), yH, hitPanel.getWidth() - xDiff, hitPanel.getHeight() );
                }else if( cursorType == Cursor.N_RESIZE_CURSOR){     //North resizing
                    hitPanel.setBounds( xH, e.getY(), hitPanel.getWidth(), hitPanel.getHeight() - yDiff );
                }else if( cursorType == Cursor.S_RESIZE_CURSOR){     //South resizing
                    hitPanel.setSize( hitPanel.getWidth(), hitPanel.getHeight() + yDiff );
                }else if( cursorType == Cursor.E_RESIZE_CURSOR){     //East resizing
                    hitPanel.setSize( hitPanel.getWidth() + xDiff, hitPanel.getHeight() );
                }else if( cursorType == Cursor.NW_RESIZE_CURSOR){     //NorthWest resizing
                    hitPanel.setBounds( e.getX(), e.getY(), hitPanel.getWidth() - xDiff, hitPanel.getHeight() - yDiff );
                }else if( cursorType == Cursor.NE_RESIZE_CURSOR){     //NorthEast resizing
                    hitPanel.setBounds( xH, e.getY(), hitPanel.getWidth() + xDiff, hitPanel.getHeight() - yDiff );
                }else if( cursorType == Cursor.SW_RESIZE_CURSOR){     //SouthWest resizing
                    hitPanel.setBounds( e.getX(), yH, hitPanel.getWidth() - xDiff, hitPanel.getHeight() + yDiff );
                }else if( cursorType == Cursor.SE_RESIZE_CURSOR){     //SouthEast resizing
                    hitPanel.setBounds( xH, yH, hitPanel.getWidth() + xDiff, hitPanel.getHeight() + yDiff );
                }else{      //moving subpanel
                    hitPanel.setLocation( e.getX()-deltaX, e.getY()-deltaY );
                oldX = e.getX();
                oldY = e.getY();
        public void mouseMoved(final MouseEvent e) {
            Component c = getComponentAt(e.getPoint());
            if (c instanceof SubPanel) {
                int x  = e.getX();
                int y  = e.getY();
                int xC = c.getX();
                int yC = c.getY();
                int w  = c.getWidth();
                int h  = c.getHeight();
                if(       y >= yC-TOL   && y <= yC+TOL && x >= xC-TOL   && x <= xC+TOL  ){
                    c.setCursor(new Cursor(Cursor.NW_RESIZE_CURSOR));
                }else if( y >= yC-TOL   && y <= yC+TOL && x >= xC-TOL+w && x <= xC+TOL+w ){
                    c.setCursor(new Cursor(Cursor.NE_RESIZE_CURSOR));
                }else if( y >= yC-TOL+h && y <= yC+TOL+h && x >= xC-TOL   && x <= xC+TOL ){
                    c.setCursor(new Cursor(Cursor.SW_RESIZE_CURSOR));
                }else if( y >= yC-TOL+h && y <= yC+TOL+h && x >= xC-TOL+w && x <= xC+TOL+w ){
                    c.setCursor(new Cursor(Cursor.SE_RESIZE_CURSOR));
                }else if( x >= xC-TOL   && x <= xC+TOL ){
                    c.setCursor(new Cursor(Cursor.W_RESIZE_CURSOR));
                }else if( y >= yC-TOL   && y <= yC+TOL ){
                    c.setCursor(new Cursor(Cursor.N_RESIZE_CURSOR));
                }else if( x >= xC-TOL+w && x <= xC+TOL+w ){
                    c.setCursor(new Cursor(Cursor.E_RESIZE_CURSOR));
                }else if( y >= yC-TOL+h && y <= yC+TOL+h ){
                    c.setCursor(new Cursor(Cursor.S_RESIZE_CURSOR));
                }else{
                    c.setCursor(new Cursor(Cursor.MOVE_CURSOR));
        public void mouseReleased(final MouseEvent e) { hitPanel = null; }
        public void mouseClicked(final MouseEvent e) {}
        public void mouseEntered(final MouseEvent e) {}
        public void mouseExited(final MouseEvent e) {}
        public void setAdding(final String string) {
            adding = string;
            setCursor(new Cursor(Cursor.HAND_CURSOR));
        public void setPalette(final JPanel panel) { palette = panel; }
    class SubPanel extends JPanel {
        public SubPanel(final String name) {
            setPreferredSize(new Dimension(100, 100));
            setBorder(new TitledBorder(new LineBorder(Color.BLACK), name));
    }This application works with JFrame, but I want to display the JFrame in a webapplication (JSP Page).
    I'm using Netbeans 6.0 (GlassFish) to create webapplication using Visual Web JavaServer Faces.
    So in summary:
    How can i display the drag and drop application into a JFrame (better in a JPanel) in a webapplication (index.jsp)??
    Hope you can help...
    Thanks in advance...
    Greetings,
    Rajsh

    So have an applet that opens a JFrame... JSP or not has nothing to do with it, since it's nothing but HTML the client gets.
    You can't have a JFrame embedded in an HTML page. And if you could have an applet but don't know how to get that copied code to fit inside (I mean, content pane is content pane), you might want to consider learning how to do that.

  • Problem in JSF with Swing in a web application

    hi
    i am using jsf for my online projects.my problem is that when i use Swing concept ,the server is closed automatically when i click the swing dialog option 'OK', how can i protect server being closed automatically when user click the the options of Swing dialog box.it is so tedious because my application is going to integrate
    with online server?
    my swing java file is
    * FileExistsDialog.java
    package com.obs.ftw.util.alert;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.Rectangle2D;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.plaf.metal.MetalLookAndFeel;
    * FileExistsDialog: A JOptionPane-like dialog that displays the message
    * that a file exists.
    public class FileExistsDialog extends JDialog {
    * The component that gets the focus when the window is first opened
    private Component initialFocusOwner = null;
    * Command string for replace action (e.g., a button).
    * This string is never presented to the user and should
    * not be internationalized.
    private String CMD_REPLACE = "OK"/*NOI18N*/;
    * Command string for a cancel action (e.g., a button).
    * This string is never presented to the user and should
    * not be internationalized.
    private String CMD_CANCEL = "CANCEL"/*NOI18N*/;
    // Components we need to access after initialization
    private JButton replaceButton = null;
    private JButton cancelButton = null;
    public FileExistsDialog(){
         System.out.println("INSIDE THE FILE EXIST DIALOG");
         JFrame frame = new JFrame() {
         public Dimension getPreferredSize() {
         return new Dimension(200,100);
         frame.setTitle("Debugging frame");
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.pack();
         frame.setVisible(false);
    FileExistsDialog dialog = new FileExistsDialog(frame, true);
         dialog.addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent event) {
         System.exit(0);
         public void windowClosed(WindowEvent event) {
         System.exit(0);
         dialog.pack();
         dialog.setVisible(true);
    * Creates a new FileExistsDialog
    * @param parent parent frame
    * @param modal modal flag
    public FileExistsDialog(Frame parent,boolean modal) {
    super(parent, modal);
         //initResources();
         System.out.println("INSIDE THE FILE EXIST DIALOG CONSTRUCTOR");
    initComponents();
    pack();
    * Determines the locale, loads resources
    /* public void initResources() {
         Locale locale = Locale.getDefault();
    resources = ResourceBundle.getBundle(
              "samples.resources.bundles.FileExistsDialogResources", locale);
    imagePath = resources.getString("images.path");
    }*/ // initResources()
    * Sets all of the buttons to be the same size. This is done
    * dynamically after the buttons are created, so that the layout
    * automatically adjusts to the locale-specific strings.
    private void equalizeButtonSizes() {
         System.out.println("INSIDE THE equalizeButtonSizes()");
    String[] labels = new String[] {
    replaceButton.getText(),
         cancelButton.getText()
         // Get the largest width and height
         Dimension maxSize= new Dimension(0,0);
         Rectangle2D textBounds = null;
         Dimension textSize = null;
    FontMetrics metrics =
              replaceButton.getFontMetrics(replaceButton.getFont());
         Graphics g = getGraphics();
         for (int i = 0; i < labels.length; ++i) {
         textBounds = metrics.getStringBounds(labels, g);
         maxSize.width =
         Math.max(maxSize.width, (int)textBounds.getWidth());
         maxSize.height =
         Math.max(maxSize.height, (int)textBounds.getHeight());
    Insets insets =
         replaceButton.getBorder().getBorderInsets(replaceButton);
    maxSize.width += insets.left + insets.right;
    maxSize.height += insets.top + insets.bottom;
    // reset preferred and maximum size since BoxLayout takes both
         // into account
    replaceButton.setPreferredSize((Dimension)maxSize.clone());
    cancelButton.setPreferredSize((Dimension)maxSize.clone());
    replaceButton.setMaximumSize((Dimension)maxSize.clone());
    cancelButton.setMaximumSize((Dimension)maxSize.clone());
    } // equalizeButtonSizes()
    * This method is called from within the constructor to
    * initialize the dialog.
    private void initComponents() {
         System.out.println("INSIDE THE initComponents()");
         // Configure the window, itself
    Container contents = getContentPane();
    contents.setLayout(new GridBagLayout ());
    GridBagConstraints constraints = null;
    setTitle("Waring");
         // accessibility - all applets, frames, and dialogs should
         // have descriptions
         this.getAccessibleContext().setAccessibleDescription("Descriptions");
         addWindowListener(new WindowAdapter() {
         public void windowOpened(WindowEvent event) {
              // For some reason the window opens with no focus owner,
              // so we need to force the issue
         if (initialFocusOwner != null) {
              initialFocusOwner.requestFocus();
              // Only do this the 1st time the window is opened
              initialFocusOwner = null;
         public void windowClosing(WindowEvent event) {
         System.out.println("INSIDE THE windowClosing");     
         // Treat it like a cancel
              windowAction(CMD_CANCEL);
         // image
    JLabel imageLabel = new JLabel();
    imageLabel.setIcon(
    new ImageIcon("/images/degraded_large.gif"));
    // accessibility - set name so that low vision users get a description
    imageLabel.getAccessibleContext().setAccessibleName("OK");
    constraints = new GridBagConstraints ();
    constraints.gridheight = 2;
    constraints.insets = new Insets(12, 33, 0, 0);
    constraints.anchor = GridBagConstraints.NORTHEAST;
    contents.add(imageLabel, constraints);
    // header
    JLabel headerLabel = new JLabel ();
    headerLabel.setText("SAMPLE");
    headerLabel.setForeground(
         new Color(MetalLookAndFeel.getBlack().getRGB()));
    constraints = new GridBagConstraints ();
    constraints.insets = new Insets(12, 12, 0, 11);
    constraints.anchor = GridBagConstraints.WEST;
    contents.add(headerLabel, constraints);
         // Actual text of the message
         JTextArea contentTextArea = new JTextArea();
    contentTextArea.setEditable(false);
    contentTextArea.setText("SAMPLE");
    contentTextArea.setBackground(
              new Color(MetalLookAndFeel.getControl().getRGB()));
    // accessibility -- every component that can have the
         // keyboard focus must have a name. This text area has no
         // label, so the name must be set explicitly (if it had a
         // label, the name would be pulled from the label).
    contentTextArea.getAccessibleContext().setAccessibleName(
              "CONTENTNAME");
    constraints = new GridBagConstraints ();
    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.insets = new Insets(0, 12, 0, 11);
    constraints.anchor = GridBagConstraints.WEST;
    contents.add(contentTextArea, constraints);
         // Buttons
         JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout (new BoxLayout(buttonPanel, 0));
         replaceButton = new JButton();
         replaceButton.setActionCommand(CMD_REPLACE);
    replaceButton.setText("OK");
    replaceButton.setToolTipText("TO OK");
         replaceButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent event) {
         windowAction(event);
    buttonPanel.add(replaceButton);
    // spacing
    buttonPanel.add(Box.createRigidArea(new Dimension(5,0)));
         cancelButton = new JButton();
         cancelButton.setActionCommand(CMD_CANCEL);
    cancelButton.setText("CANCEL");
    cancelButton.setNextFocusableComponent(replaceButton);
         cancelButton.setToolTipText("TO CANCEL");
         cancelButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent event) {
         windowAction(event);
    buttonPanel.add(cancelButton);
    constraints = new GridBagConstraints ();
    constraints.gridx = 1;
    constraints.gridy = 2;
    constraints.insets = new Insets(12, 12, 11, 11);
    constraints.anchor = GridBagConstraints.WEST;
    contents.add(buttonPanel, constraints);
         // Equalize the sizes of all the buttons
         equalizeButtonSizes();
         // For some reason, the dialog appears with no input focus.
         // We added a window listener above to force the issue
         initialFocusOwner = replaceButton;
    } // initComponents()
    * The user has selected an option. Here we close and dispose the dialog.
    * If actionCommand is an ActionEvent, getCommandString() is called,
    * otherwise toString() is used to get the action command.
    * @param actionCommand may be null
    private void windowAction(Object actionCommand) {
         System.out.println("INSIDE THE WINDOW ACTION");
         String cmd = null;
    if (actionCommand != null) {
         if (actionCommand instanceof ActionEvent) {
         cmd = ((ActionEvent)actionCommand).getActionCommand();
         } else {
         cmd = actionCommand.toString();
         if (cmd == null) {
         // do nothing
         } else if (cmd.equals(CMD_REPLACE)) {
         System.out.println("your replace code here...");
         } else if (cmd.equals(CMD_CANCEL)) {
         System.out.println("your cancel code here...");
         setVisible(false);
         dispose();
    } // windowAction()
    * This main() is provided for debugging purposes, to display a
    * sample dialog.
    // main()
    } // class FileExistsDialog
    and calling java function is
    public String fileDialog(){
         return "Success";
    public void processFile(ActionEvent event){
         System.out.println("INSIDE THE FILE DIALOG");
         FileExistsDialog file     = new FileExistsDialog();
         System.out.println("SUCCESS");
    called from
         <h:commandButton action="#{userLogin.fileDialog}" actionListener="#{userLogin.processFile}"></h:commandButton>
    pls help me as soon
    advance thanks
    rgds
    oasisdeserts

    Swing is GUI library for use in desktop applications.
    JSF is a web application framework which runs on an application server and is accessed by clients via web browsers.
    To fully understand what you have done, try accessing your application from a different machine than the server.
    To answer your question, don't invoke System.exit() if you would like the process to continue. But that is the least of your problems.

Maybe you are looking for

  • How to block a number from getting thru

    I have been getting spam calls and want to block that number - anyone know how to do that on a droid X

  • How do I get rid of the images taking up half the screen?

    Just got a Classic 160 and I love it EXCEPT for the fact that half the screen is taken up by a useless image. I want to use the full width of the screen for the title/artist, etc., So if I'm listening to a song from "The Skiffle Sessions: Live in Bel

  • Can't connect to MySQL from Oracle 11g R1

    Hello Oracle's guru. Sorry for my English it's not my native langauge Enviroments: Oracle 11g R1, Windows 7, ODBC Driver 5.1.8 I have a some problem with creation gateway to connection to MySQL, and I hope somebody can help me. So, 1) ODBC name - MYS

  • Interactive Report with additional search filters

    Hi all, I want to implement a functionality where I have an interactive report which comes with default Search / Filter option , but I also want to have additional filters which are drop-downs in this case and based on the values selected from the dr

  • Mapping a drive to a Microsoft Domained share or device

    Hi We have MAC's running OS 9.2 that we need to map a drive to a share on a Microsoft Domained LAN. Can anyone point me in the right direction as to how to do this? We know that this command works from OS 10.3 - cifs://windowsIP but it does not work