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

The following examples show how to use javax.swing.JEditorPane#setBackground() . 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: BrokenProjectInfo.java    From netbeans with Apache License 2.0 6 votes vote down vote up
static JEditorPane getErrorPane(String reason) {
    JEditorPane errorLabel = new JEditorPane();
    JLabel infoLabel = new JLabel();

    errorLabel.setContentType("text/html"); // NOI18N
    errorLabel.setEditable(false);
    errorLabel.setForeground(UIManager.getDefaults().getColor("nb.errorForeground"));
    errorLabel.setRequestFocusEnabled(false);
    errorLabel.setBackground(infoLabel.getBackground());
    errorLabel.setFont(infoLabel.getFont());

    errorLabel.addHyperlinkListener(new BrokenProjectInfo());

    errorLabel.setText(reason);
    
    return errorLabel;
}
 
Example 2
Source File: OQLEditor.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void setEditable(boolean b) {
    JEditorPane editor = getEditor();
    if (editor.isEditable() == b) return;
    
    editor.setEditable(b);

    if (b) {
        if (lastBgColor != null) editor.setBackground(lastBgColor);
        if (lastCaret != null) editor.setCaret(lastCaret);
    } else {
        lastBgColor = editor.getBackground();
        lastCaret = editor.getCaret();
        editor.setBackground(disabledBgColor);
        editor.setCaret(nullCaret);
    }
}
 
Example 3
Source File: OQLEditor.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public void setEditable(boolean b) {
    JEditorPane editor = getEditor();
    if (editor.isEditable() == b) return;
    
    editor.setEditable(b);

    if (b) {
        if (lastBgColor != null) editor.setBackground(lastBgColor);
        if (lastCaret != null) editor.setCaret(lastCaret);
    } else {
        lastBgColor = editor.getBackground();
        lastCaret = editor.getCaret();
        editor.setBackground(disabledBgColor);
        editor.setCaret(nullCaret);
    }
}
 
Example 4
Source File: SingleResultOverview.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Creates the main text representation of this result.
 *
 * @param text
 * @return
 */
private Component makeMainLabel(String text) {
	JEditorPane label = new ExtendedHTMLJEditorPane("text/html", text);
	StyleSheet css = ((HTMLEditorKit) label.getEditorKit()).getStyleSheet();
	css.addRule("body {font-family:Sans;font-size:11pt}");
	css.addRule("h3 {margin:0; padding:0}");
	css.addRule("h4 {margin-bottom:0; margin-top:1ex; padding:0}");
	css.addRule("p  {margin-top:0; margin-bottom:1ex; padding:0}");
	css.addRule("ul {margin-top:0; margin-bottom:1ex; list-style-image: url("
			+ Tools.getResource("icons/help/circle.png") + ")}");
	css.addRule("ul li {padding-bottom: 2px}");
	css.addRule("li.outPorts {padding-bottom: 0px}");
	css.addRule("ul li ul {margin-top:0; margin-bottom:1ex; list-style-image: url("
			+ Tools.getResource("icons/help/line.png") + ")");
	css.addRule("li ul li {padding-bottom:0}");

	label.setEditable(false);
	label.setBackground(Colors.WHITE);

	JScrollPane pane = new JScrollPane(label);
	pane.setBackground(Colors.WHITE);
	pane.setBorder(null);
	return pane;
}
 
Example 5
Source File: mxCellEditor.java    From blog-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 
 */
public mxCellEditor(mxGraphComponent graphComponent)
{
	this.graphComponent = graphComponent;

	// Creates the plain text editor
	textArea = new JTextArea();
	textArea.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
	textArea.setOpaque(false);

	// Creates the HTML editor
	editorPane = new JEditorPane();
	editorPane.setOpaque(false);
	editorPane.setBackground(new Color(0,0,0,0));
	editorPane.setContentType("text/html");

	// Workaround for inserted linefeeds in HTML markup with
	// lines that are longar than 80 chars
	editorPane.setEditorKit(new NoLinefeedHtmlEditorKit());

	// Creates the scollpane that contains the editor
	// FIXME: Cursor not visible when scrolling
	scrollPane = new JScrollPane();
	scrollPane.setBorder(BorderFactory.createEmptyBorder());
	scrollPane.getViewport().setOpaque(false);
	scrollPane.setVisible(false);
	scrollPane.setOpaque(false);

	// Installs custom actions
	editorPane.getActionMap().put(CANCEL_EDITING, cancelEditingAction);
	textArea.getActionMap().put(CANCEL_EDITING, cancelEditingAction);
	editorPane.getActionMap().put(SUBMIT_TEXT, textSubmitAction);
	textArea.getActionMap().put(SUBMIT_TEXT, textSubmitAction);

	// Remembers the action map key for the enter keystroke
	editorEnterActionMapKey = editorPane.getInputMap().get(enterKeystroke);
	textEnterActionMapKey = editorPane.getInputMap().get(enterKeystroke);
}
 
