SWING or AWT

Hi, i'm new in Java. I need to develop an application and i need to make some forms.
What API should i use? AWT or SWING. What are the differences betwen these two?
I would appreciate if somebody could give me more info or a link about this topic.
Regards, thanks everybody.

olivarespablo,
It's a long story, but here's the gist: AWT was Java's original drawing library. While AWT stands for "Abstract Windowing Toolkit," it was joked of as the "Awkward Windowing Toolkit" for its less-than-desired GUI abilities. Also AWT widgets were based on widgets native to each platform, and were designed as a thin layer over native widgets. This thin layer was supposed to provide the "abstraction" that would allow cross platform GUI building.
It turned out in practice that this abstraction layer was often difficult to implement, and restricted designers to whatever was common among different platforms. Hence, the Java 1.2 release included an all-Java GUI widget library called "Swing".
Here's where things stand: only AWT is supported natively by most browsers; thus, if you want to build applets, AWT is your choice. Browsers can run Swing applets, but that usually requires that the Swing Browser Plugin, and that's something you can't guarantee a user will have.
If you're writing a desktop application, Swing would be your natural choice.
For more info, see this page:
http://java.sun.com/docs/books/tutorial/uiswing/
That's the Swing tutorial. The bottom of the page contains a link to the old AWT tutorial.
Also search the 'Net for more articles--you'll likely need to read more than just the tutorials above to get a solid overview of how the pieces fit together.
--A                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Shall i use Swing or AWT for creating a chessboard applet??

    Hi,
    I need to build an applet which should dislpay a chessboard where i should
    be able to move the pieces around, read in a game analysis, etc...
    I am a beginner and i would like some advice on if i should use swing or awt?
    Which one is it easier to work with in terms of dispaying the pieces, moving the pieces and achieving other more challenging functionalities?
    Is it good idea to mix both of them? i.e have a japplet and use a canvas for displaying the board??
    Any advice would be much obliged.

    I used to think AWT
    And someone told me Swing was better..and that all of the Drag-n-Drop stuff doesn't work well with AWT.
    I have to admit that I used AWT up until a project about 3 months ago--I liked it better, but Swing does seem to have more builtins for handling the things you would need to for the Chess Board. Not that you CAN'T do them with AWT, but that they are harder to do with AWT.
    As far as reading in game analysis, etc..that really is independent of Swing/AWT

  • Need  java code to perform refresh button action using swings and awt

    i need java code to perform refresh button action using swings and awt.please help me

    Wait ! Noboby ? OK, I'll do it
    public void onBtnAction ()
        if (!fresh)
            refresh ();
    }Seriously, did you expect anyone to answer such a cryptic question ?

  • Quick practical question: swing vs. awt

    Hi,
    I have an app/applet w/ a fairly simple calculator-type gui. But I want it to run well even on old Pentiums. How much will it matter if I use swing or awt, in terms of performance of the app, ie. user response to gui input? Is it really noticeable?
    Does the system resource usage differ as well even while there is no user input?
    TIA,
    Reggie

    In my experience swing often performs better than awt does, as far as memory and speed...
    Swing can't run in IE without a plugin tho, so consider that before you start switching

  • Swing vs AWT (which should I learn?)

    I am writting an mp3 player in Java. I am fairly new to Java as all I know is the programming language; I do not know how to make a GUI. I want to make a cross platform mp3 player that should run on mac, windows and Linux. I also want to use some custom buttons made in Photoshop.
    Should I invest time in learning Swing or AWT?
    Thank you for your help.

    Hello,
    this depends on how far You intend to go with "customizing". Swing leaves a few things to the Operating System e.g. Windows or Linux. My swing apps look different under Linux than they do under Windows, because the Frame in which these apps are are drawn is administered by the OP System. On the other hand if customizing means for example changing the java cup icon upper left or changing the Title of the frame, then You will have no problems. More generally spoken: nearly everything can be done as long as You stay with the possibilities You have (Buttons, TextField, Bars ... have a look at the Swing Platfrom !).

  • Is it possible to use events for objects that do not use swing or awt

    Dear Experts
    I want to know if events are possible with plain java objects. A simple class that is capable of firing an event and another simple class that can receive that event. My question is
    1. If it is possible - then what is the approach that needs to be taken and would appreciate an example.
    2. Is Observer Pattern in java going to help?
    To explain further i am doing [Add,Modify,Delete,Traverse] Data tutorial using swing in Net beans. I have a ButtonState Manager class that enables and disables buttons according to a given situation. For example if add is clicked the modify button becomes Save and another becomes Cancel. The other buttons are disabled. What i want is the ButtonStateManager class to do a little further - i.e. if Save is clicked it should report to DBClass that it has to save the current record which was just added. I am foxed how this can be done or what is the right way. Thanks for reading a long message. Appreciate your help.
    Best regards

    Thanks Kayaman
    i guess i am doing something else maybe it is crazy but i need to work further i guess... i cant post the entire code as it is too big but some snippets
    public class DatabaseApplication extends javax.swing.JFrame {
        ButtonStateManager bsm;
        /** Creates new form DatabaseApplication */
        public DatabaseApplication() {
            initComponents();
            // ButtonStateManager has a HUGE constructor that takes all the buttons as argument!
            bsm = new ButtonStateManager(
                    btnAdd,
                    btnModify,
                    btnDelete,
                    btnQuit,
                    btnMoveNext,
                    btnMovePrevious,
                    btnMoveLast,
                    btnMoveFirst );One of the methods in the ButtonStateManager Class is as follows
      private void modifyButtonState()
            btnAdd.setText("Save");
            btnModify.setEnabled(false);
            btnDelete.setText("Cancel");
            btnQuit.setEnabled(false);
            ...Finally the Crazy way i was trying to do ... using EXCEPTIONS!
      void modifyClicked() throws DBAction
            if(btnModify.getText().equalsIgnoreCase("MODIFY"))
                modifyButtonState();
            else
                throw new DBAction("SaveAddedRecord");
        }And Finally how i was Tackling exceptions....
      private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {                                      
          try {
                bsm.addClicked();
            } catch (Exception e1) {
                processDBAction(e1.getMessage());
        private void processDBAction(String msg)
            if(msg.equalsIgnoreCase("SAVEMODIFIEDRECORD"))
                System.err.println(msg);
                bsm.normalButtonState();
            }Edited by: standman on Mar 30, 2011 4:51 PM

  • Running the Swing or AWT code in the UNIX

    I have developed the code to modify the XML attribute values using Java. Those attribute values are accepted from the GUI which i have designed using swings as well as AWT.
    The code is perfectly working in the DOS/Windows environment. The applet/Display is perfectly popping up and accepting the data and it is making the required changes in the XML and creating the new XML.
    But the problem i am facing is,
    I compiled the same code in UNIX and then run the code. But it threw the exception as below. Can anyone help me out for this. What i need to do in order to run that code successfully??.
    bash-3.00$ java GUIAjay
    No X11 DISPLAY variable was set, but this program performed an operation which requires it.
    at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:159)
    at java.awt.Window.<init>(Window.java:407)
    at java.awt.Frame.<init>(Frame.java:402)
    at javax.swing.JFrame.<init>(JFrame.java:207)
    at GUIAjay.<init>(GUIAjay.java:44)
    at GUIAjay.main(GUIAjay.java:39)
    I tried to set the X11 window server as:
    export DISPLAY=10.5.21.117:0
    But yet the User Interface is not popping up in the UNIX??.
    May be the problem is because GUI is not supported in UNIX.. So please suggest me on this..

    *Don't post general Java questions here*

  • Is there an internet browser component in swing or awt?

    Im developing an internet browser using swing, is there any component or that?

    If you just need to open a url you can use
    java.awt.Desktop.getDesktop().open(...);
    should check first if desktop is present and OPEN is supported, otherwise there are some snippet you can google that search/launch a browser based on OS.
    If you need to integrate a browser in your app, as far as I know, SWT makes it easier.
    Bye.

  • Should I compare SWT to Swing or AWT?

    I am currently doing my dissertation on ways to speed up a Java GUI. Obviously I am comparing the SWT (Eclipse project) to Swing and not really focusing on the AWT (Sun dont seem to be?!). I am interested in looking at how you could create a Swing interface that could compete with the speed of the SWT? I am also looking at the feature set of each and hopefully going to conclude, which is the better widget toolkit, for a highly performant GUI with respect to speed and features?
    Any facts (& opinions :-) would be more than welcome!
    - Simon

    I tried the "panel.paint(Canvas.getGraphics());". However, I still don't have anything printed. My code is as follows.
    JFrame frame = new JFrame("FrameDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setPreferredSize(new Dimension(300, 200));
    jp = new JPanel();
    jp.setPreferredSize(new Dimension(300, 200));
    gpc = MyPlotCanvas.createPlotCanvas();
    Canvas c = gpc.getGraphicsCanvas();
    jp.paint( c.getGraphics() );
    frame.add(jp);
    frame.setSize(600, 500);
    frame.show();

  • Swing vs AWT

    Why and when should you use one over the other?

    Does anyone use AWT visual components anymore?I guess that's more like what I'm asking. Graphics is
    AWT, yes? Meaning things like drawRect, drawLine,
    setFont are also AWT. Although I'm guessing there are
    swing counterparts to those.AWT is low level stuff ([java.awt.]Graphics, Image)
    AWT is a select of imate manupilation tools (BufferedImage, ImageFilter)
    AWT is a heavy weight Windowing Toolkit
    Swing is a light weight windowing toolkit, build on top of AWT (the low level stuff, and four (or so) "heavy weight" components (namely Window, Frame Dialog and Container).

  • How to create a semi circuler slider using java swing or awt

    I am trying to create a Jslider like thing but in semicirculer shape. Thanks in advance for providing any help.

    Is it possible to create such UI in java swing?Just to further illustrate, Swing only provides the raw foundation you need to be able to build a GUI. With the stock components you can create static user interfaces with standard controls. If you want to go further, you need to either find a component that somebody else already wrote, or you go into custom painting as previous posters suggested. To do an animating component for example, you would need all the frames as BufferedImage objects and you would combine custom painting with a Swing timer to update the displayed frame at a specified framerate.
    if you search for "java swing animation" using google, I'm sure you can find the examples you need. And here is the trail about swing timers:
    http://java.sun.com/docs/books/tutorial/uiswing/misc/timer.html

  • Swing vs awt speed?

    I want to make some not fancy but fast frontends for some console programs , so which toolkit should i use?
    the only important factor is speed, which one is faster?

    I'm told AWT is faster. I have yet to see anything but a game where it mattered.

  • Swing Vs. Awt question

    this link http://www.jguru.com/faq/view.jsp?EID=106026
    mentions on feature at the end of the article that
    "If you're not very careful when programming, it can be slower than AWT (all components are drawn) "
    What is means. I mean what kind of carefulness he is talking about?
    I have JApplet and Jframe used heavily and looks like it's kind of slow.
    I am thinking to change it to awt based.
    Any advise
    thnks

    I don't know what that means either. But I do notice that it was written nearly seven years ago. Things that were said seven years ago about Java performance are totally useless today, so don't pay any attention to that.

  • Swing layout + awt paintcomponent issue

    Hi guys
    I have a small issue while creating my very first application, or better, creating its GUI.
    i would like to insert in a jpanel three JTextFields on top of the panel where the user could eventually enter data, once the data are entered, a paintComponent displays the results beneath it using graphics, with simple drawLine from the paintComponent method.
    The problem is that i dont succeed to design a "good looking" panel where i can combine the organized layout of the fields and the space left for the lines of the paintcomponent method
    i can enter the fields and the lines like this:
    //contstructor definition
    add(field10);
    add(field2);
    add(field3);
    //eof constructor definition
    public void paintComponent(Graphics g){
    g.drawString("ciao"20,20);
    }but i cannot do this...
    //contructor definition
    setLayout(new GridLayout(3,2));
    add(field10);
    add(field2);
    add(field3);
    //eof constructor definition
    public void paintComponent(Graphics g){
    g.drawString("ciao"20,20);
    }because the GridLayout will occupy the whole panel and the size of the fields will be huge, so that there will be no space left for the paintComponents.
    What i would like to do is to let the GridLayout to occupy only the upper part of the JPanel so that the part below could be left to graphic content.
    I hope it sounds clear.
    Thank you
    Take care
    Edited by: classboy on Sep 8, 2009 9:28 PM

    One of the keys to understanding use of layout managers with Java is that they can be nested. More accurately, you can next Components and have each one use its own layout manager. One solution to your problem is to have a main JPanel use a BorderLayout, then add another JPanel, say called textFieldPanel that uses GridLayout and holds the three JTextFields. This panel can be added to the main panel BorderLayout.SOUTH or .NORTH, depending on your preference, and then have a third JPanel a drawingPanel that overrides paintComponent and displays the graphics, and add this to the main JPanel BorderLayout.CENTER.
    The iterations possible here are close to endless.
    Much luck.

  • Creating a Table (not SWING or AWT)

    Hello Everyone,
    I'm trying to come up with a design to create a table grid in pure java that will be displayed on my web page. This is a 2-dimensional table that will have rows and columns. The data for each cell is retrieved from a mySQL table.
    Here's where it gets sticky. The users of my web page can enter a product number. Based on that number I'm returning a combination of sizes and colors for that product. To populate the table I need to call 3 different tables.
    My first table is SIZE
    My second table is COLOR
    My third table is DETAILS
    The DETAILS table has two fields: Color and Size. If the Color and Size field match up against the COLOR and SIZE tables then create a cell for that combination.
    Here's the logic I've come up with so far:
    Loop through SIZE.
    Loop through COLOR.
    Loop through DETAILS.
    if color and size field of table DETAILS equals the size or color of the table SIZE and COLOR then create a new cell.
    It should look something like this:
    Hello Everyone,
    I'm trying to come up with a design to create a table grid in pure java that will be displayed on my web page. This is a 2-dimensional table that will have rows and columns. The data for each cell is retrieved from a mySQL table.
    Here's where it gets sticky. The users of my web page can enter a product number. Based on that number I'm returning a combination of sizes and colors for that product. To populate the table I need to call 3 different tables.
    My first table is SIZE
    My second table is COLOR
    My third table is DETAILS
    The DETAILS table has two fields: Color and Size. If the Color and Size field match up against the COLOR and SIZE tables then create a cell for that combination.
    Here's the logic I've come up with so far:
    Loop through SIZE.
    Loop through COLOR.
    Loop through DETAILS.
    if color and size field of table DETAILS equals the size or color of the table SIZE and COLOR then create a new cell.
    It should look something like this:
    � ����������� Small Medium Large
    Black | � � ok � � ok � ��� <blank>
    Blue � | � � ok � � <blank> � � ok
    Red � | � � ok � � <blank>��<blank>
    I created 3 different Java classes. The classes are Table, Row, Cell. The Table class has a bean setter/getter array: private Row[] rowDetails; The Row class has setter/getter details about each individual cell: private Cell[] sizes; The Cell class holds the details like quantityAvailable. I'm struggling with this one on the logic and how to loop through each element.
    I think this is the right approach but I'm not sure. I was hoping that someone can help me out with the logic.
    Thank you!!

    Sorry, the formatting for the table came out pooly.
    The headers are the size and on the left side it should be the color. an OK means that a combination exists and a <blank> means that there's no such combination. In that case I should skip over the cell and proceed to the next one.
    Small Medium Large
    Black | ok ok <blank>
    Blue | ok <blank> ok
    Red | ok ok ok

Maybe you are looking for