Example usage for javax.swing JPanel setBackground

List of usage examples for javax.swing JPanel setBackground

Introduction

In this page you can find the example usage for javax.swing JPanel setBackground.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.")
public void setBackground(Color bg) 

Source Link

Document

Sets the background color of this component.

Usage

From source file:MyStatsPanel.java

JPanel setFields() {
    getDatabaseInfo();/*from   www . j av  a 2  s . com*/
    GroupLayout layout;
    JPanel p;

    numGuestsIn = new JLabel("Total guests in house .............................");
    numGuestsIn.setFont(new Font("Courier New", Font.PLAIN, 20));
    numGuestsIn.setForeground(Color.WHITE);
    checkIns = new JLabel("Todays guest check ins ............................");
    checkIns.setForeground(Color.WHITE);
    checkIns.setFont(new Font("Courier New", Font.PLAIN, 20));
    numGuestsOut = new JLabel("Todays guest check outs ...........................");
    numGuestsOut.setFont(new Font("Courier New", Font.PLAIN, 20));
    numGuestsOut.setForeground(Color.WHITE);
    overnights = new JLabel("Total overnight guests ............................");
    overnights.setForeground(Color.WHITE);
    overnights.setFont(new Font("Courier New", Font.PLAIN, 20));

    JLabel n1 = new JLabel(totalGuestsIn);
    n1.setForeground(Color.WHITE);
    n1.setFont(new Font("Courier New", Font.PLAIN, 20));
    JLabel n2 = new JLabel(todaysCheckIns);
    n2.setForeground(Color.WHITE);
    n2.setFont(new Font("Courier New", Font.PLAIN, 20));
    JLabel n3 = new JLabel(todaysCheckOuts);
    n3.setForeground(Color.WHITE);
    n3.setFont(new Font("Courier New", Font.PLAIN, 20));
    JLabel n4 = new JLabel(totalOvernights);
    n4.setForeground(Color.WHITE);
    n4.setFont(new Font("Courier New", Font.PLAIN, 20));

    p = new JPanel();
    p.setBackground(Color.GRAY);

    layout = new GroupLayout(p);
    p.setLayout(layout);
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
    hGroup.addGroup(layout.createParallelGroup().addComponent(numGuestsIn).addComponent(checkIns)
            .addComponent(numGuestsOut).addComponent(overnights));
    hGroup.addGroup(
            layout.createParallelGroup().addComponent(n1).addComponent(n2).addComponent(n3).addComponent(n4));
    layout.setHorizontalGroup(hGroup);

    GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup();
    vGroup.addGroup(layout.createParallelGroup(BASELINE).addComponent(numGuestsIn).addComponent(n1));
    vGroup.addGroup(layout.createParallelGroup(BASELINE).addComponent(checkIns).addComponent(n2));
    vGroup.addGroup(layout.createParallelGroup(BASELINE).addComponent(numGuestsOut).addComponent(n3));
    vGroup.addGroup(layout.createParallelGroup(BASELINE).addComponent(overnights).addComponent(n4));

    layout.setVerticalGroup(vGroup);

    return (p);
}

From source file:org.biojava.bio.view.MotifAnalyzer.java

public void displayCharts(int chartNum) throws IOException {
    JFrame chartsFrame = new JFrame("Charts Analysis" + chartNum);
    chartsFrame.setSize(700, 600);/*ww w. j  a v  a2  s  .c  o m*/
    JTabbedPane tabs = new JTabbedPane();
    chartsFrame.add(tabs);
    String dataset = ((Dataset) datasetComboBox.getSelectedItem()).name();

    //tabs.addTab("Log", getOutputTextPane(log));
    tabs.addTab("Statistics", new JScrollPane(getStatisticsTab(chartNum)));
    String[] chartsNames = FileNames.getCharts(chartNum);
    for (int i = 0; i < chartsNames.length; i++) {
        JPanel image1 = new JPanel(new BorderLayout());
        image1.add(new JLabel(new ImageIcon(ImageIO.read(new File(chartsNames[i])))));
        image1.setBackground(Color.white);
        tabs.addTab("Chart " + (i + 1) + "(" + dataset + ")", image1);
    }
    chartsFrame.setVisible(true);

}

From source file:com.titan.mainframe.MainFrame.java

