在加拿大
已解决,虽然没有成功的将2、3、4整合,但是成功的将1、2、3、4都整合了。。。首先我要做个这样的窗口:
然后最下面一行按钮点击每一个都会有相应的对话框出来,比如点击supprimer按钮会出来这样的对话框:
我现在已经已经完成了这些窗口,拿成功叫出supprimer为例子:1. classePrincipale:public class InterfacePrincipale extends JFrame{        //declaration des attribus... public InterfacePrincipale() {        super("Nordic Pneus - Système de Gestion de l'Inventaire (SGI)");        init();    }    public static void main(String[] args) {        JFrame fenetre = new InterfacePrincipale();        fenetre.setBounds(400, 300, 600, 400);        fenetre.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);        fenetre.setVisible(true);    }    private void init() {        //分别构建上中下等panel。。。        //Mettre des ecouteurs sur les boutons.        Ecouteur ecouteur = new Ecouteur();        bouttonSupprimer.setActionCommand("supprimer");        bouttonSupprimer.addActionListener(ecouteur);        。。。    }    //classe interne d'Ecouteur    private class Ecouteur implements ActionListener {    DialogSupprimerPneus supprimerDialog;     if (evt.getActionCommand().equals("supprimer")){                            supprimerDialog = new DialogSupprimerPneus();                            supprimerDialog.setVisible(true);     }}2. classe DialogSupprimerPneus:package tp3.interfacegraphiques;import java.awt.GridLayout;import javax.swing.JDialog;@SuppressWarnings("serial")public class DialogSupprimerPneus extends JDialog{    private PanneauSupprimerInfo panneauInfo;    private PanneauSupprimerBoutton panneauBoutton;    public DialogSupprimerPneus() {        this.setTitle("Nordic Pneus (SGI) - Suppression");            panneauInfo = new PanneauSupprimerInfo();        panneauBoutton = new PanneauSupprimerBoutton();            this.setLayout(new GridLayout(2,1, 5, 5));            this.add(panneauInfo);        this.add(panneauBoutton);            setBounds(400, 300, 600, 250);            }}3. classe PanneauSupprimerBoutton:package tp3.interfacegraphiques;import java.awt.FlowLayout;import javax.swing.JButton;import javax.swing.JPanel;@SuppressWarnings("serial")public class PanneauSupprimerBoutton extends JPanel{    private JButton annuler;    private JButton supprimer;    PanneauSupprimerBoutton(){        init();    }    private void init(){            annuler = new JButton("Annuler");        supprimer = new JButton("Supprimer");            this.setLayout(new FlowLayout(FlowLayout.RIGHT));        this.add(supprimer);            this.add(annuler);    }}4. classe PanneauSupprimerInfo:package tp3.interfacegraphiques;import java.awt.GridLayout;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.border.TitledBorder;@SuppressWarnings("serial")public class PanneauSupprimerInfo extends JPanel{    private JLabel descrip;    private JLabel nbPneus;    private JTextField textDescrip;    private JTextField textNbPneus;    PanneauSupprimerInfo(){        init();    }    private void init(){        this.setBorder(new TitledBorder(null, "Information du pneu",                TitledBorder.LEADING, TitledBorder.TOP, null, null));        this.setLayout(new GridLayout(2, 2, 10, 4));            descrip = new JLabel("Description:");        nbPneus = new JLabel("Nombre de pneus:");        textDescrip = new JTextField();        textNbPneus = new JTextField();            this.add(descrip);        this.add(textDescrip);        this.add(nbPneus);        this.add(textNbPneus);            textDescrip.setEditable(false);        }}我现在的问题是想把2、3、4三个class整合到一个class里面,可是老是出现nullPointerException:
我的整合方法如下:package tp3.interfacegraphiques;import java.awt.FlowLayout;import java.awt.GridLayout;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.border.TitledBorder;@SuppressWarnings("serial")public class DialogSupprimerPneus extends JDialog{    private JPanel panneauInfo;    private JLabel descrip;    private JLabel nbPneus;    private JTextField textDescrip;    private JTextField textNbPneus;    private JPanel panneauBoutton;    private JButton annuler;    private JButton supprimer;    public DialogSupprimerPneus() {        init();    }    private void init(){        panneauInfo.setBorder(new TitledBorder(null, "Information du pneu",                TitledBorder.LEADING, TitledBorder.TOP, null, null));        panneauInfo.setLayout(new GridLayout(2, 2, 10, 4));            descrip = new JLabel("Description:");        nbPneus = new JLabel("Nombre de pneus:");        textDescrip = new JTextField();        textNbPneus = new JTextField();            panneauInfo.add(descrip);        panneauInfo.add(textDescrip);        panneauInfo.add(nbPneus);        panneauInfo.add(textNbPneus);            textDescrip.setEditable(false);            annuler = new JButton("Annuler");        supprimer = new JButton("Supprimer");            panneauBoutton.setLayout(new FlowLayout(FlowLayout.RIGHT));        panneauBoutton.add(supprimer);            panneauBoutton.add(annuler);            this.setTitle("Nordic Pneus (SGI) - Suppression");                    this.setLayout(new GridLayout(2,1, 5, 5));            this.add(panneauInfo);        this.add(panneauBoutton);            setBounds(400, 300, 600, 250);            }}请问是哪里出了问题导致的呢?谢谢! 
 ·加拿大新闻 体验德系经典:这车专注家庭出行,实力如何?
·加拿大新闻 加拿大留学生暴减,大学周边房租大跳水
·加拿大新闻 51网“枫情万种”摄影征集活动网友投票结束!18幅作品分别获奖
·加拿大新闻 不到6.5万买合资SUV,2026款奕跑是否值得考虑?
·加拿大新闻 多伦多下周或迎首场降雪为冬季拉开序幕
 ·中文新闻 苏菲·特纳 (Sophie Turner) 的前贵族佩里格林·皮尔逊 (Peregrine Pea
·中文新闻 《邪恶》明星乔纳森·贝利成为首位公开同性恋者,被评为《人