1.you write an appication not applet, start() will not be automatically called.
2.JFrame frame is never add to your application, so nothing shows.

解决方案 »

  1.   

    CutAndCat p=new CutAndCat();
    p.show();
      

  2.   

    JFrame frame is never add to your application这句话有点看不懂,怎样才能将frame加到我的程序中去呢。frame.show()和p.show()都不行。
      

  3.   

    your application is a frame. to show your application. show() should be called by your application. your defined a frame, but this frame is not your application and not added to your application. so nothing no the screen.modified code is here
      

  4.   

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class CutAndCat extends JFrame implements ItemListener
    {
        boolean inAnApplet = true;
        JPanel cards;
        String comboBoxItems[] = { "          分割           ", "          合并           "};
        //JFrame  frame=new JFrame("分割&合并");
        JPanel cbp = new JPanel();    public CutAndCat(){
        super("分割&合并");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JComboBox c = new JComboBox(comboBoxItems);
        c.setEditable(false);
        c.addItemListener(this);
        cbp.add(c);    //Use the default layout manager, BorderLayout
        getContentPane().add(cbp, BorderLayout.NORTH);    cards = new JPanel();
        cards.setLayout(new CardLayout());
        cards.add(new PanelForCut(), "          分割           ");
        cards.add(new PanelForCat(), "          合并           ");
    getContentPane().add(cards,BorderLayout.CENTER);
        addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    if (inAnApplet) {
                        dispose();
                    } else {
                        System.exit(0);
                    }
                }
            });
         pack();
         setVisible(true);
        }
        public void itemStateChanged(ItemEvent evt) {
            CardLayout cl = (CardLayout)(cards.getLayout());
            cl.show(cards, (String)evt.getItem());
        }    public static void main(String args[])
        {
    try {
        Font font=new Font("",Font.PLAIN,12);
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        UIManager.put("Label.font",font);
        UIManager.put("Button.font",font);
        UIManager.put("TabbedPane.font",font);
        UIManager.put("FileChooser.font",font);
            }
        catch (Exception e) {   }
            CutAndCat p=new CutAndCat();
            }
    }