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();
}
});
}
use of java.awt.event.MouseAdapter in project ACS by ACS-Community.
the class LoggingClient method getStatusLinePnl.
/**
* Returns the panel for the status line
*
* @return the panel for the status line
*/
private JPanel getStatusLinePnl() {
if (statusLinePnl == null) {
try {
// Load the icons for the status of the connection
connectionStatusIcons = new ImageIcon[5];
connectionStatusIcons[CONNECTED_ICON] = new ImageIcon(this.getClass().getResource("/console-connected.png"));
connectionStatusIcons[CONNECTING_ICON] = new ImageIcon(this.getClass().getResource("/console-connecting.png"));
connectionStatusIcons[DISCONNECTED_ICON] = new ImageIcon(this.getClass().getResource("/console-disconnected.png"));
connectionStatusIcons[SUSPENDED_ICON] = new ImageIcon(this.getClass().getResource("/console-suspended.png"));
connectionStatusIcons[DELAY_ICON] = new ImageIcon(this.getClass().getResource("/console-delay.png"));
connectionStatusLbl = new JLabel(connectionStatusIcons[CONNECTING_ICON]);
// Create a label to show the status of the connection with the DB
connectionDBLbl = new JLabel();
statusLinePnl = new javax.swing.JPanel();
statusLinePnl.setName("Status_line");
statusLinePnl.setLayout(new java.awt.GridBagLayout());
GridBagConstraints constraintsProgressBar = new GridBagConstraints();
constraintsProgressBar.gridx = 0;
constraintsProgressBar.gridy = 0;
constraintsProgressBar.fill = GridBagConstraints.BOTH;
constraintsProgressBar.anchor = GridBagConstraints.WEST;
constraintsProgressBar.weightx = 1.0;
constraintsProgressBar.insets = new Insets(1, 2, 1, 1);
statusLinePnl.add(progressBar, constraintsProgressBar);
GridBagConstraints constraintsNumFlt = new GridBagConstraints();
constraintsNumFlt.gridx = 1;
constraintsNumFlt.gridy = 0;
constraintsNumFlt.insets = new Insets(1, 1, 1, 1);
maxNumOfLogsLbl.setVisible(true);
maxNumOfLogsLbl.setBorder(BorderFactory.createLoweredBevelBorder());
Font fntNumFlt = maxNumOfLogsLbl.getFont();
Font newFontNumFlt = fntNumFlt.deriveFont(fntNumFlt.getSize() - 2);
maxNumOfLogsLbl.setFont(newFontNumFlt);
statusLinePnl.add(maxNumOfLogsLbl, constraintsNumFlt);
GridBagConstraints constraintsEngineFlt = new GridBagConstraints();
constraintsEngineFlt.gridx = 2;
constraintsEngineFlt.gridy = 0;
constraintsEngineFlt.insets = new Insets(1, 1, 1, 1);
engineFiltersLbl.setVisible(true);
engineFiltersLbl.setBorder(BorderFactory.createLoweredBevelBorder());
Font fntEngineFlt = engineFiltersLbl.getFont();
Font newFontEngineFlt = fntEngineFlt.deriveFont(fntEngineFlt.getSize() - 2);
engineFiltersLbl.setFont(newFontEngineFlt);
statusLinePnl.add(engineFiltersLbl, constraintsEngineFlt);
GridBagConstraints constraintsTableFlt = new GridBagConstraints();
constraintsTableFlt.gridx = 3;
constraintsTableFlt.gridy = 0;
constraintsTableFlt.insets = new Insets(1, 1, 1, 1);
tableFiltersLbl.setVisible(true);
tableFiltersLbl.setBorder(BorderFactory.createLoweredBevelBorder());
Font fntTableFlt = tableFiltersLbl.getFont();
Font newFontTableFlt = fntTableFlt.deriveFont(fntTableFlt.getSize() - 2);
tableFiltersLbl.setFont(newFontTableFlt);
statusLinePnl.add(tableFiltersLbl, constraintsTableFlt);
GridBagConstraints constraintsAudience = new GridBagConstraints();
constraintsAudience.gridx = 4;
constraintsAudience.gridy = 0;
constraintsAudience.insets = new Insets(1, 1, 1, 1);
audienceLbl.setVisible(true);
audienceLbl.setBorder(BorderFactory.createLoweredBevelBorder());
Font fnt = audienceLbl.getFont();
Font newFont = fnt.deriveFont(fnt.getSize() - 2);
audienceLbl.setFont(newFont);
statusLinePnl.add(audienceLbl, constraintsAudience);
GridBagConstraints constraintsConnectionDBStatus = new GridBagConstraints();
constraintsConnectionDBStatus.gridx = 5;
constraintsConnectionDBStatus.gridy = 0;
constraintsConnectionDBStatus.insets = new Insets(1, 2, 1, 2);
statusLinePnl.add(connectionDBLbl, constraintsConnectionDBStatus);
GridBagConstraints constraintsJlogErrors = new GridBagConstraints();
constraintsConnectionDBStatus.gridx = 6;
constraintsConnectionDBStatus.gridy = 0;
constraintsConnectionDBStatus.insets = new Insets(1, 2, 1, 2);
statusLinePnl.add(jlogErrorLbl, constraintsJlogErrors);
jlogErrorLbl.setVisible(false);
jlogErrorLbl.setToolTipText("Error reading logs");
jlogErrorLbl.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
jlogErrorLbl.setVisible(false);
errorDialog.setVisible(true, LoggingClient.this);
super.mouseClicked(e);
}
});
GridBagConstraints constraintsConnectionStatus = new GridBagConstraints();
constraintsConnectionStatus.gridx = 7;
constraintsConnectionStatus.gridy = 0;
constraintsConnectionStatus.insets = new Insets(1, 2, 1, 2);
statusLinePnl.add(connectionStatusLbl, constraintsConnectionStatus);
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
return statusLinePnl;
}
Aggregations