Archive for category Applet

Frame Height in Applet

Actually the the height we defined for JFrame may differ as what we assume . In windows JFrame uses its height including it’s title bar and the bottom border of window frame.It can be illustrated below :
Let’s we code the JFrame size.

In syntax: JFrame_var_name.setSize(Width_px, Height_px);
foreg.  xxx.setSize(100, 100);

In this code we can see that we defined a JFrame size to 100px width and 100px height. But actually some programmer feels problem on the height of the windows size , even we had declare the size of the JFrame to 100. The JFrame height includes the title bar and it’s bottom liner height.

Read the rest of this entry »

Tags: , , , , ,

Small Applet

[sourcecode=’java’]
//import directives
import javax.swing.*;

public class HelloJava {

//main method
public static void main( String[] args ) {
JFrame frame = new JFrame( “Hello Java !!” ); //Labeling Frame Title
JLabel label = new JLabel(“Hello Java !!”, JLabel.CENTER );
frame.getContentPane( ).add( label );
frame.setSize( 400, 300 ); //width and height
frame.setVisible( true );
}
}
[/sourcecode]

Output:

applet

applet

Tags: , ,