JPPF, java, parallel computing, distributed computing, grid computing, parallel, distributed, cluster, grid, cloud, open source, android, .net
JPPF, java, parallel computing, distributed computing, grid computing, parallel, distributed, cluster, grid, cloud, open source, android, .net
JPPF

The open source
grid computing
solution

 Home   About   Features   Download   Documentation   Forums 

Embedding the administration console

From JPPF 6.0 Documentation

Jump to: navigation, search
Main Page > Customizing JPPF > Embedded console


As of version 5,0, JPPF provides a very simple API to obtain a reference to the Swing component which encloses the administration console user interface, and add it to an existing Swing-based UI. This reference is obtained by calling the static method getAdminConsole() of the class JPPFAdminConsole, which returns a JComponent object. This JComponent can then be added to any Swing container.

The JPPF admin console will only be created once, even if JPPFAdminConsole.getAdminConsole() is called multiple times. In other words, it is guaranteed that the same JComponent instance will always be returned.

JPPFAdminConsole also provides access to the JPPF client, topology manager and job monitor that the console uses for its monitoring and management operations:

public class JPPFAdminConsole {
  // Get the admin console as a JComponent that can be added to a Swing container
  public static JComponent getAdminConsole();

  // Get the JPPF client used by the admin console
  public static JPPFClient getJPPFClient();

  // Get the topology manager used by the admin console
  public static TopologyManager getTopologyManager();

  // Get the job monitor used by the admin console
  public static JobMonitor getJobMonitor();

  // Launch the administration console as a standalone application
  public static void main(final String[] args);
}

Here is an example of how it can be used:

import javax.swing.*;

// these imports require jppf-admin.jar
import org.jppf.ui.console.JPPFAdminConsole;
import org.jppf.ui.utils.GuiUtils;

public class EmbeddedConsole {
  public static void main(final String[] args) throws Exception {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    JPanel mainPanel = new JPanel();
    // layout the components vetically within a box
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    // the top component is a label with an image and some text
    ImageIcon icon = GuiUtils.loadIcon("../admin/jppf_logo.gif");
    JLabel label = new JLabel("Test JPPF embedded console", icon, SwingConstants.LEFT);
    mainPanel.add(label);
    // add the JPPF admin console as the bottom component
    mainPanel.add('''JPPFAdminConsole.getAdminConsole()''');
    // finally, add the UI to a JFrame and display it
    JFrame frame = new JFrame("Embedded console");
    frame.setSize(800, 600);
    frame.add(mainPanel);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
  }
}

Since JPPFAdminConsole is part of the console code, you will need to include "jppf-admin.jar" in your build path or class path, both at compile time and at runtime.

When embedded within an external GUI, the admin console will probably look different than when run as a standalone application. This is due to the Swing look and feel that is used. When run standalone, the console uses the JGoodies Looks v2.2.2 "PlasticXPLookAndFeel".

The GUI resulting from the example code above will look like this:

EmbeddedConsole.gif

Main Page > Customizing JPPF > Embedded console



JPPF Copyright © 2005-2018 JPPF.org Powered by MediaWiki