List of usage examples for java.awt Cursor getPredefinedCursor
public static Cursor getPredefinedCursor(int type)
From source file:org.languagetool.gui.ResultArea.java
ResultArea(final ResourceBundle messages, final LanguageToolSupport ltSupport, final JTextPane statusPane) { this.messages = messages; this.ltSupport = ltSupport; this.statusPane = statusPane; statusPane.setContentType("text/html"); statusPane.setText(Main.HTML_GREY_FONT_START + messages.getString("resultAreaText") + Main.HTML_FONT_END); statusPane.setEditable(false);/*from w w w. ja va 2 s .c om*/ statusPane.addHyperlinkListener(new MyHyperlinkListener()); statusPane.setTransferHandler(new RetainLineBreakTransferHandler()); ltSupport.addLanguageToolListener(new LanguageToolListener() { @Override public void languageToolEventOccurred(LanguageToolEvent event) { if (event.getType() == LanguageToolEvent.Type.CHECKING_STARTED) { final Language lang = ltSupport.getLanguage(); final String langName; if (lang.isExternal()) { langName = lang.getTranslatedName(messages) + Main.EXTERNAL_LANGUAGE_SUFFIX; } else { langName = lang.getTranslatedName(messages); } final String startCheckText = Main.HTML_GREY_FONT_START + Tools.makeTexti18n(messages, "startChecking", langName) + "..." + Main.HTML_FONT_END; statusPane.setText(startCheckText); setStartText(startCheckText); if (event.getCaller() == marker) { statusPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); } } else if (event.getType() == LanguageToolEvent.Type.CHECKING_FINISHED) { inputText = event.getSource().getTextComponent().getText(); setRuleMatches(event.getSource().getMatches()); if (event.getCaller() == marker || event.getCaller() == null) { displayResult(); if (event.getCaller() == marker) { statusPane.setCursor(Cursor.getDefaultCursor()); } } } else if (event.getType() == LanguageToolEvent.Type.RULE_DISABLED || event.getType() == LanguageToolEvent.Type.RULE_ENABLED) { inputText = event.getSource().getTextComponent().getText(); setRuleMatches(event.getSource().getMatches()); displayResult(); } } }); }
From source file:Main.java
@Override public void mouseMoved(MouseEvent event) { boolean isHyperlink = isHyperlink(event); if (isHyperlink) { tree.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else {/* w w w. j av a 2 s . c o m*/ tree.setCursor(Cursor.getDefaultCursor()); } }
From source file:com.igormaznitsa.sciareto.ui.tabs.TabTitle.java
public TabTitle(@Nonnull final Context context, @Nonnull final TabProvider parent, @Nullable final File associatedFile) { super(new GridBagLayout()); this.parent = parent; this.context = context; this.associatedFile = associatedFile; this.changed = this.associatedFile == null; this.setOpaque(false); final GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 1000.0d;//from ww w . j av a 2 s . c o m final TabTitle theInstance = this; this.titleLabel = new JLabel() { private static final long serialVersionUID = 8689945842487138781L; @Override protected void processKeyEvent(@Nonnull final KeyEvent e) { theInstance.getParent().dispatchEvent(e); } @Override public String getToolTipText() { return theInstance.getToolTipText(); } @Override public boolean isFocusable() { return false; } }; this.add(this.titleLabel, constraints); final Icon uiCloseIcon = UIManager.getIcon("InternalFrameTitlePane.closeIcon"); this.closeButton = new JButton(uiCloseIcon == null ? NIMBUS_CLOSE_ICON : uiCloseIcon) { private static final long serialVersionUID = -8005282815756047979L; @Override public String getToolTipText() { return theInstance.getToolTipText(); } @Override public boolean isFocusable() { return false; } }; this.closeButton.setToolTipText("Close tab"); this.closeButton.setBorder(null); this.closeButton.setContentAreaFilled(false); this.closeButton.setMargin(new Insets(0, 0, 0, 0)); this.closeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); this.closeButton.setOpaque(false); this.closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(@Nonnull final ActionEvent e) { doSafeClose(); } }); constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 0.0d; constraints.insets = new Insets(2, 8, 2, 0); this.add(this.closeButton, constraints); updateView(); ToolTipManager.sharedInstance().registerComponent(closeButton); ToolTipManager.sharedInstance().registerComponent(this.titleLabel); ToolTipManager.sharedInstance().registerComponent(this); }
From source file:EditorPaneExample6.java
public EditorPaneExample6() { super("JEditorPane Example 6"); pane = new JEditorPane(); pane.setEditable(false); // Start read-only getContentPane().add(new JScrollPane(pane), "Center"); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1;//w w w .j ava 2 s .co m c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("File name: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridx = 1; c.gridy = 0; c.gridwidth = 1; c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; textField = new JTextField(32); panel.add(textField, c); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; c.gridwidth = 2; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); // Add a "Save" button saveButton = new JButton("Save"); saveButton.setEnabled(false); c.gridwidth = 1; c.gridx = 2; c.gridy = 0; c.weightx = 0.0; panel.add(saveButton, c); getContentPane().add(panel, "South"); // Change page based on text field textField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String fileName = textField.getText().trim(); file = new File(fileName); absolutePath = file.getAbsolutePath(); String url = "file:///" + absolutePath; try { // Check if the new page and the old // page are the same. URL newURL = new URL(url); URL loadedURL = pane.getPage(); if (loadedURL != null && loadedURL.sameFile(newURL)) { return; } // Try to display the page textField.setEnabled(false); // Disable input textField.paintImmediately(0, 0, textField.getSize().width, textField.getSize().height); saveButton.setEnabled(false); saveButton.paintImmediately(0, 0, saveButton.getSize().width, saveButton.getSize().height); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // Busy cursor loadingState.setText("Loading..."); loadingState.paintImmediately(0, 0, loadingState.getSize().width, loadingState.getSize().height); loadedType.setText(""); loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height); pane.setEditable(false); pane.setPage(url); loadedType.setText(pane.getContentType()); } catch (Exception e) { JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url }, "File Open Error", JOptionPane.ERROR_MESSAGE); loadingState.setText("Failed"); textField.setEnabled(true); setCursor(Cursor.getDefaultCursor()); } } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadingState.setText("Page loaded."); textField.setEnabled(true); // Allow entry of new file name textField.requestFocus(); setCursor(Cursor.getDefaultCursor()); // Allow editing and saving if appropriate pane.setEditable(file.canWrite()); saveButton.setEnabled(file.canWrite()); } } }); // Save button saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { String type = pane.getContentType(); OutputStream os = new BufferedOutputStream(new FileOutputStream(file + ".save")); pane.setEditable(false); textField.setEnabled(false); saveButton.setEnabled(false); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); Document doc = pane.getDocument(); int length = doc.getLength(); if (type.endsWith("/rtf")) { // Saving RTF - use the OutputStream try { pane.getEditorKit().write(os, doc, 0, length); os.close(); } catch (BadLocationException ex) { } } else { // Not RTF - use a Writer. Writer w = new OutputStreamWriter(os); pane.write(w); w.close(); } } catch (IOException e) { JOptionPane.showMessageDialog(pane, new String[] { "Unable to save file", file.getAbsolutePath(), }, "File Save Error", JOptionPane.ERROR_MESSAGE); } pane.setEditable(file.canWrite()); textField.setEnabled(true); saveButton.setEnabled(file.canWrite()); setCursor(Cursor.getDefaultCursor()); } }); }
From source file:com.mirth.connect.client.ui.MessageExportDialog.java
private void export() { String errorMessage = messageExportPanel.validate(true); if (StringUtils.isNotEmpty(errorMessage)) { parent.alertError(this, errorMessage); return;// ww w . j a v a 2 s .c om } int exportCount = 0; MessageWriterOptions writerOptions = messageExportPanel.getMessageWriterOptions(); if (StringUtils.isBlank(writerOptions.getRootFolder())) { parent.alertError(parent, "Please enter a valid root path to store exported files."); setVisible(true); return; } setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try { if (messageExportPanel.isExportLocal()) { PaginatedMessageList messageList = new PaginatedMessageList(); messageList.setChannelId(channelId); messageList.setClient(parent.mirthClient); messageList.setMessageFilter(messageFilter); messageList.setPageSize(pageSize); messageList.setIncludeContent(true); writerOptions.setBaseFolder(SystemUtils.getUserHome().getAbsolutePath()); MessageWriter messageWriter = MessageWriterFactory.getInstance().getMessageWriter(writerOptions, encryptor); AttachmentSource attachmentSource = null; if (writerOptions.includeAttachments()) { attachmentSource = new AttachmentSource() { @Override public List<Attachment> getMessageAttachments(Message message) throws ClientException { return PlatformUI.MIRTH_FRAME.mirthClient .getAttachmentsByMessageId(message.getChannelId(), message.getMessageId()); } }; } try { exportCount = new MessageExporter().exportMessages(messageList, messageWriter, attachmentSource); messageWriter.finishWrite(); } finally { messageWriter.close(); } } else { writerOptions.setIncludeAttachments(messageExportPanel.isIncludeAttachments()); exportCount = parent.mirthClient.exportMessagesServer(channelId, messageFilter, pageSize, writerOptions); } setVisible(false); setCursor(Cursor.getDefaultCursor()); parent.alertInformation(parent, exportCount + " message" + ((exportCount == 1) ? " has" : "s have") + " been successfully exported to: " + writerOptions.getRootFolder()); } catch (Exception e) { setCursor(Cursor.getDefaultCursor()); Throwable cause = (e.getCause() == null) ? e : e.getCause(); parent.alertThrowable(parent, cause); } }
From source file:EditorPaneExample9.java
public EditorPaneExample9() { super("JEditorPane Example 9"); pane = new JEditorPane(); pane.setEditable(false); // Read-only getContentPane().add(new JScrollPane(pane), "Center"); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1;//from ww w . ja va 2 s . c o m c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridy = 3; panel.add(new JLabel(LOAD_TIME), c); c.gridy = 4; c.gridwidth = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; onlineLoad = new JCheckBox("Online Load"); panel.add(onlineLoad, c); onlineLoad.setSelected(true); onlineLoad.setForeground(typeLabel.getForeground()); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; textField = new JTextField(32); panel.add(textField, c); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); timeLabel = new JLabel(""); c.gridy = 3; panel.add(timeLabel, c); getContentPane().add(panel, "South"); // Change page based on text field textField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String url = textField.getText(); try { // Check if the new page and the old // page are the same. URL newURL = new URL(url); URL loadedURL = pane.getPage(); if (loadedURL != null && loadedURL.sameFile(newURL)) { return; } // Try to display the page textField.setEnabled(false); // Disable input textField.paintImmediately(0, 0, textField.getSize().width, textField.getSize().height); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // Busy cursor loadingState.setText("Loading..."); loadingState.paintImmediately(0, 0, loadingState.getSize().width, loadingState.getSize().height); loadedType.setText(""); loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height); timeLabel.setText(""); timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height); startTime = System.currentTimeMillis(); // Choose the loading method if (onlineLoad.isSelected()) { // Usual load via setPage pane.setPage(url); loadedType.setText(pane.getContentType()); } else { pane.setContentType("text/html"); loadedType.setText(pane.getContentType()); if (loader == null) { loader = new HTMLDocumentLoader(); } HTMLDocument doc = loader.loadDocument(new URL(url)); loadComplete(); pane.setDocument(doc); displayLoadTime(); } } catch (Exception e) { System.out.println(e); JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url }, "File Open Error", JOptionPane.ERROR_MESSAGE); loadingState.setText("Failed"); textField.setEnabled(true); setCursor(Cursor.getDefaultCursor()); } } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadComplete(); displayLoadTime(); } } }); }
From source file:org.multibit.viewsystem.swing.action.ShowPreferencesSubmitAction.java
/** * Change preferences./*from w w w . j a va 2 s. c o m*/ */ @Override public void actionPerformed(ActionEvent event) { // boolean feeValidationError = false; boolean wantToFireDataStructureChanged = false; try { if (mainFrame != null) { mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); } // String updateStatusText = ""; if (dataProvider != null) { controller.getModel().setUserPreference(CoreModel.PREVIOUS_UNDO_CHANGES_TEXT, dataProvider.getPreviousUndoChangesText()); // String previousSendFee = dataProvider.getPreviousSendFee(); // String newSendFee = dataProvider.getNewSendFee(); // controller.getModel().setUserPreference(BitcoinModel.PREVIOUS_SEND_FEE, previousSendFee); // // // Check fee is set. // if (newSendFee == null || "".equals(newSendFee)) { // // Fee must be set validation error. // controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, previousSendFee); // feeValidationError = true; // updateStatusText = controller.getLocaliser().getString("showPreferencesPanel.aFeeMustBeSet"); // } // // if (!feeValidationError) { // if (newSendFee.startsWith(ShowPreferencesPanel.UNPARSEABLE_FEE)) { // String newSendFeeTrimmed = newSendFee.substring(ShowPreferencesPanel.UNPARSEABLE_FEE.length() + 1); // // Recycle the old fee and set status message. // controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, previousSendFee); // feeValidationError = true; // updateStatusText = controller.getLocaliser().getString("showPreferencesPanel.couldNotUnderstandFee", // new Object[] { newSendFeeTrimmed }); // } // } // // if (!feeValidationError) { // try { // // Check fee is a number. // BigInteger feeAsBigInteger = Utils.toNanoCoins(newSendFee); // // // Check fee is at least the minimum fee. // if (feeAsBigInteger.compareTo(BitcoinModel.SEND_MINIMUM_FEE) < 0) { // feeValidationError = true; // updateStatusText = controller.getLocaliser().getString( // "showPreferencesPanel.feeCannotBeSmallerThanMinimumFee"); // } else { // if (feeAsBigInteger.compareTo(BitcoinModel.SEND_MAXIMUM_FEE) >= 0) { // feeValidationError = true; // updateStatusText = controller.getLocaliser().getString( // "showPreferencesPanel.feeCannotBeGreaterThanMaximumFee"); // } else { // // Fee is ok. // controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, newSendFee); // } // } // } catch (NumberFormatException nfe) { // // Recycle the old fee and set status message. // controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, previousSendFee); // feeValidationError = true; // updateStatusText = controller.getLocaliser().getString("showPreferencesPanel.couldNotUnderstandFee", // new Object[] { newSendFee }); // } catch (ArithmeticException ae) { // // Recycle the old fee and set status message. // controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, previousSendFee); // feeValidationError = true; // updateStatusText = controller.getLocaliser().getString("showPreferencesPanel.couldNotUnderstandFee", // new Object[] { newSendFee }); // } // } } // Disable language selection, uncomment to enable /* String previousLanguageCode = dataProvider.getPreviousUserLanguageCode(); String newLanguageCode = dataProvider.getNewUserLanguageCode(); controller.getModel().setUserPreference(CoreModel.PREVIOUS_USER_LANGUAGE_CODE, previousLanguageCode); if (previousLanguageCode != null && !previousLanguageCode.equals(newLanguageCode)) { // New language to set on model. controller.getModel().setUserPreference(CoreModel.USER_LANGUAGE_CODE, newLanguageCode); wantToFireDataStructureChanged = true; } */ // Open URI - use dialog. String openUriDialog = dataProvider.getOpenUriDialog(); if (openUriDialog != null) { controller.getModel().setUserPreference(BitcoinModel.OPEN_URI_SHOW_DIALOG, openUriDialog); } // Open URI - use URI. String openUriUseUri = dataProvider.getOpenUriUseUri(); if (openUriUseUri != null) { controller.getModel().setUserPreference(BitcoinModel.OPEN_URI_USE_URI, openUriUseUri); } // Messaging servers boolean messagingServersHasChanged = false; String[] previousMessagingServerURLs = dataProvider.getPreviousMessagingServerURLs(); String[] newMessagingServerURLs = dataProvider.getNewMessagingServerURLs(); // newMessagingServerURLs might be NULL, and thus clear out the user preference. // So let's be explicit and say if no urls are set, we use the default. if (newMessagingServerURLs == null) { newMessagingServerURLs = CoreModel.DEFAULT_MESSAGING_SERVER_URLS; // not URL encoded but is okay as no strange characters. } if (!Arrays.equals(previousMessagingServerURLs, newMessagingServerURLs)) { messagingServersHasChanged = true; String s = StringUtils.join(newMessagingServerURLs, "|"); controller.getModel().setUserPreference(CoreModel.MESSAGING_SERVERS, s); } // Font data. boolean fontHasChanged = false; String previousFontName = dataProvider.getPreviousFontName(); String newFontName = dataProvider.getNewFontName(); controller.getModel().setUserPreference(CoreModel.PREVIOUS_FONT_NAME, previousFontName); if (newFontName != null) { controller.getModel().setUserPreference(CoreModel.FONT_NAME, newFontName); if (!newFontName.equals(previousFontName)) { fontHasChanged = true; } } String previousFontStyle = dataProvider.getPreviousFontStyle(); String newFontStyle = dataProvider.getNewFontStyle(); controller.getModel().setUserPreference(CoreModel.PREVIOUS_FONT_STYLE, previousFontStyle); if (newFontStyle != null) { controller.getModel().setUserPreference(CoreModel.FONT_STYLE, newFontStyle); if (!newFontStyle.equals(previousFontStyle)) { fontHasChanged = true; } } String previousFontSize = dataProvider.getPreviousFontSize(); String newFontSize = dataProvider.getNewFontSize(); controller.getModel().setUserPreference(CoreModel.PREVIOUS_FONT_SIZE, previousFontSize); if (newFontSize != null) { controller.getModel().setUserPreference(CoreModel.FONT_SIZE, newFontSize); if (!newFontSize.equals(previousFontSize)) { fontHasChanged = true; } } // Look and feel. boolean lookAndFeelHasChanged = false; String previousLookAndFeel = dataProvider.getPreviousLookAndFeel(); String newLookAndFeel = dataProvider.getNewLookAndFeel(); controller.getModel().setUserPreference(CoreModel.LOOK_AND_FEEL, previousLookAndFeel); if (newLookAndFeel != null && (!newLookAndFeel.equals(previousLookAndFeel) && !newLookAndFeel.equals(UIManager.getLookAndFeel().getName()))) { controller.getModel().setUserPreference(CoreModel.LOOK_AND_FEEL, newLookAndFeel); lookAndFeelHasChanged = true; } /* // Currency ticker. boolean showTicker = dataProvider.getNewShowTicker(); boolean showBitcoinConvertedToFiat = dataProvider.getNewShowBitcoinConvertedToFiat(); boolean showCurrency = dataProvider.getNewShowCurrency(); boolean showRate = dataProvider.getNewShowRate(); boolean showBid = dataProvider.getNewShowBid(); boolean showAsk = dataProvider.getNewShowAsk(); boolean showExchange = dataProvider.getNewShowExchange(); boolean restartTickerTimer = false; if (dataProvider.getPreviousShowCurrency() != showCurrency) { wantToFireDataStructureChanged = true; restartTickerTimer = true; } else if (dataProvider.getPreviousShowBitcoinConvertedToFiat() != showBitcoinConvertedToFiat) { wantToFireDataStructureChanged = true; if (showBitcoinConvertedToFiat) { restartTickerTimer = true; } } else if (dataProvider.getPreviousShowTicker() != showTicker || showTicker != dataProvider.isTickerVisible()) { wantToFireDataStructureChanged = true; if (showTicker) { restartTickerTimer = true; } } else if (dataProvider.getPreviousShowRate() != showRate) { wantToFireDataStructureChanged = true; restartTickerTimer = true; } else if (dataProvider.getPreviousShowBid() != showBid) { wantToFireDataStructureChanged = true; restartTickerTimer = true; } else if (dataProvider.getPreviousShowAsk() != showAsk) { wantToFireDataStructureChanged = true; restartTickerTimer = true; } else if (dataProvider.getPreviousShowExchange() != showExchange) { wantToFireDataStructureChanged = true; restartTickerTimer = true; } controller.getModel().setUserPreference(ExchangeModel.TICKER_SHOW, Boolean.valueOf(showTicker).toString()); controller.getModel().setUserPreference(ExchangeModel.SHOW_BITCOIN_CONVERTED_TO_FIAT, Boolean.valueOf(showBitcoinConvertedToFiat).toString()); String columnsToShow = ""; if (showCurrency) columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_CURRENCY; if (showRate) columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_LAST_PRICE; if (showBid) columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_BID; if (showAsk) columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_ASK; if (showExchange) columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_EXCHANGE; if ("".equals(columnsToShow)) { // A user could just switch all the columns off in the settings // so // put a 'none' in the list of columns // this is to stop the default columns appearing. columnsToShow = TickerTableModel.TICKER_COLUMN_NONE; } controller.getModel().setUserPreference(ExchangeModel.TICKER_COLUMNS_TO_SHOW, columnsToShow); String previousExchange1 = dataProvider.getPreviousExchange1(); String newExchange1 = dataProvider.getNewExchange1(); if (newExchange1 != null && !newExchange1.equals(previousExchange1)) { controller.getModel().setUserPreference(ExchangeModel.TICKER_FIRST_ROW_EXCHANGE, newExchange1); ExchangeData newExchangeData = new ExchangeData(); newExchangeData.setShortExchangeName(newExchange1); this.exchangeController.getModel().getShortExchangeNameToExchangeMap().put(newExchange1, newExchangeData); wantToFireDataStructureChanged = true; restartTickerTimer = true; } String previousCurrency1 = dataProvider.getPreviousCurrency1(); String newCurrency1 = dataProvider.getNewCurrency1(); if (newCurrency1 != null && !newCurrency1.equals(previousCurrency1)) { controller.getModel().setUserPreference(ExchangeModel.TICKER_FIRST_ROW_CURRENCY, newCurrency1); String newCurrencyCode = newCurrency1; if (ExchangeData.BITCOIN_CHARTS_EXCHANGE_NAME.equals(newExchange1)) { // Use only the last three characters - the currency code. if (newCurrency1.length() >= 3) { newCurrencyCode = newCurrency1.substring(newCurrency1.length() - 3); } } try { CurrencyConverter.INSTANCE.setCurrencyUnit(CurrencyUnit.of(newCurrencyCode)); } catch ( org.joda.money.IllegalCurrencyException e) { e.printStackTrace(); } wantToFireDataStructureChanged = true; restartTickerTimer = true; } String previousShowSecondRow = Boolean.valueOf(dataProvider.getPreviousShowSecondRow()).toString(); String newShowSecondRow = Boolean.valueOf(dataProvider.getNewShowSecondRow()).toString(); if (newShowSecondRow != null && !newShowSecondRow.equals(previousShowSecondRow)) { // New show second row is set on model. controller.getModel().setUserPreference(ExchangeModel.TICKER_SHOW_SECOND_ROW, newShowSecondRow); wantToFireDataStructureChanged = true; restartTickerTimer = true; } String previousExchange2 = dataProvider.getPreviousExchange2(); String newExchange2 = dataProvider.getNewExchange2(); if (newExchange2 != null && !newExchange2.equals(previousExchange2)) { controller.getModel().setUserPreference(ExchangeModel.TICKER_SECOND_ROW_EXCHANGE, newExchange2); ExchangeData newExchangeData = new ExchangeData(); newExchangeData.setShortExchangeName(newExchange2); this.exchangeController.getModel().getShortExchangeNameToExchangeMap().put(newExchange2, newExchangeData); wantToFireDataStructureChanged = true; restartTickerTimer = true; } String previousCurrency2 = dataProvider.getPreviousCurrency2(); String newCurrency2 = dataProvider.getNewCurrency2(); if (newCurrency2 != null && !newCurrency2.equals(previousCurrency2)) { controller.getModel().setUserPreference(ExchangeModel.TICKER_SECOND_ROW_CURRENCY, newCurrency2); wantToFireDataStructureChanged = true; restartTickerTimer = true; } String previousOerApicode = dataProvider.getPreviousOpenExchangeRatesApiCode(); String newOerApiCode = dataProvider.getNewOpenExchangeRatesApiCode(); if (newOerApiCode != null && !newOerApiCode.equals(previousOerApicode)) { wantToFireDataStructureChanged = true; restartTickerTimer = true; controller.getModel().setUserPreference(ExchangeModel.OPEN_EXCHANGE_RATES_API_CODE, newOerApiCode); } */ // Can undo. controller.getModel().setUserPreference(CoreModel.CAN_UNDO_PREFERENCES_CHANGES, "true"); /* if (restartTickerTimer) { // Reinitialise the currency converter. CurrencyConverter.INSTANCE.initialise(controller); // Cancel any existing timer. if (mainFrame.getTickerTimer1() != null) { mainFrame.getTickerTimer1().cancel(); } if (mainFrame.getTickerTimer2() != null) { mainFrame.getTickerTimer2().cancel(); } // Start ticker timer. Timer tickerTimer1 = new Timer(); mainFrame.setTickerTimer1(tickerTimer1); TickerTimerTask tickerTimerTask1 = new TickerTimerTask(this.exchangeController, mainFrame, true); tickerTimerTask1.createExchangeObjects(controller.getModel().getUserPreference(ExchangeModel.TICKER_FIRST_ROW_EXCHANGE)); mainFrame.setTickerTimerTask1(tickerTimerTask1); tickerTimer1.schedule(tickerTimerTask1, 0, TickerTimerTask.DEFAULT_REPEAT_RATE); boolean showSecondRow = Boolean.TRUE.toString().equals( controller.getModel().getUserPreference(ExchangeModel.TICKER_SHOW_SECOND_ROW)); if (showSecondRow) { Timer tickerTimer2 = new Timer(); mainFrame.setTickerTimer2(tickerTimer2); TickerTimerTask tickerTimerTask2 = new TickerTimerTask(this.exchangeController, mainFrame, false); tickerTimerTask2.createExchangeObjects(controller.getModel().getUserPreference( ExchangeModel.TICKER_SECOND_ROW_EXCHANGE)); mainFrame.setTickerTimerTask2(tickerTimerTask2); tickerTimer2.schedule(tickerTimerTask2, TickerTimerTask.TASK_SEPARATION, TickerTimerTask.DEFAULT_REPEAT_RATE); } } */ if (messagingServersHasChanged) { // TODO: Maybe something here so messaging servers are updated and go live immediately? // Currently servers are set here in class SendRequest: /* public void setMessage(CoinSparkMessagePart [] MessageParts,String [] DeliveryServers) */ } if (fontHasChanged) { wantToFireDataStructureChanged = true; } if (lookAndFeelHasChanged) { try { if (CoreModel.SYSTEM_LOOK_AND_FEEL.equals(newLookAndFeel)) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } else { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (newLookAndFeel.equalsIgnoreCase(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } } Font newFont = dataProvider.getSelectedFont(); if (newFont != null) { UIManager.put("ToolTip.font", newFont); } if (wantToFireDataStructureChanged || lookAndFeelHasChanged) { ColorAndFontConstants.init(); FontSizer.INSTANCE.initialise(controller); HelpContentsPanel.clearBrowser(); // Switch off blinks. this.bitcoinController.getModel().setBlinkEnabled(false); try { controller.fireDataStructureChanged(); SwingUtilities.updateComponentTreeUI(mainFrame); } finally { // Switch blinks back on. this.bitcoinController.getModel().setBlinkEnabled(true); } } } finally { if (mainFrame != null) { mainFrame.setCursor(Cursor.getDefaultCursor()); } } }
From source file:it.imtech.configuration.StartWizard.java
/** * Creates a new wizard with active card (Select Language/Server) *//* ww w . jav a2 s. co m*/ public StartWizard() { Globals.setGlobalVariables(); ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader); if (!checkAppDataFiles()) { JOptionPane.showMessageDialog(null, Utility.getBundleString("copy_appdata", bundle), Utility.getBundleString("copy_appdata_title", bundle), JOptionPane.ERROR_MESSAGE); System.exit(1); } DOMConfigurator.configure(Globals.LOG4J); logger = Logger.getLogger(StartWizard.class); logger.info("Starting Application Phaidra Importer"); mainFrame = new JFrame(); if (Utility.internetConnectionAvailable()) { Globals.ONLINE = true; } it.imtech.utility.Utility.cleanUndoDir(); XMLConfiguration internalConf = setConfiguration(); logger.info("Configuration path estabilished"); XMLConfiguration config = setConfigurationPaths(internalConf, bundle); headerPanel = new HeaderPanel(); footerPanel = new FooterPanel(); JButton nextButton = (JButton) footerPanel.getComponentByName("next_button"); JButton prevButton = (JButton) footerPanel.getComponentByName("prev_button"); nextButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (getCurrentCard() instanceof ChooseServer) { ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader); try { mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); Server selected = chooseServer.getSelectedServer(); logger.info("Selected Server = " + selected.getServername()); SelectedServer.getInstance(null).makeEmpty(); SelectedServer.getInstance(selected); if (Globals.ONLINE) { logger.info("Testing server connection..."); ChooseServer.testServerConnection(SelectedServer.getInstance(null).getBaseUrl()); } chooseFolder.updateLanguage(); MetaUtility.getInstance().preInitializeData(); logger.info("Preinitialization done (Vocabulary and Languages"); c1.next(cardsPanel); mainFrame.setCursor(null); } catch (Exception ex) { logger.error(ex.getMessage()); JOptionPane.showMessageDialog(new Frame(), Utility.getBundleString("preinitializemetadataex", bundle)); } } else if (getCurrentCard() instanceof ChooseFolder) { mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); boolean error = chooseFolder.checkFolderSelectionValidity(); if (error == false) { BookImporter x = BookImporter.getInstance(); mainFrame.setCursor(null); mainFrame.setVisible(false); } } } }); prevButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (getCurrentCard() instanceof ChooseServer) { ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader); String title = Utility.getBundleString("dialog_1_title", bundle); String text = Utility.getBundleString("dialog_1", bundle); ConfirmDialog confirm = new ConfirmDialog(mainFrame, true, title, text, Utility.getBundleString("confirm", bundle), Utility.getBundleString("back", bundle)); confirm.setVisible(true); boolean close = confirm.getChoice(); confirm.dispose(); if (close == true) { mainFrame.dispose(); } } else { c1.previous(cardsPanel); } } }); cardsPanel = new JPanel(new CardLayout()); cardsPanel.setBackground(Color.WHITE); chooseServer = new ChooseServer(config); chooseFolder = new ChooseFolder(); cardsPanel.add(chooseServer, "1"); cardsPanel.add(chooseFolder, "2"); cardsPanel.setLayout(c1); c1.show(cardsPanel, "1"); //Main Panel style mainPanel = new JPanel(new BorderLayout()); mainPanel.add(BorderLayout.NORTH, headerPanel); mainPanel.add(BorderLayout.CENTER, cardsPanel); mainPanel.add(BorderLayout.PAGE_END, footerPanel); mainFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); mainFrame.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent windowEvent) { ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader); String title = Utility.getBundleString("dialog_1_title", bundle); String text = Utility.getBundleString("dialog_1", bundle); ConfirmDialog confirm = new ConfirmDialog(mainFrame, true, title, text, Utility.getBundleString("confirm", bundle), Utility.getBundleString("back", bundle)); confirm.setVisible(true); boolean close = confirm.getChoice(); confirm.dispose(); if (close == true) { mainFrame.dispose(); } } }); //Add Style mainFrame.getContentPane().setBackground(Color.white); mainFrame.getContentPane().setLayout(new BorderLayout()); mainFrame.getContentPane().setPreferredSize(new Dimension(640, 400)); mainFrame.getContentPane().add(BorderLayout.CENTER, mainPanel); mainFrame.pack(); //Center frame in the screen Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); int x = (dim.width - mainFrame.getSize().width) / 2; int y = (dim.height - mainFrame.getSize().height) / 2; mainFrame.setLocation(x, y); mainFrame.setVisible(true); }
From source file:GUI.PizzaCat.java
@Override public void actionPerformed(ActionEvent e) { startButton.setEnabled(false);// w w w . jav a 2s .com setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // Instances of javax.swing.SwingWorker are not reusuable, so // we create new instances as needed. task = new Task(); task.addPropertyChangeListener(this); task.execute(); }
From source file:edu.scripps.fl.pubchem.xmltool.gui.PubChemXMLExtractorGUI.java
public void actionPerformed(ActionEvent e) { try {/*from w w w. jav a2 s .c om*/ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (e.getSource() == jbnFileXML) gc.fileChooser(jtfFileXML, "", "open"); else if (e.getSource() == jbnRunExtractor) { URL template = templateForExcel(); File fileExcelOutput = extract(template); if (fileExcelOutput != null) { log.info("Opening excel file through Desktop: " + fileExcelOutput); Desktop.getDesktop().open(fileExcelOutput); } } else if (e.getSource() == jbnCreateReport) { URL template = getClass().getClassLoader().getResource("ExcelTemplate.xlsx"); File fileExcelOutput = extract(template); if (fileExcelOutput != null) { log.info("Opening report through Desktop: " + fileExcelOutput); String fileName = FilenameUtils.removeExtension(fileExcelOutput.getAbsolutePath()); File filePDFOutput = new File(fileName + ".pdf"); File fileWordOutput = new File(fileName + ".docx"); filePDFOutput.deleteOnExit(); fileWordOutput.deleteOnExit(); new ReportController().createReport(pcDep, fileExcelOutput, filePDFOutput, fileWordOutput, isInternal); gc.openPDF(isInternal, filePDFOutput, this); Desktop.getDesktop().open(fileWordOutput); } } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } catch (Throwable throwable) { SwingGUI.handleError(this, throwable); } }