Show Java memory usage in Jas plotter
Source code name: "canvas2D_gui_jas.py"
Programming language: Python
Topic: Plots/2D
DMelt Version 1. Last modified: 05/25/2016. License: Pro
https://datamelt.org/code/cache/canvas2D_gui_jas_4416.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.


from javax.swing import *
from java.awt import *
from java.awt.event import *
from jas.hist import  JASHist
from jas.hist.test import MemoryDataSource

"""
This is a GUI example to show memory usage 
"""


frame =JDialog();
topPanel = JPanel();
lowerPanel = JPanel();

plot = JASHist()
plot.setBackground(Color.white)
plot.setTitle("Java Memory Usage")
plot.getYAxis().setLabel("MB")
plot.getXAxis().setLabel("Time")
mem=MemoryDataSource()
plot.addData(mem).show(1);

def exitme(event):
       frame.dispose()

def startme(event):
        plot.addData(mem).show(1);
def stopme(event):
         plot.removeAllData();

jB1 = JButton("Start", actionPerformed=startme)
jB2 = JButton("Stop", actionPerformed=stopme)
jB3 = JButton("Exit", actionPerformed=exitme)

lowerPanel.add(jB1)
lowerPanel.add(jB2)
lowerPanel.add(jB3)
topPanel.setLayout(BorderLayout())

jScrollPane1 = JScrollPane()
jScrollPane1.getViewport().add( plot );
topPanel.add(jScrollPane1,BorderLayout.CENTER);
frame.add( topPanel,  BorderLayout.CENTER );
frame.add( lowerPanel, BorderLayout.SOUTH );

frame.setSize(600, 400);
frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE)
frame.setVisible(1)



You see the box below because you did not login.