9 Replies - 7894 Views - Last Post: 16 June 2010 - 04:28 AM Rate Topic: -----

#1 harmy01   User is offline

  • D.I.C Head
  • member icon

Reputation: 15
  • View blog
  • Posts: 179
  • Joined: 15-June 10

Starting to learn GUI

Posted 15 June 2010 - 11:38 PM

Hello friends,

I am currently studying computer science in my local university. This semester we covered programming one (paper), which covers loops method, objects, and so on with Bluej (basic java, i assume?). so programming two begins in one month which will cover GUI and inheritance using netbean. I was hoping to get headstart by reading books about GUI/inheritance, but struggled to find any on Google/amazon.com.

my question is "What did you first study to learn GUI/inheritance, does using netbeans help??
Note: I have absolutely no experience using GUI/inheritance)

NETBEANS experience: i have been trying to design a calculator using netbeans and guess what? i find it really challenging using it, most of the thing don't work cording to plan.

Thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: Starting to learn GUI

#2 YasuoDancez   User is offline

  • D.I.C Head

Reputation: 20
  • View blog
  • Posts: 135
  • Joined: 30-September 09

Re: Starting to learn GUI

Posted 15 June 2010 - 11:55 PM

I would rather get underneath the coding for GUI and do the coding instead of the GUI Builder that NetBeans has.

I started learning GUIs from youtube videos and www.vtc.com a course named Java Graphics.
I also started reading from some other books I have like Dietel and Dietel How To Program and another Book i forget the name of now ( didn't use for that long ), and O'Reilly Java Swing.
Was This Post Helpful? 3
  • +
  • -

#3 harmy01   User is offline

  • D.I.C Head
  • member icon

Reputation: 15
  • View blog
  • Posts: 179
  • Joined: 15-June 10

Re: Starting to learn GUI

Posted 16 June 2010 - 12:19 AM

Thanks for the reply buddy:). more opinions welcome :)
Was This Post Helpful? 0
  • +
  • -

#4 YasuoDancez   User is offline

  • D.I.C Head

Reputation: 20
  • View blog
  • Posts: 135
  • Joined: 30-September 09

Re: Starting to learn GUI

Posted 16 June 2010 - 12:33 AM

You're welcome.
Was This Post Helpful? 0
  • +
  • -

#5 xor-logic   User is offline

  • HAL9000 was an Apple product
  • member icon

Reputation: 128
  • View blog
  • Posts: 767
  • Joined: 04-February 10

Re: Starting to learn GUI

Posted 16 June 2010 - 01:36 AM

I have no experience using netbeans, but program-generated UIs... ugh. Actually the same goes for ANY computer-generated code. WHY use it? I've had to maintain some such code at work, and I wanted to punch babies after about an hour of it.

If you want to learn to program, learn to program.

I personally learned most of my GUI skills from Sams Teach Yourself Java in 21 Days (although it's really become something like a year as I do it in my free time, and I have precious little of that). Also, I've heard really good things about Head First Java, and I in fact got my grubby paws on a digital copy of it and it seems like a great way to learn (I believe they cover GUIs pretty early on). I'd recommend the latter book - it seems like they're actually interested in helping you learn the stuff, and they do a good job of teaching it. The first book I mentioned (Sam's), while very detailed in parts, is less suited to learning than it is as a reference book, to be left on the shelf until info is needed on a very particular subject.
Was This Post Helpful? 2
  • +
  • -

#6 bcranger   User is offline

  • D.I.C Lover
  • member icon

Reputation: 253
  • View blog
  • Posts: 1,199
  • Joined: 01-February 10

Re: Starting to learn GUI

Posted 16 June 2010 - 02:02 AM

I learned Java last year in AP Computer Science but we did not cover GUIs as it was not on the AP exam...

So I decided to learn it by myself. I used the Tutorial(Trails) found on http://java.sun.com/...torial/uiswing/, java's official website. To me, I think that guide on Swing is the best tutorial you can come across. I know there's lots of books, etc but the Trails give you examples (toonnnnnsss of them) and really good explanations.

Really I think you should get Javax Swing down packed before you start using Netbeans. I tried using NetBeans, its quicker in some aspects and easier to position objects but I personally prefer writing the code myself as NetBeans doesn't float my boat.

BTW DONT USE AWT FOR GUI, USE JAVAX SWING.

For inheritance, the Java website also has a nice tutorial on that at: http://java.sun.com/...heritance.html.

Personally, I didn't use that tutorial since our computer class covered it in class. In class, we used the GridWorld case study as our primary tool for understanding inheritance. GridWorld is a case study (originally Marine Biology) that CollegeBoard has developed to help AP Computer students better understand inheritance and polymorphism. If you really want to work with inheritance hands on and have some fun, you can go to http://www.collegebo...sci_a/case.html and download the GridWorld material. GridWorld also introduces you to GUI aspects in a way; you basically move objects(actors) around on a grid and make modifications to actors. Later you will implement inheritance yourself by extending classes such as Bug and Critter. Lastly, CollegeBoard offers GridWorld case study questions which are quite beneficial if you want to test your knowledge of GridWorld (and inheritance/polymorphism).

But really, you should stick to programming from scratch before you start using NetBeans. Besides, you want to know how to do GUIs the good old fashioned way ;)

If your getting into GUI, you might also want to look up EventListeners. ActionListeners perform the action that you want when you click a button, for instance. MouseListeners, KeyListeners, etc are some others which you may find useful.

I have some sample GUIs that I can post if you need, its got comments for the code explaning what everything does. But if you look at Java's official tutorials, you should get it down pretty good. And one more thing, write a LOT of code if you want to really make it stick in your head. Make a TicTacToe game or a simple Banking Application with GUI to help you remember better.

If you need any more help, feel free to leave a comment =)
Was This Post Helpful? 3
  • +
  • -