Example 6
Source File: AboutDialog.java    From FancyBing with GNU General Public License v3.0 5 votes vote down vote up
private JPanel createPanel(String text)
{
    JPanel panel = new JPanel(new GridLayout(1, 1));
    JEditorPane editorPane = new JEditorPane();
    editorPane.setBorder(GuiUtil.createEmptyBorder());
    editorPane.setEditable(false);
    if (Platform.isMac())
    {
        editorPane.setForeground(UIManager.getColor("Label.foreground"));
        editorPane.setBackground(UIManager.getColor("Label.background"));
    }
    else
    {
        editorPane.setForeground(Color.black);
        editorPane.setBackground(Color.white);
    }
    panel.add(editorPane);
    EditorKit editorKit =
        JEditorPane.createEditorKitForContentType("text/html");
    editorPane.setEditorKit(editorKit);
    editorPane.setText(text);
    editorPane.addHyperlinkListener(new HyperlinkListener()
        {
            public void hyperlinkUpdate(HyperlinkEvent event)
            {
                HyperlinkEvent.EventType type = event.getEventType();
                if (type == HyperlinkEvent.EventType.ACTIVATED)
                {
                    URL url = event.getURL();
                    if (! Platform.openInExternalBrowser(url))
                        m_messageDialogs.showError(null,
                                                   i18n("MSG_ABOUT_OPEN_URL_FAIL"),
                                                   "", false);
                }
            }
        });
    return panel;
}
 
Example 7
Source File: ResultPanelOutput.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance of ResultPanelOutput
 */
ResultPanelOutput(ResultDisplayHandler displayHandler) {
    super();
    if (LOG) {
        System.out.println("ResultPanelOutput.<init>");
    }
    
    textPane = new JEditorPane();
    textPane.setFont(new Font("monospaced", Font.PLAIN, getFont().getSize()));
    textPane.setEditorKit(new OutputEditorKit());
    textPane.setEditable(false);
    textPane.getCaret().setVisible(true);
    textPane.getCaret().setBlinkRate(0);
    textPane.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    setViewportView(textPane);

    /*
     * On GTK L&F, background of the text pane is gray, even though it is
     * white on a JTextArea. The following is a hack to fix it:
     */
    Color background = UIManager.getColor("TextPane.background");   //NOI18N
    if (background != null) {
        textPane.setBackground(background);
    }

    doc = textPane.getDocument();

    AccessibleContext ac = textPane.getAccessibleContext();
    ac.setAccessibleName(NbBundle.getMessage(getClass(),
                                            "ACSN_OutputTextPane"));//NOI18N
    ac.setAccessibleDescription(NbBundle.getMessage(getClass(),
                                            "ACSD_OutputTextPane"));//NOI18N
    
    this.displayHandler = displayHandler;
}
 
Example 8
Source File: RubyConsole.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
public JComponent createComponent() {
    JPanel panel = new JPanel();
    JPanel console = new JPanel();
    panel.setLayout(new BorderLayout());

    final JEditorPane text = new JTextPane();

    text.setMargin(new Insets(8, 8, 8, 8));
    text.setCaretColor(new Color(0xa4, 0x00, 0x00));
    text.setBackground(new Color(0xf2, 0xf2, 0xf2));
    text.setForeground(new Color(0xa4, 0x00, 0x00));
    Font font = findFont("Monospaced", Font.PLAIN, 14, new String[]{
            "Monaco", "Andale Mono"});

    text.setFont(font);
    JScrollPane pane = new JScrollPane();
    pane.setViewportView(text);
    pane.setBorder(BorderFactory.createLineBorder(Color.darkGray));
    panel.add(pane, BorderLayout.CENTER);
    console.validate();

    final TextAreaReadline tar = new TextAreaReadline(text,
            getString("Wellcom") + " \n\n");

    RubyInstanceConfig config = new RubyInstanceConfig() {
        {
            //setInput(tar.getInputStream());
            //setOutput(new PrintStream(tar.getOutputStream()));
            //setError(new PrintStream(tar.getOutputStream()));
            setObjectSpaceEnabled(false);
        }
    };
    Ruby runtime = Ruby.newInstance(config);
    tar.hookIntoRuntimeWithStreams(runtime);

    run(runtime);
    return panel;
}
 
