6358357: Division by zero in Threads tab when shrinking jconsole window
Reviewed-by: mchung, leifs, jbachorik
--- a/jdk/src/share/classes/sun/tools/jconsole/Plotter.java Wed Aug 21 09:59:12 2013 +0100
+++ b/jdk/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();