public MainFrame() {
    String osName = System.getProperty("os.name").toLowerCase();
    if (osName.toLowerCase().contains("mac")) {
        com.apple.eawt.Application macApp = com.apple.eawt.Application.getApplication();
        macApp.addApplicationListener(this);
    }/*w  ww .  ja v a  2s . c om*/
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            handleQuit();
        }

        @Override
        public void windowOpened(WindowEvent e) {
            windowOpened = true;
        }
    });
    setTitle("Titan " + Global.version);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    if (TitanSetting.getInstance().width == 0 || TitanSetting.getInstance().height == 0) {
        setBounds(TitanSetting.getInstance().x, TitanSetting.getInstance().y, 1200, 700);
    } else {
        setBounds(TitanSetting.getInstance().x, TitanSetting.getInstance().y, TitanSetting.getInstance().width,
                TitanSetting.getInstance().height);
    }

    setIconImage(new ImageIcon(getClass().getClassLoader().getResource("com/titan/image/titan_icon.png"))
            .getImage());

    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(new BorderLayout(0, 0));
    splitPane.setDividerLocation(TitanSetting.getInstance().mainframeDivX);
    contentPane.add(splitPane, BorderLayout.CENTER);

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout(0, 0));

    JLabel logoLabel = new JLabel();
    logoLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            mainContentPanel.removeAll();
            mainContentPanel.add(welcomePanel, BorderLayout.CENTER);
            mainContentPanel.updateUI();
        }
    });

    //      try {
    //         BufferedImage b = ImageIO.read(MainFrame.class.getResource("/com/titan/image/titanLogo.png"));
    //         Image i = b.getScaledInstance((int) (b.getWidth() * 0.6), (int) (b.getHeight() * 0.6), Image.SCALE_SMOOTH);
    logoLabel.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/titanLogo.png")));
    //      } catch (IOException e1) {
    //         e1.printStackTrace();
    //      }
    //      logoLabel.setMaximumSize(new Dimension(150, 150));

    JPanel controlPanel = new JPanel();
    controlPanel.setBackground(new Color(239, 249, 255));
    controlPanel.setOpaque(true);
    panel.add(controlPanel, BorderLayout.CENTER);
    controlPanel.setLayout(new BorderLayout());

    JScrollPane computeScrollPane = new JScrollPane();
    tabbedPane.addTab("Compute", computeScrollPane);
    controlPanel.add(tabbedPane, BorderLayout.CENTER);

    serverTree = new JTree();
    serverTree.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            //            Object obj = mainContentPanel.getComponent(0);
            //            if (obj instanceof VMMainPanel) {
            //               ((MainPanel) obj).refresh();
            //            }
        }
    });
    serverTree.setModel(computeTreeModel);
    serverTree.setCellRenderer(new ZoneTreeRenderer());
    serverTree.setRootVisible(false);
    computeScrollPane.setViewportView(serverTree);
    updateComputeTree();

    JScrollPane zoneScrollPane = new JScrollPane();
    tabbedPane.addTab("Zone", zoneScrollPane);

    zoneTree = new JTree();
    zoneTree.setModel(zoneTreeModel);
    zoneTree.setCellRenderer(new ZoneTreeRenderer());
    zoneScrollPane.setViewportView(zoneTree);
    updateZoneTree();
    splitPane.setLeftComponent(panel);

    splitPane.setRightComponent(mainContentPanel);
    mainContentPanel.setLayout(new BorderLayout(0, 0));

    welcomePanel = new WelcomePanel();
    mainContentPanel.add(welcomePanel, BorderLayout.CENTER);
    welcomePanel.setLayout(new BorderLayout(0, 0));
    welcomePanel.add(mainScreenLabel, BorderLayout.CENTER);
    mainScreenLabel.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/mainscreen.png")));

    JPanel panel_1 = new JPanel();
    welcomePanel.add(panel_1, BorderLayout.SOUTH);

    JButton licenseButton = new JButton("License");
    licenseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            InputStream in = MainFrame.class.getResourceAsStream("/com/titan/license.txt");
            try {
                LicenseDialog dialog = new LicenseDialog(MainFrame.this, IOUtils.toString(in));
                CommonLib.centerDialog(dialog);
                dialog.setVisible(true);
            } catch (IOException e1) {
                e1.printStackTrace();
            } finally {
                IOUtils.closeQuietly(in);
            }
        }
    });
    panel_1.add(licenseButton);

    ribbonPanel = new JPanel();
    contentPane.add(ribbonPanel, BorderLayout.NORTH);
    ribbonPanel.setLayout(new BorderLayout(0, 0));

    ribbonTabbedPane = new JTabbedPane(JTabbedPane.TOP);
    ribbonTabbedPane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            //            if (!windowOpened) {
            //               return;
            //            }
            String tab = ribbonTabbedPane.getTitleAt(ribbonTabbedPane.getSelectedIndex());
            if (tab.equals("Server")) {
                if (mainServerPanel == null || !mainServerPanel.serverPanel.jprogressBarDialog.isActive()) {
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            mainContentPanel.removeAll();
                            mainServerPanel = new MainServerPanel(MainFrame.this);
                            mainContentPanel.add(mainServerPanel, BorderLayout.CENTER);
                            mainContentPanel.updateUI();
                        }
                    });
                }
            } else if (tab.equals("VM")) {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        mainContentPanel.removeAll();
                        mainContentPanel.add(new VMMainPanel(MainFrame.this), BorderLayout.CENTER);
                        mainContentPanel.updateUI();
                    }
                });
            } else if (tab.equals("Keystone")) {
                mainContentPanel.removeAll();
                mainContentPanel.add(new KeystonePanel(MainFrame.this), BorderLayout.CENTER);
                mainContentPanel.updateUI();
            } else if (tab.equals("Flavor")) {
                mainContentPanel.removeAll();
                mainContentPanel.add(new FlavorPanel(MainFrame.this), BorderLayout.CENTER);
                mainContentPanel.updateUI();
            } else if (tab.equals("Storage")) {
                mainContentPanel.removeAll();
                mainContentPanel.add(new StoragePanel(MainFrame.this), BorderLayout.CENTER);
                mainContentPanel.updateUI();
            } else if (tab.equals("Network")) {
                mainContentPanel.removeAll();
                mainContentPanel.add(new SDNPanel(MainFrame.this), BorderLayout.CENTER);
                mainContentPanel.updateUI();
            } else if (tab.equals("Setting")) {
                mainContentPanel.removeAll();
                mainContentPanel.add(new SettingPanel(MainFrame.this), BorderLayout.CENTER);
                mainContentPanel.updateUI();
            }
        }
    });
    ribbonTabbedPane.putClientProperty("type", "ribbonType");
    ribbonTabbedPane.setPreferredSize(new Dimension(1000, 140));
    ribbonPanel.add(ribbonTabbedPane, BorderLayout.CENTER);

    serverPanel = new JRibbonPanel();
    serverPanel.setLayout(new MigLayout("", "[][][][][][][][][][][][][][grow][]", "[grow][grow][]"));
    ribbonTabbedPane.addTab("Server", null, serverPanel, null);

    logoutButton = new JRibbonBigButton("Logout");
    logoutButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            logout();
        }
    });

    rbnbgbtnAddServer = new JRibbonBigButton();
    rbnbgbtnAddServer.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png")));
    rbnbgbtnAddServer.setText("Add Server");
    serverPanel.add(rbnbgbtnAddServer, "cell 0 0 1 3,growy");

    rbnbgbtnDeleteServer = new JRibbonBigButton();
    rbnbgbtnDeleteServer
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/delete.png")));
    rbnbgbtnDeleteServer.setText("Delete Server");
    serverPanel.add(rbnbgbtnDeleteServer, "cell 1 0 1 3,growy");
    logoutButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/logout.png")));
    logoutButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    logoutButton.setHorizontalTextPosition(SwingConstants.CENTER);
    serverPanel.add(logoutButton, "cell 14 0 1 3,growy");

    vmPanel = new JRibbonPanel();
    ribbonTabbedPane.addTab("VM", null, vmPanel, null);
    vmPanel.setLayout(new MigLayout("", "[][][][][][][][][][][][][][][grow][]", "[grow][grow][]"));

    launchButton = new JRibbonBigButton("Launch");
    launchButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new LaunchInstanceDialog(MainFrame.this).setVisible(true);
        }
    });
    launchButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/launch.png")));
    launchButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    launchButton.setHorizontalTextPosition(SwingConstants.CENTER);
    vmPanel.add(launchButton, "cell 0 0 1 3,growy");

    pauseButton = new JRibbonButton("Pause");
    pauseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.action("from titan: nova pause");
        }
    });
    pauseButton.setHorizontalAlignment(SwingConstants.LEFT);
    pauseButton.setIcon(
            new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/control_pause.png")));
    vmPanel.add(pauseButton, "cell 2 0,growx");

    stopButton = new JRibbonButton("Stop");
    stopButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.action("from titan: nova stop");
        }
    });
    stopButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/stop.png")));
    stopButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    stopButton.setHorizontalTextPosition(SwingConstants.CENTER);
    vmPanel.add(stopButton, "cell 1 0 1 3,growy");

    unpauseButton = new JRibbonButton("Unpause");
    unpauseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.action("from titan: nova unpause");
        }
    });
    unpauseButton.setHorizontalAlignment(SwingConstants.LEFT);
    unpauseButton
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/control_play.png")));

    suspendButton = new JRibbonButton("Suspend");
    suspendButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.action("from titan: nova suspend");
        }
    });
    suspendButton.setHorizontalAlignment(SwingConstants.LEFT);
    suspendButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/disk.png")));
    vmPanel.add(suspendButton, "cell 3 0,growx");

    softRebootButton = new JRibbonButton("Soft reboot");
    softRebootButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.action("from titan: nova soft-reboot");
        }
    });
    softRebootButton.setHorizontalAlignment(SwingConstants.LEFT);
    softRebootButton.setIcon(new ImageIcon(
            MainFrame.class.getResource("/com/titan/image/famfamfam/arrow_rotate_clockwise.png")));

    selectAllVMButton = new JRibbonButton("Select all");
    selectAllVMButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.selectAll();
        }
    });
    vmPanel.add(selectAllVMButton, "cell 4 0,growx");
    vmPanel.add(softRebootButton, "cell 9 0,growx");

    createMacroButton = new JRibbonButton("Create macro");
    createMacroButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/add.png")));
    createMacroButton.setHorizontalAlignment(SwingConstants.LEFT);

    setGroupNameButton = new JRibbonButton("Set group name");
    setGroupNameButton.setHorizontalAlignment(SwingConstants.LEFT);
    setGroupNameButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.setGroupName();
        }
    });
    vmPanel.add(setGroupNameButton, "cell 10 0");
    vmPanel.add(createMacroButton, "cell 13 0,growx");

    ribbonSeparator_3 = new JRibbonSeparator();
    vmPanel.add(ribbonSeparator_3, "cell 14 0 1 3,growy");
    vmPanel.add(unpauseButton, "cell 2 1,growx");

    remoteButton = new JRibbonButton("Remote");
    remoteButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.remote();
        }
    });
    remoteButton.setHorizontalAlignment(SwingConstants.LEFT);
    remoteButton.setIcon(new ImageIcon(
            MainFrame.class.getResource("/com/titan/image/famfamfam/application_osx_terminal.png")));

    unselectAllButton = new JRibbonButton("Unselect all");
    unselectAllButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.unselectAll();
        }
    });
    vmPanel.add(unselectAllButton, "cell 4 1,growx");
    vmPanel.add(remoteButton, "cell 2 2,growx");

    performanceMeterButton = new JRibbonButton("Performance meter");
    performanceMeterButton
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/chart_curve.png")));
    performanceMeterButton.setHorizontalAlignment(SwingConstants.LEFT);
    vmPanel.add(performanceMeterButton, "cell 13 1,growx");

    resumeButton = new JRibbonButton("Resume");
    resumeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.action("from titan: nova resume");
        }
    });
    resumeButton.setHorizontalAlignment(SwingConstants.LEFT);
    resumeButton
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/drive_disk.png")));
    vmPanel.add(resumeButton, "cell 3 1,growx");

    deleteButton = new JRibbonBigButton("Delete");
    deleteButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.action("from titan: nova delete");
        }
    });
    vmPanel.add(deleteButton, "cell 7 0 1 3,alignx center,growy");
    deleteButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/delete.png")));
    deleteButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    deleteButton.setHorizontalTextPosition(SwingConstants.CENTER);

    logButton = new JRibbonBigButton("Log");
    logButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.log();
        }
    });
    vmPanel.add(logButton, "cell 6 0 1 3,alignx center,growy");
    logButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/log.png")));
    logButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    logButton.setHorizontalTextPosition(SwingConstants.CENTER);

    hardRebootButton = new JRibbonButton("Hard reboot");
    hardRebootButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.action("from titan: nova hard-reboot");
        }
    });
    hardRebootButton.setHorizontalAlignment(SwingConstants.LEFT);
    hardRebootButton
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/arrow_undo.png")));

    ribbonSeparator = new JRibbonSeparator();
    vmPanel.add(ribbonSeparator, "cell 5 0 1 3,alignx center,growy");

    ribbonSeparator_1 = new JRibbonSeparator();
    vmPanel.add(ribbonSeparator_1, "cell 8 0 1 3,alignx center,growy");
    vmPanel.add(hardRebootButton, "cell 9 1,growx");

    ribbonSeparator_2 = new JRibbonSeparator();
    vmPanel.add(ribbonSeparator_2, "cell 11 0 1 3,grow");

    macroButton = new JRibbonBigButton("Macro");
    macroButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/code.png")));
    macroButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    macroButton.setHorizontalTextPosition(SwingConstants.CENTER);
    vmPanel.add(macroButton, "cell 12 0 1 3,growy");

    snapshotButton = new JRibbonButton("Snapshot");
    snapshotButton.setHorizontalAlignment(SwingConstants.LEFT);
    snapshotButton.setIcon(
            new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/application_cascade.png")));
    vmPanel.add(snapshotButton, "cell 3 2,growx");

    advanceButton = new JRibbonButton("Advance");
    advanceButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
        }
    });
    advanceButton.setHorizontalAlignment(SwingConstants.LEFT);
    advanceButton.setIcon(new ImageIcon(
            MainFrame.class.getResource("/com/titan/image/famfamfam/application_view_detail.png")));
    vmPanel.add(advanceButton, "cell 9 2,growx");

    executionMapButton = new JRibbonButton("Execution map");
    executionMapButton.setIcon(
            new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/chart_organisation.png")));
    executionMapButton.setHorizontalAlignment(SwingConstants.LEFT);
    vmPanel.add(executionMapButton, "cell 13 2,growx");

    keystonePanel = new JRibbonPanel();
    ribbonTabbedPane.addTab("Keystone", null, keystonePanel, null);
    keystonePanel.setLayout(new MigLayout("", "[][][][][][][][][][]", "[grow][][][][]"));

    addUserButton = new JRibbonBigButton("Add user");
    addUserButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0);
            keystonePanel.addUser();
        }
    });
    addUserButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    addUserButton.setHorizontalTextPosition(SwingConstants.CENTER);
    addUserButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/addUser.png")));
    keystonePanel.add(addUserButton, "cell 0 0 1 3,growy");

    editUserButton = new JRibbonButton("Edit user");
    editUserButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
        }
    });
    editUserButton.setHorizontalAlignment(SwingConstants.LEFT);
    editUserButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/pencil.png")));
    keystonePanel.add(editUserButton, "cell 1 0,growx");

    changePasswordButton = new JRibbonButton("Change password");
    keystonePanel.add(changePasswordButton, "cell 2 0");

    ribbonSeparator_4 = new JRibbonSeparator();
    keystonePanel.add(ribbonSeparator_4, "cell 3 0 1 3,growy");

    addRoleButton = new JRibbonBigButton("Add role");
    addRoleButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0);
            keystonePanel.addRole();
        }
    });
    addRoleButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    addRoleButton.setHorizontalTextPosition(SwingConstants.CENTER);
    addRoleButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/addRole.png")));
    keystonePanel.add(addRoleButton, "cell 4 0 1 3,growy");

    deleteUserButton = new JRibbonButton("Delete user");
    deleteUserButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
        }
    });
    deleteUserButton.setHorizontalAlignment(SwingConstants.LEFT);
    deleteUserButton
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png")));

    editRoleButton = new JRibbonButton("Edit role");
    editRoleButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
        }
    });
    editRoleButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/pencil.png")));
    editRoleButton.setHorizontalAlignment(SwingConstants.LEFT);
    keystonePanel.add(editRoleButton, "cell 5 0,growx");

    ribbonSeparator_5 = new JRibbonSeparator();
    keystonePanel.add(ribbonSeparator_5, "cell 6 0 1 3,growy");

    createTenantButton = new JRibbonBigButton("Create tenant");
    createTenantButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0);
            keystonePanel.createTenant();
        }
    });
    createTenantButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png")));
    createTenantButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    createTenantButton.setHorizontalTextPosition(SwingConstants.CENTER);
    keystonePanel.add(createTenantButton, "cell 7 0 1 3,growy");

    deleteTenantButton = new JRibbonBigButton("Delete tenant");
    deleteTenantButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0);
            keystonePanel.deleteTenant();
        }
    });
    deleteTenantButton
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/delete.png")));
    deleteTenantButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    deleteTenantButton.setHorizontalTextPosition(SwingConstants.CENTER);
    keystonePanel.add(deleteTenantButton, "cell 8 0 1 3,growy");
    keystonePanel.add(deleteUserButton, "cell 1 1,growx");

    detailUserButton = new JRibbonButton("Detail user");
    detailUserButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0);
            keystonePanel.showUserDetail();
        }
    });
    detailUserButton.setHorizontalAlignment(SwingConstants.LEFT);
    detailUserButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/zoom.png")));
    keystonePanel.add(detailUserButton, "cell 1 2,growx");

    btnDeleteRole = new JRibbonButton("Delete role");
    btnDeleteRole.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0);
            keystonePanel.deleteRole();
        }
    });
    btnDeleteRole.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png")));
    keystonePanel.add(btnDeleteRole, "cell 5 1,growx");

    assignRoleButton = new JRibbonButton("Assign role");
    assignRoleButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0);
            keystonePanel.assignRole();
        }
    });
    assignRoleButton.setSelectedIcon(
            new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/user_add.png")));
    keystonePanel.add(assignRoleButton, "cell 5 2,growx");

    lblUser = new JRibbonLabel("user");
    keystonePanel.add(lblUser, "cell 0 3 2 1,growx");

    rbnlblRole = new JRibbonLabel("role");
    keystonePanel.add(rbnlblRole, "cell 4 3 2 1,growx");

    rbnlblTenant = new JRibbonLabel();
    rbnlblTenant.setText("tenant");
    keystonePanel.add(rbnlblTenant, "cell 7 3 2 1,growx");

    flavorPanel = new JRibbonPanel();
    ribbonTabbedPane.addTab("Flavor", null, flavorPanel, null);
    flavorPanel.setLayout(new MigLayout("", "[][]", "[grow][][][]"));

    rbnbgbtnCreateFlavor = new JRibbonBigButton();
    rbnbgbtnCreateFlavor.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png")));
    rbnbgbtnCreateFlavor.setText("Create Flavor");
    flavorPanel.add(rbnbgbtnCreateFlavor, "cell 0 0 1 3,growy");

    btnDeleteFlavor = new JRibbonBigButton("Delete Flavor");
    btnDeleteFlavor.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/delete.png")));
    flavorPanel.add(btnDeleteFlavor, "cell 1 0 1 3,growy");

    storagePanel = new JRibbonPanel();
    ribbonTabbedPane.addTab("Storage", null, storagePanel, null);
    storagePanel.setLayout(new MigLayout("", "[][][][][][]", "[grow][][][]"));

    uploadImageButton = new JRibbonBigButton("Upload");
    uploadImageButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png")));
    uploadImageButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    uploadImageButton.setHorizontalTextPosition(SwingConstants.CENTER);
    storagePanel.add(uploadImageButton, "cell 0 0 1 3, growy");

    btnDelete = new JRibbonButton("Delete");
    btnDelete.setHorizontalAlignment(SwingConstants.LEFT);
    btnDelete.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png")));
    storagePanel.add(btnDelete, "cell 1 0,growx");

    ribbonSeparator_6 = new JRibbonSeparator();
    storagePanel.add(ribbonSeparator_6, "cell 2 0 1 3,grow");

    btnCreateVolume = new JRibbonBigButton("Create volume");
    btnCreateVolume.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png")));
    btnCreateVolume.setVerticalTextPosition(SwingConstants.BOTTOM);
    btnCreateVolume.setHorizontalTextPosition(SwingConstants.CENTER);
    storagePanel.add(btnCreateVolume, "cell 3 0 1 3,growy");

    btnDelete_1 = new JRibbonButton("Delete");
    btnDelete_1.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png")));
    btnDelete_1.setHorizontalAlignment(SwingConstants.LEFT);
    storagePanel.add(btnDelete_1, "cell 4 0,growx");

    btnAttach = new JRibbonButton("Attach to vm");
    btnAttach.setHorizontalAlignment(SwingConstants.LEFT);
    btnAttach.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/attach.png")));
    storagePanel.add(btnAttach, "cell 5 0,growx");

    btnChangeName = new JRibbonButton("Change name");
    btnChangeName.setHorizontalAlignment(SwingConstants.LEFT);
    btnChangeName.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/pencil.png")));
    storagePanel.add(btnChangeName, "cell 1 1,growx");

    btnDetail = new JRibbonButton("Detail");
    btnDetail.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/zoom.png")));
    btnDetail.setHorizontalAlignment(SwingConstants.LEFT);
    storagePanel.add(btnDetail, "cell 4 1,growx");

    btnDetachToVm = new JRibbonButton("Detach to vm");
    btnDetachToVm.setHorizontalAlignment(SwingConstants.LEFT);
    btnDetachToVm.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/delete.png")));
    storagePanel.add(btnDetachToVm, "cell 5 1,growx");

    btnPublicprivate = new JRibbonButton("public/private");
    btnPublicprivate.setHorizontalAlignment(SwingConstants.LEFT);
    btnPublicprivate.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/tick.png")));
    storagePanel.add(btnPublicprivate, "cell 1 2,growx");

    btnAddVolumeType = new JRibbonButton("Add volume type");
    btnAddVolumeType.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/add.png")));
    btnAddVolumeType.setHorizontalAlignment(SwingConstants.LEFT);
    storagePanel.add(btnAddVolumeType, "cell 4 2");

    btnDeleteVolumeType = new JRibbonButton("Delete volume type");
    btnDeleteVolumeType
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png")));
    btnDeleteVolumeType.setHorizontalAlignment(SwingConstants.LEFT);
    storagePanel.add(btnDeleteVolumeType, "cell 5 2");

    rbnlblImage = new JRibbonLabel();
    rbnlblImage.setText("Image");
    storagePanel.add(rbnlblImage, "cell 0 3 2 1,growx");

    rbnlblVolume = new JRibbonLabel();
    rbnlblVolume.setText("Volume");
    storagePanel.add(rbnlblVolume, "cell 3 3 3 1,growx");

    networkPanel = new JRibbonPanel();
    ribbonTabbedPane.addTab("Network", null, networkPanel, null);

    settingPanel = new JRibbonPanel();
    ribbonTabbedPane.addTab("Setting", null, settingPanel, null);
    settingPanel.setLayout(new MigLayout("", "[][][]", "[grow][grow][]"));

    rbnbgbtnSystemSetting = new JRibbonBigButton();
    rbnbgbtnSystemSetting
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/systemSetting.png")));
    rbnbgbtnSystemSetting.setText("System Setting");
    settingPanel.add(rbnbgbtnSystemSetting, "cell 0 0 1 3,growy");

    rbnbgbtnDatabase = new JRibbonBigButton();
    rbnbgbtnDatabase
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/database.png")));
    rbnbgbtnDatabase.setText("Database");
    settingPanel.add(rbnbgbtnDatabase, "cell 1 0 1 3,growy");

    rbnbtnAddGroup = new JRibbonButton();
    rbnbtnAddGroup.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/add.png")));
    rbnbtnAddGroup.setText("Add Group");
    settingPanel.add(rbnbtnAddGroup, "cell 2 0");

    rbnbtnEditGroup = new JRibbonButton();
    rbnbtnEditGroup
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/pencil.png")));
    rbnbtnEditGroup.setText("Edit Group");
    settingPanel.add(rbnbtnEditGroup, "cell 2 1");

    rbnbtnDeleteGroup = new JRibbonButton();
    rbnbtnDeleteGroup
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png")));
    rbnbtnDeleteGroup.setText("Delete Group");
    settingPanel.add(rbnbtnDeleteGroup, "cell 2 2");

    logoPanel = new JRibbonPanel();
    ribbonPanel.add(logoPanel, BorderLayout.WEST);
    logoPanel.setLayout(new BorderLayout(0, 0));
    logoPanel.add(logoLabel, BorderLayout.CENTER);

    setLocationRelativeTo(null);

    new Thread(new TitanServerUpdateThread()).start();
}

