1

Hi I'm having trouble in my code. I can't call or display my JPanel(TruthTable) inside my splitpane in the Minimize class when I click the button and Keypressed(Enter).The problem is in the class Minimize

*UPDATE: I'have solved my problem regarding to diplaying the panel my next problem is when I call the constructor the text in the panel should be updated.I also change the setText to append 'coz they say that JPanel doesnt support setText.I've already used,validate,repaint method but no luck in updating the textArea.

enter image description here

Heres my code for class Minimize:

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();


        }});


    }

Heres my code the 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));

    }
Alvin Pulido
  • 49
  • 2
  • 10
  • Please read [this](http://docs.oracle.com/javase/tutorial/uiswing/components/splitpane.html). – Moonbeam Mar 15 '12 at 15:48
  • 3
    Uh, this is too long. Can you post a SSCE that demonstrates the problem? – Jakub Zaverka Mar 15 '12 at 15:51
  • @JakubZaverka I've already edited the code and I've specified the line of code where I will display it. – Alvin Pulido Mar 15 '12 at 18:10
  • I've tried to put setVisible(true) and also repaint , validate but it doesn't display – Alvin Pulido Mar 15 '12 at 18:16
  • Search for `main()` failed. Please read the tutorial cited by @Moonbeam and edit your question to include an [sscce](http://sscce.org/) that exhibits the problem you describe. – trashgod Mar 15 '12 at 18:39
  • And in the example, please don't name your fields/variables "s" "lg" or "p1", those names are not very informative. – Jakub Zaverka Mar 15 '12 at 18:44
  • @JakubZaverka sorry it's just a temp variables,next time I will name it correctly. By the way how can I update the text in the textarea?I've used the validate, repaint methods but nothing happened. – Alvin Pulido Mar 15 '12 at 19:37

0 Answers0