Jump to content

How to build a visual interface/GUI

- - - - -

  • Please log in to reply
5 replies to this topic

#1
atomicpineapple

atomicpineapple

    Newbie

  • Members
  • Pip
  • 5 posts
Hi,
So I'm new to programming in java. I want to build a program with an GUI for the user to interact with. It would be very basic, show images and labels and buttons. I'm just having a hard time finding any information on how to do this. I know there are various different layout managers for java applets that can be used to do this but none of them are really working.

Does anyone know of any easy way to do this?

Thank you

#2
Xdawn90

Xdawn90

    Learning Programmer

  • Members
  • PipPipPip
  • 55 posts
You can use java swing to do this.

Perhaps this link is helpful to you:

Java Swing Tutorial | Java Beginner

Good luck.

Regards.

#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
Care to draw us a mockup of the UI you want?:c-smile:

#4
mr mike

mr mike

    Learning Programmer

  • Members
  • PipPipPip
  • 96 posts
What is your program going to do?

Here is one very very generic example using border layout

// add the imports to run below code

public class SomeClass extends JPanel{


     private JButton jb1, jb2, jb3;// assuming you want three j buttons

     private JPanel jp1, jp2, jp3;// " "                  ""      three j Panels to go on your panels

     private JTextField jtf1, jtf2;// same thought

     private JLabel jl;


     public SomeClass(){

             super(new BorderLayout());

             // add to the borderlayout

     }

     public JPanel northPanel(){

             // add buttons, image, or text field

     }

     public JPanel southPanel(){

             // add more stuff

     }

     // create methods for other panels

     // you can add action events for the panels here

}


MAIN METHOD

public class ShowWork{


        public static void main(String [] arrrrr){

                  JFrame frame = new JFrame("Enter name of app");

                  SomeClass sc = new SomeClass();

                  frame.add(sc);

                  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

                  frame.pack();

                  frame.setVisible(true);

        }

}


Hope this gets you started.

Edited by mr mike, 23 December 2010 - 05:35 PM.
add more


#5
atomicpineapple

atomicpineapple

    Newbie

  • Members
  • Pip
  • 5 posts
Thanks for all the replies. I ended up using netbeans design feature to build Java desktop applications, swing GUI forms, making Jframe Forms. Its exactly what i was looking for. Sorry maybe that was redundant but I'm new and i wanted to give all the information. What I'm trying to ask is if anyone knows of any good tutorials or books or anything that can help me start designing basic programs with the 'design' feature in netbeans?

Thanks for everyones help again I really appreciate it.

#6
kctan

kctan

    Newbie

  • Members
  • Pip
  • 5 posts
You may want to consider using JavaFX as well. You can create much nicer UI with JavaFX.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users