List of usage examples for javax.swing JLabel setCursor
public void setCursor(Cursor cursor)
From source file:net.sourceforge.squirrel_sql.client.preferences.UpdatePreferencesPanel.java
private JPanel createUpdateSitePanel() { JPanel pnl = new JPanel(new GridBagLayout()); pnl.setBorder(BorderFactory.createTitledBorder(i18n.UPDATE_SITE_BORDER_LABEL)); ItemListener urlUpdateItemListener = new UrlItemListener(); DocumentListener urlDocumentListener = new UrlDocumentListener(); final GridBagConstraints gbc = new GridBagConstraints(); setSeparatorConstraints(gbc, 0);/*from www.j av a 2 s . co m*/ gbc.gridwidth = 1; gbc.weightx = 0; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.EAST; siteTypeLabel = new JLabel(i18n.SITE_TYPE_LABEL, JLabel.RIGHT); pnl.add(siteTypeLabel, gbc); // Site type setSeparatorConstraints(gbc, 0); gbc.gridx = 1; gbc.gridwidth = 1; gbc.fill = GridBagConstraints.NONE; pnl.add(getSiteTypePanel(), gbc); setSeparatorConstraints(gbc, 1); pnl.add(getSep(), gbc); // Update server name setLabelConstraints(gbc, 2); _serverLabel = new JLabel(i18n.SERVER, SwingConstants.RIGHT); pnl.add(_serverLabel, gbc); setFieldConstraints(gbc, 2); _updateServerName.getDocument().addDocumentListener(urlDocumentListener); pnl.add(_updateServerName, gbc); // Update server port setLabelConstraints(gbc, 3); _portLabel = new JLabel(i18n.PORT, SwingConstants.RIGHT); pnl.add(_portLabel, gbc); setFieldConstraints(gbc, 3); _updateServerPort.getDocument().addDocumentListener(urlDocumentListener); pnl.add(_updateServerPort, gbc); // Path to release.xml setLabelConstraints(gbc, 4); _pathLabel = new JLabel(i18n.PATH, SwingConstants.RIGHT); pnl.add(_pathLabel, gbc); setFieldConstraints(gbc, 4); _updateServerPath.getDocument().addDocumentListener(urlDocumentListener); pnl.add(_updateServerPath, gbc); // Channnel combo-box setLabelConstraints(gbc, 5); _channelLabel = new JLabel(i18n.CHANNEL, SwingConstants.RIGHT); pnl.add(_channelLabel, gbc); setFieldConstraints(gbc, 5); gbc.fill = GridBagConstraints.NONE; _updateServerChannel.addItemListener(urlUpdateItemListener); pnl.add(_updateServerChannel, gbc); // URL text field setLabelConstraints(gbc, 6); _urlLabel = new JLabel(i18n.URL, SwingConstants.RIGHT); pnl.add(_urlLabel, gbc); setFieldConstraints(gbc, 6); updateUrl(); pnl.add(_updateUrl, gbc); setFieldConstraints(gbc, 7); JLabel lblProxy = new JLabel(s_stringMgr.getString("UpdatePreferencesPanel.proxyHintHtml")); lblProxy.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); lblProxy.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { _prefrenceTabActvivationListener.activateTabForClass(ProxyPreferenceTabComponent.class); } }); pnl.add(lblProxy, gbc); // Test Connection Button Panel (Both the button and the status label setFieldConstraints(gbc, 8); Box buttonBox = Box.createHorizontalBox(); buttonBox.add(_testConnectionButton); buttonBox.add(Box.createHorizontalStrut(20)); buttonBox.add(_testConnectionStatusLabel); _testConnectionButton.addActionListener(new TestConnectionButtonListener()); pnl.add(buttonBox, gbc); // Separator setSeparatorConstraints(gbc, 9); pnl.add(getSep(), gbc); // Local update directory setLabelConstraints(gbc, 10); _localPathLabel = new JLabel(i18n.LOCAL_PATH, SwingConstants.RIGHT); pnl.add(_localPathLabel, gbc); setFieldConstraints(gbc, 10); pnl.add(_localPath, gbc); return pnl; }
From source file:org.datacleaner.panels.WelcomePanel.java
private JComponent createContentPanel() { JComponent result = null;//w ww . ja v a 2 s.com final String welcomePanelClassName = SystemProperties.getString(SystemProperties.UI_DESKTOP_WELCOME_PANEL, null); if (!Strings.isNullOrEmpty(welcomePanelClassName)) { final Injector injector = _dcModule.createInjectorBuilder().with(WelcomePanel.class, this) .createInjector(); try { @SuppressWarnings("unchecked") final Class<? extends JComponent> componentClass = (Class<? extends JComponent>) Class .forName(welcomePanelClassName); result = injector.getInstance(componentClass); } catch (Exception e) { logger.error("Failed to instantiate welcome panel class: {}", welcomePanelClassName, e); } } if (result == null) { result = new DCPanel(); if (Version.isCommunityEdition()) { final JXEditorPane editorPane = new JXEditorPane("text/html", "You're now using the <b>Community Edition</b> of DataCleaner.<br/><br/>" + "We hope that you enjoy this free product. We encourage you to also check out the " + "commercial DataCleaner editions which feature added functionality, " + "helpful getting started wizards and commercial support. " + "You can find more information about them online."); editorPane.setEditable(false); editorPane.setOpaque(false); editorPane.setFont(WidgetUtils.FONT_HEADER2); editorPane.setPreferredSize(new Dimension(DCSplashPanel.WIDTH_CONTENT, 120)); final JButton tryProfessionalButton = WidgetFactory.createDefaultButton("Try professional edition", IconUtils.APPLICATION_ICON); tryProfessionalButton .addActionListener(new OpenBrowserAction("http://datacleaner.org/get_datacleaner")); final JButton readMoreButton = WidgetFactory.createDefaultButton("Compare the editions", IconUtils.WEBSITE); readMoreButton.addActionListener(new OpenBrowserAction("http://datacleaner.org/editions")); final JButton discussionForumButton = WidgetFactory .createDefaultButton("Visit the discussion forum", "images/menu/forum.png"); discussionForumButton.setToolTipText( "Visit the online discussion forum for questions and answers in the community"); final OpenBrowserAction forumActionListener = new OpenBrowserAction("http://datacleaner.org/forum"); discussionForumButton.addActionListener(forumActionListener); final JButton twitterButton = WidgetFactory.createDefaultButton(null, "images/menu/twitter.png"); twitterButton.setToolTipText("Spread the message about #DataCleaner on Twitter"); twitterButton.addActionListener(new OpenBrowserAction("https://twitter.com/intent/tweet?text=" + UrlEscapers.urlFormParameterEscaper().escape("I'm using @DataCleaner (v. " + Version.getVersion() + ") for some really fancy #dataquality stuff!"))); final JButton linkedInButton = WidgetFactory.createDefaultButton(null, "images/menu/linkedin.png"); linkedInButton.setToolTipText("Join our LinkedIn group of users and professionals"); linkedInButton .addActionListener(new OpenBrowserAction("http://www.linkedin.com/groups?gid=3352784")); final JLabel loveFeedbackAnimation = new JLabel( ImageManager.get().getImageIcon("images/window/we_love_community_and_feedback.gif"), JLabel.LEFT); loveFeedbackAnimation.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); loveFeedbackAnimation.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { forumActionListener.actionPerformed(null); } }); final DCPanel innerPanel = new DCPanel(); innerPanel.setLayout(new VerticalLayout()); innerPanel.setBorder( new CompoundBorder(WidgetUtils.BORDER_LIST_ITEM_LEFT_ONLY, new EmptyBorder(0, 20, 0, 0))); innerPanel.add(editorPane); innerPanel.add(DCPanel.flow(tryProfessionalButton, readMoreButton)); innerPanel.add(Box.createVerticalStrut(80)); innerPanel.add(loveFeedbackAnimation); innerPanel.add(Box.createVerticalStrut(20)); innerPanel.add(DCPanel.flow(discussionForumButton, twitterButton, linkedInButton)); innerPanel.add(Box.createVerticalStrut(5)); result.setLayout(new VerticalLayout()); result.add(Box.createVerticalStrut(100)); result.add(innerPanel); } } return wrapContent(result); }
From source file:org.nuclos.client.dbtransfer.DBTransferImport.java
private boolean setupPreviewPanel(List<PreviewPart> previewParts) { boolean blnTransferWithWarnings = false; jpnPreviewHeader.removeAll();// w ww . ja v a2 s . c om jpnPreviewFooter.removeAll(); // setup parameter scroll pane jpnPreviewContent.removeAll(); double[] rowContraints = new double[previewParts.size()]; for (int i = 0; i < previewParts.size(); i++) rowContraints[i] = TableLayout.PREFERRED; final int iWidthBeginnigSpace = 3; final int iWidthSeparator = 6; final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate(); JLabel lbPreviewHeaderEntity = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.11", "Entit\u00e4t")); JLabel lbPreviewHeaderTable = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.12", "Tabellenname")); JLabel lbPreviewHeaderRecords = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.4", "Datens\u00e4tze")); lbPreviewHeaderRecords.setToolTipText( localeDelegate.getMessage("dbtransfer.import.step1.5", "Anzahl der betroffenen Datens\u00e4tze")); utils.initJPanel(jpnPreviewContent, new double[] { iWidthBeginnigSpace, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED }, rowContraints); int iWidthEntityLabelSize = 0; int iWidthTableLabelSize = 0; int iWidthRecordsLabelSize = 0; int iCountNew = 0; int iCountDeleted = 0; int iCountChanged = 0; int iRow = 0; for (final PreviewPart pp : previewParts) { String tooltip = ""; JLabel lbEntity = new JLabel(pp.getEntity()); JLabel lbTable = new JLabel(pp.getTable()); JLabel lbRecords = new JLabel(String.valueOf(pp.getDataRecords())); lbRecords.setHorizontalAlignment(SwingConstants.RIGHT); if (lbEntity.getPreferredSize().width < lbPreviewHeaderEntity.getPreferredSize().width) lbEntity.setPreferredSize(lbPreviewHeaderEntity.getPreferredSize()); if (lbTable.getPreferredSize().width < lbPreviewHeaderTable.getPreferredSize().width) lbTable.setPreferredSize(lbPreviewHeaderTable.getPreferredSize()); if (lbRecords.getPreferredSize().width < lbPreviewHeaderRecords.getPreferredSize().width) lbRecords.setPreferredSize(lbPreviewHeaderRecords.getPreferredSize()); iWidthEntityLabelSize = iWidthEntityLabelSize < lbEntity.getPreferredSize().width ? lbEntity.getPreferredSize().width : iWidthEntityLabelSize; iWidthTableLabelSize = iWidthTableLabelSize < lbTable.getPreferredSize().width ? lbTable.getPreferredSize().width : iWidthTableLabelSize; iWidthRecordsLabelSize = iWidthRecordsLabelSize < lbRecords.getPreferredSize().width ? lbRecords.getPreferredSize().width : iWidthRecordsLabelSize; Icon icoStatement = null; switch (pp.getType()) { case PreviewPart.NEW: tooltip = localeDelegate.getMessage("dbtransfer.import.step1.6", "Entit\u00e4t wird hinzugef\u00fcgt"); icoStatement = ParameterEditor.COMPARE_ICON_NEW; iCountNew++; break; case PreviewPart.CHANGE: tooltip = localeDelegate.getMessage("dbtransfer.import.step1.7", "Entit\u00e4t wird ge\u00e4ndert"); icoStatement = ParameterEditor.COMPARE_ICON_VALUE_CHANGED; iCountChanged++; break; case PreviewPart.DELETE: tooltip = localeDelegate.getMessage("dbtransfer.import.step1.8", "Entit\u00e4t wird gel\u00f6scht"); icoStatement = ParameterEditor.COMPARE_ICON_DELETED; iCountDeleted++; break; } JLabel lbIcon = new JLabel(icoStatement); JLabel lbStatemnts = new JLabel("<html><u>" + localeDelegate.getMessage("dbtransfer.import.step1.9", "Script anzeigen") + "...</u></html>"); lbStatemnts.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); lbStatemnts.addMouseListener(new MouseListener() { @Override public void mouseReleased(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseClicked(MouseEvent e) { String statements = ""; for (String statement : pp.getStatements()) { statements = statements + statement + ";\n\n"; } JTextArea txtArea = new JTextArea(statements); txtArea.setEditable(false); txtArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JScrollPane scroll = new JScrollPane(txtArea); scroll.getVerticalScrollBar().setUnitIncrement(20); scroll.setPreferredSize(new Dimension(600, 300)); scroll.setBorder(BorderFactory.createEmptyBorder()); MainFrameTab overlayFrame = new MainFrameTab( localeDelegate.getMessage("dbtransfer.import.step1.10", "Script f\u00fcr") + " " + pp.getEntity() + " (" + pp.getTable() + ")"); overlayFrame.setLayeredComponent(scroll); ifrm.add(overlayFrame); } }); lbIcon.setToolTipText(tooltip); lbStatemnts.setToolTipText(tooltip); lbEntity.setToolTipText(tooltip); lbTable.setToolTipText(tooltip); jpnPreviewContent.add(lbEntity, "1," + iRow + ",l,c"); jpnPreviewContent.add(lbTable, "3," + iRow + ",l,c"); jpnPreviewContent.add(lbRecords, "5," + iRow + ",r,c"); jpnPreviewContent.add(lbIcon, "7," + iRow + ",l,c"); jpnPreviewContent.add(lbStatemnts, "8," + iRow + ",l,c"); if (pp.getWarning() > 0) { lbIcon.setIcon(Icons.getInstance().getIconPriorityCancel16()); blnTransferWithWarnings = true; } iRow++; } jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "2,0,2," + (iRow - 1)); jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "4,0,4," + (iRow - 1)); jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "6,0,6," + (iRow - 1)); // setup preview header utils.initJPanel(jpnPreviewHeader, new double[] { iWidthBeginnigSpace, iWidthEntityLabelSize, iWidthSeparator, iWidthTableLabelSize, iWidthSeparator, iWidthRecordsLabelSize, iWidthSeparator, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, TableLayout.PREFERRED }, new double[] { TableLayout.PREFERRED }); if (previewParts.isEmpty()) { jpnPreviewHeader.add(new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.18", "Keine Struktur\u00e4nderungen am Datenbankschema.")), "0,0,8,0"); return blnTransferWithWarnings; } jpnPreviewHeader.add(lbPreviewHeaderEntity, "1,0"); jpnPreviewHeader.add(lbPreviewHeaderTable, "3,0"); jpnPreviewHeader.add(lbPreviewHeaderRecords, "5,0"); jpnPreviewHeader.add(new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.13", "\u00c4nderung")), "7,0"); // setup preview footer utils.initJPanel(jpnPreviewFooter, new double[] { TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED }, new double[] { TableLayout.PREFERRED }); final JLabel lbCompare = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.14", "\u00c4nderungen") + ":"); final JLabel lbCompareNew = new JLabel(iCountNew + ""); final JLabel lbCompareDeleted = new JLabel(iCountDeleted + ""); final JLabel lbCompareValueChanged = new JLabel(iCountChanged + ""); lbCompareNew.setIcon(ParameterEditor.COMPARE_ICON_NEW); lbCompareDeleted.setIcon(ParameterEditor.COMPARE_ICON_DELETED); lbCompareValueChanged.setIcon(ParameterEditor.COMPARE_ICON_VALUE_CHANGED); lbCompareNew.setToolTipText(localeDelegate.getMessage("dbtransfer.import.step1.15", "Neue Entit\u00e4ten")); lbCompareDeleted.setToolTipText( localeDelegate.getMessage("dbtransfer.import.step1.17", "Gel\u00f6schte Entit\u00e4ten")); lbCompareValueChanged.setToolTipText( localeDelegate.getMessage("dbtransfer.import.step1.16", "Ge\u00e4nderte Entit\u00e4ten")); jpnPreviewFooter.add(lbCompare, "1,0,r,c"); jpnPreviewFooter.add(lbCompareNew, "2,0,r,c"); jpnPreviewFooter.add(lbCompareValueChanged, "3,0,r,c"); jpnPreviewFooter.add(lbCompareDeleted, "4,0,r,c"); return blnTransferWithWarnings; }
From source file:org.ut.biolab.medsavant.client.view.component.KeyValuePairPanel.java
public void addKey(final String key, boolean showExpand) { Color rowColor = Color.WHITE; if (keyKeyComponentMap.size() % 2 == 0) { rowColor = ViewUtil.getAlternateRowColor(); }// w ww . j av a2 s .com if (newRowsGoIntoMoreSection) { keysInMoreSection.add(key); } rowColor = Color.white; String layoutConstraints = "insets 3 3 3 3, filly"; JPanel valuePanel = ViewUtil.getClearPanel(); valuePanel.setLayout(new MigLayout(layoutConstraints)); valuePanel.setBackground(rowColor); int i = 0; JPanel keyPanel = ViewUtil.getClearPanel(); keyPanel.setLayout(new MigLayout(layoutConstraints + ", alignx right, hmin 30")); keyPanel.setBackground(rowColor); final JLabel keyLabel = getKeyLabel(key); //keyLabel.setBorder(ViewUtil.getMediumBorder()); keyKeyComponentMap.put(key, keyLabel); if (showExpand) { keyLabel.setText("? " + key.toUpperCase()); keyLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); keyLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { toggleMoreVisibility(); if (keyLabel.getText().startsWith("?")) { keyLabel.setText("? " + key.toUpperCase()); } else { keyLabel.setText("? " + key.toUpperCase()); } } }); } keyPanel.add(keyLabel); keyLabel.setVisible(keysVisible); kvpPanel.add(keyPanel, incrementConstraintRow(i++)); kvpPanel.add(valuePanel, incrementConstraintRow(i++)); JPanel[] extraComponents = new JPanel[additionalColumns]; for (int j = 0; j < additionalColumns; j++) { JPanel panel = ViewUtil.getClearPanel(); panel.setBackground(rowColor); ViewUtil.applyHorizontalBoxLayout(panel); //panel.setBorder(border); //panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); extraComponents[j] = panel;//ViewUtil.getClearPanel(); kvpPanel.add(extraComponents[j], incrementConstraintRow(i++)); } // add hidden panel keyDetailConstraints.gridy++; keyDetailConstraints.gridy++; JPanel detailPanel = ViewUtil.getClearPanel(); detailPanel.setBackground(rowColor); //detailPanel.setBorder(ViewUtil.getTinyLineBorder()); detailPanel.setVisible(false); keyDetailComponentMap.put(key, detailPanel); kvpPanel.add(detailPanel, keyDetailConstraints); // update all constraints to skip a line for (int k = 0; k < 2 + additionalColumns; k++) { incrementConstraintRow(k); } keyValueComponentMap.put(key, valuePanel); keyExtraComponentsMap.put(key, extraComponents); setMoreVisibility(showingMore); }
From source file:utybo.branchingstorytree.swing.visuals.AboutDialog.java
@SuppressWarnings("unchecked") public AboutDialog(OpenBSTGUI parent) { super(parent); setTitle(Lang.get("about.title")); setModalityType(ModalityType.APPLICATION_MODAL); JPanel banner = new JPanel(new FlowLayout(FlowLayout.CENTER)); banner.setBackground(OpenBSTGUI.OPENBST_BLUE); JLabel lblOpenbst = new JLabel(new ImageIcon(Icons.getImage("FullLogoWhite", 48))); lblOpenbst.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); banner.add(lblOpenbst, "flowx,cell 0 0,alignx center"); getContentPane().add(banner, BorderLayout.NORTH); JPanel pan = new JPanel(); pan.setLayout(new MigLayout("insets 10, gap 10px", "[grow]", "[][][grow]")); getContentPane().add(pan, BorderLayout.CENTER); JLabel lblWebsite = new JLabel("https://utybo.github.io/BST/"); Font f = lblWebsite.getFont(); @SuppressWarnings("rawtypes") Map attrs = f.getAttributes(); attrs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); lblWebsite.setFont(f.deriveFont(attrs)); lblWebsite.setForeground(OpenBSTGUI.OPENBST_BLUE); lblWebsite.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); lblWebsite.addMouseListener(new MouseAdapter() { @Override/*ww w. j a v a 2 s . co m*/ public void mouseClicked(MouseEvent e) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URL("https://utybo.github.io/BST/").toURI()); } catch (IOException | URISyntaxException e1) { OpenBST.LOG.warn("Exception when trying to open website", e1); } } } }); pan.add(lblWebsite, "cell 0 0,alignx center"); JLabel lblVersion = new JLabel(Lang.get("about.version").replace("$v", OpenBST.VERSION)); pan.add(lblVersion, "flowy,cell 0 1"); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBorder(new LineBorder(pan.getBackground().darker(), 1, false)); pan.add(scrollPane, "cell 0 2,grow"); JTextArea textArea = new JTextArea(); textArea.setMargin(new Insets(5, 5, 5, 5)); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.setFont(new Font(textArea.getFont().getFontName(), Font.PLAIN, (int) (Icons.getScale() * 11))); try (InputStream in = getClass().getResourceAsStream("/utybo/branchingstorytree/swing/about.txt");) { textArea.setText(IOUtils.toString(in, StandardCharsets.UTF_8)); } catch (IOException ex) { OpenBST.LOG.warn("Loading about information failed", ex); } textArea.setEditable(false); textArea.setCaretPosition(0); scrollPane.setViewportView(textArea); JLabel lblTranslatedBy = new JLabel(Lang.get("author")); pan.add(lblTranslatedBy, "cell 0 1"); setSize((int) (Icons.getScale() * 450), (int) (Icons.getScale() * 400)); setLocationRelativeTo(parent); }