JFrame
This JFrame is a class which is located at the java package javax.swing JFrame helps to form applet , this class is one type of… Read More »JFrame
This JFrame is a class which is located at the java package javax.swing JFrame helps to form applet , this class is one type of… Read More »JFrame
An applet is the software components or a small application which can run the program via JAVA programming Language.
Applets are on either desktop or on the web pages too.
The applets are mostly used for the GUI end user clients. The Applets are in GUI form.
Basically GUI is being used by the help of the JFrame which is located at the javax.swing
JFrame is the first platform for the deployment of the GUI applications. The Container classes are used to add the components at JFrame.
Some essential classes for the developing GUI app are:
First of all if we are going to develop a small GUI program which can display the only the text;
[source language=’java’]
//import directives
import javax.swing.*;
public class Text1 extends JFrame{
public Text1() {
//FOR LABEL
JLabel label = new JLabel(“Hello JAVA !!!”);
//ADDING CONTAINERS TO COMPONENTS
this.getContentPane().add(label);
this.setSize(200,200);
this.setVisible(true);
}
public static void main (String[] args) {
// invoking constructor
new Text1();
}
}
[/source]
Many developers want their own Layout Manager with user-defined so JAVA has provided a separate method for the every container of JFrame Component and that method is setBounds(). This method helps the developers to position the container as per their need .
About SetBounds() method:
This method consists four parameter
1 2 3 |
Syntax: <strong> </strong><em><strong>xxx.setBounds(int x_axis, int y_axis, int width, int height);</strong> </em> |
We can arrange the containers with the help of this method easily.Read More »Trick of Positioning the Containers of JFrame
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.
1 2 |
<em>In syntax: JFrame_var_name.setSize(Width_px, Height_px);</em> foreg. xxx.setSize(100, <strong>100</strong>); |
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.