From source file:com.mirth.connect.connectors.http.HttpListener.java

private void initComponentsManual() {
    staticResourcesTable.setModel(new RefreshTableModel(StaticResourcesColumn.getNames(), 0) {
        @Override//  w w w .  java2s  .co  m
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return true;
        }
    });

    staticResourcesTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    staticResourcesTable.setRowHeight(UIConstants.ROW_HEIGHT);
    staticResourcesTable.setFocusable(true);
    staticResourcesTable.setSortable(false);
    staticResourcesTable.setOpaque(true);
    staticResourcesTable.setDragEnabled(false);
    staticResourcesTable.getTableHeader().setReorderingAllowed(false);
    staticResourcesTable.setShowGrid(true, true);
    staticResourcesTable.setAutoCreateColumnsFromModel(false);
    staticResourcesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    staticResourcesTable.setRowSelectionAllowed(true);
    staticResourcesTable.setCustomEditorControls(true);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        staticResourcesTable.setHighlighters(HighlighterFactory
                .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR));
    }

    class ContextPathCellEditor extends TextFieldCellEditor {
        public ContextPathCellEditor() {
            getTextField().setDocument(new MirthFieldConstraints("^\\S*$"));
        }

        @Override
        protected boolean valueChanged(String value) {
            if (StringUtils.isEmpty(value) || value.equals("/")) {
                return false;
            }

            if (value.equals(getOriginalValue())) {
                return false;
            }

            for (int i = 0; i < staticResourcesTable.getRowCount(); i++) {
                if (value.equals(fixContentPath((String) staticResourcesTable.getValueAt(i,
                        StaticResourcesColumn.CONTEXT_PATH.getIndex())))) {
                    return false;
                }
            }

            parent.setSaveEnabled(true);
            return true;
        }

        @Override
        public Object getCellEditorValue() {
            String value = fixContentPath((String) super.getCellEditorValue());
            String baseContextPath = getBaseContextPath();
            if (value.equals(baseContextPath)) {
                return null;
            } else {
                return fixContentPath(StringUtils.removeStartIgnoreCase(value, baseContextPath + "/"));
            }
        }

        @Override
        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row,
                int column) {
            String resourceContextPath = fixContentPath((String) value);
            setOriginalValue(resourceContextPath);
            getTextField().setText(getBaseContextPath() + resourceContextPath);
            return getTextField();
        }
    }
    ;

    staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTEXT_PATH.getIndex())
            .setCellEditor(new ContextPathCellEditor());
    staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTEXT_PATH.getIndex())
            .setCellRenderer(new DefaultTableCellRenderer() {
                @Override
                protected void setValue(Object value) {
                    super.setValue(getBaseContextPath() + fixContentPath((String) value));
                }
            });

    class ResourceTypeCellEditor extends MirthComboBoxTableCellEditor implements ActionListener {
        private Object originalValue;

        public ResourceTypeCellEditor(JTable table, Object[] items, int clickCount, boolean focusable) {
            super(table, items, clickCount, focusable, null);
            for (ActionListener actionListener : comboBox.getActionListeners()) {
                comboBox.removeActionListener(actionListener);
            }
            comboBox.addActionListener(this);
        }

        @Override
        public boolean stopCellEditing() {
            if (ObjectUtils.equals(getCellEditorValue(), originalValue)) {
                cancelCellEditing();
            } else {
                parent.setSaveEnabled(true);
            }
            return super.stopCellEditing();
        }

        @Override
        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row,
                int column) {
            originalValue = value;
            return super.getTableCellEditorComponent(table, value, isSelected, row, column);
        }

        @Override
        public void actionPerformed(ActionEvent evt) {
            ((AbstractTableModel) staticResourcesTable.getModel()).fireTableCellUpdated(
                    staticResourcesTable.getSelectedRow(), StaticResourcesColumn.VALUE.getIndex());
            stopCellEditing();
            fireEditingStopped();
        }
    }

    String[] resourceTypes = ResourceType.stringValues();
    staticResourcesTable.getColumnExt(StaticResourcesColumn.RESOURCE_TYPE.getIndex()).setMinWidth(100);
    staticResourcesTable.getColumnExt(StaticResourcesColumn.RESOURCE_TYPE.getIndex()).setMaxWidth(100);
    staticResourcesTable.getColumnExt(StaticResourcesColumn.RESOURCE_TYPE.getIndex())
            .setCellEditor(new ResourceTypeCellEditor(staticResourcesTable, resourceTypes, 1, false));
    staticResourcesTable.getColumnExt(StaticResourcesColumn.RESOURCE_TYPE.getIndex())
            .setCellRenderer(new MirthComboBoxTableCellRenderer(resourceTypes));

    class ValueCellEditor extends AbstractCellEditor implements TableCellEditor {

        private JPanel panel;
        private JLabel label;
        private JTextField textField;
        private String text;
        private String originalValue;

        public ValueCellEditor() {
            panel = new JPanel(new MigLayout("insets 0 1 0 0, novisualpadding, hidemode 3"));
            panel.setBackground(UIConstants.BACKGROUND_COLOR);

            label = new JLabel();
            label.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseReleased(MouseEvent evt) {
                    new ValueDialog();
                    stopCellEditing();
                }
            });
            panel.add(label, "grow, pushx, h 19!");

            textField = new JTextField();
            panel.add(textField, "grow, pushx, h 19!");
        }

        @Override
        public boolean isCellEditable(EventObject evt) {
            if (evt == null) {
                return false;
            }
            if (evt instanceof MouseEvent) {
                return ((MouseEvent) evt).getClickCount() >= 2;
            }
            return true;
        }

        @Override
        public Object getCellEditorValue() {
            if (label.isVisible()) {
                return text;
            } else {
                return textField.getText();
            }
        }

        @Override
        public boolean stopCellEditing() {
            if (ObjectUtils.equals(getCellEditorValue(), originalValue)) {
                cancelCellEditing();
            } else {
                parent.setSaveEnabled(true);
            }
            return super.stopCellEditing();
        }

        @Override
        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row,
                int column) {
            boolean custom = table.getValueAt(row, StaticResourcesColumn.RESOURCE_TYPE.getIndex())
                    .equals(ResourceType.CUSTOM.toString());
            label.setVisible(custom);
            textField.setVisible(!custom);

            panel.setBackground(table.getSelectionBackground());
            label.setBackground(panel.getBackground());
            label.setMaximumSize(new Dimension(table.getColumnModel().getColumn(column).getWidth(), 19));

            String text = (String) value;
            this.text = text;
            originalValue = text;
            label.setText(text);
            textField.setText(text);

            return panel;
        }

        class ValueDialog extends MirthDialog {

            public ValueDialog() {
                super(parent, true);
                setTitle("Custom Value");
                setPreferredSize(new Dimension(600, 500));
                setLayout(new MigLayout("insets 12, novisualpadding, hidemode 3, fill", "", "[grow]7[]"));
                setBackground(UIConstants.BACKGROUND_COLOR);
                getContentPane().setBackground(getBackground());

                final MirthSyntaxTextArea textArea = new MirthSyntaxTextArea();
                textArea.setSaveEnabled(false);
                textArea.setText(text);
                textArea.setBorder(BorderFactory.createEtchedBorder());
                add(textArea, "grow");

                add(new JSeparator(), "newline, grow");

                JPanel buttonPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3"));
                buttonPanel.setBackground(getBackground());

                JButton openFileButton = new JButton("Open File...");
                openFileButton.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        String content = parent.browseForFileString(null);
                        if (content != null) {
                            textArea.setText(content);
                        }
                    }
                });
                buttonPanel.add(openFileButton);

                JButton okButton = new JButton("OK");
                okButton.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        text = textArea.getText();
                        label.setText(text);
                        textField.setText(text);
                        staticResourcesTable.getModel().setValueAt(text, staticResourcesTable.getSelectedRow(),
                                StaticResourcesColumn.VALUE.getIndex());
                        parent.setSaveEnabled(true);
                        dispose();
                    }
                });
                buttonPanel.add(okButton);

                JButton cancelButton = new JButton("Cancel");
                cancelButton.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        dispose();
                    }
                });
                buttonPanel.add(cancelButton);

                add(buttonPanel, "newline, right");

                pack();
                setLocationRelativeTo(parent);
                setVisible(true);
            }
        }
    }
    ;

    staticResourcesTable.getColumnExt(StaticResourcesColumn.VALUE.getIndex())
            .setCellEditor(new ValueCellEditor());

    staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTENT_TYPE.getIndex()).setMinWidth(100);
    staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTENT_TYPE.getIndex()).setMaxWidth(150);
    staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTENT_TYPE.getIndex())
            .setCellEditor(new TextFieldCellEditor() {
                @Override
                protected boolean valueChanged(String value) {
                    if (value.equals(getOriginalValue())) {
                        return false;
                    }
                    parent.setSaveEnabled(true);
                    return true;
                }
            });

    staticResourcesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent evt) {
            if (getSelectedRow(staticResourcesTable) != -1) {
                staticResourcesLastIndex = getSelectedRow(staticResourcesTable);
                staticResourcesDeleteButton.setEnabled(true);
            } else {
                staticResourcesDeleteButton.setEnabled(false);
            }
        }
    });

    contextPathField.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(DocumentEvent evt) {
            changedUpdate(evt);
        }

        @Override
        public void removeUpdate(DocumentEvent evt) {
            changedUpdate(evt);
        }

        @Override
        public void changedUpdate(DocumentEvent evt) {
            ((AbstractTableModel) staticResourcesTable.getModel()).fireTableDataChanged();
        }
    });

    staticResourcesDeleteButton.setEnabled(false);
}

From source file:lcmc.common.ui.EditableInfo.java

