< prev index next >

## src/jdk.jconsole/share/classes/sun/tools/jconsole/MemoryTab.java

Print this page

    rev 48858 : Work in progress for JDK-6303622
    Use generic in Swing components like JComboBox
    1. Added generic return type and parameter type for JComboBox.
    2. Modified JList related classes as well.
    3. Reverted the changes made to "getSelectedValues" as suggested by Joe.
    4. Modified files that were failing on Linux and Mac as well.

     209                 poolPlotter.createSequence(thresholdKey, Messages.THRESHOLD, thresholdColor, false);
     210                 poolPlotter.setUseDashedTransitions(thresholdKey, true);
     211
     212                 if (isHeap) {
     213                     plotterList.add(poolPlotter);
     214                 } else {
     215                     // Will be added to plotterList below
     216                     nonHeapPlotters.add(poolPlotter);
     217                 }
     218             }
     219         }
     220         // Add non-heap plotters last
     221         for (PoolPlotter poolPlotter : nonHeapPlotters) {
     222             plotterList.add(poolPlotter);
     223         }
     224     }
     225
     226
     227     public void itemStateChanged(ItemEvent ev) {
     228         if (ev.getStateChange() == ItemEvent.SELECTED) {
     229             Plotter plotter = (Plotter)plotterChoice.getSelectedItem();
     230             plotterPanel.setPlotter(plotter);
     231             plotterPanel.repaint();
     232         }
     233     }
     234
     235     public void gc() {
     236         new Thread("MemoryPanel.gc") {
     237             public void run() {
     238                 ProxyClient proxyClient = vmPanel.getProxyClient();
     239                 try {
     240                     proxyClient.getMemoryMXBean().gc();
     241                 } catch (UndeclaredThrowableException e) {
     242                     proxyClient.markAsDead();
     243                 } catch (IOException e) {
     244                     // Ignore
     245                 }
     246             }
     247         }.start();
     248     }
     249
     363
     364                         if (plotter == heapPlotter && overviewPanel != null) {
     365                             overviewPanel.getPlotter().addValues(timeStamp, used[i]);
     366                             overviewPanel.updateMemoryInfo(used[i], committed[i], max[i]);
     367                         }
     368                     }
     369                 }
     370                 details.setText(detailsStr);
     371             }
     372         };
     373     }
     374
     375     private String formatDetails() {
     376         ProxyClient proxyClient = vmPanel.getProxyClient();
     377         if (proxyClient.isDead()) {
     378             return "";
     379         }
     380
     381         String text = "<table cellspacing=0 cellpadding=0>";
     382
     383         Plotter plotter = (Plotter)plotterChoice.getSelectedItem();
     384         if (plotter == null) {
     385             return "";
     386         }
     387
     388         //long time = plotter.getLastTimeStamp();
     389         long time = System.currentTimeMillis();
     390         String timeStamp = formatDateTime(time);
     391         text += newRow(Messages.TIME, timeStamp);
     392
     393         long used = plotter.getLastValue(usedKey);
     394         long committed = plotter.getLastValue(committedKey);
     395         long max = plotter.getLastValue(maxKey);
     396         long threshold = plotter.getLastValue(thresholdKey);
     397
     398         text += newRow(Messages.USED, formatKBytes(used));
     399         if (committed > 0L) {
     400             text += newRow(Messages.COMMITTED, formatKBytes(committed));
     401         }
     402         if (max > 0L) {
     403             text += newRow(Messages.MAX, formatKBytes(max));
     625             g.drawString(str, x-1, y+1);
     626             g.drawString(str, x+1, y+1);
     627             g.setColor(Color.black);
     628             g.drawString(str, x, y);
     629
     630             str = Messages.NON_HEAP;
     631             stringWidth = fm.stringWidth(str);
     632             x = nonHeapRect.x + (nonHeapRect.width - stringWidth) / 2;
     633             y = nonHeapRect.y + nonHeapRect.height - 6;
     634             g.setColor(Color.white);
     635             g.drawString(str, x-1, y-1);
     636             g.drawString(str, x+1, y-1);
     637             g.drawString(str, x-1, y+1);
     638             g.drawString(str, x+1, y+1);
     639             g.setColor(Color.black);
     640             g.drawString(str, x, y);
     641
     642             // Highlight current plotter
     643             g.setColor(Color.blue);
     644             r = null;
     645             Plotter plotter = (Plotter)plotterChoice.getSelectedItem();
     646             if (plotter == heapPlotter) {
     647                 r = heapRect;
     648             } else if (plotter == nonHeapPlotter) {
     649                 r = nonHeapRect;
     650             } else if (plotter instanceof PoolPlotter) {
     651                 r = getBarRect((PoolPlotter)plotter);
     652             }
     653             if (r != null) {
     654                 g.drawRect(r.x - 1, r.y - 1, r.width + 2, r.height + 2);
     655             }
     656         }
     657
     658         private Rectangle getBarRect(PoolPlotter poolPlotter) {
     659             return new Rectangle(leftMargin + poolPlotter.barX,
     660                                  height - bottomMargin - barHeight,
     661                                  barWidth, barHeight);
     662         }
     663
     664         public Dimension getPreferredSize() {
     665             return new Dimension(nonHeapRect.x + nonHeapRect.width + rightMargin,
     209                 poolPlotter.createSequence(thresholdKey, Messages.THRESHOLD, thresholdColor, false);
     210                 poolPlotter.setUseDashedTransitions(thresholdKey, true);
     211
     212                 if (isHeap) {
     213                     plotterList.add(poolPlotter);
     214                 } else {
     215                     // Will be added to plotterList below
     216                     nonHeapPlotters.add(poolPlotter);
     217                 }
     218             }
     219         }
     220         // Add non-heap plotters last
     221         for (PoolPlotter poolPlotter : nonHeapPlotters) {
     222             plotterList.add(poolPlotter);
     223         }
     224     }
     225
     226
     227     public void itemStateChanged(ItemEvent ev) {
     228         if (ev.getStateChange() == ItemEvent.SELECTED) {
     229             Plotter plotter = plotterChoice.getSelectedItem();
     230             plotterPanel.setPlotter(plotter);
     231             plotterPanel.repaint();
     232         }
     233     }
     234
     235     public void gc() {
     236         new Thread("MemoryPanel.gc") {
     237             public void run() {
     238                 ProxyClient proxyClient = vmPanel.getProxyClient();
     239                 try {
     240                     proxyClient.getMemoryMXBean().gc();
     241                 } catch (UndeclaredThrowableException e) {
     242                     proxyClient.markAsDead();
     243                 } catch (IOException e) {
     244                     // Ignore
     245                 }
     246             }
     247         }.start();
     248     }
     249
     363
     364                         if (plotter == heapPlotter && overviewPanel != null) {
     365                             overviewPanel.getPlotter().addValues(timeStamp, used[i]);
     366                             overviewPanel.updateMemoryInfo(used[i], committed[i], max[i]);
     367                         }
     368                     }
     369                 }
     370                 details.setText(detailsStr);
     371             }
     372         };
     373     }
     374
     375     private String formatDetails() {
     376         ProxyClient proxyClient = vmPanel.getProxyClient();
     377         if (proxyClient.isDead()) {
     378             return "";
     379         }
     380
     381         String text = "<table cellspacing=0 cellpadding=0>";
     382
     383         Plotter plotter = plotterChoice.getSelectedItem();
     384         if (plotter == null) {
     385             return "";
     386         }
     387
     388         //long time = plotter.getLastTimeStamp();
     389         long time = System.currentTimeMillis();
     390         String timeStamp = formatDateTime(time);
     391         text += newRow(Messages.TIME, timeStamp);
     392
     393         long used = plotter.getLastValue(usedKey);
     394         long committed = plotter.getLastValue(committedKey);
     395         long max = plotter.getLastValue(maxKey);
     396         long threshold = plotter.getLastValue(thresholdKey);
     397
     398         text += newRow(Messages.USED, formatKBytes(used));
     399         if (committed > 0L) {
     400             text += newRow(Messages.COMMITTED, formatKBytes(committed));
     401         }
     402         if (max > 0L) {
     403             text += newRow(Messages.MAX, formatKBytes(max));
     625             g.drawString(str, x-1, y+1);
     626             g.drawString(str, x+1, y+1);
     627             g.setColor(Color.black);
     628             g.drawString(str, x, y);
     629
     630             str = Messages.NON_HEAP;
     631             stringWidth = fm.stringWidth(str);
     632             x = nonHeapRect.x + (nonHeapRect.width - stringWidth) / 2;
     633             y = nonHeapRect.y + nonHeapRect.height - 6;
     634             g.setColor(Color.white);
     635             g.drawString(str, x-1, y-1);
     636             g.drawString(str, x+1, y-1);
     637             g.drawString(str, x-1, y+1);
     638             g.drawString(str, x+1, y+1);
     639             g.setColor(Color.black);
     640             g.drawString(str, x, y);
     641
     642             // Highlight current plotter
     643             g.setColor(Color.blue);
     644             r = null;
     645             Plotter plotter = plotterChoice.getSelectedItem();
     646             if (plotter == heapPlotter) {
     647                 r = heapRect;
     648             } else if (plotter == nonHeapPlotter) {
     649                 r = nonHeapRect;
     650             } else if (plotter instanceof PoolPlotter) {
     651                 r = getBarRect((PoolPlotter)plotter);
     652             }
     653             if (r != null) {
     654                 g.drawRect(r.x - 1, r.y - 1, r.width + 2, r.height + 2);
     655             }
     656         }
     657
     658         private Rectangle getBarRect(PoolPlotter poolPlotter) {
     659             return new Rectangle(leftMargin + poolPlotter.barX,
     660                                  height - bottomMargin - barHeight,
     661                                  barWidth, barHeight);
     662         }
     663
     664         public Dimension getPreferredSize() {
     665             return new Dimension(nonHeapRect.x + nonHeapRect.width + rightMargin,

< prev index next >