Example 9
Source File: DocumentationUI.java    From whyline with MIT License 5 votes vote down vote up
public DocumentationUI(WhylineUI whylineUI) {
	
	super("documentation", whylineUI);

	doc = new JEditorPane("text/html", "");
	// This makes the pane respect the background, foreground, font.
	doc.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
	doc.setBackground(UI.getControlBackColor());
	doc.setForeground(UI.getControlTextColor());
	doc.setOpaque(true);
	doc.setFont(UI.getMediumFont());
	doc.setEditable(false);
	
	WhylineScrollPane pane = new WhylineScrollPane(doc);
	pane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
	pane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
	pane.setBorder(new WhylineControlBorder());
	
	setContent(pane);

	setMinimumSize(new Dimension(UI.getDefaultInfoPaneWidth(whylineUI), 0));
	
	doc.addHyperlinkListener(new HyperlinkListener() {
		public void hyperlinkUpdate(HyperlinkEvent e) {
			if(e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
				Util.openURL(e.getURL().toString());
		}
	});
	
}
 
Example 10
Source File: Main.java    From orbit-image-analysis with GNU General Public License v3.0 5 votes vote down vote up
public Main() {
  setLayout(new BorderLayout());

  JTabbedPane tabs = new JTabbedPane();
  add("Center", tabs);

  addDemo(tabs, "JButtonBar", "ButtonBarMain");
  addDemo(tabs, "JDirectoryChooser", "ChooseDirectory");
  addDemo(tabs, "JFontChooser", "ChooseFont");
  addDemo(tabs, "JOutlookBar", "OutlookBarMain");
  addDemo(tabs, "JTaskPane", "TaskPaneMain");
  addDemo(tabs, "PropertySheet", "PropertySheetMain");
  addDemo(tabs, "JTipOfTheDay", "TOTDTest");
  
  try {
    JEditorPane pane = new JEditorPane("text/html", "<html>") {
      protected void paintComponent(java.awt.Graphics g) {
        Graphics2D g2d = (Graphics2D)g;
        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
          RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        super.paintComponent(g);
      }
    };
    pane.setPage(Main.class.getResource("demo.html"));
    pane.setBackground(Color.white);
    pane.setEditable(false);
    pane.setOpaque(true);
    add("South", pane);
  } catch (Exception e) {
  }
}
 
Example 11
Source File: ToolTipSupport.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private JEditorPane createHtmlTextToolTip() {
    class HtmlTextToolTip extends JEditorPane {
        public @Override void setSize(int width, int height) {
            Dimension prefSize = getPreferredSize();
            if (width >= prefSize.width) {
                width = prefSize.width;
            } else { // smaller available width
                super.setSize(width, 10000); // the height is unimportant
                prefSize = getPreferredSize(); // re-read new pref width
            }
            if (height >= prefSize.height) { // enough height
                height = prefSize.height;
            }
            super.setSize(width, height);
        }
        @Override
        public void setKeymap(Keymap map) {
            //#181722: keymaps are shared among components with the same UI
            //a default action will be set to the Keymap of this component below,
            //so it is necessary to use a Keymap that is not shared with other components
            super.setKeymap(addKeymap(null, map));
        }
    }

    JEditorPane tt = new HtmlTextToolTip();
    /* See NETBEANS-403. It still appears possible to use Escape to close the popup when the
    focus is in the editor. */
    tt.putClientProperty(SUPPRESS_POPUP_KEYBOARD_FORWARDING_CLIENT_PROPERTY_KEY, true);

    // setup tooltip keybindings
    filterBindings(tt.getActionMap());
    tt.getActionMap().put(HIDE_ACTION.getValue(Action.NAME), HIDE_ACTION);
    tt.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), HIDE_ACTION.getValue(Action.NAME));
    tt.getKeymap().setDefaultAction(NO_ACTION);

    Font font = UIManager.getFont(UI_PREFIX + ".font"); // NOI18N
    Color backColor = UIManager.getColor(UI_PREFIX + ".background"); // NOI18N
    Color foreColor = UIManager.getColor(UI_PREFIX + ".foreground"); // NOI18N

    if (font != null) {
        tt.setFont(font);
    }
    if (foreColor != null) {
        tt.setForeground(foreColor);
    }
    if (backColor != null) {
        tt.setBackground(backColor);
    }

    tt.setOpaque(true);
    tt.setBorder(BorderFactory.createCompoundBorder(
        BorderFactory.createLineBorder(tt.getForeground()),
        BorderFactory.createEmptyBorder(0, 3, 0, 3)
    ));
    tt.setContentType("text/html"); //NOI18N

    return tt;
}
 