/** Adds parameters to the panel. */
private void addParams(final JPanel optionsPanel, final String prefix, final String[] params,
        final MyButton thisApplyButton, final int leftWidth, final int rightWidth,
        final Map<String, Widget> sameAsFields) {
    swingUtils.isSwingThread();//from  w w w  .jav a  2 s. c om
    if (params == null) {
        return;
    }
    final MultiKeyMap<String, JPanel> panelPartsMap = new MultiKeyMap<String, JPanel>();
    final Collection<PanelPart> panelPartsList = new ArrayList<PanelPart>();
    final MultiKeyMap<String, Integer> panelPartRowsMap = new MultiKeyMap<String, Integer>();

    for (final String param : params) {
        final Widget paramWi = createWidget(param, prefix, rightWidth);
        /* sub panel */
        final String section = getSection(param);
        final JPanel panel;
        final AccessMode.Type accessType = getAccessType(param);
        final String accessTypeString = accessType.toString();
        final Boolean advanced = isAdvanced(param);
        final String advancedString = advanced.toString();
        if (panelPartsMap.containsKey(section, accessTypeString, advancedString)) {
            panel = panelPartsMap.get(section, accessTypeString, advancedString);
            panelPartRowsMap.put(section, accessTypeString, advancedString,
                    panelPartRowsMap.get(section, accessTypeString, advancedString) + 1);
        } else {
            panel = new JPanel(new SpringLayout());

            panel.setBackground(getSectionColor(section));
            if (advanced) {
                advancedPanelList.add(panel);
                panel.setVisible(access.isAdvancedMode());
            }
            panelPartsMap.put(section, accessTypeString, advancedString, panel);
            panelPartsList.add(new PanelPart(section, accessType, advanced));
            panelPartRowsMap.put(section, accessTypeString, advancedString, 1);
        }

        /* label */
        final JLabel label = new JLabel(getParamShortDesc(param));
        final String longDesc = getParamLongDesc(param);
        paramWi.setLabel(label, longDesc);

        /* tool tip */
        paramWi.setToolTipText(getToolTipText(param, paramWi));
        label.setToolTipText(longDesc + additionalToolTip(param));
        int height = 0;
        if (paramWi instanceof Label) {
            height = application.getDefaultSize("Browser.LabelFieldHeight");
        }
        addField(panel, label, paramWi.getComponent(), leftWidth, rightWidth, height);
    }
    final boolean wizard = Widget.WIZARD_PREFIX.equals(prefix);
    for (final String param : params) {
        final Widget paramWi = getWidget(param, prefix);
        if (wizard) {
            final Widget rpwi = getWidget(param, null);
            if (rpwi == null) {
                LOG.error("addParams: unknown param: " + param);
                continue;
            }
            if (paramWi.getValue() == null || paramWi.getValue().isNothingSelected()) {
                rpwi.setValueAndWait(null);
            } else {
                final Value value = paramWi.getValue();
                rpwi.setValueAndWait(value);
            }
        }
    }
    for (final String param : params) {
        final Widget paramWi = getWidget(param, prefix);
        Widget rpwi = null;
        if (wizard) {
            rpwi = getWidget(param, null);
        }
        final Widget realParamWi = rpwi;
        paramWi.addListeners(new WidgetListener() {
            @Override
            public void check(final Value value) {
                checkParameterFields(paramWi, realParamWi, param, getParametersFromXML(), thisApplyButton);
            }
        });
    }

    /* add sub panels to the option panel */
    final Map<String, JPanel> sectionMap = new HashMap<String, JPanel>();
    final Collection<JPanel> notAdvancedSections = new HashSet<JPanel>();
    final Collection<JPanel> advancedSections = new HashSet<JPanel>();
    for (final PanelPart panelPart : panelPartsList) {
        final String section = panelPart.getSection();
        final AccessMode.Type accessType = panelPart.getType();
        final String accessTypeString = accessType.toString();
        final Boolean advanced = panelPart.isAdvanced();
        final String advancedString = advanced.toString();

        final JPanel panel = panelPartsMap.get(section, accessTypeString, advancedString);
        final int rows = panelPartRowsMap.get(section, accessTypeString, advancedString);
        final int columns = 2;
        SpringUtilities.makeCompactGrid(panel, rows, columns, 1, 1, // initX, initY
                1, 1); // xPad, yPad
        final JPanel sectionPanel;
        if (sectionMap.containsKey(section)) {
            sectionPanel = sectionMap.get(section);
        } else {
            sectionPanel = getParamPanel(getSectionDisplayName(section), getSectionColor(section));
            sectionMap.put(section, sectionPanel);
            addSectionPanel(section, wizard, sectionPanel);
            optionsPanel.add(sectionPanel);
            if (sameAsFields != null) {
                final Widget sameAsCombo = sameAsFields.get(section);
                if (sameAsCombo != null) {
                    final JPanel saPanel = new JPanel(new SpringLayout());
                    saPanel.setBackground(Browser.BUTTON_PANEL_BACKGROUND);
                    final JLabel label = new JLabel(Tools.getString("ClusterBrowser.SameAs"));
                    sameAsCombo.setLabel(label, "");
                    addField(saPanel, label, sameAsCombo.getComponent(), leftWidth, rightWidth, 0);
                    SpringUtilities.makeCompactGrid(saPanel, 1, 2, 1, 1, // initX, initY
                            1, 1); // xPad, yPad
                    sectionPanel.add(saPanel);
                }
            }
        }
        sectionPanel.setVisible(isSectionEnabled(section));
        sectionPanel.add(panel);
        if (advanced) {
            advancedSections.add(sectionPanel);
        } else {
            notAdvancedSections.add(sectionPanel);
        }
    }
    boolean advanced = false;
    for (final Map.Entry<String, JPanel> sectionEntry : sectionMap.entrySet()) {
        final JPanel sectionPanel = sectionEntry.getValue();
        if (advancedSections.contains(sectionPanel)) {
            advanced = true;
        }
        if (!notAdvancedSections.contains(sectionPanel)) {
            advancedOnlySectionList.add(sectionEntry.getKey());
            sectionPanel.setVisible(access.isAdvancedMode() && isSectionEnabled(sectionEntry.getKey()));
        }
    }
    moreOptionsPanel.setVisible(advanced && !access.isAdvancedMode());
}

From source file:com.juanhg.cicloc.cicloCApplet.java

