changeset 9698:68be998c2596

6358357: Division by zero in Threads tab when shrinking jconsole window Reviewed-by: mchung, leifs, jbachorik
author egahlin
date Mon, 19 Aug 2013 12:57:17 +0200
parents eb18a483e772
children bddf55211ed8
files src/share/classes/sun/tools/jconsole/Plotter.java
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/tools/jconsole/Plotter.java	Wed Aug 21 09:59:12 2013 +0100
+++ b/src/share/classes/sun/tools/jconsole/Plotter.java	Mon Aug 19 12:57:17 2013 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -337,6 +337,13 @@
     public void paintComponent(Graphics g) {
         super.paintComponent(g);
 
+        int width = getWidth()-rightMargin-leftMargin-10;
+        int height = getHeight()-topMargin-bottomMargin;
+        if (width <= 0 || height <= 0) {
+            // not enough room to paint anything
+            return;
+        }
+
         Color oldColor = g.getColor();
         Font  oldFont  = g.getFont();
         Color fg = getForeground();