Creating JPopupMenu using Java Swing
Creating JPopupMenu using Java Swing:https://youtu.be/aPj8HdhQwyU ________________________________________________ How to make JPopupMenu
package Test;
import javax.swing.*;
import java.awt.event.*;
public class PopupMenu {
PopupMenu(){
JFrame frame = new JFrame("Popup Menu Example");
JPopupMenu popupmenu = new JPopupMenu("Edit");
JMenuItem cut = new JMenuItem("Cut");
JMenuItem copy = new JMenuItem("Copy");
JMenuItem paste = new JMenuItem("Paste");
popupmenu.add(cut);
popupmenu.add(copy);
popupmenu.add(paste);
frame.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
popupmenu.show(frame, e.getX(), e.getY());
}
});
frame.add(popupmenu);
frame.setSize(500,300);
frame.setLayout(null);
frame.setVisible(true);
}
public static void main(String[] args) {
new PopupMenu();
}
}
YouTube
https://instagram.com/darkhers
https://www.facebook.com/darkhers
TikTok
https://www.tiktok.com/@darkhers
https://www.pinterest.co.uk/darkhers
Comments
Post a Comment