Graphics Unit Interface(gui)-1 : JTabbedPane

graphics mode এ জাভা দিয়ে সহজে তৈরি করা যায় tabe ।tabe করার জন্য JTabbedPane use করা হয় । এটি swing এর একটি child class . javax.swing.JTabbbedPane.
প্রথমে TabeLayout নামে একটি class create করুন। কোড টুকু লিখুন ।


import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

public class TabeLayout extends JFrame{

public TabeLayout(){
super("Tabed introduction");
JTabbedPane tabbepane=new JTabbedPane();

JLabel label1=new JLabel("Label one");
JPanel panel1=new JPanel();

panel1.add(label1);
tabbepane.addTab("ONE ",null,panel1,"First panel");

JLabel label2=new JLabel("Label Two");

JPanel panel2=new JPanel();
panel2.setBackground(Color.orange);
panel2.add(label2);
tabbepane.addTab("Two",null, panel2, "Second panel");

JLabel label3=new JLabel();
JPanel panel3=new JPanel();
panel3.setLayout(new BorderLayout());
panel3.add(new JButton("top"),BorderLayout.NORTH);
panel3.add(new JButton("Footer"),BorderLayout.SOUTH);
panel3.add(new JButton("LEft"),BorderLayout.WEST);
panel3.add(new JButton("Right"),BorderLayout.EAST);

panel3.add(label3);
tabbepane.addTab("Three", null,panel3,"Third panel");

add(tabbepane);

}

}

এবার tabelayout_test নামে আরো একটি ক্লাস তৈরি করুন ।এটি মুলত main class . tabelayout class এখানে কল করা হয়েছে।

import javax.swing.JFrame;

public class tabelayout_test {

public static void main(String arg[]){

TabeLayout tl=new TabeLayout();
tl.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
tl.setSize(300, 250);
tl.setTitle(“I Love Allah. and (s) . “);
tl.setVisible(true)
;

}
}

Capture


কোড বিশ্লেষনঃ

প্রথমে package name গুলো import করে নিতে হবে ।
import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

public class TabeLayout extends JFrame{

public TabeLayout(){
super(“Tabed introduction”);

এখানে tabbedPane create করা হয়েছে।
JTabbedPane tabbepane=new JTabbedPane();

label create করলাম

JLabel label1=new JLabel(“Label one”);

প্যানেল create করলাম

JPanel panel1=new JPanel();

label is added to panel.

panel1.add(label1);

panel is added to TabbedPane

tabbepane.addTab(“ONE “,null,panel1,”First panel”);

**********************************************************************
২য় tab এর কাজ শুরু
JLabel label2=new JLabel(“Label Two”);

JPanel panel2=new JPanel();

কালার add করেছি ।
panel2.setBackground(Color.orange);

panel2.add(label2);
tabbepane.addTab(“Two”,null, panel2, “Second panel”);
**********************************************************************
৩য় tab এর কাজ শুরু

JLabel label3=new JLabel();
JPanel panel3=new JPanel();
একটি বর্ডারলেয়াউট তৈরি করেছি।

panel3.setLayout(new BorderLayout());
চারটি লেয়াঊট করলাম।

panel3.add(new JButton(“top”),BorderLayout.NORTH);
panel3.add(new JButton(“Footer”),BorderLayout.SOUTH);
panel3.add(new JButton(“LEft”),BorderLayout.WEST);
panel3.add(new JButton(“Right”),BorderLayout.EAST);

label3 added to panel3

panel3.add(label3);

panel3 added to tabbedpane.

tabbepane.addTab(“Three”, null,panel3,”Third panel”);
অবশেষে tabbedpane কে আমরা JFrame add করলাম।

add(tabbepane);

}

}

এটি main class.

import javax.swing.JFrame;

public class tabelayout_test {

public static void main(String arg[]){

************calling TabeLayout class here*************

TabeLayout tl=new TabeLayout();
tl.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
tl.setSize(300, 250);
tl.setTitle(“I Love Allah. and (s) . “);
tl.setVisible(true)
;

}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s