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

Similar Messages

  • How to fire an event  with a non-AWT/Swing class?

    Hi, Everybody,
    I have an object that parse an XML file. When I meet an element with the value "true", I would like to fire an event, for instance a KeyEvent, just like a special key is pressed.
    Could you provide me an example?
    Thanks.
    Youbin

    use the firepropertychange methods as you do in beans.
    iam giving an eg.
    class abc
        MyListener lis;
        addMyListener(MyListener lis)
            this.lis = lis;
        abc()
            lis.fireEvent(new MyEvent("Class Instantiated"));
    class MyEvent extends EventObject
        String e;
        MyEvent(Object src)
            super(src);
        MyEvent(String e)
            this.e = e;
    interface MyListener
        public void fireMyEvent(MyEvent e);
    }You can use this methedology.Any class implementing MyListener will the be notified of the event and your class abc can now generate events wherever it wants just like i fired an event during initialization.
    you can also use observable/observer to achieve the same.

  • 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.

  • 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! :-)

  • URGENT!! I can not see swing classes -:((((

    I am using Plug-In 1.3 and JRE but I do not see the swing classes.
    In addition there is an error InstantiationException when I use other applet with AWT.
    Microsoft (R) VM for Java, 5.0 Release 5.0.0.3234
    ==============================================
    ? help
    c clear
    f run finalizers
    g garbage collect
    m memory usage
    q quit
    t thread list
    ==============================================
    java.lang.ClassNotFoundException: javax.swing.JApplet
         at com/ms/vm/loader/URLClassLoader.loadClass
         at java/lang/ClassLoader.loadClassInternal
         at java/lang/ClassLoader.resolveClass
         at com/ms/vm/loader/URLClassLoader.loadClass
         at com/ms/vm/loader/URLClassLoader.loadClass
         at com/ms/applet/AppletPanel.processSentEvent
         at com/ms/applet/AppletPanel.processSentEvent
         at com/ms/applet/AppletPanel.run
         at java/lang/Thread.run

    Thank you very much for your answers, but although it seems that it has found swing classes without putting anything in the classpath, it continue giving me problems. I think both error are because I am using database classes, shoud I put this classes in the classpath???? How??????
    Java(TM) Plug-in: Version 1.3.1
    Using JRE version 1.3.1 Java HotSpot(TM) Client VM
    User home directory = C:\Documents and Settings\IRENE
    Proxy Configuration: Browser Proxy Configuration
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    q: hide console
    s: dump system properties
    t: dump thread list
    x: clear classloader cache
    0-5: set trace level to <n>
    java.lang.NoClassDefFoundError: symantec/itools/db/beans/binding/QueryNavigator
         at java.lang.Class.newInstance0(Native Method)
         at java.lang.Class.newInstance(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)
    java.lang.NoClassDefFoundError: symantec/itools/db/beans/binding/ParentInvalidRecordException
         at Prueba.<init>(Prueba.java:59)
         at java.lang.Class.newInstance0(Native Method)
         at java.lang.Class.newInstance(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)

  • 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

  • How can I use java swing class in JSP page design

    I am a new developer in Java server pages. I want to use layout managers available in java swing classes to design the page. Can any body suggest me a way to do this.Is it possible if I do it with servelets.

    So, you want to use layout managers within your JSPs?
    The immediate answer is that "it isn't a good idea". The more considered answer is "tell us what you're up to".
    Are you coding all presentation within a traditional JSP? That is, HTML, customer or library tags and/java scriptlets?
    Or are you building your HTML within your servlets and sending that back to the browser?
    If the first, then you are probably better off either using explicit HTML tables (or the equivalent custom tags) or finding a library that you can use.
    If the second, you can write classes similar to the Swing layout managers that end up being a fancy way of putting elements into an HTML table. We have exactly that in my current environment. I wouldn't recommend rolling your own and I'd tend to leave all that presentation stuff to the JSP.
    In any case, you can't really use the Swing layout managers as they are for an entirely different pradigm.

  • Add swing classes to the jeode, is that legal?

    Hi All,
    I already know that the jeode not support Swing 1.1.1 but my question is: Is it legitimate to add some swing classes to the jeode, that are relevant to my project , that will be kind of part of he jeode on my PDA (i know how to do this!) .
    i repeat i know how to integrate those calss with the yours jvm (jeode)and it is working good.
    Thanks Sendy.

    Hi!
    Can you tell me how to add some swing classes to the jeode? I put "swingall.jar" on the PDA and i've got an warning: "warning: running version 1.1... " and does not work.
    Thank�s!

  • IE02 not able to display class overview & measuring point/counter tab,

    Hi Dear,
    I am not able to display class overview & Measuring point/counter tab in T-code IE02.
    But it is display in IE01 & IE03.
    Kindly suggest

    Mayursinh Dayatar,
    Its probably an authorisation issue.
    Are there any error messages??
    PeteA

  • Can't find Swing classes

    I'm running RH8, but quite new to linux, so it's possible I just don't have something set up right. I downloaded and installed the rpm for J2SE 1.4.1, which I believe is supposed to include Swing, right? Then I typed in the first example out of my book, which happens to use a couple of the Swing classes, and I get the following errors when I try to compile it:
    [root@rissa HelloJava]# javac HelloJava1.java
    HelloJava1.java:2: Superclass `javax.swing.JComponent' of class `HelloJava1'
    found.
    public class HelloJava1 extends javax.swing.JComponent
    ^
    HelloJava1.java:6: Type `javax.swing.JFrame' not found in the declaration of
    local variable `f'.
    javax.swing.JFrame f = new javax.swing.JFrame("HelloJava1");
    ^
    2 errors
    Anyone have any ideas what's up with my install?
    Lisa

    So what do I set where to make this work?As you said you need to set your path variable. How
    that is done depends on the shell that you are
    running.
    But if I just add the j2sdk/bin to my paths, it still uses the one in /usr/bin by default. How do I keep it from using that one? Obviously, I can't take /usr/bin out of my path, since I'll need other stuff in that directory.
    >>
    Also, even if I am running 1.3.1, shouldn't Swingwork
    anyway? The book I'm using is actually written for
    1.3, so anything in it ought to work no matterwhich
    copy I'm actually using, I would think.
    That is correct. You can try the following to verify
    whether a class is found or not.
    java javax.swing.JComponent
    If you run the above if it does not find the class
    then you will get a class not found exception. If it
    finds it then you will get an error that says that
    'main' was not found.
    Trying this under both versions gives me different exceptions in thread "main". I'm not even sure where it should be looking for the classes, let alone where it is looking for them, or for that matter, if they're even there to find.
    Response in 1.3.1:
    Exception in thread "main" java.lang.NoClassDefFoundError: javax.swing.JComponen
    t
    at 0x4028115f: java.lang.Throwable.Throwable(java.lang.String) (/usr/lib/libg
    cj.so.3)
    at 0x4027408e: java.lang.Error.Error(java.lang.String) (/usr/lib/libgcj.so.3)
    at 0x40275b1a: java.lang.LinkageError.LinkageError(java.lang.String) (/usr/li
    b/libgcj.so.3)
    at 0x40276f76: java.lang.NoClassDefFoundError.NoClassDefFoundError(java.lang.
    String) (/usr/lib/libgcj.so.3)
    at 0x402c60f9: gnu.gcj.runtime.FirstThread.run() (/usr/lib/libgcj.so.3)
    at 0x40267fdc: JvThreadRun(java.lang.Thread) (/usr/lib/libgcj.so.3)
    at 0x4023478c: JvRunMain(java.lang.Class, byte const, int, byte const, bool
    ean) (/usr/lib/libgcj.so.3)
    at 0x08048900: ?? (??:0)
    at 0x420158d4: ?? (??:0)
    at 0x080486c1: ?? (??:0)
    Response in 1.4.1_02:
    Exception in thread "main" java.lang.NoSuchMethodError: main
    You are not setting the CLASSPATH correct?Correct, although I did briefly try that as well, out of desparation, but it seemed to have no effect on anything.
    Lisa

  • Question : Save AWT Image Class to File..

    I Have a Question.. @.@a
    I'm doing AWT transform now..
    Well...
    I have a problem..
    I want to save AWT Image class to file..
    But.. I don't now that..
    Input Image Class same below..
    Image imageContent = (Image)attachment.getContent();
    How does it save imageContent Image class to file..?

    I had the same problem... convert it to a BufferedImage (http://forum.java.sun.com/thread.jspa?threadID=665744&tstart=15), then use javax.imageio.ImageIO.write to save it to a file.

  • Batch input on IE02  "Class type" popup when class overview - but why??

    Hi guys!
    Usually when i go to IE02, i access "class overview" and there i see directly the Classification of this equipment, also i can edit it.
    BUT:
    As soon i use a Batch input on IE02, it brings up an additional popup when i click "class overview". The popup "Class type"? - i don't understand why i get this popup only when using a Batch input...
    Can i avoid this popup somehow in the batch input?
    thanks

    >
    shashi jha wrote:
    > This is mandatory field about which the sap is searching for the data
    >
    Hi!
    But when i access IE02 without a batch input, this popup does not appear!
    Edited by: Thomas Roithmeier on Mar 24, 2009 12:46 PM

  • Swing Class to send encoded url??

    Can a normal Java Swing class( NOT a SERVLET) able to use the
    javax.servlet.http.HttpServletRequest methods?
    Explaination:
    1). The user enters a handphone number into a textfield
    2). Then clicks on the "Send" button.
    3). The ActionListener of the "Send" button will retrieve the handphone number from above, performs some database retrieval.
    4). Encode a static url together with the handphone number, message and sender number.
    5). Create a HttpServletRequest and uses the sendRedirect(encodedURL) to the WWW.
    In Addition Info
    This Swing class will be running all the while
    The host computer has 24*7 internet connection
    Is it possible to do it in Java Swing?

    Can a normal Java Swing class( NOT a SERVLET) able to use the
    javax.servlet.http.HttpServletRequest methods?No, Swing cannot directly call request methods. But url may be encoded by other means.
    5). Create a HttpServletRequest and uses the sendRedirect(encodedURL) to the WWW.You may need to make Applet-Servlet/JSP communication.
    Thanks
    Hafizur Rahman
    SCJP

  • Should I extend swing classes from Oracle JDK

    While attempting to use Swing classes, I'm not sure where to entend from. I've seen some examples on Oracle's site which uses swing classes extended from JDeveloper's customized JDK DCaf. Is that the place where I should extend from? If so, where can I see the reference for those classes?
    Thanks for your help.

    Of course, one way to add a little bit of protection for yourself is to quote the part of the message that is relevant. Then the only one that can edit the quoted part, is you. A bit like that ;)
    Andrew Thompson wrote:
    we have lazy moderatorsMore seriously:
    Andrew Thompson wrote:
    we have community moderators that can ...Mods can also edit other's posts, such as discussed here: {thread:id=1246269}
    However I doubt they would be able or willing to do so on a large-scale.
    And I'm not sure they can retrieve a posts history to know which of the contenders lies.