Example 12
Source File: PropertySheetPanel.java    From orbit-image-analysis with GNU General Public License v3.0 4 votes vote down vote up
private void buildUI() {
  LookAndFeelTweaks.setBorderLayout(this);
  LookAndFeelTweaks.setBorder(this);

  actionPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 2, 0));
  actionPanel.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
  add("North", actionPanel);

  sortButton = new JToggleButton(new ToggleSortingAction());
  sortButton.setUI(new BlueishButtonUI());
  sortButton.setText(null);
  actionPanel.add(sortButton);

  asCategoryButton = new JToggleButton(new ToggleModeAction());
  asCategoryButton.setUI(new BlueishButtonUI());
  asCategoryButton.setText(null);
  actionPanel.add(asCategoryButton);

  descriptionButton = new JToggleButton(new ToggleDescriptionAction());
  descriptionButton.setUI(new BlueishButtonUI());
  descriptionButton.setText(null);
  actionPanel.add(descriptionButton);

  split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
  split.setBorder(null);
  split.setResizeWeight(1.0);
  split.setContinuousLayout(true);
  add("Center", split);
  
  tableScroll = new JScrollPane();
  split.setTopComponent(tableScroll);

  descriptionPanel = new JEditorPane("text/html", "<html>");
  descriptionPanel.setBorder(BorderFactory.createEmptyBorder());
  descriptionPanel.setEditable(false);
  descriptionPanel.setBackground(UIManager.getColor("Panel.background"));
  LookAndFeelTweaks.htmlize(descriptionPanel);

  selectionListener = new SelectionListener();

  descriptionScrollPane = new JScrollPane(descriptionPanel);
  descriptionScrollPane.setBorder(LookAndFeelTweaks.addMargin(BorderFactory
    .createLineBorder(UIManager.getColor("controlDkShadow"))));
  descriptionScrollPane.getViewport().setBackground(
    descriptionPanel.getBackground());
  descriptionScrollPane.setMinimumSize(new Dimension(50, 50));
  split.setBottomComponent(descriptionScrollPane);
  
  // by default description is not visible, toolbar is visible.
  setDescriptionVisible(false);
  setToolBarVisible(true);
}
 
Example 13
Source File: OperatorDocumentationBrowser.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Prepares the dockable and its elements.
 */
