Jump to content

SWT vs. Swing - Debate?

- - - - -

  • Please log in to reply
3 replies to this topic

#1
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas
I was just curious what GUI API people use. Feel free to elaborate on why you chose the one you use.

I personally use Swing. Even though SWT uses native controls, which I like, I find the code is less cumbersome to write with Swing. Does anybody share that view? (Maybe it's just because Swing was what I learned in college, and I'm a creature of habit.) Plus, I just like NetBeans too much to switch to Eclipse. :)

Edit: Obviously, this question is intended for the Java developers. :)
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.

– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#2
lor

lor

    Programming Goddess

  • Members
  • PipPipPipPipPipPipPip
  • 884 posts
Swing. Don't really have a reason, used it in Netbeans also.


#3
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
Swing, once you get the hang of it, it's not all that hard.
And as you mentioned, I don't want to change from IntelliJ to eclipse for it.

Ever tried creating a Swing gui like this?

     JFrame frame = new JFrame(){{

         add( new JPanel(){{

               add( new JLabel("Hey there"){{ 

                    setBackground(Color.black);

                    setForeground( Color.white);

                }});


                add( new JButton("Ok"){{

                    addActionListener( new ActionListener(){

                        public void actionPerformed( ActionEvent ae ){

                            System.out.println("Button pushed");

                        }

                     });

                 }});

        }});

    }};

For small GUIs like this example it does look pretty good in terms of readability.
Possible performance impact, but if it's for a Gui that gets created once I don't really care.

Now, after reading your blog, I think for more userfriendlyness the SWT can be nice because the users may feel more comfortable.

SWT has the downside of being dependant on 32 or 64 bit, And these days the computers are shifting between the 2.
So you'll need support for both (SWT 32bit library clashes with JVM 64 bit and vica versa), which will require some extra coding.
Swing doesn't have this problem.

Edited by wim DC, 02 April 2011 - 01:58 AM.


#4
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas

Quote

Now, after reading your blog, I think for more userfriendlyness the SWT can be nice because the users may feel more comfortable.

As for making the users feel more comfortable, I completely see your point, however, I feel I can achieve the same thing in Swing with just a little bit of work fine tuning things. It just takes a little bit of elbow grease to make a really good GUI, and you can't be a lazy programmer. It's certainly possible to make a bad GUI no matter what API you use, so I look at it as more of how the programmer applies his or her chosen API.

Quote

Ever tried creating a Swing gui like this?

I'll admit, that one threw me for a loop! Kinda clever. Almost as if you're coding in the functional paradigm rather than procedural. I like it. Probably wouldn't use it much, though.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.

– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users