UI SECTION
_data_provider = MPDataProviderFactory.getMPDataProvider(VMConnectionFactory.getVMConnectionImpl());
_frame = new JFrame("Java Heap Memory Observe Tool");
_frame.pack();
_frame.setLocation(0, 0);
_frame.setSize(1000, 650);
_frame.setVisible(true);
_frame.setResizable(false);
_frame.getContentPane().setLayout(new GridBagLayout());
_frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
_data_provider.closeConnections();
System.exit(0);
}
});
/* memory access panel*/
_classes_list = new JList();
_memory_access_panel = new ViewMemoryPanel(_data_provider);
_memory_access_panel.setSize(1000, 300);
_memory_access_panel.update();
_frame.getContentPane().add(_memory_access_panel, new GridBagConstraints(0, 0, 3, 1, 1, 1,
GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0));
JPanel lists_panel = new JPanel();
JScrollPane pane = new JScrollPane() {
public Dimension getPreferredSize() {return new Dimension(350, 250);}
};
_classes_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
_classes_list.addListSelectionListener(new ClassesListSelectionListener());
pane.getViewport().setView(_classes_list);
lists_panel.add(pane);
_frame.getContentPane().add(lists_panel, new GridBagConstraints(0, 1, 2, 1, 1, 1,
GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
_view_objects_panel = new ViewObjectsPanel(_data_provider);
_view_objects_panel.initUI(true);
_frame.getContentPane().add(_view_objects_panel, new GridBagConstraints(2, 1, 1, 1, 1, 1,
GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
JPanel button_panel = new JPanel();
_statistics_btn = new JButton("Statistics");
_statistics_btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
StatisticsDialog.showDialog(_frame, _data_provider.calculateStatistics());
}
});
button_panel.add(_statistics_btn);
_vm_controller = new JButton("Resume");
_vm_controller.addActionListener(new VMActionListener());
button_panel.add(_vm_controller);
_connection_controller = new JButton("Connect");
_connection_controller.addActionListener(new ConnectionActionListener());
button_panel.add(_connection_controller);
_frame.getContentPane().add(button_panel, new GridBagConstraints(2, 2, 1, 1, 1, 1,
GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
setDisconnected();
_frame.invalidate();
_frame.validate();
_frame.repaint();