6358357: Division by zero in Threads tab when shrinking jconsole window

Reviewed-by: mchung, leifs, jbachorik
This commit is contained in:
Erik Gahlin 2013-08-19 12:57:17 +02:00
parent 0e8b101643
commit bf1e11707b

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -337,6 +337,13 @@ public class Plotter extends JComponent
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(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(); Color oldColor = g.getColor();
Font oldFont = g.getFont(); Font oldFont = g.getFont();
Color fg = getForeground(); Color fg = getForeground();