/* JTabbedPanedemo */
import javax.swing.*;
import java.awt.*;
public class JTabbedPanedemo extends JApplet
{
JButton b1,b2,b3,b4,b5,b6,b7,b8;
public void init()
{
try
{
SwingUtilities.invokeAndWait(new Runnable(){
public void run()
{
makeGUI();
}
});
}
catch(Exception e)
{
System.out.println("Cant create becuase"+e);
}
}
private void makeGUI()
{
JTabbedPane jtp=new JTabbedPane();
jtp.addTab("B.Tech",new BTechPanel());
jtp.addTab("M.Tech",new MTechPanel());
jtp.addTab("MCA",new MCAPanel());
add(jtp);
}
public class BTechPanel extends JPanel
{
public BTechPanel()
{
b1=new JButton("CSE");
b2=new JButton("IT");
add(b1);
add(b2);
}
}
public class MTechPanel extends JPanel
{
public MTechPanel()
{
b3=new JButton("CSE");
b4=new JButton("IT");
b5=new JButton("Cyber");
add(b3);
add(b4);
add(b5);
}
}
public class MCAPanel extends JPanel
{
public MCAPanel()
{
b6=new JButton("MCA");
b7=new JButton("MPCc");
add(b6);
add(b7);
}
}
}
******************************************************************
<html>
<body>
<applet code="JTabbedPanedemo.class" width=200 height=300>
</applet>
</body>
</html>
Output:
No comments:
Post a Comment