1

嗨,我的代码有问题。当我单击按钮和 Keypressed(Enter) 时,我无法在 Minimize 类的拆分窗格中调用或显示我的 JPanel(TruthTable)。问题出在 Minimize 类中

*更新:我已经解决了关于显示面板的问题我的下一个问题是当我调用构造函数时,面板中的文本应该被更新。我还将 setText 更改为追加“因为他们说 JPanel 不支持 setText.I '已经使用,验证,重绘方法,但在更新 textArea 时没有运气。

在此处输入图像描述

这是我的最小化类代码:

package splashdemo;

public class Minimize extends JPanel implements ClipboardOwner
{

      simButton.addActionListener(new ActionListener()
      { public void actionPerformed(ActionEvent ae)
        {
            LogicGates lg= new LogicGates();
            lg.geth();
            sim s=new sim();
            s.InputExp(lg.g,lg.g1);
            s.menu();
            s.setSize(700,700);
            s.setVisible(false);
            Frame f = new Frame();
            Panel panel = new Panel();
            f.add(BorderLayout.SOUTH, panel);
            f.add(BorderLayout.CENTER, new sim());
            f.add(BorderLayout.SOUTH, panel);
            f.setSize(580, 500);
            panel.add(s.button);
            f.show();
            f.setVisible(false);


JOptionPane.showMessageDialog(null, b);
ex=b;
cAppend();
JOptionPane.showMessageDialog(null, ex1);
InToPost(ex1);
        foutput= doTrans();
        JOptionPane.showMessageDialog(null, foutput);

             TruthTable_1 kl = new TruthTable_1(foutput);

            Minimize mi = new Minimize();
             s.InputExp(lg.g,lg.g1);
             s.menu();
            lg.gatessplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mi, lg.p1);

//here's the splitpane where I should display the TruthTable_1 panel but it doesn't diplay
          lg.p1.add(lg.gatessplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, s,kl));
            lg.gatessplit.setOneTouchExpandable(true);
            lg.gatessplit.setDividerLocation(250);
            lg.gatessplit.setPreferredSize(new Dimension(900, 500));
            lg.createAndShowGUI();


        }});


    }

这是我的代码 TruthTable_1:constructors

public TruthTable_1() {
      super();
tableArea.append("This is a Test");
      //setBackground(Color.black);
    createg();

      setVisible(true);
    }
        public void createg(){
            setLayout(new BorderLayout());
        line= 0;
        truth= 'T';
        fallacy= 'F';
        final JPanel top= new JPanel();
        input= new TextField(35);
        TFCheck= new Checkbox("Select for \"1/0\" (default\"T/F\")");
        check= new JButton("Check");
        check.addActionListener(this);

        top.add(input);
        top.add(TFCheck);
        top.add(check);
                top.setVisible(false);
        tableArea= new JTextArea(16, 40);
        tableArea.setEditable(false);
        tableArea.setFont(new Font("Lucida Console", Font.PLAIN, 14));
        // all letters are the same width in this font

        go= new JButton("Do it to it!");
        go.addActionListener(this);
        input.addActionListener(this);
                go.setVisible(false);
        add(top, BorderLayout.NORTH);
        scrolls= new JScrollPane(tableArea);// add scroll buttons to the area
        add(scrolls, BorderLayout.CENTER);
        add(go, BorderLayout.SOUTH);
        setSize(535, 500);
        //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocation(100, 100);
        }
    public TruthTable_1(String f){
            createg();

                 tableArea.append(run(f));

    }
4

0 回答 0