Java Code Examples for javax.swing.JEditorPane#setFocusable()

The following examples show how to use javax.swing.JEditorPane#setFocusable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AboutDialog.java    From jeveassets with GNU General Public License v2.0 6 votes vote down vote up
private JEditorPane createEditorPane(final boolean addBorder, final String text) {
	JEditorPane jEditorPane = new JEditorPane("text/html",
			"<html><div style=\"font-family: Arial, Helvetica, sans-serif; font-size: 11pt; white-space: nowrap;\">"
			+ text
			+ "</div>"
			);
	jEditorPane.setEditable(false);
	jEditorPane.setFocusable(false);
	jEditorPane.setOpaque(false);
	jEditorPane.setFont(jPanel.getFont());
	jEditorPane.addHyperlinkListener(DesktopUtil.getHyperlinkListener(getDialog()));
	if (addBorder) {
		jEditorPane.setBorder(BorderFactory.createEmptyBorder(11, 11, 11, 11));
	}
	return jEditorPane;
}
 
Example 2
Source File: LongMessageDialog.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Creates a dialog to display a long message.
 *
 * @param owner
 *            the owner window in which the dialog is displayed
 * @param i18nKey
 *            the i18n key
 * @param message
 *            the actual message
 * @param i18nArgs
 *            additional i18n arguments
 * @since 6.5.0
 */
public LongMessageDialog(Window owner, String i18nKey, String message, Object... i18nArgs) {
	super(owner, i18nKey, ModalityType.APPLICATION_MODAL, i18nArgs);
	JEditorPane textComponent = new ExtendedHTMLJEditorPane("text/html", message);
	// so it does not steel ENTER from the default button
	textComponent.setFocusable(false);
	StyleSheet css = ((HTMLEditorKit) textComponent.getEditorKit()).getStyleSheet();
	css.addRule("body { margin : 0; font-family : sans-serif; font-size : 9px; font-style : normal; }");
	css.addRule(".error { font-weight:bold; color:red; font-style:plain; }");
	css.addRule("code { font-weight:bold; color:#000088; }");
	textComponent.setEditable(false);
	JScrollPane scrollPane = new ExtendedJScrollPane(textComponent);
	scrollPane.setBorder(createBorder());
	layoutDefault(scrollPane, NORMAL, makeCloseButton());
}
 
