Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. CardLayout in AWT

CardLayout in AWT

Scheduled Pinned Locked Moved Java
linuxjavahelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pritam N Bohra
    wrote on last edited by
    #1

    I've trying CardLayout prog. but the program is not displaying the buttons at all. I tried a lot but could not find out the error. If you could look into this code and tell me where I am going wrong I would be grateful to you. The code is as follows: import java.awt.*; import java.awt.event.*; class CardLayoutTry implements ActionListener { Frame frm; Button window,linux; Checkbox chkWin7,chkWin8,chkWinXP,chkWinVis; Checkbox chkUbuntu,chkMint,chkFedora,chkRedHat; Panel deck, panWin,panLin; CardLayout cardLO; Label lblWin,lblLin; CardLayoutTry() { cardLO=new CardLayout(); frm=new Frame("Operating System"); frm.addWindowListener(new WindowAdapter(){ @Override public void windowClosing(WindowEvent we) { frm.setVisible(false); System.exit(0); }}); frm.setVisible(true); frm.setSize(300,300); deck=new Panel(); // main panel deck.setLayout(cardLO); // setting the layout panWin=new Panel(); panLin=new Panel(); window=new Button("Windows"); frm.add(window); window.addActionListener(this); linux=new Button("Linux"); frm.add(linux); linux.addActionListener(this); // ADDING LINUX DETAILS lblLin=new Label("LINUX OPERATING SYSTEM",Label.CENTER); panLin.add(lblLin); chkUbuntu=new Checkbox("Ubuntu",true,null); chkMint=new Checkbox("Mint"); chkFedora=new Checkbox("Fedora"); chkRedHat=new Checkbox("Red Hat"); panLin.add(chkUbuntu); panLin.add(chkMint); panLin.add(chkFedora); panLin.add(chkRedHat); deck.add(panLin,"LinuxPanel"); // ADDING WINDOWS DETAILS lblLin=new Label("WINDOWS OPERATING SYSTEM",Label.CENTER); panLin.add(lblLin); chkWin8=new Checkbox("Windows 8",true,null); chkWin7=new Chec

    S 1 Reply Last reply
    0
    • P Pritam N Bohra

      I've trying CardLayout prog. but the program is not displaying the buttons at all. I tried a lot but could not find out the error. If you could look into this code and tell me where I am going wrong I would be grateful to you. The code is as follows: import java.awt.*; import java.awt.event.*; class CardLayoutTry implements ActionListener { Frame frm; Button window,linux; Checkbox chkWin7,chkWin8,chkWinXP,chkWinVis; Checkbox chkUbuntu,chkMint,chkFedora,chkRedHat; Panel deck, panWin,panLin; CardLayout cardLO; Label lblWin,lblLin; CardLayoutTry() { cardLO=new CardLayout(); frm=new Frame("Operating System"); frm.addWindowListener(new WindowAdapter(){ @Override public void windowClosing(WindowEvent we) { frm.setVisible(false); System.exit(0); }}); frm.setVisible(true); frm.setSize(300,300); deck=new Panel(); // main panel deck.setLayout(cardLO); // setting the layout panWin=new Panel(); panLin=new Panel(); window=new Button("Windows"); frm.add(window); window.addActionListener(this); linux=new Button("Linux"); frm.add(linux); linux.addActionListener(this); // ADDING LINUX DETAILS lblLin=new Label("LINUX OPERATING SYSTEM",Label.CENTER); panLin.add(lblLin); chkUbuntu=new Checkbox("Ubuntu",true,null); chkMint=new Checkbox("Mint"); chkFedora=new Checkbox("Fedora"); chkRedHat=new Checkbox("Red Hat"); panLin.add(chkUbuntu); panLin.add(chkMint); panLin.add(chkFedora); panLin.add(chkRedHat); deck.add(panLin,"LinuxPanel"); // ADDING WINDOWS DETAILS lblLin=new Label("WINDOWS OPERATING SYSTEM",Label.CENTER); panLin.add(lblLin); chkWin8=new Checkbox("Windows 8",true,null); chkWin7=new Chec

      S Offline
      S Offline
      Shubhashish_Mandal
      wrote on last edited by
      #2

      This should come at the end

      frm.setSize(300,300);
      frm.setVisible(true);

      Regards Shubhashish

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups