AWT/Swing in JSP

Can we use Abstract Window Toolkit(AWT) or Swing classes in JSP? If is it so, is it preferable to use those in jsp?
Details are welcome.
Thanks

Yes and no. It really depends what you are talking about. There is less than no point trying to run any of the AWT windowing stuff because you are not generating a Java front end you are generating an HTML front end. Java UI components would just not work in that context- the UI would only appear on the Server, not on the client side. Unless you wrote it as an applet, at which point it has nothing to do with jsp and becomes and applet programming question.
If you are talking about the image processing APIs then yes, I have used those and it was quite tricky because I was trying to run it on a server that did not have X windows running on it and AWT needs that to run properly.

Similar Messages

  • AWT/Swing gui flickering

    I am trying to add the swing JDesktopPane to java.awt.Frame .The JDesktopPane includes
    JInternalFrame.The problem is that the GUI is flickering when resized or moved.
    I migrated from jre1.4 to jre1.5 and the flickering of the JDesktopPane stops but the
    JInternalFrame is still flickering when resized/moved.I am wondering if at this point
    this is a AWT/Swing issue.

    Never ever mix AWT and Swing!At least not their components. :p ;)

  • Awt swing 1.1

    Hi,
    Where can I actually download AWT swing 1.1 package to run with jdk 1.1.?

    http://java.sun.com/products/archive/jfc/1.1.1/index.html

  • Swing and jsp

    hello world
    i have a projet web application with jsp. how integrate swing in jsp?
    thank you in advance

    hello world
    i have a projet web application with jsp. how
    integrate swing in jsp?
    thank you in advance1)You can Send a POST Request Using a URL
    http://www.javaalmanac.com/egs/java.net/Post.html
    2)You can get Text from the server
    http://www.javaalmanac.com/egs/java.net/ReadFromURL.html
    3)You can get Cookies
    http://www.javaalmanac.com/egs/java.net/GetCookies.html
    4)You can send cookies
    http://www.javaalmanac.com/egs/java.net/SendCookie.html
    5)You can view html pages using JEditorPane.
    also check
    http://www.javaalmanac.com/egs/java.net/pkg.html
    You need to write and handle everything

  • A new AWT/Swing?

    I have a question for the community.
    IMHO, and I am not alone, AWT/Swing have major flaws that really ought to be fixed. Probably, because the APIs themselves are seriously flawed, what is required is a replacement for Swing.
    How would one go about proposing such a thing and getting Sun's support?
    Specific issues:
    1) A set of specific design rules should be codified, which all conforming components, layout managers, UIs, etc., should obey. Along with the rules, there should be automated tests, so that it could be confirmed whether components, layout managers, UIs, etc., work correctly.
    Currently, Swing and 3rd party components often do not work well together, for reasons such as
    a) Highly irrational behavior of layout managers. Currently, none of the AWT/Swing layout managers behave in a reasonable way under all circumstances, with the possible exception of BorderLayout. Also, layout managers use constraints in inconsistent ways, and they are ill-suited to control by GUI builders.
    b) Failure to use minimumSize, preferredSize, and size consistently.
    c) Inconsistent use of UIs. What is the division of responsibility between the UI, layout managers, L&F, and the main class(es)?
    2) Software design rules. For example, there is currently at least one Swing class that alters its behavior depending on which container it is placed in. That violates basic principles of OO development. Perusing the AWT/Swing source code, you will find plenty of objectional coding practices. It seems that the pressure to maintain backwards compatibility has been a real impediment to "doing things right".
    3) Performance. AWT/Swing are notorious for various performance problems, including
    a) Non-linear CPU cost associated with building certain graphical data structures (combo-boxes, for one).
    b) Layout managers that call getMinimumSize or getPreferredSize on child components multiple times. Currently, the layout managers are the CPU bottleneck in many AWT/Swing GUIs.
    c) Some text components are almost unbelievably slow. Try scrolling a lot of text through a JTextArea and you will be disappointed.
    d) The current validation logic is extremely complex, inefficient, and undocumented. I count approximately 15 basic API methods that affect how and when components are repainted. I defy ANYONE to explain how it all works. The typical result is that repaints occur FAR more often than is necessary.
    A lot of optimization is required to fix these problems. That means automating tests, profiling, removing extra repaints, CPU bottlenecks, etc.
    4) Excessive complexity of the APIs. For example, it seems that building practical tables and trees is harder than it should be. The APIs are complex and documentation obscure or lacking in detail. Also, the separation between model and view is often tainted. It shouldn't be necessary to do so much conversion between model and view indices, for example. A basic set of model classes should be shared by all components that use underlying data models. These model classes should support standard functionality such as filtering, sorting, etc.
    5) No portable remote operation. Yes, I am familiar with SAWT (slow and buggy), and the possibility of using X11 remotely when the Java application is run on a *nix platform (slow over a high-latency network such as the Internet and unusable on Windows systems).  There does not seem to be a usable, universal solution.
    Yes, I am familiar with SWT. However, for a variety of reasons, I believe that the AWT approach is superior. SWT is more platform dependent and it has the X11 reverse-object-orientation in which child classes know about their parents. I have done some performance testing, which suggests that
    1) SWT layout managers are faster than their corresponding AWT/Swing managers
    2) Most other graphics, including 2D graphics, are faster in AWT/Swing than SWT.
    I am sure that SWT encapsulates some good ideas. However, it seems that if the efficiency of validation and layouts could be improved, then AWT/Swing performance would be excellent, while maintaining OO and platform-independent characteristics.
    Possibly, these issues could be worked out piecemeal. For example, a new, rational set of layout managers could be developed entirely independently.
    Other issues, such as defining how UIs, L&F, and component classes should be architected, are going to be more problematic. Creating order in the current chaos will be difficult.
    Any ideas?

    >
    How would one go about proposing such a thing and
    getting Sun's support?
    As for proposing such a thing, you can always become a member of the Java Community Process Program (it's free for individual members): http://www.jcp.org/en/home/index. As a member you can post a Java Specification Request with your suggestions. If you want to operate on a smaller scale you can report bugs to the bug database.
    As for getting Sun's support....well, good luck! :-)

  • Swing or JSP

    Iam making a application for my company which will be accessed by more than 300 centers all over country. So the GUI I would make should use JSP or SWING . What are the pros and cons of each. The application will be dealing Finance matters.So at client end SWING or JSP ?
    Plz Help me

    To give you a good answer I would need a lot more information, but right now it sounds like your best bet is to use JSP. Here are two enormous reasons why:
    1) You will not have to deploy any software at the client end - as long as they have a web browser they will be able to connect. They do not even need Java support. This has several related advantages, including that you will never have to deal with "updating" the clients - you can change the code on your end freely.
    2) The total amount of work you put into it is probably going to be a lot less. Since you are just using HTML and not writing a GUI proper, it will be a lot easier.
    The main reason you might discover that you do NOT want to use JSP is that it limits your functionality. For example, if you decide you need an interactive chat room you are going to end up coming back to Swing and deploying either an applet, Java Web Start app, or standalone application... unless you do not mind it being a really crappy chat room.
    Drake

  • Difference between AWT,Swing and swt

    Hello,
    I am giving a seminar about swing in which I need to point out differences between AWT,Swing and SWT(Software Widget Tool).
    I have two questions:
    1)I read that-A heavyweight component is one that is associated with its own native screen resource (commonly known as a peer). A lightweight component is one that "borrows" the screen resource of an ancestor-which makes it lighter.Can anybody explain What native screen resource is and how it is borrowed?
    2)I read that SWT uses native widgets and how can it be better than swing?If it is in what way?

    Use Swing for new projects. AWT is the rendering layer underneath Swing in many cases, and AWT provides utility things like Graphics. SWT is an alternative to Swing which used more native rendering, but actually with Java 6, Swing is using a lot of native rendering.
    Fire up NetBeans and use Matisse. Build an application. Run it under Windows, and then under Linux, and then realize how great it is.

  • Tutorial on AWT/Swing control flow

    Greetings all,
    Just wondering if any of you folks know of a good tutorial on AWT/Swing control flow? I'm doing some pretty complex stuff with a table whose editors call other windows and insert values into the table based on callback objects...weird stuff happening with loss of focus when the other windows come out, etc etc etc.
    I have it working via a series of what I consider kludges, but I would really like to implement it cleanly, and it's looking like that's going to require understanding <ugh> <grin>
    So it looks like it's time that I bit the bullet and got to grips with control flow in AWT/Swing. Is there a tutorial out there that could help me with this?
    Many TIA

    skiaddict1 wrote:
    Let's take your word for it, but if you have the slightest doubt please consider the subject: EDT violation is a classic here.OK sure, but I really don't think I'm violating it. I avoid multi-threading like the plague, and only introduced it for my report writer because I wanted to have a little window advising the user that the report was in the process of being written.Raise your left hand and swear this report writer is not running when you experience the problem you describe! >o(
    OK, this is just kidding, as per the rest of your description, it sounds reasonable now to assume that your problem is not related to EDT violation.
    I'm doing some pretty complex stuff with a table whose editors call other windows and insert values into the table based on callback objects...This summary is a bit worrying, and I thought you would mention problems in the display of the table being edited. But you seem to refer to problems in other windows, or did I misunderstand?
    Or do you mean, loss of focus in the editor still being edited? Can you please clarify what you do and what your problems are?
    In particular, what does the other windows come out mean?OK, I was trying to be sparse with details because I didn't think they were relevant.Actually the worrying seems all the more justified, now that you have described it more extensively: I was afraid that you would raise other windows while editing, and that's the case. I know little of focus though...
    I have a table in window A, one of whose columns has a custom editor which, when a cell in the column is double-clicked, registers itself with window B as a choice-listener (see later) then asks window B to come to the front. Window B, when the user performs a choice amongst the UI elements in there, fires a choice-event to its listener, i.e. the custom editor. At which point the editor saves away the chosen value (for use by getCellEditorValue()), sets the text in the cell appropriately, turns edit mode off via fireEditStopped(), and brings window A back to the front.
    (...) once the custom editor asks window B to come to the front, the table in window A loses focus and when it is brought back to the front, the table's JScrollPane seems to have the focus (visually, it has the focus rectangle around it). Pressing the Tab key has no effect on focus; you have to use the mouse to focus something.I assume you have read the tutorial on using tables in Swing.
    It contains an example where a custom editor is bringing up a dialog: http://download.oracle.com/javase/tutorial/uiswing/components/table.html#editor
    AFAIK, the example does not suffer from focus problems.
    What I am finding, and I reiterate this is new since I rewrote the windowing subsystem for the app (the custom editor was not changed in the rewrite), is that (...)Just what do you call "rewriting the windowing system" (just to rule out the possibility of something Ramboesque)?
    I have no idea why this loss of focus is occurring, and I am at a loss to begin to figure it out. As I wrote above, I have a series of kludges which gets around the symptoms, but I would really rather figure it out and fix it.OK I admit I cannot tell what happens exactly, but:
    1) instead of bringing window B to front, couldn't the editor bring up a dialog B (e.g. using JOptionPane.showXxxDialog() to bring up just the choice panel? The advantage is that it is more "synchronous", you can control when the window A's table model is updated.
    2) what worries me too is that you update the model of the table being edited while you're editing one cell of it? Would it be possible, and make sense in your case, to update this model later (that is, post the model update as an invokeLater(...) call)? I don't see how seeing the table updating underneath helps the user editing its cell, but you may have your reasons.
    What do you call flow control , or control flow in AWT/Swing?Basically, what I am after is something that will help me begin to understand/diagnose problems such as the above when they happen in my code. I am deeply averse to multi-threading (...) Things in my code were working, and that was enough for me.
    But the above behaviour, and another weird behaviour I was having last week, which again I have solved with what I consider a kludge, and again which only began with my new windowing subsystem, have caused me to realise that it's time I really got to grips with this issue.Yes, when they say beware of threads when using Swing , nobody tells to not use threads! Just to be aware of how special Swing is with regards to threads (at least, compared to AWT, that didn't make such warning).
    I would like, for example, to really deep-down understand exactly when listeners for AWT-Swing events get called. I don't really care so much when the events get put on the queue, but I do care when exactly my event handlers will be called. This will help me diagnose problems, I'm sure.Well they get called in the EDT, by some framework code that, in an infinite loop, does something along the lines of:
    - pop next event from the event queue
    - determine which is the target widget
    - let the widget transform the event and send it to all registered listeners
    Now with dialogs, things gets dimmer, because while a dialog is brought up (via a<tt>setVisible(true)</TT> call on the EDT, the EDT is indeed suspended, and a new event thread manages the events for the dialog).
    I'm sorry I have no reference for that behavior, and my description is certainly blurry (and possibly wrong), but I don't think your problem is so much related to threading as I initially thought.
    N.B.: Darryl's second link does features sequence diagrams that try to demonstrate what happen (in a specific example with asynchronous access, but you can derive the simpler, regular, working, from it).OK, yes I saw that diagram, I was offput by the asynchronicity but I will have another look tomorrow also. Thanks againDon't put too much hopes in there, indeed it's definitely not the kind of info I understand you're looking after.
    Much luck all the same, and feel free to come back with your findings, or with more questions, about the initial subject (reference on event flow) and the specific problem (your focus issues with the editor).
    I also cannot end this message without suggesting that you try to reproduce the problem with an SSCCE (http://sscce.org), that you could post here for us to try out. See this recent discussion about the multiple interests of this approach: {message:id=9587964}
    Best regards,
    J.

  • Swing in JSP

    Hi All,
    I am having a .jar (swing) application need to make it web-base by jsp.
    Does anybody have any idea how to display a swing application in jsp?
    Thanks & Regards
    Ritesh

    It depends what kind of interactivity you want. Another possibility is to use the swing/awt graphics stuff to build an image file. The JSP then uses an IMG tag with the source pointing to a servlet which builds the image.
    But it's essetial to understand that what a JSP does is to build an HTML page, which is delivered to the browser after the JSP has run. A JSP can't interact with the user. The user makes another, separate request to the server to move on.

  • Awt/swing class overview

    Hi,
    I have some questions about the general class structure of AWT and Swing:
    - How are AWT and Swing intended to work together -- should I treat AWT as an implementation detail and operate on Swing level only, or should they be used together?
    - What exactly is the purpose of the JComponent class, if there is already aws.Component?
    - Why is the GUI button class "JButton" a subclass of aws.Container? In what way is a button a container component?
    Thanks in advance.

    Hey, you really want to know all the details, do you?
    There is nothing wrong with mixing swing components and awt components, but there are some limitations.
    Read this nice article at the Swing Connection:
    http://java.sun.com/products/jfc/tsc/articles/mixing/index.html
    We need to sort some things out:
    AWT in general is not outdated.
    Swing builds on and extends AWT concepts (e.g. layout managers are part of the AWT package as is the Color class and many other features). It does not replace AWT.
    The only part of AWT that really is outdated are the heavyweight components like Button, CheckBox, ...
    All of these are replaced by lightweight Swing components (and many more components and features are added in Swing).
    Still the AWT components are frequently used in applets. That's because no browser has a recent Java version preconfigured. (Yet, If possible (like in intranet deployment) I would insist that users install recent version of Sun's Java plug-in, so that I can use swing features.)
    The only AWT components that are still used are Frame, Window and Dialog because the corresponding Swing components subclass them.
    Why do you think there is no root for components? All components subclass awt.Component and all Swing components (except for JFrame, JWindow, JDialog) subclass JComponent.
    Stephen

  • Swing or JSP/Struts application?

    I'm deploying an application for a public hospital in Argentina and i have doubts about the framework to use.
    The application will be used in very old computers (pentium I/II or older) but will count with a good server (bought specifically for this use).
    This limitation of hardware also has made me rethink the election of the framework of persistence. It would be appropriate to use hibernate?
    I'll appreciate if you can help me with this decisions.
    Adriana

    To give you a good answer I would need a lot more information, but right now it sounds like your best bet is to use JSP. Here are two enormous reasons why:
    1) You will not have to deploy any software at the client end - as long as they have a web browser they will be able to connect. They do not even need Java support. This has several related advantages, including that you will never have to deal with "updating" the clients - you can change the code on your end freely.
    2) The total amount of work you put into it is probably going to be a lot less. Since you are just using HTML and not writing a GUI proper, it will be a lot easier.
    The main reason you might discover that you do NOT want to use JSP is that it limits your functionality. For example, if you decide you need an interactive chat room you are going to end up coming back to Swing and deploying either an applet, Java Web Start app, or standalone application... unless you do not mind it being a really crappy chat room.
    Drake

  • Can i use swing under JSP?

    i have a JSP, now my question is, can I display swing components under JSP?

    A JSP is just a way to write HTML back to browser.
    It is a mix of HTML and java.
    A JSP is converted to a java source file, with code like:
    out.println(".... HTML code you wrote ...");In this way a java application writes back to the client browser on a page request.
    A totally different mechanism are either a java applet (embedded in an HTML page),
    or Java WebStart, which distributes entire java applications via the net.
    If you are familiar with Swing, or have an existing Swing application, or need a
    user friendly GUI, those are the ways.

  • Application UI Design using Swing or JSP

    I am in the Design phase of my first project. the technology involved is not defined and the team(of 2) is not sure what would be best to use. we got to work on a staging table. mostly updating it. one complete partition(can have as many as 100K rows) has to be displayed in the UI. once it is updated the effected rows need to be inserted/updated to another permanent table, both in Oracle.
    so in short, the GUI should allow sorting and filtering options to the user to work on the staging table records. I am not sure how JSP's will fit into this piture. the network traffic is a big concern here.
    we might go with Swing Jtable. will that be feasible for this kind of UI? also can this be implemented using MVC(can be struts?) or just Model 1 architecture should do?
    I thought of using hibernate for the ORM but the DBA told that the schema is a bit conplex to work with hibernate. so i might be using plain JDBC prepare statements.
    can anyone put some light based on there experience.
    suggestion and views are welcome!

    Triple-post:
    http://forum.java.sun.com/thread.jspa?threadID=5246519
    http://forum.java.sun.com/thread.jspa?threadID=5246518
    http://forum.java.sun.com/thread.jspa?threadID=5246520

  • Eclipse: transform normal awt/swing app to bean class?

    hi all.
    i have to modify an existing java app that's based on awt and swing. i'd like to edit in in visual editor for eclipse (java bean classes), but how can i do that? is it possible anyhow??
    thanks.
    j0sh

    i do have a visual editor plugin, but it uses "visual" classes, and now id like to know how to transform normal classes to visual classes... =)

  • TCL/Tk- Awt- Swing

    This is my first Java code. I am attempting to use Java for an applet
    that was originally in TCL/Tk. My first pass used just Awt. Now I have
    a Swing version.
    Linux 2.4.8-26mdk
    java version "1.4.0_02"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_02-b02)
    Java HotSpot(TM) Client VM (build 1.4.0_02-b02, mixed mode)
    appletviewer
    The Awt version works as I expect. The Swing version also works as
    expected except that the filled arc does not display correctly when
    the arc to be displayed is smaller than the previous one.
    AwtCircle.java:
    package org.emle.equipment;
    import java.applet.*;
    import java.awt.*;
    import javax.swing.*;
    public class AwtCircle extends Applet
      private int fractionDenominator;
      private double decimalValue;
      private Button dButtons[] = new Button[9];
      public void init ()
        fractionDenominator = 4;
        decimalValue = 1.0 / (double)fractionDenominator;
        Box dBox = Box.createHorizontalBox();
        for (int ii=2; ii<=8; ii++)
          dButtons[ii] = new Button("1/" + ii);
          dBox.add(dButtons[ii]);
        } this.add(dBox);
      public void paint(Graphics argG)
        argG.setColor(Color.white);
        argG.fillRect(0, 0, 500, 500);
        argG.setColor(Color.lightGray);
        argG.fillArc(100, 50, 100, 100, 0, (int)(decimalValue * 360.0));
      public boolean action(Event argE, Object argO)
        for (int ii=2; ii <= 8; ii++)
          if (argE.target == dButtons[ii])
            fractionDenominator = ii;
        decimalValue = 1.0 / (double)fractionDenominator;
        showStatus("1/" + fractionDenominator);
        paint (getGraphics());
        return true;
    SwingCircle.java:
    package org.emle.equipment;
    public class SwingCircle extends javax.swing.JApplet
      implements java.awt.event.ActionListener
      private int fractionDenominator;
      private double decimalValue;
      private java.awt.Button dButtons[] = new java.awt.Button[9];
      public void init ()
        fractionDenominator = 4;
        decimalValue = 1.0 / (double)fractionDenominator;
        javax.swing.Box dBox = javax.swing.Box.createHorizontalBox();
        for (int ii=2; ii<=8; ii++)
          dButtons[ii] = new java.awt.Button("1/" + ii);
          dBox.add(dButtons[ii]);
          dButtons[ii].addActionListener(this);
        } getContentPane().add(dBox,java.awt.BorderLayout.SOUTH);
      public void paint(java.awt.Graphics argG)
        argG.setColor(java.awt.Color.white);
        argG.drawRect(0, 0, getSize().width - 1, getSize().height - 1);
        argG.setColor(java.awt.Color.lightGray);
        argG.fillArc(100, 50, 100, 100, 0, (int)(decimalValue * 360.0));
        dButtons[fractionDenominator].requestFocus();
      public void actionPerformed(java.awt.event.ActionEvent argE)
        String cmd = argE.getActionCommand();
        for (int ii=2; ii <= 8; ii++)
          if (dButtons[ii].getActionCommand().equals(cmd))
            fractionDenominator = ii;
        decimalValue = 1.0 / (double)fractionDenominator;
        showStatus("1/" + fractionDenominator);
        paint(getGraphics());
        return;
    C.W.Holeman II
    [email protected] http://MistyMountain.org/~cwhii
    Remove the fives Send spam to [email protected]

    Cimi has made tcl/tk-cvs packages.
    http://bbs.archlinux.org/viewtopic.php? … light=cimi

Maybe you are looking for

  • Digital Security - What do You Think?

    Here's a thought: what if we used our own digits (ie 'fingers') to make up the digits of our passcode? So, while it's possible that the hacker may find one or two of our prints, they are very unlikely to find all five of them, and to guess the length

  • Domain name quick question

    if i upload my site using the iweb FTP client will it show just the domain name that i bought from someone else or is it going to include other things? like i want it to be just www.domainname.com and not web.me.com/Firstname_lastname/www.domainname.

  • CD importing problems

    I have loaded hundreds of CDs into iTunes. Did the diagnostics ok and have clean CDs, minor scratches play fine. Why does a few CDs refuse to load ?

  • B2B-51507 An Error was reported from a Javascript rule

    Hi All, I am not able to process EDI dat file with validate option enabled at the agreement level. Please see the below error message, please suggest! <?xml version="1.0" encoding="UTF-8" ?><ns1:Exception xmlns:ns1="http://integration.oracle.com/B2B/

  • Are logic boards interchangeable - such as the 3 early 2005 power mac  comp

    Hello all, I have another question similar to the one about whether or not different cases can be interchanged. My "new" question is this: Are the 3 "early 2005" Power Mac logic boards interchangeable? In other words, could one use a dual 2.0 or 2.3