#7 harmy01   User is offline

  • D.I.C Head
  • member icon

Reputation: 15
  • View blog
  • Posts: 179
  • Joined: 15-June 10

Re: Starting to learn GUI

Posted 16 June 2010 - 03:48 AM

Ah! everything seems to fall into my brain now, thank you both for replying. I've got some valuable information to work with. @bcranger yes i'd love to see your GUI design please post :)

Thanks again!
Was This Post Helpful? 0
  • +
  • -

#8 m-e-g-a-z   User is offline

  • Winning
  • member icon


Reputation: 497
  • View blog
  • Posts: 1,457
  • Joined: 19-October 09

Re: Starting to learn GUI

Posted 16 June 2010 - 03:56 AM

Remember there are GUI tutorials on here :) like this one here.
Was This Post Helpful? 0
  • +
  • -

#9 bcranger   User is offline

  • D.I.C Lover
  • member icon

Reputation: 253
  • View blog
  • Posts: 1,199
  • Joined: 01-February 10

Re: Starting to learn GUI

Posted 16 June 2010 - 04:01 AM

This is your basic GUI

import javax.swing.*;

// This is your basic GUI

public class BasicGUI extends JFrame
{
 
  // GUI constructor
  public BasicGUI()
  {
    // a menubar
    JMenuBar menuBar = new JMenuBar();
    // makes this default menubar
    setJMenuBar(menuBar);
    
    // a menu
    JMenu file = new JMenu("File");
    // add menu to menubar
    menuBar.add(file);
    
    // a menuItem
    JMenuItem exit = new JMenuItem("Exit");
    // add menu item to menu
    file.add(exit);
    
    // almost always the same; allows user to press "X" for closing
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // sets size(width, height)
    setSize(200,200);
    // sets location (x,y)
    setLocation(200,200);
    // makes the frame visible
    setVisible(true);
  }
  
  public static void main(String[] args)
  {
    // create an instance of your GUI
    BasicGUI program = new BasicGUI();
  }
  
}



Remember, all menu items, buttons, etc need action listeners

public class GUI extends JFrame implements ActionListener



add action listeners to components
JMenuItem exit = new JMenuItem("Exit");
exit.setActionCommand("Exit");
exit.addActionListener(this);



you need an action listener method

public void actionPerformed(ActionEvent e)
{
  String c = e.getActionCommand();

  if(c.equals(...))
{
.....
}
}



Oh and for actionlisteners

import java.awt.event.*;
import java.awt.*;
Was This Post Helpful? 0
  • +
  • -

#10 YasuoDancez   User is offline

  • D.I.C Head

Reputation: 20
  • View blog
  • Posts: 135
  • Joined: 30-September 09

Re: Starting to learn GUI

Posted 16 June 2010 - 04:28 AM

View Postbcranger, on 16 June 2010 - 01:02 AM, said:

I learned Java last year in AP Computer Science but we did not cover GUIs as it was not on the AP exam...

So I decided to learn it by myself. I used the Tutorial(Trails) found on http://java.sun.com/...torial/uiswing/, java's official website. To me, I think that guide on Swing is the best tutorial you can come across. I know there's lots of books, etc but the Trails give you examples (toonnnnnsss of them) and really good explanations.

Really I think you should get Javax Swing down packed before you start using Netbeans. I tried using NetBeans, its quicker in some aspects and easier to position objects but I personally prefer writing the code myself as NetBeans doesn't float my boat.

BTW DONT USE AWT FOR GUI, USE JAVAX SWING.

For inheritance, the Java website also has a nice tutorial on that at: http://java.sun.com/...heritance.html.

Personally, I didn't use that tutorial since our computer class covered it in class. In class, we used the GridWorld case study as our primary tool for understanding inheritance. GridWorld is a case study (originally Marine Biology) that CollegeBoard has developed to help AP Computer students better understand inheritance and polymorphism. If you really want to work with inheritance hands on and have some fun, you can go to http://www.collegebo...sci_a/case.html and download the GridWorld material. GridWorld also introduces you to GUI aspects in a way; you basically move objects(actors) around on a grid and make modifications to actors. Later you will implement inheritance yourself by extending classes such as Bug and Critter. Lastly, CollegeBoard offers GridWorld case study questions which are quite beneficial if you want to test your knowledge of GridWorld (and inheritance/polymorphism).

But really, you should stick to programming from scratch before you start using NetBeans. Besides, you want to know how to do GUIs the good old fashioned way ;)

If your getting into GUI, you might also want to look up EventListeners. ActionListeners perform the action that you want when you click a button, for instance. MouseListeners, KeyListeners, etc are some others which you may find useful.

I have some sample GUIs that I can post if you need, its got comments for the code explaning what everything does. But if you look at Java's official tutorials, you should get it down pretty good. And one more thing, write a LOT of code if you want to really make it stick in your head. Make a TicTacToe game or a simple Banking Application with GUI to help you remember better.

If you need any more help, feel free to leave a comment =)


Thanks for that AP link I'm going to go over that material and see what else I can learn.

I've forgotten a split second about Heads First. It's a great book and you learn how to make a simple Drum Sequencer with midi, a simple chat program and more.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1