Hi all, small question Quick response is required plzz. pardon if its a basic question, am new to programming and want to stick to good programming rule as much as possible.
Question:
i have a JFrame which contain a JScrollPane which contain a JPanel as viewportView.
i have implemented the JPanel with MouseListener and MouseMotionListener with the code shown below to chk if the event Fires but no response. (i also tried it on the JScrollPane)
where should i have put the MouseListener and MouseMotionListener ???
plz help, its urgent.
code to fire mouse action :
@Override
public void mouseClicked(MouseEvent event){
System.out.println(event.getPoint());
}//close mouseClicked
@Override
public void mousePressed(MouseEvent event){
System.out.println(event.getPoint());
}//close mouse pressed
@Override
public void mouseMoved(MouseEvent event){}//close mouseMoved
@Override
public void mouseDragged(MouseEvent event){}//close mouseDragged
@Override
public void mouseExited(MouseEvent event){}//close mouseDragged
@Override
public void mouseReleased(MouseEvent event){}//close mouseDragged
@Override
public void mouseEntered(MouseEvent event){}//close mouseDragged
code for initialisation :
P.S:
PuzzlePanel is a class which extends JPanel
PuzzleScrollPane is a class which extends JScrollPane
public class PuzzlePane extends JFrame{
ImageData puzzleImageData;
Dimension gameSetting = new Dimension();
protected PuzzlePanel pp ;
protected PuzzleScrollPane jsp ;
protected Gallery gDialog ;
protected Dimension dimDesktop ;
public PuzzlePane(){
initUI();
}//close public declaration
public void initUI(){
dimDesktop = Toolkit.getDefaultToolkit().getScreenSize();
this.setSize(dimDesktop);
this.setPreferredSize(this.getSize());
pp = new PuzzlePanel();
jsp = new PuzzleScrollPane(pp);
jsp.setBorder(new BevelBorder(1));
jsp.setBackground(Color.cyan);
jsp.setOpaque(false);
jsp.getViewport().setOpaque(false);
jsp.setSize(new Dimension(500,500));
/*jsp.getVerticalScrollBar().setValue(0);
jsp.getHorizontalScrollBar().setValue(0);*/
this.add(jsp);
this.pack();
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.setVisible(true);
}//close initUI