public OperatorDocumentationBrowser() {
	dockKey.putProperty(ResourceDockKey.PROPERTY_KEY_DEFAULT_FALLBACK_LOCATION, RelativeDockablePosition.BOTTOM_RIGHT);

	setLayout(new BorderLayout());
	contentGbc = new GridBagConstraints();

	contentPanel = new JPanel(new GridBagLayout()) {

		@Override
		public Dimension getPreferredSize() {
			return new Dimension(getParent().getWidth(), super.getPreferredSize().height);
		}
	};

	editor = new JEditorPane("text/html", "<html>-</html>") {

		@Override
		public Dimension getPreferredSize() {
			return new Dimension(getParent().getWidth(), super.getPreferredSize().height);
		}
	};

	// Instantiate Editor and set Settings
	editor.addHyperlinkListener(new OperatorHelpLinkListener());
	editor.setEditable(false);
	HTMLEditorKit hed = new HTMLEditorKit();
	hed.setStyleSheet(createStyleSheet(hed.getStyleSheet()));
	editor.setEditorKit(hed);
	editor.setBackground(Colors.PANEL_BACKGROUND);
	editor.setContentType("text/html");

	// add editor to scrollPane
	JScrollPane scrollPane = new ExtendedJScrollPane(contentPanel);
	scrollPane.setBorder(null);
	scrollPane.setMinimumSize(MINIMUM_DOCUMENTATION_SIZE);
	scrollPane.setPreferredSize(MINIMUM_DOCUMENTATION_SIZE);

	contentGbc.gridx = 0;
	contentGbc.gridy = 0;
	contentGbc.weightx = 1.0f;
	contentGbc.fill = GridBagConstraints.HORIZONTAL;
	contentPanel.add(editor, contentGbc);

	// add filler at bottom
	contentGbc.gridy += 1;
	contentGbc.weighty = 1.0f;
	contentGbc.fill = GridBagConstraints.BOTH;
	contentPanel.add(new JLabel(), contentGbc);

	// prepare contentGbc for feedback form
	contentGbc.gridy += 1;
	contentGbc.weighty = 0.0f;
	contentGbc.fill = GridBagConstraints.HORIZONTAL;

	// add scrollPane to Dockable
	this.add(scrollPane, BorderLayout.CENTER);

	this.setVisible(true);
	this.validate();

	documentationUpdateQueue.start();
}
 
Example 14
Source File: AboutDialog.java    From RemoteSupportTool with Apache License 2.0 4 votes vote down vote up
public void createAndShow() {
    // init dialog
    setTitle(settings.getString("i18n.aboutTitle"));
    setPreferredSize(new Dimension(600, 350));
    setMinimumSize(new Dimension(400, 300));
    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            setVisible(false);
            dispose();
        }
    });

    // sidebar
    SidebarPanel sidebarPanel = new SidebarPanel(
            ImageUtils.loadImage(this.sidebarImageUrl),
            ImageUtils.loadImage(brandingImageUrl)
    );

    // about section
    JEditorPane aboutPane = new JEditorPane();
    aboutPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
    aboutPane.setEditable(false);
    aboutPane.setOpaque(true);
    aboutPane.setBackground(Color.WHITE);
    aboutPane.setContentType("text/html");
    aboutPane.setText(replaceVariables(getAboutText()));
    aboutPane.setCaretPosition(0);
    aboutPane.addHyperlinkListener(e -> {
        //LOGGER.debug("hyperlink / " + e.getEventType() + " / " + e.getURL());
        if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType()))
            AppUtils.browse(e.getURL());
    });
    JScrollPane aboutScrollPane = new JScrollPane(aboutPane);
    aboutScrollPane.setOpaque(false);
    aboutScrollPane.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));

    // close button
    JButton closeButton = new JButton();
    closeButton.setText(settings.getString("i18n.close"));
    closeButton.addActionListener(e -> {
        setVisible(false);
        dispose();
    });

    // website button
    JButton websiteButton = new JButton();
    websiteButton.setText(settings.getString("i18n.website"));
    websiteButton.addActionListener(e -> AppUtils.browse(this.settings.getString("website.author")));

    // github button
    JButton githubButton = new JButton();
    githubButton.setText(settings.getString("i18n.source"));
    githubButton.addActionListener(e -> AppUtils.browse(this.settings.getString("website.source")));

    // build bottom bar
    JPanel buttonBarLeft = new JPanel(new FlowLayout());
    buttonBarLeft.setOpaque(false);
    buttonBarLeft.add(websiteButton);
    buttonBarLeft.add(githubButton);

    JPanel buttonBarRight = new JPanel(new FlowLayout());
    buttonBarRight.setOpaque(false);
    buttonBarRight.add(closeButton);

    JPanel bottomBar = new JPanel(new BorderLayout());
    bottomBar.setOpaque(false);
    bottomBar.add(buttonBarLeft, BorderLayout.WEST);
    bottomBar.add(buttonBarRight, BorderLayout.EAST);

    // add components to the dialog
    getRootPane().setOpaque(true);
    getRootPane().setBackground(Color.WHITE);
    getRootPane().setLayout(new BorderLayout());
    getRootPane().add(sidebarPanel, BorderLayout.WEST);
    getRootPane().add(aboutScrollPane, BorderLayout.CENTER);
    getRootPane().add(bottomBar, BorderLayout.SOUTH);

    // show dialog
    pack();
    setLocationRelativeTo(this.getOwner());
    setVisible(true);
}
 
