use of javax.swing.JPopupMenu in project jna by java-native-access.
the class ShapedWindowDemo method main.
public static void main(String[] args) {
try {
System.setProperty("sun.java2d.noddraw", "true");
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
}
final JFrame frame = new JFrame("Shaped Window Demo");
MouseInputAdapter handler = new MouseInputAdapter() {
private Point offset;
private void showPopup(MouseEvent e) {
final JPopupMenu m = new JPopupMenu();
m.add(new AbstractAction("Hide") {
public void actionPerformed(ActionEvent e) {
frame.setState(JFrame.ICONIFIED);
}
private static final long serialVersionUID = 1L;
});
m.add(new AbstractAction("Close") {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
private static final long serialVersionUID = 1L;
});
m.pack();
m.show(e.getComponent(), e.getX(), e.getY());
}
public void mousePressed(MouseEvent e) {
offset = e.getPoint();
if (e.isPopupTrigger()) {
showPopup(e);
}
}
public void mouseDragged(MouseEvent e) {
if (!SwingUtilities.isLeftMouseButton(e))
return;
Point where = e.getPoint();
where.translate(-offset.x, -offset.y);
Point loc = frame.getLocationOnScreen();
loc.translate(where.x, where.y);
frame.setLocation(loc.x, loc.y);
}
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
showPopup(e);
}
}
};
frame.addMouseListener(handler);
frame.addMouseMotionListener(handler);
ClockFace face = new ClockFace(new Dimension(150, 150));
frame.getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
frame.getContentPane().add(face);
frame.setUndecorated(true);
try {
Shape mask = new Area(new Ellipse2D.Float(0, 0, 150, 150));
WindowUtils.setWindowMask(frame, mask);
if (WindowUtils.isWindowAlphaSupported()) {
WindowUtils.setWindowAlpha(frame, .7f);
}
frame.setIconImage(face.getIconImage());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocation(100, 100);
frame.setVisible(true);
} catch (UnsatisfiedLinkError e) {
e.printStackTrace();
String msg = e.getMessage() + "\nError loading the JNA library";
JTextArea area = new JTextArea(msg);
area.setOpaque(false);
area.setFont(UIManager.getFont("Label.font"));
area.setEditable(false);
area.setColumns(80);
area.setRows(8);
area.setWrapStyleWord(true);
area.setLineWrap(true);
JOptionPane.showMessageDialog(frame, new JScrollPane(area), "Library Load Error: " + System.getProperty("os.name") + "/" + System.getProperty("os.arch"), JOptionPane.ERROR_MESSAGE);
System.exit(1);
}
}
use of javax.swing.JPopupMenu in project ACS by ACS-Community.
the class SmartTextPane method getPopup.
/**
* Insert the method's description here.
* Creation date: (18.2.2002 17:58:02)
* @return javax.swing.JPopupMenu
*/
public javax.swing.JPopupMenu getPopup() {
if (popup == null) {
popup = new JPopupMenu("Smart text pane");
JMenuItem saveItem = new JMenuItem("Save");
saveItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
saveTextToFile();
}
});
popup.add(saveItem);
}
return popup;
}
use of javax.swing.JPopupMenu in project ACS by ACS-Community.
the class ConnectionWidget method initialize.
/**
* Init the GUI
*/
private void initialize() {
popMenu = new JPopupMenu();
reconnectMI = new JMenuItem("Reconnect");
popMenu.add(reconnectMI);
reconnectMI.addActionListener(this);
}
use of javax.swing.JPopupMenu in project ACS by ACS-Community.
the class ErrorTreeCellRenderer method getNewNodePopupMenu.
/**
* This method initializes jPopupMenu
*
* @return javax.swing.JPopupMenu
*/
private JPopupMenu getNewNodePopupMenu() {
if (newNodePopupMenu == null) {
newNodePopupMenu = new JPopupMenu();
newNodePopupMenu.add(getNewErrorMenuItem());
newNodePopupMenu.add(getNewCompletionMenuItem());
}
return newNodePopupMenu;
}
use of javax.swing.JPopupMenu in project ACS by ACS-Community.
the class ErrorTreeCellRenderer method getAddPopupMenu.
/**
* This method initializes jPopupMenu
*
* @return javax.swing.JPopupMenu
*/
private JPopupMenu getAddPopupMenu() {
if (addPopupMenu == null) {
addPopupMenu = new JPopupMenu();
addPopupMenu.add(getAddFileItem());
addPopupMenu.add(getAddDirectoryItem());
addPopupMenu.add(getAddDefaultsItem());
}
return addPopupMenu;
}
Aggregations