use of java.awt.event.MouseAdapter in project robo4j by Robo4J.
the class LCDColorConverter method createButton.
private Component createButton(String string, final int buttonMaskVal) {
JButton button = new JButton(string);
button.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
MockupLcd.this.maskVal = MockupLcd.this.maskVal & ~buttonMaskVal;
}
@Override
public void mousePressed(MouseEvent e) {
MockupLcd.this.maskVal = MockupLcd.this.maskVal | buttonMaskVal;
try {
Thread.sleep(30);
} catch (InterruptedException e1) {
//
}
}
});
return button;
}
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;
}
use of java.awt.event.MouseAdapter in project EnrichmentMapApp by BaderLab.
the class ColumnHeaderRankOptionRenderer method getTableCellRendererComponent.
@Override
public Component getTableCellRendererComponent(JTable table, final Object value, boolean isSelected, boolean hasFocus, int row, int col) {
// Convert RankingOption to display String
String text = null;
if (value instanceof RankingOption) {
RankingOption rankingOption = (RankingOption) value;
text = rankingOption.getTableHeaderText();
} else if (value instanceof RankOptionErrorHeader) {
RankOptionErrorHeader headerValue = (RankOptionErrorHeader) value;
text = headerValue.getRankingOption().getTableHeaderText();
}
// Use the default renderer to paint the header nicely (with sort arrows)
JTableHeader header = table.getTableHeader();
TableCellRenderer delegate = table.getTableHeader().getDefaultRenderer();
Component component = delegate.getTableCellRendererComponent(table, text, isSelected, hasFocus, row, col);
// Create the panel
JButton button = new JButton("Sort");
SwingUtil.makeSmall(button);
if (isAquaLAF())
button.putClientProperty("JButton.buttonType", "gradient");
button.addActionListener(e -> menuButtonClicked(table, button));
JPanel buttonPanel = new JPanel(new BorderLayout());
buttonPanel.add(button, BorderLayout.CENTER);
buttonPanel.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
buttonPanel.setForeground(header.getForeground());
buttonPanel.setBackground(header.getBackground());
JPanel panel = new JPanel(new BorderLayout());
panel.setForeground(header.getForeground());
panel.setBackground(header.getBackground());
panel.add(component, BorderLayout.CENTER);
panel.add(buttonPanel, BorderLayout.NORTH);
if (value instanceof RankOptionErrorHeader) {
JLabel icon = new JLabel(IconManager.ICON_TIMES_CIRCLE);
icon.setForeground(Color.RED.darker());
icon.setFont(iconManager.getIconFont(13.0f));
icon.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
icon.setOpaque(false);
panel.add(icon, BorderLayout.WEST);
}
// Add mouse listener
if (mouseListener != null) {
header.removeMouseListener(mouseListener);
}
header.addMouseListener(mouseListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int col = header.columnAtPoint(e.getPoint());
if (col == colIndex)
if (e.getY() <= button.getHeight())
button.doClick();
else
sortColumn(table);
else
sortOrder = null;
}
});
return panel;
}
use of java.awt.event.MouseAdapter in project EnrichmentMapApp by BaderLab.
the class SettingsPopupPanel method popup.
public void popup(Component parent) {
JPopupMenu menu = new JPopupMenu();
menu.add(this);
menu.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e)) {
menu.setVisible(false);
}
}
});
menu.show(parent, 0, parent.getHeight());
}
use of java.awt.event.MouseAdapter in project intellij-community by JetBrains.
the class StudyBrowserWindow method makeGoButton.
private JButton makeGoButton(@NotNull final String toolTipText, @NotNull final Icon icon, final int direction) {
final JButton button = new JButton(icon);
button.setEnabled(false);
button.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 1) {
Platform.runLater(() -> myEngine.getHistory().go(direction));
}
}
});
button.setToolTipText(toolTipText);
return button;
}
Aggregations