Example 15
Source File: PropertySheetPanel.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
private void buildUI() {
  LookAndFeelTweaks.setBorderLayout(this);
  LookAndFeelTweaks.setBorder(this);

  actionPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 2, 0));
  actionPanel.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
  actionPanel.setOpaque(false);
  add("North", actionPanel);

  sortButton = new JToggleButton(new ToggleSortingAction());
  sortButton.setUI(new BlueishButtonUI());
  sortButton.setText(null);
  sortButton.setOpaque(false);
  actionPanel.add(sortButton);

  asCategoryButton = new JToggleButton(new ToggleModeAction());
  asCategoryButton.setUI(new BlueishButtonUI());
  asCategoryButton.setText(null);
  asCategoryButton.setOpaque(false);
  actionPanel.add(asCategoryButton);

  descriptionButton = new JToggleButton(new ToggleDescriptionAction());
  descriptionButton.setUI(new BlueishButtonUI());
  descriptionButton.setText(null);
  descriptionButton.setOpaque(false);
  actionPanel.add(descriptionButton);

  split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
  split.setBorder(null);
  split.setResizeWeight(1.0);
  split.setContinuousLayout(true);
  add("Center", split);
  
  tableScroll = new JScrollPane();
  tableScroll.setBorder(BorderFactory.createEmptyBorder());
  split.setTopComponent(tableScroll);

  descriptionPanel = new JEditorPane("text/html", "<html>");
  descriptionPanel.setBorder(BorderFactory.createEmptyBorder());
  descriptionPanel.setEditable(false);
  descriptionPanel.setBackground(UIManager.getColor("Panel.background"));
  LookAndFeelTweaks.htmlize(descriptionPanel);

  selectionListener = new SelectionListener();

  descriptionScrollPane = new JScrollPane(descriptionPanel);
  descriptionScrollPane.setBorder(LookAndFeelTweaks.addMargin(BorderFactory
    .createLineBorder(UIManager.getColor("controlDkShadow"))));
  descriptionScrollPane.getViewport().setBackground(
    descriptionPanel.getBackground());
  descriptionScrollPane.setMinimumSize(new Dimension(50, 50));
  split.setBottomComponent(descriptionScrollPane);
  
  // by default description is not visible, toolbar is visible.
  setDescriptionVisible(false);
  setToolBarVisible(true);
}
 
Example 16
Source File: CheckForUpdateAction.java    From nextreports-designer with Apache License 2.0 4 votes vote down vote up
private JComponent createPanel(String html) {
	System.setProperty("awt.useSystemAAFontSettings", "on");
	final JEditorPane editorPane = new JEditorPane();    	
	HTMLEditorKit kit = new HTMLEditorKit();
	editorPane.setEditorKit(kit);
    editorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
    editorPane.setFont(new Font("Arial", Font.PLAIN, 12));
    editorPane.setPreferredSize(new Dimension(350, 120));
    editorPane.setEditable(false);
    editorPane.setContentType("text/html");
    editorPane.setBackground(new Color(234, 241, 248));        
   
    Document doc = kit.createDefaultDocument();
    editorPane.setDocument(doc);
    editorPane.setText(html);

    // Add Hyperlink listener to process hyperlinks
    editorPane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(final HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) {
                EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        SwingUtilities.getWindowAncestor(editorPane).setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                        editorPane.setToolTipText(e.getURL().toExternalForm());
                    }
                });
            } else if (e.getEventType() == HyperlinkEvent.EventType.EXITED) {
                EventQueue.invokeLater(new Runnable() {
                    public void run() {                            
                        SwingUtilities.getWindowAncestor(editorPane).setCursor(Cursor.getDefaultCursor());
                        editorPane.setToolTipText(null);
                    }
                });
            } else if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {       
            	    FileUtil.openUrl(e.getURL().toString(), AboutAction.class);                       
            }
        }
    });        
    editorPane.addMouseListener(mouseListener);
    JScrollPane sp = new JScrollPane(editorPane);       
    return sp;
}