setSize(225, 300);  Point p = parent.getLocation(); Dimension d = parent.getSize(); int centerX = p.x + d.width/2; int centerY = p.y + d.height/2; Dimension myD = getSize(); setLocation(new Point(centerX - myD.width/2, centerY - myD.height/2));
  public ConsoleNodeOutputFilter(boolean[] initialValues, boolean acceptAll) {    super((java.awt.Frame)null, "Filter", true); // modal dialog    filterPanel = new JPanel(new BorderLayout());    // ok and cancel buttons panel    JPanel buttonPanel = new JPanel();    JButton okButton = new JButton("OK");    // only update the filter if the user selects "OK"    okButton.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {        allSelected = allCB.isSelected();        if (!allSelected) {          msgArray[NodeEvent.STANDARD_OUT] = standardCB.isSelected();          msgArray[NodeEvent.STANDARD_ERR] = errorCB.isSelected();          msgArray[NodeEvent.NODE_CREATED] = createCB.isSelected();          msgArray[NodeEvent.NODE_DESTROYED] = destroyCB.isSelected();          msgArray[NodeEvent.CLUSTER_ADDED] = clusterAddCB.isSelected();          msgArray[NodeEvent.IDLE_UPDATE] = idlenessCB.isSelected();          msgArray[NodeEvent.HEARTBEAT] = heartbeatCB.isSelected();        }        setVisible(false);      }    });    buttonPanel.add(okButton);    JButton cancelButton = new JButton("Cancel");    cancelButton.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {        setVisible(false);      }    });    buttonPanel.add(cancelButton);    // Message Types Panel    JPanel msgTypesPanel = new JPanel();    msgTypesPanel.setLayout(new GridBagLayout());    TitledBorder msgTypesTitledBorder = new TitledBorder("Messages Types");    Font msgfont = msgTypesTitledBorder.getTitleFont();    Font msgtitleFont = msgfont.deriveFont(Font.ITALIC);    msgTypesTitledBorder.setTitleFont(msgtitleFont);    msgTypesPanel.setBorder(msgTypesTitledBorder);    allCB = new JCheckBox(ALL);    allCB.setSelected(acceptAll);    allCB.addActionListener(allCBSelected);    allSelected = acceptAll;    standardCB = new JCheckBox(STANDARDOUT);    standardCB.addActionListener(unselectAllCB);    errorCB = new JCheckBox(ERRORMSGS);    errorCB.addActionListener(unselectAllCB);    createCB = new JCheckBox(NODECREATION);    createCB.addActionListener(unselectAllCB);    destroyCB = new JCheckBox(NODEDESTROYED);    destroyCB.addActionListener(unselectAllCB);    clusterAddCB = new JCheckBox(CLUSTERADD);    clusterAddCB.addActionListener(unselectAllCB);    idlenessCB = new JCheckBox(IDLENESS);    idlenessCB.addActionListener(unselectAllCB);    heartbeatCB = new JCheckBox(HEARTBEAT);    heartbeatCB.addActionListener(unselectAllCB);    int x = 0;    int y = 0;    msgTypesPanel.add(allCB,		   new GridBagConstraints(x, y++, 1, 1, 0.0, 0.0,					  GridBagConstraints.WEST,					  GridBagConstraints.HORIZONTAL,					  new Insets(0, 0, 0, 0), 0, 0));    msgTypesPanel.add(standardCB,		   new GridBagConstraints(x, y++, 1, 1, 1.0, 0.0,					  GridBagConstraints.WEST,					  GridBagConstraints.HORIZONTAL,					  new Insets(0, 0, 0, 0), 0, 0));    msgTypesPanel.add(errorCB,		   new GridBagConstraints(x, y++, 1, 1, 0.0, 0.0,					  GridBagConstraints.WEST,					  GridBagConstraints.HORIZONTAL,					  new Insets(0, 0, 0, 0), 0, 0));    msgTypesPanel.add(createCB,		   new GridBagConstraints(x, y++, 1, 1, 1.0, 0.0,					  GridBagConstraints.WEST,					  GridBagConstraints.HORIZONTAL,					  new Insets(0, 0, 0, 0), 0, 0));    msgTypesPanel.add(destroyCB,		   new GridBagConstraints(x, y++, 1, 1, 0.0, 0.0,					  GridBagConstraints.WEST,					  GridBagConstraints.HORIZONTAL,					  new Insets(0, 0, 0, 0), 0, 0));    msgTypesPanel.add(clusterAddCB,		   new GridBagConstraints(x, y++, 1, 1, 1.0, 0.0,					  GridBagConstraints.WEST,					  GridBagConstraints.HORIZONTAL,					  new Insets(0, 0, 0, 0), 0, 0));    msgTypesPanel.add(idlenessCB,		   new GridBagConstraints(x, y++, 1, 1, 0.0, 0.0,					  GridBagConstraints.WEST,					  GridBagConstraints.HORIZONTAL,					  new Insets(0, 0, 0, 0), 0, 0));    msgTypesPanel.add(heartbeatCB,		   new GridBagConstraints(x, y++, 1, 1, 1.0, 0.0,					  GridBagConstraints.WEST,					  GridBagConstraints.HORIZONTAL,					  new Insets(0, 0, 0, 0), 0, 0));    box.add(msgTypesPanel);    filterPanel.add(buttonPanel, BorderLayout.SOUTH);    filterPanel.add(box, BorderLayout.CENTER);    getContentPane().add(filterPanel);    pack();    if (initialValues != null) {      msgArray = initialValues;      standardCB.setSelected(msgArray[NodeEvent.STANDARD_OUT]);      errorCB.setSelected(msgArray[NodeEvent.STANDARD_ERR]);      createCB.setSelected(msgArray[NodeEvent.NODE_CREATED]);      destroyCB.setSelected(msgArray[NodeEvent.NODE_DESTROYED]);      clusterAddCB.setSelected(msgArray[NodeEvent.CLUSTER_ADDED]);      idlenessCB.setSelected(msgArray[NodeEvent.IDLE_UPDATE]);      heartbeatCB.setSelected(msgArray[NodeEvent.HEARTBEAT]);    }    setVisible(true);  }