Advertisement
CastelShal

JTabbedPane Prac

Aug 29th, 2023
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. package shalYIT;
  2. import javax.swing.*;
  3. import java.awt.*;
  4.  
  5.  
  6. public class JPaneDemo2 {
  7.     JTabbedPane jtp;
  8.     JTextField tf;
  9.     JPanel jp;
  10.     JFrame jf;
  11.     JPaneDemo2(){
  12.         jtp = new JTabbedPane();
  13.         jtp.add("SIS", new JSisPanel());
  14.         jtp.add("RADIO", new JColorPanel());
  15.         jp = new JPanel();
  16.         jp.setLayout(new FlowLayout());
  17.         jp.add(jtp);
  18.         jf = new JFrame();
  19.         jf.getContentPane().add(jp);
  20.         jf.setSize(400, 500);
  21.         jf.setVisible(true);
  22.     }
  23.  
  24.     public static void main(String[] args) {
  25.         // TODO Auto-generated method stub
  26.         new JPaneDemo2();
  27.     }
  28.  
  29. }
  30.  
  31. class JSisPanel extends JPanel{
  32.     JComboBox<String> jc;
  33.     JSisPanel(){
  34.         jc = new JComboBox<String>();
  35.         jc.addItem("abc");
  36.         jc.addItem("def");
  37.         jc.addItem("ghi");
  38.         jc.addItem("jkl");
  39.         jc.addItem("mno");
  40.         add(jc);
  41.     }
  42. }
  43.  
  44. class JColorPanel extends JPanel{
  45.     JRadioButton r1, r2, r3, r4;
  46.     ButtonGroup bg;
  47.     JColorPanel(){
  48.         r1 = new JRadioButton("A");
  49.         r2 = new JRadioButton("B");
  50.         r3 = new JRadioButton("C");
  51.         r4 = new JRadioButton("D");
  52.         bg = new ButtonGroup();
  53.         bg.add(r1);
  54.         bg.add(r2);
  55.         bg.add(r3);
  56.         bg.add(r4);
  57.         add(r1);add(r2);add(r3);add(r4);
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement