Skip to content


Browse files Browse the repository at this point in the history
8260690: JConsole User Guide Link from the Help menu is not accessibl…
…e by keyboard

Reviewed-by: aivanov, dmarkov
  • Loading branch information
skodanda authored and Dmitry Markov committed May 21, 2021
1 parent e48d7d6 commit b5d32bb
Showing 1 changed file with 122 additions and 14 deletions.
136 changes: 122 additions & 14 deletions src/jdk.jconsole/share/classes/sun/tools/jconsole/
@@ -1,5 +1,5 @@
* Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -25,17 +25,50 @@


import java.awt.*;
import java.awt.event.*;
import java.awt.BasicStroke;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.FlowLayout;
import java.awt.Graphics2D;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.geom.Rectangle2D;
import java.beans.PropertyVetoException;

import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;

import static java.awt.BorderLayout.*;
import static*;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultHighlighter;
import javax.swing.text.Document;
import javax.swing.text.Highlighter;
import javax.swing.text.JTextComponent;
import javax.swing.text.View;

import static java.awt.BorderLayout.CENTER;
import static java.awt.BorderLayout.NORTH;
import static java.awt.BorderLayout.SOUTH;

import static;
import static;

public class AboutDialog extends InternalDialog {
Expand All @@ -51,6 +84,8 @@ public class AboutDialog extends InternalDialog {

private JLabel statusBar;
private Action closeAction;
private JEditorPane helpLink;
private final String urlStr = getOnlineDocUrl();

public AboutDialog(JConsole jConsole) {
super(jConsole, Messages.HELP_ABOUT_DIALOG_TITLE, false);
Expand All @@ -72,25 +107,49 @@ public AboutDialog(JConsole jConsole) {
String jConsoleVersion = Version.getVersion();
String vmName = System.getProperty("");
String vmVersion = System.getProperty("java.vm.version");
String urlStr = getOnlineDocUrl();
String locUrlStr = urlStr;
if (isBrowseSupported()) {
urlStr = "<a style='color:#35556b' href=\"" + urlStr + "\">" + urlStr + "</a>";
locUrlStr = "<a style='color:#35556b' href=\"" + locUrlStr + "\">" + locUrlStr + "</a>";

JPanel infoAndLogoPanel = new JPanel(new BorderLayout(10, 10));

String colorStr = String.format("%06x", textColor.getRGB() & 0xFFFFFF);
JEditorPane helpLink = new JEditorPane("text/html",
helpLink = new JEditorPane("text/html",
"<html><font color=#"+ colorStr + ">" +
Resources.format(Messages.HELP_ABOUT_DIALOG_JCONSOLE_VERSION, jConsoleVersion) +
"<p>" + Resources.format(Messages.HELP_ABOUT_DIALOG_JAVA_VERSION, (vmName +", "+ vmVersion)) +
"<p>" + urlStr + "</html>");
"<p>" + locUrlStr + "</html>");


infoAndLogoPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

helpLink.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if ((e.getKeyCode() == KeyEvent.VK_ENTER) || (e.getKeyCode() == KeyEvent.VK_SPACE)) {

helpLink.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
public void focusLost(FocusEvent e) {

helpLink.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
Expand Down Expand Up @@ -128,6 +187,25 @@ public void hyperlinkUpdate(HyperlinkEvent e) {

public void highlight() {
try {

Highlighter hilite = helpLink.getHighlighter();
Document doc = helpLink.getDocument();
String text = doc.getText(0, doc.getLength());
int pos = text.indexOf(urlStr, 0);
hilite.addHighlight(pos, pos + urlStr.length(), new HighlightPainter());
} catch (BadLocationException e) {
// ignore

public void removeHighlights() {
Highlighter hilite = helpLink.getHighlighter();

public void showDialog() {
statusBar.setText(" ");
Expand Down Expand Up @@ -192,4 +270,34 @@ private static class TPanel extends JPanel {

private static class HighlightPainter
extends DefaultHighlighter.DefaultHighlightPainter {

public HighlightPainter() {
public Shape paintLayer(Graphics g, int offs0, int offs1, Shape bounds,
JTextComponent c, View view) {
Rectangle alloc;

if (bounds instanceof Rectangle) {
alloc = (Rectangle)bounds;
} else {
alloc = bounds.getBounds();

Graphics2D g2d = (Graphics2D)g;

float[] dash = { 2F, 2F };
Stroke dashedStroke = new BasicStroke(1F, BasicStroke.CAP_SQUARE,
BasicStroke.JOIN_MITER, 3F, dash, 0F);
new Rectangle2D.Float(alloc.x, alloc.y,
alloc.width - 1, alloc.height - 1)));
return alloc;

3 comments on commit b5d32bb

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk11u-dev

Copy link

@openjdk openjdk bot commented on b5d32bb Sep 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheRealMDoerr the backport was successfully created on the branch TheRealMDoerr-backport-b5d32bbf in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

this pull request contains a backport of commit b5d32bbf from the openjdk/jdk repository.

The commit being backported was authored by K Suman Rajkumaar on 21 May 2021 and was reviewed by Alexey Ivanov and Dmitry Markov.


If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch TheRealMDoerr-backport-b5d32bbf:TheRealMDoerr-backport-b5d32bbf
$ git checkout TheRealMDoerr-backport-b5d32bbf
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push TheRealMDoerr-backport-b5d32bbf

Please sign in to comment.