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();

Similar Messages

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

  • 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

  • SWT vs SWING

    Anyone here can help me decide about what�s the better enivoronmente to develope low-consumption resource app, SWT or SWING.
    I have some desktop ERP application developed with SWING but i have poor results (responsiveness talking).
    Also we have here some old HW (32 MB RAM, Pentium) and it�s hard to run this app.
    Can anyone here tall me where can i get some advices to improve it.
    Thanks a lot, in advance.

    SWT would be faster. For an example, check out the Eclipse Project.

  • 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

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

  • 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

  • How to embed SWT to swings

    I have found information regarding how to embed Swings in SWT.
    But i have to embed Swt browser in swings
    Please see the links for examples:
    http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/Bringupabrowser.htm
    http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/EmbedSwingandAWTinSWT.htm
    I have to show two browsers in same window which i have partially done by embeding swings in swt. but need the otherway.
    Here is that code:
    import java.awt.Color;
    import java.awt.Frame;
    import java.awt.Panel;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JPanel;
    import javax.swing.JSeparator;
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.awt.SWT_AWT;
    import org.eclipse.swt.browser.Browser;
    import org.eclipse.swt.browser.LocationEvent;
    import org.eclipse.swt.browser.LocationListener;
    import org.eclipse.swt.browser.ProgressEvent;
    import org.eclipse.swt.browser.ProgressListener;
    import org.eclipse.swt.browser.StatusTextEvent;
    import org.eclipse.swt.browser.StatusTextListener;
    import org.eclipse.swt.layout.GridData;
    import org.eclipse.swt.layout.GridLayout;
    import org.eclipse.swt.widgets.Composite;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Event;
    import org.eclipse.swt.widgets.Label;
    import org.eclipse.swt.widgets.Listener;
    import org.eclipse.swt.widgets.ProgressBar;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Text;
    import org.eclipse.swt.widgets.ToolBar;
    import org.eclipse.swt.widgets.ToolItem;
    import com.jgoodies.forms.layout.CellConstraints;
    import com.jgoodies.forms.layout.FormLayout;
    public class BringUpBrowser {
    public static void main(String[] args) {
         BringUpBrowser browser= new BringUpBrowser();
         browser.showBrowser();
    public void showBrowser(){
    Display display = new Display();
    final Shell shell = new Shell(display);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    shell.setLayout(gridLayout);
    shell.setMaximized(true);
    final Browser browser1 = new Browser(shell, SWT.NONE);
    GridData data1 = new GridData();
    data1.horizontalAlignment = GridData.FILL;
    data1.verticalAlignment = GridData.FILL;
    data1.horizontalSpan = 3;
    data1.grabExcessHorizontalSpace = true;
    data1.grabExcessVerticalSpace = true;
    browser1.setLayoutData(data1);
    browser1.setUrl("www.indussoftware.com");
    ToolBar toolbar = new ToolBar(shell, SWT.NONE);
    ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH);
    itemBack.setText("Back");
    ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH);
    itemForward.setText("Forward");
    ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH);
    itemStop.setText("Stop");
    ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH);
    itemRefresh.setText("Refresh");
    ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH);
    itemGo.setText("Go");
    GridData data = new GridData();
    data.horizontalSpan = 3;
    toolbar.setLayoutData(data);
    Label labelAddress = new Label(shell, SWT.NONE);
    labelAddress.setText("Address");
    final Text location = new Text(shell, SWT.BORDER);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.horizontalSpan = 2;
    data.grabExcessHorizontalSpace = true;
    location.setLayoutData(data);
    final Browser browser = new Browser(shell, SWT.NONE);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.FILL;
    data.horizontalSpan = 3;
    data.grabExcessHorizontalSpace = true;
    data.grabExcessVerticalSpace = true;
    browser.setLayoutData(data);
    final Label status = new Label(shell, SWT.NONE);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    status.setLayoutData(data);
    final ProgressBar progressBar = new ProgressBar(shell, SWT.NONE);
    data = new GridData();
    data.horizontalAlignment = GridData.END;
    progressBar.setLayoutData(data);
    Composite composite = new Composite(shell, SWT.EMBEDDED);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.CENTER;
    data.horizontalSpan = 3;
    composite.setLayoutData(data);
    Frame frame = SWT_AWT.new_Frame(composite);
    JPanel panel = new JPanel();
    panel.setLayout(new FormLayout("0:grow(0.4),0:grow(0.2),0:grow(0.4)","5dlu,5dlu,16dlu"));
    frame.add(panel);
    CellConstraints cc = new CellConstraints();
    JButton button = new JButton("Close");
    panel.add(new JSeparator(),cc.xyw(1, 1, 3));
    panel.add(button,cc.xy(2, 3));
    button.addActionListener(new ActionListener(){
              public void actionPerformed(ActionEvent e) {
                   //this = null;
    //end of chakri
    /* event handling */
    Listener listener = new Listener() {
    public void handleEvent(Event event) {
    ToolItem item = (ToolItem) event.widget;
    String string = item.getText();
    if (string.equals("Back"))
    browser.back();
    else if (string.equals("Forward"))
    browser.forward();
    else if (string.equals("Stop"))
    browser.stop();
    else if (string.equals("Refresh"))
    browser.refresh();
    else if (string.equals("Go"))
    browser.setUrl(location.getText());
    browser.addProgressListener(new ProgressListener() {
    public void changed(ProgressEvent event) {
    if (event.total == 0)
    return;
    int ratio = event.current * 100 / event.total;
    progressBar.setSelection(ratio);
    public void completed(ProgressEvent event) {
    progressBar.setSelection(0);
    browser.addStatusTextListener(new StatusTextListener() {
    public void changed(StatusTextEvent event) {
    status.setText(event.text);
    browser.addLocationListener(new LocationListener() {
    public void changed(LocationEvent event) {
    if (event.top)
    location.setText(event.location);
    public void changing(LocationEvent event) {
    itemBack.addListener(SWT.Selection, listener);
    itemForward.addListener(SWT.Selection, listener);
    itemStop.addListener(SWT.Selection, listener);
    itemRefresh.addListener(SWT.Selection, listener);
    itemGo.addListener(SWT.Selection, listener);
    location.addListener(SWT.DefaultSelection, new Listener() {
    public void handleEvent(Event e) {
    browser.setUrl(location.getText());
    shell.open();
    browser.setUrl("http://google.co.in");
    while (!shell.isDisposed()) {
    if (!display.readAndDispatch())
    display.sleep();
    display.dispose();
    Here Iam facing problems while adding Listeners.
    Can u help me in this?

    GANGINENI wrote:
    hi i developed a program for timer in applet, i want to include it in to jFrame, can some one help me,i am developing program in netbeansYes.
    1) ....
    h1. Edit:
    in light of camickr's note, I am deleting my post. The original poster is now on my DNH list and will remain there until his behavior changes.
    Edited by: Encephalopathic on Oct 31, 2008 2:20 PM

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

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

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

  • Which Time variable should use compare this month with last month

    We want to calculate the increaed number of employees according to one action reason e.g. Entry to company compare with last month. In this case we have to use time variable in BEx query designer. Now can see 0calmonth has serval variable available.
    1) Should we use [0CMLMON] for last month and use offset for this month like [0CMLMON]-1 or [0CMLMON]+1 or use variable [0RSTTCM1], which variable should we use for this month and last month? Do we need to create variables by manually?
    2) Then using calculated KF to calculate the increaed number of employees, is this logic correct? If it is wrong, please info.
    Edited by: hi ni on Apr 22, 2008 7:58 AM

    Hi,
    For the comparison of last 2 months data, you can use two Restricted Key figures with reference to 0CALMONTH and it is better to use only customer exit variable for both RKF's.For the Last month use offset value as -1.
    Rgs,
    I.R.K

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

  • How should I compare internet socket addresses?

    I'm having my first go at rudimentary network programming. I need to compare two network addresses. What seems to me to be a general way of doing this is
    struct sockaddr a, b;
    a.sa_family == b.sa_family && a.sa_data == b.sa_data;
    1. Is this The Right Way?
    2. Is there some standard method that abbreviates this? Something like
    struct sockaddr a, b;
    sa_cmp(a, b);
    While I'm at it, is there some standard ready-made method that, given an adress family (e.g. AF_INET) will return the only matching protocol family (e.g. PF_INET)? Is it absolutely safe to use them interchangeably? mpd does this
    switch (addrp->sa_family) {
    #ifdef HAVE_TCP
    case AF_INET:
    pf = PF_INET;
    break;
    #ifdef HAVE_IPV6
    case AF_INET6:
    pf = PF_INET6;
    break;
    #endif
    #endif /* HAVE_TCP */
    #ifdef HAVE_UN
    case AF_UNIX:
    pf = PF_UNIX;
    break;
    #endif /* HAVE_UN */
    default:
    FATAL("unknown address family: %i\n", addrp->sa_family);
    should I do it too?
    Last edited by peets (2008-06-28 05:10:32)

    sa_family_t sa_family Address family.
    char sa_data[] Socket address (variable-length data).
    (at least) On this machine :
    /usr/include/bits/sockaddr.h:
    typedef unsigned short int sa_family_t;
    While I'm at it, is there some standard ready-made method that, given an adress family (e.g. AF_INET) will return the only matching protocol family (e.g. PF_INET)? Is it absolutely safe to use them interchangeably?
    I don't know if it is absolutely safe [i.e. portable]. I believe on Linux AF_* = (corresponding) PF_*. i.e.: #define AF_INET PF_INET etc. (/usr/include/bits/socket.h)
    should I do it too?
    Well, you've said this is rudimentary stuff you're trying to do. Are you using IPV6 ? If not, perhaps stick to ipv4 and use sockaddr_in ? Also, write for the operating system(s) You use for now rather than try to be portable as far as C net programming goes.
    Last edited by sniffles (2008-06-28 07:33:22)

Maybe you are looking for

  • Function Code can not be selected

    Dear expert, Please help me, there is a uploader For MIGO, USer is uploading data using this uploader, Sometimes when user try to upload data, he gets a message on status BAR: Function cannot be selected, When i Double Click on that Message i Get Fol

  • Airplay no longer works with iTunes

    Airplay no longer works with iTunes 10.6; try to stream to speakers connected to Airplay device--use to work fine. Now, in iTunes, the icon in the bottom corner actually says 2 speakers, as it should, but when I open it it only shows speakers connect

  • Help! Safari and trojan? How do I identify and get rid of it?

    Please help me understand and get rid of this-your expertise sincerly appreciated! I posted about this problem a couple of weeks ago, but got no response. I seem to have a trojan attached to Safari (my analysis). It delays or stops loading of all pag

  • FreeBSD guest on Oracle VM Server 2.1.2

    Hi everybody, I'm new to using Oracle VM. Has anyone sucessfully got a FreeBSD guest to work on the server? Thanks. Sean

  • How can i print calender in colours instead of black and white

    I use various colours for my calenders put when I print them out they all appear as black and white. Can any one help me or can it be done. Thanks