use of java.awt.event.MouseAdapter in project Botnak by Gocnak.
the class BaseTableHeaderUI method installListeners.
public void installListeners() {
super.installListeners();
myMouseAdapter = new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
if ((header == null) || (header.getTable() == null)) {
return;
}
boolean rolloverEnabled = Boolean.TRUE.equals(header.getClientProperty("rolloverEnabled"));
boolean sortingAllowed = false;
if (JTattooUtilities.getJavaVersion() >= 1.6) {
sortingAllowed = header.getTable().getRowSorter() != null;
}
if (rolloverEnabled || sortingAllowed || header.getReorderingAllowed()) {
if (header.getBounds().contains(e.getPoint())) {
int oldRolloverCol = rolloverCol;
rolloverCol = header.getColumnModel().getColumnIndexAtX(e.getX());
updateRolloverColumn(oldRolloverCol, rolloverCol);
} else {
int oldRolloverCol = rolloverCol;
rolloverCol = -1;
updateRolloverColumn(oldRolloverCol, rolloverCol);
}
}
}
public void mouseEntered(MouseEvent e) {
if ((header == null) || (header.getTable() == null)) {
return;
}
boolean rolloverEnabled = Boolean.TRUE.equals(header.getClientProperty("rolloverEnabled"));
boolean sortingAllowed = false;
if (JTattooUtilities.getJavaVersion() >= 1.6) {
sortingAllowed = header.getTable().getRowSorter() != null;
}
if (rolloverEnabled || sortingAllowed || header.getReorderingAllowed()) {
int oldRolloverCol = rolloverCol;
rolloverCol = header.getColumnModel().getColumnIndexAtX(e.getX());
updateRolloverColumn(oldRolloverCol, rolloverCol);
}
}
public void mouseExited(MouseEvent e) {
if ((header == null) || (header.getTable() == null)) {
return;
}
boolean rolloverEnabled = Boolean.TRUE.equals(header.getClientProperty("rolloverEnabled"));
boolean sortingAllowed = false;
if (JTattooUtilities.getJavaVersion() >= 1.6) {
sortingAllowed = header.getTable().getRowSorter() != null;
}
if (rolloverEnabled || sortingAllowed || header.getReorderingAllowed()) {
int oldRolloverCol = rolloverCol;
rolloverCol = -1;
updateRolloverColumn(oldRolloverCol, rolloverCol);
}
}
};
myMouseMotionAdapter = new MouseMotionAdapter() {
public void mouseMoved(MouseEvent e) {
if ((header == null) || (header.getTable() == null)) {
return;
}
boolean rolloverEnabled = Boolean.TRUE.equals(header.getClientProperty("rolloverEnabled"));
boolean sortingAllowed = false;
if (JTattooUtilities.getJavaVersion() >= 1.6) {
sortingAllowed = header.getTable().getRowSorter() != null;
}
if (rolloverEnabled || sortingAllowed || header.getReorderingAllowed()) {
if (header.getDraggedColumn() == null) {
int oldRolloverCol = rolloverCol;
rolloverCol = header.getColumnModel().getColumnIndexAtX(e.getX());
updateRolloverColumn(oldRolloverCol, rolloverCol);
}
}
}
public void mouseDragged(MouseEvent e) {
if ((header == null) || (header.getTable() == null)) {
return;
}
boolean rolloverEnabled = Boolean.TRUE.equals(header.getClientProperty("rolloverEnabled"));
boolean sortingAllowed = false;
if (JTattooUtilities.getJavaVersion() >= 1.6) {
sortingAllowed = header.getTable().getRowSorter() != null;
}
if (rolloverEnabled || sortingAllowed || header.getReorderingAllowed()) {
if (header.getDraggedColumn() != null && header.getDraggedColumn().getIdentifier() != null) {
rolloverCol = header.getColumnModel().getColumnIndex(header.getDraggedColumn().getIdentifier());
} else if (header.getResizingColumn() != null) {
rolloverCol = -1;
}
}
}
};
header.addMouseListener(myMouseAdapter);
header.addMouseMotionListener(myMouseMotionAdapter);
}
use of java.awt.event.MouseAdapter in project CoreNLP by stanfordnlp.
the class DisplayMatchesPanel method getTreeJPanel.
// END - sebschu
private ScrollableTreeJPanel getTreeJPanel(Tree t, List<Tree> matchedParts) {
final ScrollableTreeJPanel treeJP = new ScrollableTreeJPanel(SwingConstants.CENTER, SwingConstants.TOP);
treeJP.setFontName(fontName);
treeJP.setFontSize(fontSize);
treeJP.setDefaultColor(defaultColor);
treeJP.setMatchedColor(matchedColor);
treeJP.setTree(t);
treeJP.setMatchedParts(matchedParts);
treeJP.setBackground(Color.WHITE);
treeJP.setFocusable(true);
final JPopupMenu treePopup = new JPopupMenu();
JMenuItem copy = new JMenuItem("Copy");
copy.setActionCommand((String) TransferHandler.getCopyAction().getValue(Action.NAME));
copy.addActionListener(new TregexGUI.TransferActionListener());
int mask = TregexGUI.isMacOSX() ? InputEvent.META_MASK : InputEvent.CTRL_MASK;
copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, mask));
treePopup.add(copy);
JMenuItem exportTree = new JMenuItem("Export tree as image");
exportTree.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
doExportTree();
}
});
treePopup.add(exportTree);
//BEGIN - sebschu
JMenuItem showDependencies = new JMenuItem("Show dependencies");
showDependencies.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
showDependencies();
}
});
treePopup.add(showDependencies);
JMenuItem showUniversalDependencies = new JMenuItem("Show universal dependencies");
showUniversalDependencies.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
showUniversalDependencies();
}
});
treePopup.add(showUniversalDependencies);
//END - sebschu
treeJP.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
treeJP.requestFocusInWindow();
}
private void maybeShowPopup(MouseEvent e) {
if (e.isPopupTrigger())
treePopup.show(e.getComponent(), e.getX(), e.getY());
}
@Override
public void mousePressed(MouseEvent e) {
maybeShowPopup(e);
}
@Override
public void mouseReleased(MouseEvent e) {
maybeShowPopup(e);
}
});
DisplayMouseMotionAdapter d = new DisplayMouseMotionAdapter();
treeJP.addMouseMotionListener(d);
treeJP.addMouseListener(d);
treeJP.setTransferHandler(new DisplayTransferHandler());
InputMap imap = treeJP.getInputMap();
imap.put(KeyStroke.getKeyStroke("ctrl C"), TransferHandler.getCopyAction().getValue(Action.NAME));
ActionMap map = treeJP.getActionMap();
map.put(TransferHandler.getCopyAction().getValue(Action.NAME), TransferHandler.getCopyAction());
return treeJP;
}
use of java.awt.event.MouseAdapter in project EnrichmentMapApp by BaderLab.
the class DataSetSelector method getTableScrollPane.
private JScrollPane getTableScrollPane() {
if (tableScrollPane == null) {
tableScrollPane = new JScrollPane();
tableScrollPane.setViewportView(getTable());
final Color bg = UIManager.getColor("Table.background");
tableScrollPane.setBackground(bg);
tableScrollPane.getViewport().setBackground(bg);
tableScrollPane.getViewport().addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
getTable().clearSelection();
}
});
}
return tableScrollPane;
}
use of java.awt.event.MouseAdapter in project EnrichmentMapApp by BaderLab.
the class DataSetSelector method getTable.
private JTable getTable() {
if (table == null) {
final DefaultSelectorTableCellRenderer defRenderer = new DefaultSelectorTableCellRenderer();
final CheckBoxTableCellRenderer checkBoxRenderer = new CheckBoxTableCellRenderer();
table = new JTable(new DefaultTableModel(HEARDER_NAMES, 0)) {
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
if (column == SELECTED_COL_IDX)
return checkBoxRenderer;
return defRenderer;
}
};
table.setTableHeader(null);
table.setShowGrid(false);
JTextField tmpField = new JTextField();
makeSmall(tmpField);
table.setRowHeight(Math.max(table.getRowHeight(), tmpField.getPreferredSize().height - 4));
table.setIntercellSpacing(new Dimension(0, 1));
table.getSelectionModel().addListSelectionListener(e -> {
if (!e.getValueIsAdjusting()) {
updateRemoveButton();
if (table.getSelectedRowCount() > 0)
previousSelectedRows = Arrays.stream(table.getSelectedRows()).boxed().collect(Collectors.toList());
}
});
table.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
final boolean isMac = LookAndFeelUtil.isMac();
// COMMAND button down on MacOS (or CONTROL button down on another OS) or SHIFT?
if ((isMac && e.isMetaDown()) || (!isMac && e.isControlDown()) || e.isShiftDown())
// Ignore!
return;
final int col = table.columnAtPoint(e.getPoint());
if (col == SELECTED_COL_IDX) {
final int row = table.rowAtPoint(e.getPoint());
// Restore previous multiple-row selection first
if (previousSelectedRows != null && previousSelectedRows.contains(row)) {
for (int i : previousSelectedRows) table.addRowSelectionInterval(i, i);
}
toggleChecked(row);
}
}
});
}
return table;
}
use of java.awt.event.MouseAdapter in project azure-tools-for-java by Microsoft.
the class CreateRedisCacheForm method initWidgetListeners.
private void initWidgetListeners() {
txtRedisName.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent documentEvent) {
validateEmptyFields();
}
@Override
public void removeUpdate(DocumentEvent documentEvent) {
validateEmptyFields();
}
@Override
public void changedUpdate(DocumentEvent documentEvent) {
validateEmptyFields();
}
});
cbSubs.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
currentSub = (SubscriptionDetail) cbSubs.getSelectedItem();
fillLocationsAndResourceGrps(currentSub);
validateEmptyFields();
}
});
rdoCreateNewGrp.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
txtNewResGrp.setVisible(true);
cbUseExist.setVisible(false);
newResGrp = true;
validateEmptyFields();
}
});
txtNewResGrp.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent documentEvent) {
validateEmptyFields();
}
@Override
public void removeUpdate(DocumentEvent documentEvent) {
validateEmptyFields();
}
@Override
public void changedUpdate(DocumentEvent documentEvent) {
validateEmptyFields();
}
});
rdoUseExist.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
txtNewResGrp.setVisible(false);
cbUseExist.setVisible(true);
newResGrp = false;
validateEmptyFields();
}
});
cbUseExist.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
validateEmptyFields();
}
});
cbLocations.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
validateEmptyFields();
}
});
lblPricing.addMouseListener(new LinkListener(PRICING_LINK));
cbPricing.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
validateEmptyFields();
}
});
chkNoSSL.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (chkNoSSL.isSelected()) {
noSSLPort = true;
} else {
noSSLPort = false;
}
}
});
cbLocations.setRenderer(new ListCellRendererWrapper<Object>() {
@Override
public void customize(JList jList, Object o, int i, boolean b, boolean b1) {
if (o != null && (o instanceof Location)) {
setText(" " + ((Location) o).displayName());
}
}
});
}
Aggregations