3

I am working on a java questionnaire app, and there is one problem: for example, there is two main questions, and the first main question has a subquestion, all the questions are sigle choice. Assuming that I click on one choice of the first main question, its subquestion should be triggered out and displayed between the first main question and the second question. If I click on the choice again, the subquestion should be disappeared. How can I make the question panels show and hide animately? Can you just tell me the basic methods? Thank you.

Jonathan Spooner
  • 7,682
  • 2
  • 34
  • 41
loql
  • 271
  • 1
  • 2
  • 9

1 Answers1

3

Here is some basic code on an example of hiding something visually in java.

public static void main(String args[]){
JFrame f = new JFrame();
f.setLayout(new BorderLayout());
final JPanel p = new JPanel();
p.add(new JLabel("A Panel"));
f.add(p, BorderLayout.CENTER);

//create a button which will hide the panel when clicked.
JButton b = new JButton("HIDE");
b.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
            p.setVisible(false);
    }
});
COD3BOY
  • 11,964
  • 1
  • 38
  • 56
Gabriel
  • 3,039
  • 6
  • 34
  • 44