≡ Menu

Java UI (User Interface)

One aspect that I haven’t touched on yet is Java UI (User Interface). I left this topic out of all the previous tutorials on purpose, because I think it’s one of Java’s weak points. If you’re reading this and you disagree, then that’s great, I’d love to hear your thoughts on the positive aspects of Java UI, please leave them in the comments section at the end of this post.

First of all, what is a User Interface?

You may have noticed that, so far, there has been no real “interaction” between you and the code you’ve been writing. All that happens is you say “Run as Java Application” and then your code may output something into the console. But then your program ends and that’s it! There hasn’t been any real interaction with you while the program is running. This is where a User Interface becomes really crucial.

An example of a User Interface is a window (or dialog) that displays a form on your screen. This form has fields for you to fill out, like username and password. You have the ability to type in your username/password combination, then hit a “submit” button, and then the program will spring to life and verify that your username/password is indeed correct. THIS interaction is made possible by a User Interface.

Why do I think Java UI is weak?

I have two main reasons why I dislike Java UI in general:

  1. It’s not very pretty
  2. It’s confusing

I realize these two reasons aren’t the most compelling reasons for disliking all things Java UI, but it was compelling enough for me and every one of my University computer science friends to use something else! Plus when it comes down to it, most applications you use on a daily basis are NOT using Java UI… that’s because they’re either web applications (like Facebook or Kijiji) or just built on some other products (like Visual Studio).

If you would like to see a sample of what this Java UI is all about, here’s a tutorial that covers one of the methods for creating a UI. This framework is known as Swing:

Another UI tool is called AWT or Abstract Window Toolkit and Sun has a pretty comprehensive tutorial:

What UI should I use then?

Well here’s where it gets a bit tricky. You see I am a web application developer, and therefore I do almost all of my work for web applications. So I am very comfortable using the web as my Graphical User Interface. In order to do this yourself, you’ll have to learn how to use webpages as your UI. This is where HTML comes in!

What is HTML?

HTML stands for Hyper Text Markup Language, and all it does is define a language that allows you to talk to internet browsers (like Internet Explorer, Google Chrome or Firefox). If you understand “how to program with HTML”, then you can create some great user interfaces for your audience… well… so long as you’re also good at knowing what a good website looks like. If you’re like me, most programmers aren’t designers! I may know how to code, but to make a website LOOK good may take me just as long as creating all of the functionality for the website!

HTML is nowhere near as complex or difficult as Java programming and it’s MUCH easier to get started with creating your first webpage using HTML than creating your first Java program. So no worries ladies and gentlemen, with my guidance, you could be an HTML rock star in a few weeks!

In any case I don’t want to start teaching HTML just yet, as I want to focus on Java. My goal for this blog is to eventually grow this tutorial series to a point where you could build your own web application. This would mean you’ll eventually be learning some HTML, so stay with me on this journey guys!

{ 7 comments… add one }

  • Reddy November 24, 2014, 2:19 pm

    The “Next” button on https://howtoprogramwithjava.com/java-ui/ takes me back to the “exceptions” page.

  • Ramesh-X December 27, 2015, 8:26 am

    I agree with you when you say that java UI is not very pretty.. But as I see it is not confusing. It is organized very well so that anyone can override what they want and create a completely different UI soon. But it also looks ugly..

  • Borislav Stoilov February 29, 2016, 6:02 am

    I totally agree with you about Java UI being ugly. Java was not created to be used as a UI language, but in my opinion JFrame is important part of java and should not be skipped so lightly.
    There are many java programs with JFrame base UI (like eclipse).
    Also I sometimes use the java ui for small projects, because its lightweight and you don’t need any third party libraries or frameworks ( or even servers some times ).

  • Sridevi October 31, 2016, 8:12 am

    Very nice article. I recently learned basics of Java. I am planning to learn Java UI and your article kind of helped me to decide if I should proceed or not. Thanks.

  • kawther Ateeq December 27, 2016, 10:16 am

    thanks a lot your article is very unique and i had fun to learn here in your website
    Regards kawther.

  • Htun January 12, 2017, 8:57 pm


Leave a Comment