private void autogeneratedCode() {
    JPanel panel_control = new JPanel();
    panel_control.setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.RAISED, null, null),
            new BevelBorder(BevelBorder.RAISED, null, null, null, null)));

    JPanel panelInputs = new JPanel();
    panelInputs.setToolTipText("");
    panelInputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));

    JPanel panelOutputs = new JPanel();
    panelOutputs.setToolTipText("");
    panelOutputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));

    JPanel panelTitleOutputs = new JPanel();
    panelTitleOutputs.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));

    JLabel labelOutputData = new JLabel("Datos de la Simulaci\u00F3n");
    labelOutputData.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panelTitleOutputs.add(labelOutputData);

    lblPhase = new JLabel("Trabajo Ciclo:");
    lblPhase.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblTrabajoCValue = new JLabel();
    lblTrabajoCValue.setText("0");
    lblTrabajoCValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JLabel lblPosicion = new JLabel("Trabajo:");
    lblPosicion.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblTrabajoValue = new JLabel();
    lblTrabajoValue.setText("0");
    lblTrabajoValue.setFont(new Font("Tahoma", Font.PLAIN, 14));
    hotImage = loadImage(hot);/*  w  w  w.j av  a 2s  . c  om*/

    coldImage = loadImage(cold);

    lblE = new JLabel("Rendimiento:");
    lblE.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblEValue = new JLabel();
    lblEValue.setText("0");
    lblEValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    GroupLayout gl_panelOutputs = new GroupLayout(panelOutputs);
    gl_panelOutputs.setHorizontalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panelOutputs.createSequentialGroup().addGap(22).addGroup(gl_panelOutputs
                    .createParallelGroup(Alignment.LEADING)
                    .addGroup(gl_panelOutputs.createSequentialGroup()
                            .addComponent(lblE, GroupLayout.PREFERRED_SIZE, 84, GroupLayout.PREFERRED_SIZE)
                            .addGap(26).addComponent(lblEValue, GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE))
                    .addGroup(gl_panelOutputs.createSequentialGroup()
                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.TRAILING)
                                    .addGroup(gl_panelOutputs.createSequentialGroup()
                                            .addComponent(lblPhase, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addGap(26))
                                    .addGroup(gl_panelOutputs.createSequentialGroup()
                                            .addComponent(lblPosicion, GroupLayout.PREFERRED_SIZE, 81,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addGap(29)))
                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING, false)
                                    .addComponent(lblTrabajoValue, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(lblTrabajoCValue, GroupLayout.PREFERRED_SIZE, 103,
                                            GroupLayout.PREFERRED_SIZE))))
                    .addGap(109))
            .addGroup(gl_panelOutputs.createSequentialGroup().addComponent(panelTitleOutputs,
                    GroupLayout.PREFERRED_SIZE, 262, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(82, Short.MAX_VALUE)));
    gl_panelOutputs
            .setVerticalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
                    .addGroup(gl_panelOutputs.createSequentialGroup()
                            .addComponent(panelTitleOutputs, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(ComponentPlacement.UNRELATED)
                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE)
                                    .addComponent(lblTrabajoCValue).addComponent(lblPhase))
                            .addPreferredGap(ComponentPlacement.UNRELATED)
                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE)
                                    .addComponent(lblPosicion, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblTrabajoValue, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(ComponentPlacement.UNRELATED)
                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
                                    .addComponent(lblE, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblEValue, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE))
                            .addGap(79)));
    panelOutputs.setLayout(gl_panelOutputs);

    panel_1 = new JPanel();
    panel_1.setBorder(new LineBorder(new Color(0, 0, 0)));

    JPanel panel_6 = new JPanel();
    panel_6.setBorder(new LineBorder(new Color(0, 0, 0)));
    GroupLayout gl_panel_control = new GroupLayout(panel_control);
    gl_panel_control.setHorizontalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING)
            .addGroup(gl_panel_control.createSequentialGroup().addContainerGap()
                    .addGroup(gl_panel_control.createParallelGroup(Alignment.LEADING, false)
                            .addComponent(panelOutputs, 0, 0, Short.MAX_VALUE)
                            .addComponent(panelInputs, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(panel_6, 0, 0, Short.MAX_VALUE).addComponent(panel_1,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addContainerGap(92, Short.MAX_VALUE)));
    gl_panel_control.setVerticalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING)
            .addGroup(gl_panel_control.createSequentialGroup().addContainerGap()
                    .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 213, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(panelOutputs, GroupLayout.PREFERRED_SIZE, 129, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(panel_6, GroupLayout.PREFERRED_SIZE, 146, Short.MAX_VALUE)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(panel_1,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addGap(17)));

    btnLaunchSimulation = new JButton("Iniciar");
    btnLaunchSimulation.setFont(new Font("Tahoma", Font.PLAIN, 16));
    btnLaunchSimulation.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            btnLaunchSimulationEvent(event);
        }
    });

    btnCold = new JButton("");
    btnCold.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            btnHot.setEnabled(true);
            btnCold.setEnabled(false);
            isHot = false;
            lblE.setText("Eficiencia");

            lblModeValue.setText("Modo Frig");
            panelMode.setBackground(Color.BLUE);

        }
    });
    btnCold.setIcon(new ImageIcon(coldImage));
    btnCold.setEnabled(true);

    panelMode = new JPanel();
    panelMode.setBorder(new LineBorder(new Color(0, 0, 0)));
    panelMode.setBackground(Color.ORANGE);

    btnHot = new JButton("");
    btnHot.setIcon(new ImageIcon(hotImage));
    btnHot.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            btnHot.setEnabled(false);
            btnCold.setEnabled(true);
            isHot = true;
            lblE.setText("Rendimiento");

            lblModeValue.setText("Modo Motor");
            panelMode.setBackground(Color.ORANGE);
        }
    });
    btnHot.setEnabled(false);
    GroupLayout gl_panel_6 = new GroupLayout(panel_6);
    gl_panel_6.setHorizontalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING).addGroup(gl_panel_6
            .createSequentialGroup().addContainerGap()
            .addGroup(gl_panel_6.createParallelGroup(Alignment.LEADING, false)
                    .addComponent(panelMode, Alignment.TRAILING, 0, 0, Short.MAX_VALUE)
                    .addComponent(btnHot, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE))
            .addGap(10)
            .addGroup(gl_panel_6.createParallelGroup(Alignment.TRAILING, false)
                    .addComponent(btnCold, GroupLayout.PREFERRED_SIZE, 112, GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnLaunchSimulation, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                            Short.MAX_VALUE))
            .addContainerGap()));
    gl_panel_6.setVerticalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panel_6.createSequentialGroup().addGap(10)
                    .addGroup(gl_panel_6.createParallelGroup(Alignment.LEADING)
                            .addComponent(panelMode, 0, 0, Short.MAX_VALUE).addComponent(btnLaunchSimulation,
                                    GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addGroup(gl_panel_6.createParallelGroup(Alignment.TRAILING)
                            .addComponent(btnCold, GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE)
                            .addComponent(btnHot, GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE))
                    .addContainerGap()));

    lblModeValue = new JLabel("Modo Motor");
    lblModeValue.setFont(new Font("Tahoma", Font.PLAIN, 17));
    GroupLayout gl_panelMode = new GroupLayout(panelMode);
    gl_panelMode.setHorizontalGroup(gl_panelMode.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panelMode.createSequentialGroup().addContainerGap()
                    .addComponent(lblModeValue, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    gl_panelMode
            .setVerticalGroup(gl_panelMode.createParallelGroup(Alignment.LEADING)
                    .addGroup(gl_panelMode
                            .createSequentialGroup().addContainerGap().addComponent(lblModeValue,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGap(52)));
    panelMode.setLayout(gl_panelMode);
    panel_6.setLayout(gl_panel_6);

    JLabel lblNewLabel = new JLabel("GNU GENERAL PUBLIC LICENSE");
    panel_1.add(lblNewLabel);

    JLabel LabelT1 = new JLabel("T1");
    LabelT1.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JLabel labelT2 = new JLabel("T2");
    labelT2.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JLabel labelVmin = new JLabel("Vm\u00EDn");
    labelVmin.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JPanel panelTitle = new JPanel();
    panelTitle.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));

    lblT2Value = new JLabel("300");
    lblT2Value.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblVminValue = new JLabel("2");
    lblVminValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblT1Value = new JLabel("400");
    lblT1Value.setFont(new Font("Tahoma", Font.PLAIN, 14));

    sliderT1 = new JSlider();
    sliderT1.setMinimum(350);
    sliderT1.setMaximum(450);
    sliderT1.setMinorTickSpacing(1);
    sliderT1.setValue(400);
    sliderT1.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent event) {
            sliderT1Event();
        }
    });

    sliderT2 = new JSlider();
    sliderT2.setMinimum(270);
    sliderT2.setMaximum(330);
    sliderT2.setMinorTickSpacing(1);
    sliderT2.setValue(300);
    sliderT2.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            sliderT2Event();
        }
    });

    sliderVMin = new JSlider();
    sliderVMin.setMaximum(4);
    sliderVMin.setMinimum(1);
    sliderVMin.setValue(2);
    sliderVMin.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            sliderVminEvent();
        }
    });

    JLabel lblVmax = new JLabel("Vm\u00E1x");
    lblVmax.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblVmaxValue = new JLabel("7");
    lblVmaxValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    sliderVMax = new JSlider();
    sliderVMax.setMaximum(10);
    sliderVMax.setMinimum(6);
    sliderVMax.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            sliderVmaxEvent();
        }
    });
    sliderVMax.setValue(7);
    sliderVMax.setMinorTickSpacing(1);

    JLabel labelN = new JLabel("N");
    labelN.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblNValue = new JLabel("10");
    lblNValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    sliderN = new JSlider();
    sliderN.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            sliderNEvent();
        }
    });
    sliderN.setValue(10);
    sliderN.setMinorTickSpacing(1);

    GroupLayout gl_panelInputs = new GroupLayout(panelInputs);
    gl_panelInputs.setHorizontalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panelInputs.createSequentialGroup().addGap(19).addGroup(gl_panelInputs
                    .createParallelGroup(Alignment.LEADING, false)
                    .addComponent(labelN, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lblVmax, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(labelVmin, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                            Short.MAX_VALUE)
                    .addComponent(labelT2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(LabelT1, GroupLayout.PREFERRED_SIZE, 65, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING, false)
                            .addGroup(gl_panelInputs.createSequentialGroup()
                                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                                            .addComponent(lblT1Value, GroupLayout.PREFERRED_SIZE, 42,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblT2Value, GroupLayout.PREFERRED_SIZE, 56,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblVminValue, GroupLayout.PREFERRED_SIZE, 56,
                                                    GroupLayout.PREFERRED_SIZE))
                                    .addGap(18)
                                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING, false)
                                            .addComponent(sliderT1, 0, 0, Short.MAX_VALUE)
                                            .addComponent(sliderT2, 0, 0, Short.MAX_VALUE)
                                            .addComponent(sliderVMin, GroupLayout.PREFERRED_SIZE, 88,
                                                    GroupLayout.PREFERRED_SIZE)))
                            .addGroup(gl_panelInputs.createSequentialGroup()
                                    .addComponent(lblVmaxValue, GroupLayout.PREFERRED_SIZE, 56,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addGap(18).addComponent(sliderVMax, GroupLayout.PREFERRED_SIZE, 88,
                                            GroupLayout.PREFERRED_SIZE))
                            .addGroup(gl_panelInputs.createSequentialGroup()
                                    .addComponent(lblNValue, GroupLayout.PREFERRED_SIZE, 56,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addGap(18)
                                    .addComponent(sliderN, GroupLayout.PREFERRED_SIZE, 88,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.RELATED)))
                    .addContainerGap())
            .addComponent(panelTitle, GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE));
    gl_panelInputs.setVerticalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panelInputs.createSequentialGroup()
                    .addComponent(panelTitle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addGap(18)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_panelInputs.createSequentialGroup().addComponent(LabelT1).addGap(12)
                                    .addComponent(labelT2).addGap(17).addComponent(labelVmin).addGap(17)
                                    .addComponent(lblVmax, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addGap(17).addComponent(labelN, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE))
                            .addGroup(gl_panelInputs.createSequentialGroup()
                                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                                            .addComponent(lblT1Value, GroupLayout.PREFERRED_SIZE, 17,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(sliderT1, GroupLayout.PREFERRED_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                                            .addComponent(lblT2Value, GroupLayout.PREFERRED_SIZE, 17,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(sliderT2, GroupLayout.PREFERRED_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                                    .addGap(11)
                                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                                            .addComponent(lblVminValue, GroupLayout.PREFERRED_SIZE, 17,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(sliderVMin, GroupLayout.PREFERRED_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                                    .addPreferredGap(ComponentPlacement.UNRELATED)
                                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                                            .addComponent(lblVmaxValue, GroupLayout.PREFERRED_SIZE, 17,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(sliderVMax, GroupLayout.PREFERRED_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING)
                                            .addComponent(lblNValue, GroupLayout.PREFERRED_SIZE, 17,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(sliderN, GroupLayout.PREFERRED_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
                    .addGap(8)));

    JLabel lblDatosDeEntrada = new JLabel("Datos de Entrada");
    lblDatosDeEntrada.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panelTitle.add(lblDatosDeEntrada);
    panelInputs.setLayout(gl_panelInputs);
    panel_control.setLayout(gl_panel_control);

    JPanel panel_visualizar = new JPanel();
    panel_visualizar.setBackground(Color.WHITE);

    GroupLayout groupLayout = new GroupLayout(getContentPane());
    groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
            .addGroup(Alignment.LEADING, groupLayout.createSequentialGroup().addContainerGap()
                    .addComponent(panel_control, GroupLayout.PREFERRED_SIZE, 286, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(panel_visualizar,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(93, Short.MAX_VALUE)));
    groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.TRAILING).addGroup(groupLayout
            .createSequentialGroup().addContainerGap()
            .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
                    .addComponent(panel_visualizar, GroupLayout.DEFAULT_SIZE, 567, Short.MAX_VALUE)
                    .addComponent(panel_control, GroupLayout.PREFERRED_SIZE, 568, GroupLayout.PREFERRED_SIZE))
            .addContainerGap()));

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);

    panelPiston = new JPanelGrafica();
    panelPiston.setBackground(Color.WHITE);

    JPanel panel_5 = new JPanel();
    panel_5.setBackground(Color.WHITE);

    JPanel panel = new JPanel();
    panel.setBackground(Color.WHITE);
    GroupLayout gl_panel_visualizar = new GroupLayout(panel_visualizar);
    gl_panel_visualizar.setHorizontalGroup(gl_panel_visualizar.createParallelGroup(Alignment.LEADING)
            .addComponent(tabbedPane, GroupLayout.DEFAULT_SIZE, 845, Short.MAX_VALUE)
            .addGroup(gl_panel_visualizar.createSequentialGroup().addContainerGap()
                    .addComponent(panelPiston, GroupLayout.PREFERRED_SIZE, 355, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(panel, GroupLayout.PREFERRED_SIZE, 183, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(panel_5, GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE).addContainerGap()));
    gl_panel_visualizar.setVerticalGroup(gl_panel_visualizar.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panel_visualizar.createSequentialGroup()
                    .addComponent(tabbedPane, GroupLayout.PREFERRED_SIZE, 289, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addGroup(gl_panel_visualizar.createParallelGroup(Alignment.LEADING)
                            .addComponent(panel, GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE)
                            .addComponent(panelPiston, GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE)
                            .addComponent(panel_5, GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE))
                    .addContainerGap()));

    panelTermo = new JPanelGrafica();
    panelTermo.setBackground(Color.WHITE);
    GroupLayout gl_panel = new GroupLayout(panel);
    gl_panel.setHorizontalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addComponent(panelTermo,
            GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE));
    gl_panel.setVerticalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addComponent(panelTermo,
            GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE));
    panel.setLayout(gl_panel);

    panelPistonInterno = new JPanelGrafica();
    panelPistonInterno.setBackground(Color.WHITE);
    GroupLayout gl_panelPiston = new GroupLayout(panelPiston);
    gl_panelPiston.setHorizontalGroup(gl_panelPiston.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panelPiston.createSequentialGroup()
                    .addComponent(panelPistonInterno, GroupLayout.PREFERRED_SIZE, 354,
                            GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    gl_panelPiston.setVerticalGroup(gl_panelPiston.createParallelGroup(Alignment.LEADING)
            .addComponent(panelPistonInterno, GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE));
    panelPiston.setLayout(gl_panelPiston);

    JPanel panelBulb = new JPanel();
    panelBulb.setBackground(Color.WHITE);

    JPanel panelLED = new JPanel();
    panelLED.setBackground(Color.WHITE);

    lblBulbValue = new JLabel("-  Horas");

    lblLEDValue = new JLabel("-  Horas");
    GroupLayout gl_panel_5 = new GroupLayout(panel_5);
    gl_panel_5.setHorizontalGroup(gl_panel_5.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panel_5.createSequentialGroup()
                    .addGroup(gl_panel_5.createParallelGroup(Alignment.LEADING, false)
                            .addComponent(panelLED, 0, 0, Short.MAX_VALUE)
                            .addComponent(panelBulb, GroupLayout.PREFERRED_SIZE, 132, Short.MAX_VALUE))
                    .addGap(18).addGroup(gl_panel_5.createParallelGroup(Alignment.LEADING)
                            .addComponent(lblBulbValue).addComponent(lblLEDValue))
                    .addContainerGap(87, Short.MAX_VALUE)));
    gl_panel_5.setVerticalGroup(gl_panel_5.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panel_5.createSequentialGroup()
                    .addComponent(panelBulb, GroupLayout.PREFERRED_SIZE, 143, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addComponent(panelLED, GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE))
            .addGroup(gl_panel_5.createSequentialGroup().addGap(64).addComponent(lblBulbValue)
                    .addPreferredGap(ComponentPlacement.RELATED, 135, Short.MAX_VALUE).addComponent(lblLEDValue)
                    .addGap(64)));

    LEDOnImage = loadImage(LEDOn);
    LEDOffImage = loadImage(LEDOff);
    lblLED = new JLabel(new ImageIcon(LEDOffImage));
    lblLED.setBackground(Color.WHITE);

    GroupLayout gl_panelLED = new GroupLayout(panelLED);
    gl_panelLED.setHorizontalGroup(gl_panelLED.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panelLED.createSequentialGroup()
                    .addComponent(lblLED, GroupLayout.PREFERRED_SIZE, 131, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(33, Short.MAX_VALUE)));
    gl_panelLED.setVerticalGroup(gl_panelLED.createParallelGroup(Alignment.TRAILING).addGroup(Alignment.LEADING,
            gl_panelLED.createSequentialGroup().addContainerGap().addComponent(lblLED, GroupLayout.DEFAULT_SIZE,
                    126, Short.MAX_VALUE)));
    panelLED.setLayout(gl_panelLED);

    bulbOnImage = loadImage(bulbOn);
    bulbOffImage = loadImage(bulbOff);
    lblBulb = new JLabel(new ImageIcon(bulbOffImage));
    lblBulb.setBackground(Color.WHITE);

    GroupLayout gl_panelBulb = new GroupLayout(panelBulb);
    gl_panelBulb.setHorizontalGroup(gl_panelBulb.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panelBulb.createSequentialGroup()
                    .addComponent(lblBulb, GroupLayout.PREFERRED_SIZE, 134, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(30, Short.MAX_VALUE)));
    gl_panelBulb.setVerticalGroup(gl_panelBulb.createParallelGroup(Alignment.LEADING).addComponent(lblBulb,
            GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE));
    panelBulb.setLayout(gl_panelBulb);
    panel_5.setLayout(gl_panel_5);

    JPanel panelXV = new JPanel();
    panelXV.setBackground(Color.WHITE);
    tabbedPane.addTab("Grficas V", null, panelXV, null);

    JPanel panel_2 = new JPanel();

    JPanel panel_3 = new JPanel();

    JPanel panel_4 = new JPanel();

    panelTV = new JPanelGrafica();
    GroupLayout gl_panel_4 = new GroupLayout(panel_4);
    gl_panel_4.setHorizontalGroup(
            gl_panel_4.createParallelGroup(Alignment.LEADING).addGap(0, 272, Short.MAX_VALUE)
                    .addComponent(panelTV, GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE));
    gl_panel_4
            .setVerticalGroup(gl_panel_4.createParallelGroup(Alignment.LEADING).addGap(0, 241, Short.MAX_VALUE)
                    .addGroup(gl_panel_4.createSequentialGroup()
                            .addComponent(panelTV, GroupLayout.PREFERRED_SIZE, 241, GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(306, Short.MAX_VALUE)));
    panel_4.setLayout(gl_panel_4);
    GroupLayout gl_panelXV = new GroupLayout(panelXV);
    gl_panelXV.setHorizontalGroup(gl_panelXV.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panelXV.createSequentialGroup().addContainerGap()
                    .addComponent(panel_2, GroupLayout.PREFERRED_SIZE, 263, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(panel_3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(panel_4, GroupLayout.PREFERRED_SIZE, 272, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(11, Short.MAX_VALUE)));
    gl_panelXV.setVerticalGroup(gl_panelXV.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panelXV.createSequentialGroup().addContainerGap()
                    .addGroup(gl_panelXV.createParallelGroup(Alignment.LEADING)
                            .addComponent(panel_4, GroupLayout.PREFERRED_SIZE, 241, GroupLayout.PREFERRED_SIZE)
                            .addGroup(gl_panelXV.createParallelGroup(Alignment.TRAILING, false)
                                    .addComponent(panel_3, Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                                    .addComponent(panel_2, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 241,
                                            Short.MAX_VALUE)))
                    .addContainerGap(317, Short.MAX_VALUE)));

    panelUV = new JPanelGrafica();
    GroupLayout gl_panel_3 = new GroupLayout(panel_3);
    gl_panel_3.setHorizontalGroup(gl_panel_3.createParallelGroup(Alignment.LEADING).addComponent(panelUV,
            GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE));
    gl_panel_3.setVerticalGroup(gl_panel_3.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panel_3.createSequentialGroup()
                    .addComponent(panelUV, GroupLayout.PREFERRED_SIZE, 241, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(306, Short.MAX_VALUE)));
    panel_3.setLayout(gl_panel_3);

    panelPV = new JPanelGrafica();
    GroupLayout gl_panel_2 = new GroupLayout(panel_2);
    gl_panel_2.setHorizontalGroup(gl_panel_2.createParallelGroup(Alignment.LEADING).addComponent(panelPV,
            GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE));
    gl_panel_2.setVerticalGroup(gl_panel_2.createParallelGroup(Alignment.LEADING).addComponent(panelPV,
            GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE));
    panel_2.setLayout(gl_panel_2);
    panelXV.setLayout(gl_panelXV);

    JPanel panelXT = new JPanel();
    panelXT.setBackground(Color.WHITE);
    tabbedPane.addTab("Grficas T", null, panelXT, null);

    JPanel panel_9 = new JPanel();

    panelPT = new JPanelGrafica();
    GroupLayout gl_panel_9 = new GroupLayout(panel_9);
    gl_panel_9.setHorizontalGroup(
            gl_panel_9.createParallelGroup(Alignment.LEADING).addGap(0, 263, Short.MAX_VALUE)
                    .addComponent(panelPT, GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE));
    gl_panel_9
            .setVerticalGroup(gl_panel_9.createParallelGroup(Alignment.LEADING).addGap(0, 241, Short.MAX_VALUE)
                    .addComponent(panelPT, GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE));
    panel_9.setLayout(gl_panel_9);

    JPanel panel_10 = new JPanel();

    panelST = new JPanelGrafica();
    GroupLayout gl_panel_10 = new GroupLayout(panel_10);
    gl_panel_10.setHorizontalGroup(
            gl_panel_10.createParallelGroup(Alignment.LEADING).addGap(0, 272, Short.MAX_VALUE)
                    .addComponent(panelST, GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE));
    gl_panel_10
            .setVerticalGroup(gl_panel_10.createParallelGroup(Alignment.LEADING).addGap(0, 241, Short.MAX_VALUE)
                    .addGroup(gl_panel_10.createSequentialGroup()
                            .addComponent(panelST, GroupLayout.PREFERRED_SIZE, 241, GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    panel_10.setLayout(gl_panel_10);

    JPanel panel_11 = new JPanel();

    panelUT = new JPanelGrafica();
    GroupLayout gl_panel_11 = new GroupLayout(panel_11);
    gl_panel_11.setHorizontalGroup(
            gl_panel_11.createParallelGroup(Alignment.LEADING).addGap(0, 272, Short.MAX_VALUE)
                    .addComponent(panelUT, GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE));
    gl_panel_11
            .setVerticalGroup(gl_panel_11.createParallelGroup(Alignment.LEADING).addGap(0, 241, Short.MAX_VALUE)
                    .addGroup(gl_panel_11.createSequentialGroup()
                            .addComponent(panelUT, GroupLayout.PREFERRED_SIZE, 241, GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    panel_11.setLayout(gl_panel_11);
    GroupLayout gl_panelXT = new GroupLayout(panelXT);
    gl_panelXT.setHorizontalGroup(gl_panelXT.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panelXT.createSequentialGroup().addContainerGap()
                    .addComponent(panel_9, GroupLayout.PREFERRED_SIZE, 263, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(panel_10, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(panel_11, GroupLayout.PREFERRED_SIZE, 272, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(11, Short.MAX_VALUE)));
    gl_panelXT.setVerticalGroup(gl_panelXT.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panelXT.createSequentialGroup().addContainerGap()
                    .addGroup(gl_panelXT.createParallelGroup(Alignment.LEADING)
                            .addComponent(panel_11, GroupLayout.PREFERRED_SIZE, 241, GroupLayout.PREFERRED_SIZE)
                            .addGroup(gl_panelXT.createParallelGroup(Alignment.TRAILING, false)
                                    .addComponent(panel_10, Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                                    .addComponent(panel_9, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 241,
                                            Short.MAX_VALUE)))
                    .addContainerGap(317, Short.MAX_VALUE)));
    panelXT.setLayout(gl_panelXT);
    panel_visualizar.setLayout(gl_panel_visualizar);

    getContentPane().setLayout(groupLayout);
}

From source file:com.juanhg.pot.PotApplet.java

private void autogeneratedCode() {
    JPanel panel_control = new JPanel();
    panel_control.setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.RAISED, null, null),
            new BevelBorder(BevelBorder.RAISED, null, null, null, null)));

    JPanel panelInputs = new JPanel();
    panelInputs.setToolTipText("");
    panelInputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));

    JPanel panelOutputs = new JPanel();
    panelOutputs.setToolTipText("");
    panelOutputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));

    JPanel panelTitleOutputs = new JPanel();
    panelTitleOutputs.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));

    JLabel labelOutputData = new JLabel("Datos de la Simulaci\u00F3n");
    labelOutputData.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panelTitleOutputs.add(labelOutputData);

    JLabel lblW = new JLabel("W:");
    lblW.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblWValue = new JLabel();
    lblWValue.setText("-");
    lblWValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblQ = new JLabel("Q:");
    lblQ.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblQValue = new JLabel();
    lblQValue.setText("-");
    lblQValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblT2 = new JLabel("T:");
    lblT2.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblTOValue = new JLabel();
    lblTOValue.setText("-");
    lblTOValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblU = new JLabel("U:");
    lblU.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblP = new JLabel("P:");
    lblP.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblVO = new JLabel("V:");
    lblVO.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblVOValue = new JLabel();
    lblVOValue.setText("-");
    lblVOValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblPValue = new JLabel();
    lblPValue.setText("-");
    lblPValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblUValue = new JLabel();
    lblUValue.setText("-");
    lblUValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    GroupLayout gl_panelOutputs = new GroupLayout(panelOutputs);
    gl_panelOutputs.setHorizontalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
            .addComponent(panelTitleOutputs, GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE)
            .addGroup(gl_panelOutputs.createSequentialGroup().addGap(31).addGroup(gl_panelOutputs
                    .createParallelGroup(Alignment.TRAILING)
                    .addGroup(gl_panelOutputs.createSequentialGroup()
                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING, false)
                                    .addComponent(lblQ, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                            Short.MAX_VALUE)
                                    .addComponent(lblW, GroupLayout.PREFERRED_SIZE, 43,
                                            GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(ComponentPlacement.RELATED)
                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
                                    .addComponent(lblWValue, GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
                                    .addComponent(lblQValue, GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)))
                    .addGroup(Alignment.LEADING, gl_panelOutputs.createSequentialGroup()
                            .addComponent(lblT2, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblTOValue,
                                    GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)))
                    .addGap(18)/*from   w w w.  j  a  v a  2 s  . co m*/
                    .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_panelOutputs.createSequentialGroup()
                                    .addComponent(lblU, GroupLayout.PREFERRED_SIZE, 43,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addGap(6).addComponent(lblUValue, GroupLayout.PREFERRED_SIZE, 90,
                                            GroupLayout.PREFERRED_SIZE))
                            .addGroup(gl_panelOutputs.createSequentialGroup()
                                    .addComponent(lblP, GroupLayout.PREFERRED_SIZE, 43,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addGap(6).addComponent(lblPValue, GroupLayout.PREFERRED_SIZE, 90,
                                            GroupLayout.PREFERRED_SIZE))
                            .addGroup(gl_panelOutputs.createSequentialGroup()
                                    .addComponent(lblVO, GroupLayout.PREFERRED_SIZE, 43,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addGap(6).addComponent(lblVOValue, GroupLayout.PREFERRED_SIZE, 90,
                                            GroupLayout.PREFERRED_SIZE)))
                    .addGap(25)));
    gl_panelOutputs.setVerticalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panelOutputs
                    .createSequentialGroup().addComponent(panelTitleOutputs, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING).addGroup(gl_panelOutputs
                            .createSequentialGroup()
                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
                                    .addComponent(lblU, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblUValue, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE))
                            .addGap(6)
                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
                                    .addComponent(lblP, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblPValue, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE))
                            .addGap(6)
                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
                                    .addComponent(lblVO, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblVOValue, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE)))
                            .addGroup(gl_panelOutputs.createSequentialGroup().addGroup(gl_panelOutputs
                                    .createParallelGroup(Alignment.TRAILING)
                                    .addGroup(gl_panelOutputs.createSequentialGroup()
                                            .addComponent(lblW, GroupLayout.PREFERRED_SIZE, 17,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblQ,
                                                    GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE))
                                    .addGroup(gl_panelOutputs.createSequentialGroup()
                                            .addComponent(lblWValue, GroupLayout.PREFERRED_SIZE, 17,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblQValue,
                                                    GroupLayout.PREFERRED_SIZE, 17,
                                                    GroupLayout.PREFERRED_SIZE)))
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
                                            .addComponent(lblT2, GroupLayout.PREFERRED_SIZE, 17,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblTOValue, GroupLayout.PREFERRED_SIZE, 17,
                                                    GroupLayout.PREFERRED_SIZE))))
                    .addContainerGap()));
    panelOutputs.setLayout(gl_panelOutputs);

    JPanel panelLicense = new JPanel();
    panelLicense.setBorder(new LineBorder(new Color(0, 0, 0)));

    JPanel panel_6 = new JPanel();
    panel_6.setBorder(new LineBorder(new Color(0, 0, 0)));
    GroupLayout gl_panel_control = new GroupLayout(panel_control);
    gl_panel_control
            .setHorizontalGroup(gl_panel_control.createParallelGroup(Alignment.LEADING)
                    .addGroup(Alignment.TRAILING, gl_panel_control.createSequentialGroup().addContainerGap()
                            .addGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING)
                                    .addComponent(panelInputs, Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                            346, Short.MAX_VALUE)
                                    .addComponent(panelOutputs, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(panel_6, GroupLayout.PREFERRED_SIZE, 346, Short.MAX_VALUE)
                                    .addComponent(panelLicense, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            346, Short.MAX_VALUE))
                            .addContainerGap()));
    gl_panel_control.setVerticalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING)
            .addGroup(gl_panel_control.createSequentialGroup().addContainerGap()
                    .addComponent(panelInputs, GroupLayout.DEFAULT_SIZE, 292, Short.MAX_VALUE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(panelOutputs, GroupLayout.PREFERRED_SIZE, 108, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(panel_6, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(panelLicense,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addGap(24)));

    btnLaunchSimulation = new JButton("Iniciar");
    btnLaunchSimulation.setFont(new Font("Tahoma", Font.PLAIN, 16));
    btnLaunchSimulation.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            btnLaunchSimulationEvent(event);
        }
    });
    GroupLayout gl_panel_6 = new GroupLayout(panel_6);
    gl_panel_6.setHorizontalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING,
            gl_panel_6.createSequentialGroup().addContainerGap()
                    .addComponent(btnLaunchSimulation, GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE)
                    .addContainerGap()));
    gl_panel_6.setVerticalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panel_6
                    .createSequentialGroup().addContainerGap().addComponent(btnLaunchSimulation,
                            GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(69, Short.MAX_VALUE)));
    panel_6.setLayout(gl_panel_6);

    JLabel lblNewLabel = new JLabel("GNU GENERAL PUBLIC LICENSE");
    panelLicense.add(lblNewLabel);

    lblT = new JLabel("Temperatura");
    lblT.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblV = new JLabel("Volumen");
    lblV.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblMo = new JLabel("Masa Inicial");
    lblMo.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JPanel panelTitle = new JPanel();
    panelTitle.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));

    lblVValue = new JLabel("15");
    lblVValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblMoValue = new JLabel("5");
    lblMoValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblTValue = new JLabel("300");
    lblTValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    sliderT = new JSlider();
    sliderT.setMinimum(280);
    sliderT.setMaximum(330);
    sliderT.setMinorTickSpacing(1);
    sliderT.setValue(300);
    sliderT.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent event) {
            sliderI1Event();
        }
    });

    sliderV = new JSlider();
    sliderV.setMinimum(3);
    sliderV.setMaximum(30);
    sliderV.setMinorTickSpacing(1);
    sliderV.setValue(15);
    sliderV.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            sliderI2Event();
        }
    });

    sliderMo = new JSlider();
    sliderMo.setMinimum(1);
    sliderMo.setMaximum(1000);
    sliderMo.setValue(5);
    sliderMo.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            sliderI3Event();
        }
    });

    lblM = new JLabel("Masa Final");
    lblM.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblMValue = new JLabel("4");
    lblMValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    sliderM = new JSlider();
    sliderM.setMinimum(1);
    sliderM.setMaximum(1000);
    sliderM.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            sliderI4Event();
        }
    });
    sliderM.setValue(4);
    sliderM.setMinorTickSpacing(1);

    lblType = new JLabel("Combustible");
    lblType.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblTypeValue = new JLabel("Madera");
    lblTypeValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    sliderType = new JSlider();
    sliderType.setMinimum(1);
    sliderType.setMaximum(4);
    sliderType.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            sliderI5Event();
        }
    });
    sliderType.setValue(1);
    sliderType.setMinorTickSpacing(1);

    lblMc = new JLabel("Masa Combustible");
    lblMc.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblMcValue = new JLabel("10");
    lblMcValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    sliderMc = new JSlider();
    sliderMc.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            sliderI6Event();
        }
    });
    sliderMc.setMinimum(1);
    sliderMc.setValue(10);
    sliderMc.setMinorTickSpacing(1);
    sliderMc.setMaximum(50);

    btn1 = new JButton("1");
    btn1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            btn1function();
        }
    });

    btn2 = new JButton("2");
    btn2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            btn1.setEnabled(true);
            btn2.setEnabled(false);
            btn3.setEnabled(true);

            lblT.setEnabled(true);
            lblTValue.setEnabled(true);
            sliderT.setEnabled(true);

            lblV.setEnabled(true);
            lblVValue.setEnabled(true);
            sliderV.setEnabled(true);

            lblMo.setEnabled(false);
            lblMoValue.setEnabled(false);
            sliderMo.setEnabled(false);

            lblM.setEnabled(false);
            lblMValue.setEnabled(false);
            sliderM.setEnabled(false);

            lblType.setEnabled(true);
            lblTypeValue.setEnabled(true);
            sliderType.setEnabled(true);

            lblMc.setEnabled(true);
            lblMcValue.setEnabled(true);
            sliderMc.setEnabled(true);

            model.setCurrentPhase(2);
            readInputs();
            updateFire();
            updateScrews();
            updatePot();

            updatePanels();
            repaint();
        }
    });

    btn3 = new JButton("3");
    btn3.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            btn1.setEnabled(true);
            btn2.setEnabled(true);
            btn3.setEnabled(false);

            lblT.setEnabled(true);
            lblTValue.setEnabled(true);
            sliderT.setEnabled(true);

            lblV.setEnabled(false);
            lblVValue.setEnabled(false);
            sliderV.setEnabled(false);

            lblMo.setEnabled(false);
            lblMoValue.setEnabled(false);
            sliderMo.setEnabled(false);

            lblM.setEnabled(true);
            lblMValue.setEnabled(true);
            sliderM.setEnabled(true);

            lblType.setEnabled(true);
            lblTypeValue.setEnabled(true);
            sliderType.setEnabled(true);

            lblMc.setEnabled(true);
            lblMcValue.setEnabled(true);
            sliderMc.setEnabled(true);

            model.setCurrentPhase(3);
            readInputs();
            updateFire();
            updateScrews();
            updatePot();

            updatePanels();
            repaint();
        }
    });

    GroupLayout gl_panelInputs = new GroupLayout(panelInputs);
    gl_panelInputs.setHorizontalGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING)
            .addComponent(panelTitle, GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE)
            .addGroup(gl_panelInputs.createSequentialGroup().addGap(25)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING,
                            gl_panelInputs.createSequentialGroup().addGroup(gl_panelInputs
                                    .createParallelGroup(Alignment.TRAILING).addGroup(gl_panelInputs
                                            .createSequentialGroup()
                                            .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                                                    .addComponent(lblV, GroupLayout.PREFERRED_SIZE, 120,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(lblMo, GroupLayout.DEFAULT_SIZE, 141,
                                                            Short.MAX_VALUE)
                                                    .addComponent(lblM, GroupLayout.PREFERRED_SIZE, 120,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(lblType, GroupLayout.PREFERRED_SIZE, 120,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(lblMc, GroupLayout.PREFERRED_SIZE, 118,
                                                            GroupLayout.PREFERRED_SIZE))
                                            .addGap(18))
                                    .addComponent(lblT, GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE))
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                                            .addComponent(lblTValue, GroupLayout.PREFERRED_SIZE, 42,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblVValue, GroupLayout.PREFERRED_SIZE, 56,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblMoValue, GroupLayout.PREFERRED_SIZE, 56,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblMValue, GroupLayout.PREFERRED_SIZE, 56,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblTypeValue, GroupLayout.PREFERRED_SIZE, 70,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblMcValue, GroupLayout.PREFERRED_SIZE, 42,
                                                    GroupLayout.PREFERRED_SIZE))
                                    .addGap(4).addPreferredGap(ComponentPlacement.RELATED)
                                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                                            .addComponent(sliderMc, GroupLayout.PREFERRED_SIZE, 88,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(sliderType, GroupLayout.PREFERRED_SIZE, 88,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(sliderM, GroupLayout.PREFERRED_SIZE, 88,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(sliderMo, GroupLayout.DEFAULT_SIZE, 109,
                                                    Short.MAX_VALUE)
                                            .addComponent(sliderV, 0, 0, Short.MAX_VALUE)
                                            .addComponent(sliderT, 0, 0, Short.MAX_VALUE)))
                            .addGroup(gl_panelInputs.createSequentialGroup()
                                    .addComponent(btn1, GroupLayout.PREFERRED_SIZE, 94,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.UNRELATED)
                                    .addComponent(btn2, GroupLayout.PREFERRED_SIZE, 93,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(btn3,
                                            GroupLayout.PREFERRED_SIZE, 91, GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap()));
    gl_panelInputs.setVerticalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panelInputs.createSequentialGroup()
                    .addComponent(panelTitle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addGap(18)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE).addComponent(lblT)
                                    .addComponent(lblTValue, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE))
                            .addComponent(sliderT, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE).addComponent(lblV)
                                    .addComponent(lblVValue, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE))
                            .addComponent(sliderV, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addGap(11)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING).addComponent(lblMo)
                            .addComponent(lblMoValue, GroupLayout.PREFERRED_SIZE, 17,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(sliderMo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                            .addComponent(lblM, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblMValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)
                            .addComponent(sliderM, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                            .addComponent(lblType, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)
                            .addComponent(sliderType, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblTypeValue, GroupLayout.PREFERRED_SIZE, 17,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE)
                                    .addComponent(lblMcValue, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblMc, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE))
                            .addComponent(sliderMc, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_panelInputs.createSequentialGroup()
                                    .addComponent(btn1, GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE)
                                    .addGap(12))
                            .addGroup(gl_panelInputs.createSequentialGroup()
                                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE)
                                            .addComponent(btn2, GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE)
                                            .addComponent(btn3, GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE))
                                    .addContainerGap()))));

    JLabel lblDatosDeEntrada = new JLabel("Datos de Entrada");
    lblDatosDeEntrada.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panelTitle.add(lblDatosDeEntrada);
    panelInputs.setLayout(gl_panelInputs);
    panel_control.setLayout(gl_panel_control);

    JPanel panel_visualizar = new JPanel();
    panel_visualizar.setBackground(UIManager.getColor("Button.background"));

    GroupLayout groupLayout = new GroupLayout(getContentPane());
    groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(groupLayout.createSequentialGroup().addContainerGap()
                    .addComponent(panel_control, GroupLayout.PREFERRED_SIZE, 382, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(panel_visualizar, GroupLayout.PREFERRED_SIZE, 741, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(31, Short.MAX_VALUE)));
    groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
            .addGroup(groupLayout.createSequentialGroup()
                    .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
                            .addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(
                                    panel_visualizar, GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE))
                            .addGroup(groupLayout.createSequentialGroup().addGap(12).addComponent(panel_control,
                                    GroupLayout.PREFERRED_SIZE, 568, Short.MAX_VALUE)))
                    .addContainerGap()));

    JPanel panel = new JPanel();
    panel.setBounds(0, 0, 345, 568);
    panel.setBackground(Color.WHITE);
    panel.setBorder(new LineBorder(new Color(0, 0, 0)));

    JPanel panel_1 = new JPanel();
    panel_1.setBounds(351, 0, 390, 568);
    panel_1.setBackground(Color.WHITE);
    panel_1.setBorder(new LineBorder(new Color(0, 0, 0)));

    JPanel panel33 = new JPanel();
    panel33.setBounds(1, 38, 388, 529);
    panel33.setBackground(Color.WHITE);

    JPanel panel_5 = new JPanel();
    panel_5.setBounds(1, 1, 388, 31);
    panel_5.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));

    JLabel lblGrficas = new JLabel("Gr\u00E1ficas");
    lblGrficas.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel_5.add(lblGrficas);
    panel_visualizar.setLayout(null);

    JPanel panel32 = new JPanel();
    panel32.setBounds(1, 38, 343, 529);
    panel32.setBackground(Color.WHITE);

    JPanel panel_4 = new JPanel();
    panel_4.setBounds(1, 1, 343, 31);
    panel_4.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));

    JLabel lblSimulacion = new JLabel("Simulaci\u00F3n");
    lblSimulacion.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel_4.add(lblSimulacion);
    panel_visualizar.add(panel);
    panel.setLayout(null);
    panel.add(panel_4);
    panel.add(panel32);

    panelPot = new JPanelGrafica();
    panelPot.setBackground(Color.WHITE);
    GroupLayout gl_panel32 = new GroupLayout(panel32);
    gl_panel32.setHorizontalGroup(gl_panel32.createParallelGroup(Alignment.LEADING).addComponent(panelPot,
            GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE));
    gl_panel32.setVerticalGroup(gl_panel32.createParallelGroup(Alignment.LEADING).addComponent(panelPot,
            GroupLayout.DEFAULT_SIZE, 529, Short.MAX_VALUE));
    panel32.setLayout(gl_panel32);
    panel_visualizar.add(panel_1);
    panel_1.setLayout(null);
    panel_1.add(panel33);

    panelGraficas = new JPanelGrafica();
    panelGraficas.setBackground(Color.WHITE);
    GroupLayout gl_panel33 = new GroupLayout(panel33);
    gl_panel33.setHorizontalGroup(gl_panel33.createParallelGroup(Alignment.LEADING).addComponent(panelGraficas,
            GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE));
    gl_panel33.setVerticalGroup(gl_panel33.createParallelGroup(Alignment.LEADING).addComponent(panelGraficas,
            GroupLayout.DEFAULT_SIZE, 529, Short.MAX_VALUE));
    panel33.setLayout(gl_panel33);
    panel_1.add(panel_5);

    getContentPane().setLayout(groupLayout);
}

