下面列出了java.awt.Cursor#WAIT_CURSOR 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static boolean isWaitCursor() {
Component focus = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (focus != null) {
if (focus.getCursor().getType() == Cursor.WAIT_CURSOR) {
LOG.finer("wait cursor on focus owner"); // NOI18N
return true;
}
Window w = SwingUtilities.windowForComponent(focus);
if (w != null && isWaitCursorOnWindow(w)) {
LOG.finer("wait cursor on window"); // NOI18N
return true;
}
}
for (Frame f : Frame.getFrames()) {
if (isWaitCursorOnWindow(f)) {
LOG.finer("wait cursor on frame"); // NOI18N
return true;
}
}
LOG.finest("no wait cursor"); // NOI18N
return false;
}
private static boolean isWaitCursorOnWindow(Window w) {
if (w.getCursor().getType() == Cursor.WAIT_CURSOR) {
return true;
}
if (w instanceof JFrame) {
JRootPane root = ((JFrame)w).getRootPane();
if (null != root) {
Component glass = root.getGlassPane();
if (null != glass && glass.getCursor().getType() == Cursor.WAIT_CURSOR) {
return true;
}
}
}
return false;
}
/**
* Set file path.
*
* @param textField TextField to set the file path
* @param f File to set.
* @param imagePanel ImagePnel to set the image
* @return true - no problem / false - error occured
*/
private boolean setFilePath(JTextField textField, File f, ImagePanel imagePanel) {
final Cursor defaultCursor = new Cursor(Cursor.DEFAULT_CURSOR);
final Cursor waitCursor = new Cursor(Cursor.WAIT_CURSOR);
String prevText = textField.getText();
try {
if (textField == null || f == null) {
if (textField != null) textField.setText("");
if (imagePanel != null) imagePanel.clear();
if (imagePanel == splashImage) { this.setSplashBackgroundColor(null); }
return false;
}
this.setCursor(waitCursor);
textField.setText(f.getCanonicalPath());
if (imagePanel != null) {
ImageFile imageFile = checkFile(textField);
if (imageFile == null) {
textField.setText("");
if (imagePanel != null) imagePanel.clear();
if (imagePanel == splashImage) { this.setSplashBackgroundColor(null); }
return false;
}
if (!this.isBatchMode()) {
imagePanel.setImage(imageFile.getImage());
imagePanel.setImageFile(imageFile.getFile());
}
selectedDirectory = imageFile.getFile().getParentFile();
if (IOSImageUtil.isNullOrWhiteSpace(outputPath.getText())) {
File g = new File(f.getParentFile(), this.generateAsAssetCatalogs.isSelected() ? this.getResource("string.dir.assets", "Images.xcassets") : this.getResource("string.dir.generate", "generated"));
outputPath.setText(g.getCanonicalPath());
}
if (imagePanel == splashImage) {
Color c = imageFile.getDefaultBackgroundColor();
this.setSplashBackgroundColor(String.format("%2h%2h%2h%2h", c.getAlpha(), c.getRed(), c.getGreen(), c.getBlue()).replace(' ', '0'));
}
}
final JTextField[] paths = { icon6Path, watchPath, carplayPath, macPath, ipadIconPath, ipadLaunchPath };
for (int i = 0; i < paths.length; i++) {
if (paths[i] == textField) {
optionalImages.setSelectedIndex(i);
}
}
} catch (Throwable t) {
handleThrowable(t);
textField.setText("");
if (imagePanel != null) imagePanel.clear();
return false;
} finally {
boolean mainImageSelected = icon7Image.getImage() != null
|| splashImage.getImage() != null
|| watchImage.getImage() != null
|| icon6Image.getImage() != null;
boolean optionImageSelected = ipadIconImage.getImage() != null
|| ipadLaunchImage.getImage() != null
|| macImage.getImage() != null
|| carplayImage.getImage() != null;
forwardButton.setForeground(optionImageSelected ? COLOR_CYAN : COLOR_DARK_GRAY);
// forwardButton.setText(String.format("%s%s", optionImageSelected ? "* " : "", getResource("label.optional.forward.button", "More >>")));
// forwardButton.setBorder(new LineBorder(optionImageSelected ? COLOR_CYAN : COLOR_DARK_GRAY, 1));
backButton.setForeground(mainImageSelected ? COLOR_WINERED : COLOR_DARK_GRAY);
// backButton.setText(String.format("%s%s", getResource("label.optional.back.button", "<< Back"), mainImageSelected ? " *" : ""));
// backButton.setBorder(new LineBorder(mainImageSelected ? COLOR_WINERED : COLOR_DARK_GRAY, 1));
this.setCursor(defaultCursor);
if (!prevText.equals(textField.getText())) {
this.setStorePropertiesRequested(true);
}
}
return true;
}
public LogPanel() {
if (tailer == null) {
setPreferredSize(new Dimension(400, 300));
setLayout(new BorderLayout());
textArea = new JTextArea();
textArea.setEditable(false);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
JScrollPane scrollPanel = new JScrollPane(textArea);
linesTextField = new JTextField();
linesTextField.setPreferredSize(dim);
linesTextField.setMinimumSize(dim);
linesTextField.setMaximumSize(dim);
linesTextField.setText(String.valueOf(LINES));
JToolBar toolBar = new JToolBar();
toolBar.setRollover(true);
toolBar.add(new ClearLogAction(textArea));
toolBar.add(new ReloadLogAction(textArea, this));
JPanel topPanel = new JPanel();
topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.X_AXIS));
topPanel.add(toolBar);
topPanel.add(Box.createHorizontalStrut(5));
topPanel.add(new JLabel(I18NSupport.getString("logpanel.last.lines")));
topPanel.add(Box.createHorizontalStrut(5));
topPanel.add(linesTextField);
topPanel.add(Box.createHorizontalGlue());
add(topPanel, BorderLayout.NORTH);
add(scrollPanel, BorderLayout.CENTER);
final File log = new File(LOG);
if (!log.exists()) {
try {
new File(LOG_DIR).mkdirs();
boolean created = log.createNewFile();
} catch (IOException ex) {
ex.printStackTrace();
}
}
// read existing text in log
Thread t = new Thread(new Runnable() {
public void run() {
Cursor hourGlassCursor = new Cursor(Cursor.WAIT_CURSOR);
setCursor(hourGlassCursor);
//@todo
//reload(log, textArea);
tailer = new LogFileTailer(log, 1000, false);
tailer.addLogFileTailerListener(LogPanel.this);
tailer.setPriority(Thread.MIN_PRIORITY);
// very consuming !!!
//tailer.start();
Cursor normalCursor = new Cursor(Cursor.DEFAULT_CURSOR);
setCursor(normalCursor);
}
}, "NEXT : " + getClass().getSimpleName());
t.start();
}
}