Total members 11894 |It is currently Sun Nov 24, 2024 1:18 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Java Applications, how to develop a java application and how to start developing java? is the the content of this topic ,this topic covers Java Applications. Creating Java applications is rather easy, once you know how it works.

A tiny Java application

The basic layout of a Java application is similar to that of a C# program. The Hello World program in Java looks like this:

java code
public class StartJava
{
public static void main(string args[])
{
System.out.println("My First Java Application");
}
}


This sample program is not really difficult to understand. It defines a class called Hello World and has a method called main which most people may know from C or C++ programming. Within the main function we use the println() function to write the message "Hello World" on the screen. The println() function is similar to printf in C.

Note: when compiling Java applications make sure that your file has the name as your main class. If it does not, the java compiler will complain an error.

Windows applications with Java
Writing windows applications in Java is easy. This is because Java is a 100 % object oriented programming language and you don't need to worry about API function calls or pointers or unsafe castings.

java code
import java.awt*;
class myFrame extends Frame
{
//Class Constructor
myFrame()
{
//create a new instance of WriteText
add("Center", new WriteText());
//our main window Listener
addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
//the main function of this class
public static void main(string args[])
{
new myFrame ();
}
}
// Class to draw on Canvas
class WriteText extends Canvas
{
public void paint(Graphics g)
{
// Write strings
g.drawString("My First Frame",100,100);
}
}


Whoops! Did i say it was easy? Well, it actually is easy once you understand how it works. When writing windows applications with Java, you basically need 2 classes. The first class implements the application body and Eventlisteners. The second implements the application logic.

The AWT framework To be able to use the windows application programming features of Java you first need to import the java.awt.*; classes. There is a new newer GUI package is now in use which is javax.swing.*;. Swing the newest Java GUI API and the most widely use to the time of posting this topic.

The Java EventListener model All windows applications written in Java need to implement so called Listeners. The class framework of Java supports various forms of Listeners. WindowListeners, MouseListeners, KeyboadListeners,.. Hope it helps.



_________________
Please recommend my post if you found it helpful


Author:
Beginner
User avatar Posts: 109
Have thanks: 5 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : What is a Java Applications?
 Virtual Reality Applications     -  
 Build distribution applications by remoting(TCP/HTTP)     -  
 2d game in java-Monster-Java 2D Game Graphics and Animation     -  
 need help in java     -  
 What is Java API?!!!     -  
 java or .net     -  
 Using FTP in java     -  
 what is java     -  
 Java course     -  
 XML using JAXB API in java     -  



Topic Tags

Java Basics






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com