I have a JpopUpMenu that sends this to a frame called "j4a_Lainat", but it only leads me to "Incompatible types: cannot be converted to j3_Paaikkuna". Any help would be appreciated.
EDIT:
private void MENUMousePressed(java.awt.event.MouseEvent evt) {
ImageIcon PlusIcon = new ImageIcon(getClass().getResource("/Img/Buttons/menu_button_pressed.png"));
MENU.setIcon(PlusIcon);
BtnPressed = true;
JPopupMenu menu;
JMenuItem m1,m2,m3, m4;
// Create JButtons
// Create a JPopupMenu
menu = new JPopupMenu() {
@Override
public void paintComponent(final Graphics g) {
g.setColor(Color.WHITE);
g.fillRect(0,0,getWidth(), getHeight());
}
};
// Create JMenuItems
m1=new JMenuItem(new AbstractAction("Lainat"){
@Override
public void actionPerformed(ActionEvent e) {
j4a_Lainat j4 = new j4a_Lainat(this);
j4.setVisible(true);
}
}
);
m3=new JMenuItem(new AbstractAction("Hyväntekeväisyys"){
@Override
public void actionPerformed(ActionEvent e) {
j4d_Hyvantekevaisyys HT = new j4d_Hyvantekevaisyys(YRNIMI);
HT.setVisible(true);
}
});
m2=new JMenuItem(new AbstractAction("Tilastot"){
@Override
public void actionPerformed(ActionEvent e) {
try {
j4e_Tilastot T = new j4e_Tilastot(YRNIMI);
T.setVisible(true);
} catch (ClassNotFoundException ex) {
Logger.getLogger(j3_Paaikkuna.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(j3_Paaikkuna.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
m4=new JMenuItem("CREDITS");
menu.add(m1);
menu.add(m2);
menu.add(m3);
menu.add(m4);
Component b=(Component)evt.getSource();
Point p=b.getLocationOnScreen();
menu.show(this,0,0);
menu.setLocation(p.x-74,p.y+2+b.getHeight());
System.out.println(send);
if(send == true){
System.out.println("Toimii");
j4a_Lainat l = new j4a_Lainat(this);
l.setVisible(true);
}
}
//j4a_Lainat contructor goes as following
j4a_Lainat(j3_Paaikkuna aThis){
initComponents();
j= aThis;
}
The class from which I am calling this is j3_Paaikkuna. Simply put, I just want to open a jpopupmenu, import j3_Paaikkuna to it and use it to call an update method in j3_Paaikkuna.