PDA

View Full Version : [TUT] Java JOptionPane [Java]



A.Justice
09-08-2012, 09:10 PM
import javax.swing.JOptionPane ;

public class Pane {


public static void main(String[] args) {

JOptionPane.showMessageDialog(null, "Hi and welome to your death");

System.exit(0);

}

}


Simple Code for Java, but how does it work?

Good question buddy, I'll explain how the code works, starting from line one.

But Before I explain the code, I would like to recommend and IDE for you guys to get so you can code the code and compile it right there in the IDE.

Eclipse is a multi-language software development environment comprising an integrated development environment (IDE). Syntax Highlighting So yep a good thing.

Download Eclipse (http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/junor)



import javax.swing.JOptionPane ;

Imports JOption Class. JOptionPane Contains classes used for a graphical user interface (GUI), Input/output. JOptionPane allows you to


Allows you to create a dialog box(Similar to jScript Alert)
Display information
Request information
Give the user a choice with buttons



public class Pane {

public static void main(String[] args) {

Java public class "Pane" easy as that.The Main method is the method in which execution to any java program begins.


JOptionPane.showMessageDialog(null, "Hi and welome to your death");

System.exit(0);

In Simple terms, that basically shows the message in the quotation marks, null makes it so the user can exit(I'm not very sure about null in ths case).


Thanks for reading such a long tutorial on such a simple program.

*I'll edit this later, when I learn more about "null".*

A.Justice
11-08-2012, 01:25 PM
Quick update, Null means that the value is unknown(just learned that).

Dentafrice
11-08-2012, 08:34 PM
Just for reference that first parameter is for the parentComponent, if it's not known or there is no extra frame null will have it use the default frame.

A.Justice
11-08-2012, 09:02 PM
Just for reference that first parameter is for the parentComponent, if it's not known or there is no extra frame null will have it use the default frame.
Oh, and since you know something about Java can you tell me I have one question, Can you tell which version of Java I'm using?

Jutnux
11-08-2012, 09:16 PM
Does it really matter, seriously?

A.Justice
11-08-2012, 10:49 PM
Does it really matter, seriously?

What?!?

Dentafrice
15-08-2012, 10:46 PM
Max or linux:
java -version


java version "1.6.0_33"Java(TM) SE Runtime Environment (build 1.6.0_33-b03-424-11M3720)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03-424, mixed mode)

Windows:
http://javatester.org/version.html

Want to hide these adverts? Register an account for free!