From source file:lcmc.gui.resources.EditableInfo.java

/** Adds parameters to the panel. */
private void addParams(final JPanel optionsPanel, final String prefix, final String[] params,
        final MyButton thisApplyButton, final int leftWidth, final int rightWidth,
        final Map<String, Widget> sameAsFields) {
    if (params == null) {
        return;/*  w  w  w.j a  va 2  s .  c om*/
    }
    final MultiKeyMap<String, JPanel> panelPartsMap = new MultiKeyMap<String, JPanel>();
    final List<PanelPart> panelPartsList = new ArrayList<PanelPart>();
    final MultiKeyMap<String, Integer> panelPartRowsMap = new MultiKeyMap<String, Integer>();

    for (final String param : params) {
        final Widget paramWi = createWidget(param, prefix, rightWidth);
        /* sub panel */
        final String section = getSection(param);
        JPanel panel;
        final ConfigData.AccessType accessType = getAccessType(param);
        final String accessTypeString = accessType.toString();
        final Boolean advanced = isAdvanced(param);
        final String advancedString = advanced.toString();
        if (panelPartsMap.containsKey(section, accessTypeString, advancedString)) {
            panel = panelPartsMap.get(section, accessTypeString, advancedString);
            panelPartRowsMap.put(section, accessTypeString, advancedString,
                    panelPartRowsMap.get(section, accessTypeString, advancedString) + 1);
        } else {
            panel = new JPanel(new SpringLayout());
            panel.setBackground(Browser.PANEL_BACKGROUND);
            if (advanced) {
                advancedPanelList.add(panel);
                final JPanel p = panel;
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        p.setVisible(Tools.getConfigData().isAdvancedMode());
                    }
                });
            }
            panelPartsMap.put(section, accessTypeString, advancedString, panel);
            panelPartsList.add(new PanelPart(section, accessType, advanced));
            panelPartRowsMap.put(section, accessTypeString, advancedString, 1);
        }

        /* label */
        final JLabel label = new JLabel(getParamShortDesc(param));
        final String longDesc = getParamLongDesc(param);
        paramWi.setLabel(label, longDesc);

        /* tool tip */
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                paramWi.setToolTipText(getToolTipText(param));
                label.setToolTipText(longDesc);
            }
        });
        int height = 0;
        if (paramWi.getType() == Widget.Type.LABELFIELD) {
            height = Tools.getDefaultSize("Browser.LabelFieldHeight");
        }
        addField(panel, label, paramWi, leftWidth, rightWidth, height);
    }
    for (final String param : params) {
        final Widget paramWi = getWidget(param, prefix);
        Widget rpwi = null;
        if ("wizard".equals(prefix)) {
            rpwi = getWidget(param, null);
            if (rpwi == null) {
                Tools.appError("unkown param: " + param + ". Man pages not installed?");
                continue;
            }
            int height = 0;
            if (rpwi.getType() == Widget.Type.LABELFIELD) {
                height = Tools.getDefaultSize("Browser.LabelFieldHeight");
            }
            final Widget rpwi0 = rpwi;
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    if (paramWi.getValue() == null || paramWi.getValue() == Widget.NOTHING_SELECTED) {
                        rpwi0.setValueAndWait(null);
                    } else {
                        final Object value = paramWi.getStringValue();
                        rpwi0.setValueAndWait(value);
                    }
                }
            });
        }
    }
    for (final String param : params) {
        final Widget paramWi = getWidget(param, prefix);
        Widget rpwi = null;
        if ("wizard".equals(prefix)) {
            rpwi = getWidget(param, null);
        }
        final Widget realParamWi = rpwi;
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                paramWi.addListeners(new WidgetListener() {
                    @Override
                    public void check(final Object value) {
                        checkParameterFields(paramWi, realParamWi, param, params, thisApplyButton);
                    }
                });

            }
        });
    }

    /* add sub panels to the option panel */
    final Map<String, JPanel> sectionMap = new HashMap<String, JPanel>();
    final Set<JPanel> notAdvancedSections = new HashSet<JPanel>();
    final Set<JPanel> advancedSections = new HashSet<JPanel>();
    for (final PanelPart panelPart : panelPartsList) {
        final String section = panelPart.getSection();
        final ConfigData.AccessType accessType = panelPart.getAccessType();
        final String accessTypeString = accessType.toString();
        final Boolean advanced = panelPart.isAdvanced();
        final String advancedString = advanced.toString();

        final JPanel panel = panelPartsMap.get(section, accessTypeString, advancedString);
        final int rows = panelPartRowsMap.get(section, accessTypeString, advancedString);
        final int columns = 2;
        SpringUtilities.makeCompactGrid(panel, rows, columns, 1, 1, // initX, initY
                1, 1); // xPad, yPad
        JPanel sectionPanel;
        if (sectionMap.containsKey(section)) {
            sectionPanel = sectionMap.get(section);
        } else {
            sectionPanel = getParamPanel(section);
            sectionMap.put(section, sectionPanel);
            optionsPanel.add(sectionPanel);
            if (sameAsFields != null) {
                final Widget sameAsCombo = sameAsFields.get(section);
                if (sameAsCombo != null) {
                    final JPanel saPanel = new JPanel(new SpringLayout());
                    saPanel.setBackground(Browser.BUTTON_PANEL_BACKGROUND);
                    final JLabel label = new JLabel("Same As");
                    sameAsCombo.setLabel(label, "");
                    addField(saPanel, label, sameAsCombo, leftWidth, rightWidth, 0);
                    SpringUtilities.makeCompactGrid(saPanel, 1, 2, 1, 1, // initX, initY
                            1, 1); // xPad, yPad
                    sectionPanel.add(saPanel);
                }
            }
        }
        sectionPanel.add(panel);
        if (advanced) {
            advancedSections.add(sectionPanel);
        } else {
            notAdvancedSections.add(sectionPanel);
        }
    }
    boolean advanced = false;
    for (final JPanel sectionPanel : sectionMap.values()) {
        if (advancedSections.contains(sectionPanel)) {
            advanced = true;
        }
        if (!notAdvancedSections.contains(sectionPanel)) {
            advancedOnlySectionList.add(sectionPanel);
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    sectionPanel.setVisible(Tools.getConfigData().isAdvancedMode());
                }
            });
        }
    }
    final boolean a = advanced;
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            moreOptionsPanel.setVisible(a && !Tools.getConfigData().isAdvancedMode());
        }
    });
}

