powerPSPanel = new JPanel(); powerPSPanel.setLayout(new GridLayout(1, 1)); powerPSPanel.setBorder(BorderFactory .createTitledBorder("Power Production System")); powerPSPowerProducedLabel = new JLabel("power produced:         " + numFormat.format(myPowerPS.getPowerProduced()) + " W"); powerPSPanel.add(powerPSPowerProducedLabel);
powerPSPanel = new JPanel(); if (myPowerPS != null) { powerPSPanel.setLayout(new GridLayout(1, 1)); powerPSPanel.setBorder(BorderFactory .createTitledBorder("Power Production System")); powerPSPowerProducedLabel = new JLabel("power produced:         " + numFormat.format(myPowerPS.getPowerProduced()) + " W"); powerPSPanel.add(powerPSPowerProducedLabel); }
    private void buildGui() {        numFormat = new DecimalFormat("#,##0.00;(#)");        GridBagLayout gridbag = new GridBagLayout();        GridBagConstraints c = new GridBagConstraints();        setLayout(gridbag);        powerPSPanel = new JPanel();        powerPSPanel.setLayout(new GridLayout(1, 1));        powerPSPanel.setBorder(BorderFactory                .createTitledBorder("Power Production System"));        powerPSPowerProducedLabel = new JLabel("power produced:         "                + numFormat.format(myPowerPS.getPowerProduced()) + " W");        powerPSPanel.add(powerPSPowerProducedLabel);        powerStorePanel = new JPanel();        powerStorePanel.setLayout(new GridLayout(1, 1));        powerStorePanel.setBorder(BorderFactory                .createTitledBorder("Power Store"));        powerStoreLevelLabel = new JLabel("power level:    "                + numFormat.format(myPowerStore.getCurrentLevel()) + " W");        powerStorePanel.add(powerStoreLevelLabel);        c.fill = GridBagConstraints.BOTH;        c.gridheight = 1;        c.weightx = 1.0;        c.gridwidth = GridBagConstraints.REMAINDER;        c.weighty = 1.0;        gridbag.setConstraints(powerPSPanel, c);        add(powerPSPanel);        c.fill = GridBagConstraints.BOTH;        c.gridheight = 1;        c.weightx = 1.0;        c.gridwidth = GridBagConstraints.REMAINDER;        c.weighty = 1.0;        gridbag.setConstraints(powerStorePanel, c);        add(powerStorePanel);    }