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.
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);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With