Jump to content
xisto Community
.:Brian:.

Graphcal User Interfaces In Java How do you make them?

Recommended Posts

Ok, right now I am currently using eclipse, however I can change to whatever if there is something else that would be better for this. But I have made a number of java applications, but they all simply use the command line for doing their user input and output. However, I have been interested in learning how to program graphical user interfaces in java, and was wondering if somebody could point me in the right direction, with some easy to understand and follow tutorials.Also, once I have done that, what about making a java program that can be easily executed? (I know that this would probably make it OS dependant, by making files such as .exe, and such), but is there an easy way to do this? Do I simply make a program in some other language that acts as some sort of a wrapper around the java application somehow? I am just curious as to how to do this in order to make an application that is easily distributable and runnable over a number of platforms (I don't want people to have to worry about people going to the command line and running a ton of stuff in order to get it to work)Thanks for the help,Brian

Share this post


Link to post
Share on other sites

i would definately check out AWT and SWING for GUI dev...

as far as compiling JAVA to be machine-dependent... it's a little abstract as it defies the purpose of JAVA ("Compile once, run everywhere")

maybe check out:
http://www.thisiscool.com/gcc_mingw.htm

look into the gcj varieties... good luck if you're still looking :rolleyes:

Share this post


Link to post
Share on other sites

Ok, right now I am currently using eclipse, however I can change to whatever if there is something else that would be better for this.

Eclipse is a good java IDE if you just want to code Java without creating an interface because you will need to code it all (yes i know it takes a lot of time and sometimes a little bit boring).

Well there is another IDE that will be your perfect solution. It is Neatbeans! It has became one of the post famous and more used programming environment not only for Java, also for C/C++ applications and for creating UML diagrams and generating code from it (since version 6.0).

Netbeans allows you to easy create GUI by just dragging to the screen components such as textfields, labels, buttons, radio buttons, text areas, panels, and many other cool components. It support both the java.awt interface or the javax.swing. I heard that Netbeans won a prize because their GUI's building tool not only allows you to put components, it also have auto-align and auto-size functions that makes very easy to create professional user interfaces in minutes. It also has a preview button to easily view your interface without compiling you whole application.

Well this are only a few advantages of netbeans, I only mention these few because you ask about building interfaces; but it has many other features as managing classes in packages, to create test clases, deploy the application by creating the JAR file automatically, debugging, templates, and more!

The netbeans site is:
https://netbeans.org/ The only IDE you need for developing any application!

Share this post


Link to post
Share on other sites

There are 2 main types of java-based GUI:1. AWT/Swing elements are used in standalone Java applications and Java applets.Many commercial IDE (like JBuilder) provide a very good builders for AWT/Swing user interfaces. You can simply create a form and put on it all necessary AWT/Swing elements (buttons, textboxes etc.) using drag and drop method, which provides an opportunity for immediate visual control of your form. However, you can create such forms using java.awt and javax.swing packages in you Java code. 2. HTML forms are used in WEB applications.HTML page can be created simply using any text editor (Notepad/Wordpad). I often do this for javascript-s debugging or for some testing purposes.I think, today the most advanced technology for java-based Web applications is Java Server Faces (JSF). It is open-source. I use JSF tags directly in Eclipse text editor: unfortunally, no immediate visual control (I need every time to redeploy the application for visualising any changes).But I do not know any good FREE tools for creating Java-based Web interfaces.

Edited by java-area (see edit history)

Share this post


Link to post
Share on other sites

As others said: AWT/Swing. But for a begginer, I'd suggests you download Netbeans. It has a really nice drag-and-drop feature to make basic 2D forms (and later can be used in 2D and even 3D Graphics). Make a few of these in Netbeans and look at the code. Should be under 'generated code'. just open it up and look at it. It's quite nice to have a direct example...

Share this post


Link to post
Share on other sites
How to create a Standalone Java Application using NetBeans and MySqlGraphcal User Interfaces In Java

How to create an Standalone Application which runs on 3 pcs concurrently and connects to database and retrieves data from it. I.E. Using Net Beans6.1, which has GlassFish Application Server & MySql server 5.1 installed with it.

Please help me!

Please...Please send me a link for any example application.

-question by Kamalakar

 

Share this post


Link to post
Share on other sites

I agree that Netbeans has a user interface that is ideal for beginners. However, I hard coded all of my GUI's in Eclipse when I first started out and that helped me understand them better. Of course, Netbeans is a good tool as well.

Share this post


Link to post
Share on other sites

Ok, right now I am currently using eclipse, however I can change to whatever if there is something else that would be better for this. But I have made a number of java applications, but they all simply use the command line for doing their user input and output. However, I have been interested in learning how to program graphical user interfaces in java, and was wondering if somebody could point me in the right direction, with some easy to understand and follow tutorials.
Also, once I have done that, what about making a java program that can be easily executed? (I know that this would probably make it OS dependant, by making files such as .exe, and such), but is there an easy way to do this? Do I simply make a program in some other language that acts as some sort of a wrapper around the java application somehow? I am just curious as to how to do this in order to make an application that is easily distributable and runnable over a number of platforms (I don't want people to have to worry about people going to the command line and running a ton of stuff in order to get it to work)

Thanks for the help,
Brian

I have played a little with JBuilder, but i have not really a know what i am doing.
// $Header: z:/javafrak.java 2.1import java.awt.*;import java.lang.*;public class javafrak extends java.applet.Appletimplements Runnable{ Thread thread=null; int Max_X,Max_Y,Iter,X,Y,Col,ColR,ColG,ColB; double A,B,C,D,G,F,H,I,J,K,L,M,Zoom,verti,hori; double A1,B1,C1,D1,Step; String message1,message2,textfont; int textsize,textX,textY,textH,textW; Graphics offGraphics; Image offImage; public void init() {  Max_X=size().width;  Max_Y=size().height;  offImage=createImage(Max_X,Max_Y);  offGraphics=offImage.getGraphics();  offGraphics.fillRect(0,0,Max_X+1,Max_Y+1);  Iter  = 1250;  hori  = .000036;			 // nach rechts  verti = .000035;			 // hĂśher  Zoom  = .002500;			 // tiefer  Step  = Zoom/80;  A	 = -.765216+Zoom+hori;  B	 = -.765325-Zoom+hori;  C	 = .099886-Zoom+verti;  D	 = .099996+Zoom+verti;  message1  = "Bitte etwas Geduld";  message2  = "Fraktal wird berechnet";  textfont  = "TimesRoman";  textsize  = 36;  Font myFont=new Font(textfont, Font.BOLD, textsize);  FontMetrics myMetrix=getFontMetrics(myFont);  textH=myMetrix.getHeight();  textW=myMetrix.stringWidth(message1);  textX=(int)((Max_X-textW)/2);  textY=(int)((Max_Y-textH)/2)-myMetrix.getDescent();  setFont(myFont); } public void start() {  if(thread == null)  {   thread = new Thread(this);   thread.start();  } } public void stop() {  thread = null;  offImage = null;  offGraphics = null; } public void run() {  while (thread != null)  {   try {Thread.sleep(0);}   catch (InterruptedException e) {}   repaint();  } } public void paint(Graphics g) {  setBackground(Color.black);  g.setColor(Color.green);  g.drawString(message1,textX,textY);  g.drawString(message2,textX-textsize,textY+textH);  update(g); } public void update(Graphics g) {  A1 = A;  B1 = B;  C1 = C;  D1 = D;  A -= Step;  B += Step;  C += Step;  D -= Step;  G=(D1-C1)/Max_Y;  F=(B1-A1)/Max_X;//----------------------------------------------  for (Y = 0; Y < Max_Y; Y++)  {   for (X = 0; X < Max_X; X++)   {	Col=0;	K=G*Y+C1;	J=K;	I=F*X+A1;	H=I;	L=J*J;	M=H*H;//----------------------------------------------	frak: {		   while (Col<Iter)		   {			J=2*H*J+K;			H=M-L+I;			L=J*J;			M=H*H;			Col++;			if ((M+L)>4)			{			 break frak;			}		   }		  }// --------------  Pixel-Setzer ----------------	Col=(Col & 0x0000FF); // and	ColR=(Col & 0xE0);	ColG=(Col & 0x18);	ColG=(ColG << 3);	// shl	ColB=(Col & 0x07);	ColB=(ColB << 5);	offGraphics.setColor(new Color(ColR,ColG,ColB));	offGraphics.drawLine(X,Y,X,Y);//----------------------------------------------   }   // next X  }	// next Y//----------------------------------------------  g.drawImage(offImage,0,0,this); }}
Dirk
Edited by Dirk Wolfgang Glomp (see edit history)

Share this post


Link to post
Share on other sites
GUI in JavaGraphcal User Interfaces In Java

Am a beginner in Java.I have been asking myself the same question you posted in this post.In fact Its so educative because I have been able to learn on what best programs to use for Java GUI and in this case Netbeans.Also I have tried your code above in Eclipse and its working!

Can somebody please mention on how to code executable programs such as login systems that can connect to a database,update it,edit,do some few queries and return some results on a screen? Example: Enter names,password,create an account,enter some value in it,pay,show balance,confirm,exit etc. In Graphical User Interface.

Please help with examples,links or any code relevant to the question.

Thank you all and keep posting.

 

-reply by Mish

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.