Example 3
Source File: AccountImportDialog.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
public DonePanel() {
	jResult = new JLabel();
	jResult.setFont(new Font(this.getFont().getName(), Font.BOLD, this.getFont().getSize()));

	jHelp = new JEditorPane("text/html", "");
	//jHelp.setLineWrap(true);
	//jHelp.setWrapStyleWord(true);
	jHelp.addHyperlinkListener(DesktopUtil.getHyperlinkListener(getDialog()));
	jHelp.setFont(this.getFont());
	jHelp.setEditable(false);
	jHelp.setOpaque(false);
	jHelp.setFocusable(false);
	jHelp.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

	JScrollPane jScroll = new JScrollPane(jHelp, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	jScroll.setBorder(BorderFactory.createLineBorder(this.getBackground().darker(), 1));

	cardLayout.setHorizontalGroup(
		cardLayout.createParallelGroup()
			.addGroup(cardLayout.createSequentialGroup()
				.addGap(5)
				.addComponent(jResult)
			)
			.addComponent(jScroll, 400, 400, 400)
	);
	cardLayout.setVerticalGroup(
		cardLayout.createSequentialGroup()
			.addComponent(jResult, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			.addComponent(jScroll, 98, 98, 98)
	);
}
 
Example 4
Source File: FileLock.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
private static JEditorPane getMessage(File file) {
	JLabel jLabel = new JLabel();
	JEditorPane jEditorPane = new JEditorPane("text/html", "");
	jEditorPane.setEditable(false);
	jEditorPane.setFocusable(false);
	jEditorPane.setOpaque(false);
	jEditorPane.setText("<html><body style=\"font-family: " + jLabel.getFont().getName() + "; font-size: " + jLabel.getFont().getSize() + "pt\">"
			+ General.get().fileLockMsg(file.getName())
			+ "</body></html>");
	jEditorPane.addHyperlinkListener(DesktopUtil.getHyperlinkListener(null));
	return jEditorPane;
}
 
Example 5
Source File: AccountImportDialog.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public ImportPanel() {
	JEditorPane jHelp = new JEditorPane("text/html", "<html><body style=\"font-family: " + getFont().getName() + "; font-size: " + getFont().getSize() + "pt\">"
		+ DialoguesAccount.get().shareImportHelp() + "</body></html>");
	((HTMLDocument) jHelp.getDocument()).getStyleSheet().addRule("body { font-family: " + getFont().getFamily() + "; " + "font-size: " + this.getFont().getSize() + "pt; }");
	jHelp.setFont(getFont());
	jHelp.setEditable(false);
	jHelp.setFocusable(false);
	jHelp.setOpaque(false);

	jImportClipboard = new JButton(DialoguesAccount.get().shareImportClipboard() , Images.EDIT_PASTE.getIcon());
	jImportClipboard.setActionCommand(AccountImportAction.SHARE_FROM_CLIPBOARD.name());
	jImportClipboard.addActionListener(listener);

	jImportFile= new JButton(DialoguesAccount.get().shareImportFile(), Images.FILTER_LOAD.getIcon());
	jImportFile.setActionCommand(AccountImportAction.SHARE_FROM_FILE.name());
	jImportFile.addActionListener(listener);

	jImport = new JTextArea();
	jImport.setFont(getFont());
	jImport.setEditable(true);
	jImport.setFocusable(true);
	jImport.setOpaque(true);
	jImport.setLineWrap(true);
	jImport.setWrapStyleWord(false);

	JScrollPane jScroll = new JScrollPane(jImport, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	jScroll.setBorder(BorderFactory.createLineBorder(this.getBackground().darker(), 1));

	cardLayout.setHorizontalGroup(
		cardLayout.createParallelGroup()
			.addComponent(jHelp)
			.addGroup(cardLayout.createSequentialGroup()
				.addComponent(jScroll)
				.addGroup(cardLayout.createParallelGroup()
					.addComponent(jImportClipboard, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
					.addComponent(jImportFile, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
				)
			)
	);
	cardLayout.setVerticalGroup(
		cardLayout.createSequentialGroup()
			.addComponent(jHelp)
			.addGroup(cardLayout.createParallelGroup()
				.addComponent(jScroll)
				.addGroup(cardLayout.createSequentialGroup()
					.addComponent(jImportClipboard, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
					.addComponent(jImportFile, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				)
			)
	);
}
 
Example 6
Source File: BugReportService.java    From Shuffle-Move with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @return
 */
@SuppressWarnings("serial")
private JComponent getInstructionPanel() {
   ConfigManager preferencesManager = getUser().getPreferencesManager();
   final int width = preferencesManager.getIntegerValue(KEY_POPUP_WIDTH, DEFAULT_POPUP_WIDTH);
   JEditorPane textPane = new JEditorPane() {
      @Override
      public Dimension getPreferredSize() {
         Dimension d = super.getPreferredSize();
         d.width = width - 40;
         return d;
      }
   };
   textPane.setFocusable(false);
   textPane.setEditable(false);
   textPane.setContentType("text/html");
   textPane.addHyperlinkListener(new HyperlinkListener() {
      @Override
      public void hyperlinkUpdate(HyperlinkEvent e) {
         if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
            if (Desktop.isDesktopSupported()) {
               try {
                  Desktop.getDesktop().browse(e.getURL().toURI());
               } catch (IOException | URISyntaxException | NullPointerException e1) {
                  LOG.severe(getString(KEY_BAD_LINK, e1.getMessage()));
               }
            }
         }
      }
   });
   JScrollPane jsp = new JScrollPane(textPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
         ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
   jsp.getVerticalScrollBar().setUnitIncrement(30);
   String text = getUser().getPathManager().readEntireDocument(getFilePath(), getDefaultFileKey());
   textPane.setText(text);
   textPane.setSelectionStart(0);
   textPane.setSelectionEnd(0);
   textPane.repaint();
   jsp.validate();
   return jsp;
}
 
Example 7
Source File: JdotxtPreferencesDialog.java    From jdotxt with GNU General Public License v3.0 4 votes vote down vote up
private JPanel getHelpPanel() {
	JPanel panel = new JPanel();
	panel.setLayout(new BorderLayout());
	panel.setBackground(Color.WHITE);
	panel.setOpaque(true);

	JLabel labelIcon = new JLabel(new ImageIcon(JdotxtGUI.icon.getImage().getScaledInstance(64, 64, java.awt.Image.SCALE_SMOOTH)));
	labelIcon.setVerticalAlignment(SwingConstants.TOP);
	panel.add(labelIcon, BorderLayout.WEST);
	labelIcon.setPreferredSize(new Dimension(100, 100));

	JPanel panelInfo = new JPanel();
	panel.add(panelInfo, BorderLayout.CENTER);
	panelInfo.setLayout(new BoxLayout(panelInfo, BoxLayout.Y_AXIS));
	panelInfo.add(Box.createVerticalStrut(10));
	panelInfo.setBackground(Color.WHITE);
	panelInfo.setOpaque(true);

	JLabel labelTitle = new JLabel(JdotxtGUI.lang.getWord("jdotxt") + " (Version " + Jdotxt.VERSION + ")");
	labelTitle.setFont(JdotxtGUI.fontB.deriveFont(16f));
	panelInfo.add(labelTitle);

	panelInfo.add(Box.createVerticalStrut(20));

	JEditorPane textInfo = new JEditorPane();
	textInfo.setContentType("text/html");
	textInfo.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
	textInfo.setFont(JdotxtGUI.fontR);
	textInfo.setText(JdotxtGUI.lang.getWord("Text_help"));
	textInfo.setEditable(false);
	textInfo.setFocusable(false);
	textInfo.setAlignmentX(Component.LEFT_ALIGNMENT);
	textInfo.setBorder(BorderFactory.createEmptyBorder());
	textInfo.setMaximumSize(textInfo.getPreferredSize());

	panelInfo.add(textInfo);

	panelInfo.add(Box.createVerticalStrut(20));

	JLabel labelShortcuts = new JLabel(JdotxtGUI.lang.getWord("Shortcuts"));
	labelShortcuts.setFont(JdotxtGUI.fontB.deriveFont(14f));
	panelInfo.add(labelShortcuts);

	panelInfo.add(Box.createVerticalStrut(20));

	JEditorPane textShortcuts = new JEditorPane();
	textShortcuts.setContentType("text/html");
	textShortcuts.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
	textShortcuts.setFont(JdotxtGUI.fontR);
	textShortcuts.setText(JdotxtGUI.lang.getWord("Text_shortcuts"));
	textShortcuts.setEditable(false);
	textShortcuts.setFocusable(false);
	textShortcuts.setAlignmentX(Component.LEFT_ALIGNMENT);
	textShortcuts.setBorder(BorderFactory.createEmptyBorder());
	textShortcuts.setMaximumSize(textShortcuts.getPreferredSize());

	panelInfo.add(textShortcuts);
	panelInfo.add(Box.createVerticalGlue());

	panel.revalidate();
	return panel;
}