use of java.awt.Cursor in project briefcase by opendatakit.
the class ServerConnectionDialog method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (CONNECT.equals(e.getActionCommand())) {
// do action...
final ServerConnectionInfo info = new ServerConnectionInfo((textUrlField.getText()).trim(), textUsernameField.getText(), textPasswordField.getPassword());
okButton.setEnabled(false);
cancelButton.setEnabled(false);
String errorString;
Cursor saved = getCursor();
try {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
paint(getGraphics());
terminationFuture.reset();
ServerConnectionTest backgroundAction = new ServerConnectionTest(info, terminationFuture, asTarget);
backgroundAction.run();
isSuccessful = backgroundAction.isSuccessful();
errorString = backgroundAction.getErrorReason();
} finally {
setCursor(saved);
}
if (isSuccessful) {
serverInfo = info;
this.setVisible(false);
} else {
String errorMessage = errorString.trim();
// with punctuation and some not
if (!(errorMessage.endsWith("!") || errorMessage.endsWith("."))) {
errorMessage += ". ";
}
ODKOptionPane.showErrorDialog(this, errorMessage + MessageStrings.PROXY_SET_ADVICE, "Invalid Server URL");
okButton.setEnabled(true);
cancelButton.setEnabled(true);
}
} else {
// cancel...
terminationFuture.markAsCancelled(new TransferAbortEvent("User cancels connection."));
this.setVisible(false);
}
}
use of java.awt.Cursor in project cytoscape-impl by cytoscape.
the class StarterPanel method createLinkLabel.
private JLabel createLinkLabel(final String text, final String url) {
JLabel label = new JLabel(text);
label.setBorder(BorderFactory.createEmptyBorder(4, 8, 4, 8));
label.setForeground(LINK_FONT_COLOR);
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setCursor(new Cursor(Cursor.HAND_CURSOR));
label.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 1)
serviceRegistrar.getService(OpenBrowser.class).openURL(url);
}
});
return label;
}
use of java.awt.Cursor in project gephi by gephi.
the class TimelineDrawer method mouseMoved.
@Override
public void mouseMoved(MouseEvent evt) {
if (model == null) {
return;
}
// System.out.println("mouse moved");
currentMousePositionX = evt.getX();
int x = currentMousePositionX;
int width = getWidth();
int r = settings.selection.visibleHookWidth;
double min = model.getCustomMin();
double max = model.getCustomMax();
double intervalStart = model.getIntervalStart();
double intervalEnd = model.getIntervalEnd();
int sf = Math.max(0, getPixelPosition(intervalStart, max - min, min, width));
int st = Math.min(width, getPixelPosition(intervalEnd, max - min, min, width));
// Tooltip
double pos = getReal(currentMousePositionX, max - min, min, width);
tooltip.setModel(model);
tooltip.start(pos, evt.getLocationOnScreen(), this);
// SELECTED ZONE BEGIN POSITION, IN PIXELS
// int sf = (int) (model.getFromFloat() * (double) w);
// SELECTED ZONE END POSITION, IN PIXELS
// int st = (int) (model.getToFloat() * (double) w);
HighlightedComponent old = highlightedComponent;
Cursor newCursor;
// settings.selection.invisibleHookMargin;
int a = 0;
int position = inPosition(x, r, sf, st);
switch(position) {
case LOC_RESIZE_FROM:
newCursor = CURSOR_LEFT_HOOK;
highlightedComponent = HighlightedComponent.LEFT_HOOK;
break;
case LOC_RESIZE_CENTER:
highlightedComponent = HighlightedComponent.CENTER_HOOK;
newCursor = CURSOR_CENTRAL_HOOK;
break;
case LOC_RESIZE_TO:
highlightedComponent = HighlightedComponent.RIGHT_HOOK;
newCursor = CURSOR_RIGHT_HOOK;
break;
default:
highlightedComponent = HighlightedComponent.NONE;
newCursor = CURSOR_DEFAULT;
break;
}
if (newCursor != getCursor()) {
setCursor(newCursor);
}
// only repaint if highlight has changed (save a lot of fps)
if (highlightedComponent != old) {
repaint();
}
// now we always repaint, because of the tooltip
// repaint();
}
use of java.awt.Cursor in project com.revolsys.open by revolsys.
the class SelectRecordsOverlay method setSelectCursor.
protected void setSelectCursor(final InputEvent event) {
Cursor cursor = null;
if (event != null) {
final boolean selectBox = SwingUtil.isControlOrMetaDown(event) || this.selectBoxX1 != -1;
if (SwingUtil.isShiftDown(event)) {
if (selectBox) {
cursor = CURSOR_SELECT_BOX_ADD;
}
} else if (SwingUtil.isAltDown(event)) {
if (selectBox) {
cursor = CURSOR_SELECT_BOX_DELETE;
}
} else if (SwingUtil.isControlOrMetaDown(event)) {
if (selectBox || !hasOverlayAction()) {
cursor = CURSOR_SELECT_BOX;
}
} else if (this.selectBoxX1 != -1) {
cursor = CURSOR_SELECT_BOX;
}
}
if (cursor == null) {
clearOverlayAction(ACTION_SELECT_RECORDS);
} else {
setOverlayAction(ACTION_SELECT_RECORDS);
setMapCursor(cursor);
}
}
use of java.awt.Cursor in project zencash-swing-wallet-ui by ZencashOfficial.
the class AddressesPanel method createNewAddress.
private void createNewAddress(boolean isZAddress) {
Cursor oldCursor = this.getCursor();
try {
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
// Check for encrypted wallet
final boolean bEncryptedWallet = this.clientCaller.isWalletEncrypted();
if (bEncryptedWallet && isZAddress) {
this.setCursor(oldCursor);
PasswordDialog pd = new PasswordDialog((JFrame) (this.getRootPane().getParent()));
pd.setVisible(true);
if (!pd.isOKPressed()) {
return;
}
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
this.clientCaller.unlockWallet(pd.getPassword());
}
// zend has a bug that sometimes supposedly newly returned addresses have actually
// been used as change addresses.
String address = null;
double dBalance = 0;
do {
address = this.clientCaller.createNewAddress(isZAddress);
Log.info("Newly obtained address is: {0}", address);
String sBalance = this.clientCaller.getBalanceForAddress(address);
if (!Util.stringIsEmpty(sBalance)) {
dBalance = Double.parseDouble(sBalance);
}
if (dBalance > 0) {
Log.warning("New address {0} generated by ZEND has been used before. Will generate another!", address);
}
} while (dBalance > 0);
// Lock the wallet again
if (bEncryptedWallet && isZAddress) {
this.clientCaller.lockWallet();
}
String backupMessage = "";
if (isZAddress) {
backupMessage = langUtil.getString("panel.address.message.backup");
}
this.setCursor(oldCursor);
String label = (String) JOptionPane.showInputDialog(AddressesPanel.this, langUtil.getString("panel.address.label.input.text"), langUtil.getString("panel.address.label.input.title"), JOptionPane.PLAIN_MESSAGE, null, null, "");
this.labelStorage.setLabel(address, label);
JOptionPane.showMessageDialog(this.getRootPane().getParent(), langUtil.getString("panel.address.option.pane.text", (isZAddress ? "Z (Private)" : "T (Transparent)"), address, backupMessage), langUtil.getString("panel.address.option.pane.title"), JOptionPane.INFORMATION_MESSAGE);
this.updateWalletAddressBalanceTableInteractive();
} catch (Exception e) {
this.setCursor(oldCursor);
Log.error("Unexpected error: ", e);
AddressesPanel.this.errorReporter.reportError(e, false);
}
}
Aggregations