Maybe you are looking for

  • ADF from JDeveloper 10.1.2 not compatible with iAS 9.0.1

    Hi, We developed an ADF Application with JDeveloper 10.1.2 and we use the ADF interMedia domains (e.g. oracle.ord.im.OrdDocDomain). The application runs fine in JDeveloper, but doesn't run on our iAS 9.0.4.1. We get the following exception: java.lang

  • Syncing contacts/calendars of 2 phones on 1 computer [win XP]

    My wife and I recently got iphones (yay!!). However, we only have on computer at home running outlook 2007 and every time we sync contacts/calendars we get all of each others info. I tried creating groups in outlook, but they are not showing up in it

  • Text als data for charts

    Hey there, I'm new to numbers so excuse me if my question might have a very simple and obvious answer, but I've been trying to make this work now for about an hour or so and just can't come up with a solution, so here's my problem: I have a column in

  • Can't shut down after going on line

    After going on line I am unable to shut down the computer without using the power button. If I start up and don't go on line I am able to shut down with no problem. I have even redone my internet connection. Have a dial up connection. I have done a c

  • Powerbook G4... 10.5.5 OSX , Itouch5 and Itunes Compatibility.

    My son has a Powerbook G4 , 10.5.8 OSX and a Itouch 5.  what are my options as far as Itunes and his ability to purchase music and sync his music library with his Itouch5?