From source file:com.sshtools.sshterm.SshTerminalPanel.java

public void init(SshToolsApplication application) throws SshToolsApplicationException {
    super.init(application);
    boolean kerb_support = false;
    if (PreferencesStore.get(PREF_KRB5_MYPROXY_USE, "NONE").indexOf("true") >= 0)
        kerb_support = true;/*  ww w.java 2s  .c  om*/

    //  Additional connection tabs
    if (kerb_support == true) {
        additionalTabs = new SshToolsConnectionTab[] { new SshTermCommandTab(), new SshTermTerminalTab(),
                new GSIAuthTab(), new XForwardingTab(), new SshToolsConnectionKerberosTab() };
        SshTerminalPanel.PREF_KRB5_MYPROXY_ENABLED = true;
    } else {
        additionalTabs = new SshToolsConnectionTab[] { new SshTermCommandTab(), new SshTermTerminalTab(),
                new GSIAuthTab(), new XForwardingTab() };
        SshTerminalPanel.PREF_KRB5_MYPROXY_ENABLED = false;

    }
    //
    //portForwardingPane = new PortForwardingPane();

    //  Printing page format
    try {
        if (System.getSecurityManager() != null) {
            AccessController.checkPermission(new RuntimePermission("queuePrintJob"));
        }

        try {
            PrinterJob job = PrinterJob.getPrinterJob();

            if (job == null) {
                throw new IOException("Could not get print page format.");
            }

            pageFormat = job.defaultPage();

            if (PreferencesStore.preferenceExists(PREF_PAGE_FORMAT_ORIENTATION)) {
                pageFormat.setOrientation(
                        PreferencesStore.getInt(PREF_PAGE_FORMAT_ORIENTATION, PageFormat.LANDSCAPE));

                Paper paper = new Paper();
                paper.setImageableArea(PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_X, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_Y, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_W, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_H, 0));
                paper.setSize(PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_W, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_H, 0));
                pageFormat.setPaper(paper);
            }
        } catch (Exception e) {
            showExceptionMessage("Error", e.getMessage());
        }
    } catch (AccessControlException ace) {
        ace.printStackTrace();
    }

    enableEvents(VDU_EVENTS);

    // Set up the actions
    initActions();

    // Create the status bar
    statusBar = new StatusBar();

    dataListener = new DataNotificationListener(statusBar);

    // Create our terminal emulation object
    try {
        emulation = createEmulation();
    } catch (IOException ioe) {
        throw new SshToolsApplicationException(ioe);
    }

    emulation.addTerminalListener(this);

    // Set a scrollbar for the terminal - doesn't seem to be as simple as this
    scrollBar = new JScrollBar(JScrollBar.VERTICAL);
    emulation.setBufferSize(1000);

    // Create our swing terminal and add it to the main frame
    terminal = new TerminalPanel(emulation) {
        public void processEvent(AWTEvent evt) {
            /** We can't add a MouseWheelListener because it was not available in 1.3, so direct processing of events is necessary */
            if (evt instanceof MouseEvent && evt.getID() == 507) {
                try {
                    Method m = evt.getClass().getMethod("getWheelRotation", new Class[] {});
                    SshTerminalPanel.this.scrollBar.setValue(SshTerminalPanel.this.scrollBar.getValue()
                            + (SshTerminalPanel.this.scrollBar.getUnitIncrement()
                                    * ((Integer) m.invoke(evt, new Object[] {})).intValue()
                                    * PreferencesStore.getInt(PREF_MOUSE_WHEEL_INCREMENT, 1)));

                } catch (Throwable t) {
                    //   In theory, this should never happen
                }
            } else {
                super.processEvent(evt);
            }
        }

        public void copyNotify() {
            copyAction.actionPerformed(null);
        }

    };
    terminal.requestFocus();
    terminal.setScrollbar(scrollBar);
    terminal.addMouseMotionListener(this);

    //terminal.addMouseWheelListener(this);
    // Center panel with terminal and scrollbar
    JPanel center = new JPanel(new BorderLayout());
    center.setBackground(Color.red);
    center.add(terminal, BorderLayout.CENTER);
    center.add(scrollBar, BorderLayout.EAST);

    // Show the context menu on mouse button 3 (right click)
    terminal.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent evt) {
            if ((evt.getModifiers() & MouseEvent.BUTTON3_MASK) > 0) {
                getContextMenu()
                        .setLabel((getCurrentConnectionFile() == null) ? getApplication().getApplicationName()
                                : getCurrentConnectionFile().getName());
                getContextMenu().show(terminal, evt.getX(), evt.getY());
            } else if ((evt.getModifiers() & MouseEvent.BUTTON2_MASK) > 0) {
                pasteAction.actionPerformed(null);
            }
        }
    });

    //
    //        JPanel top = new JPanel(new BorderLayout());
    //        top.add(getJMenuBar(), BorderLayout.NORTH);
    //        top.add(north, BorderLayout.SOUTH);
    setLayout(new BorderLayout());
    add(center, BorderLayout.CENTER);

    //        add(top, BorderLayout.NORTH);
    // Make sure that the swing terminal has focus
    terminal.requestFocus();
}

