Rules to design gui screen

Advertisements

Prev Tutorial Next Tutorial

Rules to design gui screen

  • Create a frame with specific size
  • Set layout to frame
  • Add gui component (non-container component) to the frame

Create a frame with specific size

Example of Frame

import java.awt.*;

class FrameDemo 
{
public static void main(String[] args) 
{
Frame f=new Frame();
f.setTitle("myframe");
f.setSize(500,300);
f.setVisible(true);
}
}

Set layout to frame

Example of Frame

import java.awt.*;

class FrameDemo 
{
public static void main(String[] args) 
{
Frame f=new Frame();
f.setTitle("myframe");
f.setLayout(new FlowLayout()); // set layout
f.setSize(500,300);
f.setVisible(true);
}
}

Add gui component (non-container component) to the frame

Example of Frame

import java.awt.*;

class FrameDemo 
{
public static void main(String[] args) 
{
Frame f=new Frame();
f.setTitle("myframe");
f.setLayout(new FlowLayout());
Button b1=new Button("Submit");
Button b2=new Button("Cancel");
f.add(b1);  // add button component
f.add(b2);  // add button component
f.setSize(500,300);
f.setVisible(true);
}
}

Comple Example of design Gui Screen

Example GUI Screen

import java.awt.*;

class FrameDemo 
{
public static void main(String[] args) 
{
Frame f=new Frame();
f.setTitle("myframe");
f.setBackground(Color.cyan);
f.setForeground(Color.red);
f.setLayout(new FlowLayout());
Button b1=new Button("Submit");
Button b2=new Button("Cancel");
f.add(b1);
f.add(b2);
f.setSize(500,300);
f.setVisible(true);
}
}

Download code Click

frame example
Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements