i now learning Object Oriented Programming but stuck. Need help. Below is the code.
[CODE=java] PanelOption.jav a
import java.awt.*;
import java.awt.event. *;
import javax.swing.*;
import javax.swing.eve nt.*;
public class PanelOption extends JPanel
{
//some code
public PanelOption()
{
createOptionGUI ();
}
public void createOptionGUI ()
{
//some code
}
public class ButtonListener implements ActionListener
{
public void actionPerformed (ActionEvent e)
{
if (e.getSource()= =jbtnEnter)
{
PanelQuestion.Q uestion01(); // <= i wan to access to this void method but fail! How to solve?
}
}
}
}
//=============== =============== =============== =============== ==========
PanelQuestion.j ava
import java.awt.*;
import java.awt.event. *;
import javax.swing.*;
import javax.swing.eve nt.*;
public class PanelQuestion extends JPanel
{
//some code
public PanelQuestion()
{
createQuestionG UI();
}
public void createQuestionG UI()
{
//some code
}
public void Question01()
{
//some code (this is the void method that i want to invoke by PanelOption.jav a)
}
}[/CODE]
[CODE=java] PanelOption.jav a
import java.awt.*;
import java.awt.event. *;
import javax.swing.*;
import javax.swing.eve nt.*;
public class PanelOption extends JPanel
{
//some code
public PanelOption()
{
createOptionGUI ();
}
public void createOptionGUI ()
{
//some code
}
public class ButtonListener implements ActionListener
{
public void actionPerformed (ActionEvent e)
{
if (e.getSource()= =jbtnEnter)
{
PanelQuestion.Q uestion01(); // <= i wan to access to this void method but fail! How to solve?
}
}
}
}
//=============== =============== =============== =============== ==========
PanelQuestion.j ava
import java.awt.*;
import java.awt.event. *;
import javax.swing.*;
import javax.swing.eve nt.*;
public class PanelQuestion extends JPanel
{
//some code
public PanelQuestion()
{
createQuestionG UI();
}
public void createQuestionG UI()
{
//some code
}
public void Question01()
{
//some code (this is the void method that i want to invoke by PanelOption.jav a)
}
}[/CODE]
Comment