use of java.awt.event.MouseAdapter in project antlrworks by antlr.
the class XJRollOverButton method init.
private void init() {
setBorderPainted(false);
setFocusable(false);
setIconTextGap(0);
setMargin(new Insets(0, 0, 0, 0));
setContentAreaFilled(false);
addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
inside = true;
repaint();
}
@Override
public void mouseExited(MouseEvent e) {
inside = false;
repaint();
}
});
}
use of java.awt.event.MouseAdapter in project jna by java-native-access.
the class BalloonManagerDemo method main.
public static void main(String[] args) {
try {
System.setProperty("sun.java2d.noddraw", "true");
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
}
JFrame f = new JFrame("Balloon Test");
final String BALLOON_TEXT = "<html><center>" + "This is some sample balloon text<br>" + "which has been formatted with html.<br>" + "Click to dismiss.</center></html>";
final JLabel content = new JLabel(BALLOON_TEXT);
content.setIconTextGap(10);
content.setBorder(new EmptyBorder(0, 8, 0, 8));
content.setSize(content.getPreferredSize());
content.setIcon(new InfoIcon());
JLabel label = new JLabel("Click anywhere for more information");
label.setHorizontalAlignment(SwingConstants.CENTER);
label.addMouseListener(new MouseAdapter() {
private MouseListener listener = new MouseAdapter() {
public void mousePressed(MouseEvent e) {
hidePopup(e);
}
};
private Popup popup;
private void hidePopup(MouseEvent e) {
e.getComponent().removeMouseListener(listener);
if (popup != null)
popup.hide();
}
public void mousePressed(MouseEvent e) {
hidePopup(e);
popup = BalloonManager.getBalloon(e.getComponent(), content, e.getX(), e.getY());
popup.show();
content.getParent().addMouseListener(listener);
}
});
f.getContentPane().add(label);
f.pack();
f.setSize(new Dimension(300, 300));
f.setLocation(100, 100);
try {
// Force a load of JNA
WindowUtils.setWindowMask(f, WindowUtils.MASK_NONE);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} 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(null, new JScrollPane(area), "Library Load Error: " + System.getProperty("os.name") + "/" + System.getProperty("os.arch"), JOptionPane.ERROR_MESSAGE);
System.exit(1);
}
}
use of java.awt.event.MouseAdapter in project groovy by apache.
the class TableSorter method addMouseListenerToHeaderInTable.
// There is no-where else to put this.
// Add a mouse listener to the Table to trigger a table sort
// when a column heading is clicked in the JTable.
public void addMouseListenerToHeaderInTable(JTable table) {
final TableSorter sorter = this;
final JTable tableView = table;
tableView.setColumnSelectionAllowed(false);
MouseAdapter listMouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
TableColumnModel columnModel = tableView.getColumnModel();
int viewColumn = columnModel.getColumnIndexAtX(e.getX());
int column = tableView.convertColumnIndexToModel(viewColumn);
if (e.getClickCount() == 1 && column != -1) {
if (lastSortedColumn == column)
ascending = !ascending;
sorter.sortByColumn(column, ascending);
lastSortedColumn = column;
}
}
};
JTableHeader th = tableView.getTableHeader();
th.addMouseListener(listMouseListener);
}
use of java.awt.event.MouseAdapter in project neo4j by neo4j.
the class MainWindow method createStatusPanel.
private JPanel createStatusPanel(CardLayout statusPanelLayout) {
JPanel panel = withLayout(statusPanelLayout, withTitledBorder("Status", createPanel()));
for (DatabaseStatus status : DatabaseStatus.values()) {
panel.add(status.name(), status.display(model));
}
panel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (MouseEvent.BUTTON1 == e.getButton() && e.isAltDown()) {
debugWindow.show();
}
}
});
return panel;
}
use of java.awt.event.MouseAdapter in project neo4j by neo4j.
the class SysTray method setupTrayIcon.
private void setupTrayIcon() {
PopupMenu popUpMenu = createPopupMenu();
trayIcon.setPopupMenu(popUpMenu);
trayIcon.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
listener.open();
}
});
trayIcon.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
listener.open();
}
});
}
Aggregations