From source file:DesktopManagerDemo.java

public DesktopManagerDemo() {
    setTitle("Animated DesktopManager");
    m_count = m_tencount = 0;/*from  w  w  w .j  a  va2  s  . c  o m*/

    JPanel innerListenerPanel = new JPanel(new GridLayout(15, 1));
    JPanel listenerPanel = new JPanel(new BorderLayout());
    m_dmEventCanvas = new DMEventCanvas();

    m_lActivates = new JLabel("activateFrame");
    m_lBegindrags = new JLabel("beginDraggingFrame");
    m_lBeginresizes = new JLabel("beginResizingFrame");
    m_lCloses = new JLabel("closeFrame");
    m_lDeactivates = new JLabel("deactivateFrame");
    m_lDeiconifies = new JLabel("deiconifyFrame");
    m_lDrags = new JLabel("dragFrame");
    m_lEnddrags = new JLabel("endDraggingFrame");
    m_lEndresizes = new JLabel("endResizingFrame");
    m_lIconifies = new JLabel("iconifyFrame");
    m_lMaximizes = new JLabel("maximizeFrame");
    m_lMinimizes = new JLabel("minimizeFrame");
    m_lOpens = new JLabel("openFrame");
    m_lResizes = new JLabel("resizeFrame");
    m_lSetbounds = new JLabel("setBoundsForFrame");

    innerListenerPanel.add(m_lActivates);
    innerListenerPanel.add(m_lBegindrags);
    innerListenerPanel.add(m_lBeginresizes);
    innerListenerPanel.add(m_lCloses);
    innerListenerPanel.add(m_lDeactivates);
    innerListenerPanel.add(m_lDeiconifies);
    innerListenerPanel.add(m_lDrags);
    innerListenerPanel.add(m_lEnddrags);
    innerListenerPanel.add(m_lEndresizes);
    innerListenerPanel.add(m_lIconifies);
    innerListenerPanel.add(m_lMaximizes);
    innerListenerPanel.add(m_lMinimizes);
    innerListenerPanel.add(m_lOpens);
    innerListenerPanel.add(m_lResizes);
    innerListenerPanel.add(m_lSetbounds);

    listenerPanel.add("Center", m_dmEventCanvas);
    listenerPanel.add("West", innerListenerPanel);
    listenerPanel.setOpaque(true);
    listenerPanel.setBackground(Color.white);

    m_myDesktopManager = new MyDesktopManager();
    m_desktop = new JDesktopPane();
    m_desktop.setDesktopManager(m_myDesktopManager);
    m_desktop.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
    m_newFrame = new JButton("New Frame");
    m_newFrame.addActionListener(this);
    m_infos = UIManager.getInstalledLookAndFeels();
    String[] LAFNames = new String[m_infos.length];
    for (int i = 0; i < m_infos.length; i++) {
        LAFNames[i] = m_infos[i].getName();
    }
    m_UIBox = new JComboBox(LAFNames);
    m_UIBox.addActionListener(this);
    JPanel topPanel = new JPanel(true);
    topPanel.setLayout(new FlowLayout());
    topPanel.setBorder(new CompoundBorder(new SoftBevelBorder(BevelBorder.LOWERED),
            new CompoundBorder(new EmptyBorder(2, 2, 2, 2), new SoftBevelBorder(BevelBorder.RAISED))));
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add("North", topPanel);
    getContentPane().add("Center", m_desktop);
    getContentPane().add("South", listenerPanel);
    ((JPanel) getContentPane()).setBorder(new CompoundBorder(new SoftBevelBorder(BevelBorder.LOWERED),
            new CompoundBorder(new EmptyBorder(1, 1, 1, 1), new SoftBevelBorder(BevelBorder.RAISED))));
    topPanel.add(m_newFrame);
    topPanel.add(new JLabel("Look & Feel:", SwingConstants.RIGHT));
    topPanel.add(m_UIBox);
    setSize(645, 600);
    Dimension dim = getToolkit().getScreenSize();
    setLocation(dim.width / 2 - getWidth() / 2, dim.height / 2 - getHeight() / 2);
    setVisible(true);
    WindowListener l = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(l);
    m_eventTimer = new Timer(1000, this);
    m_eventTimer.setRepeats(true);
    m_eventTimer.start();
}