Example usage for javax.swing SwingConstants LEFT

List of usage examples for javax.swing SwingConstants LEFT

Introduction

In this page you can find the example usage for javax.swing SwingConstants LEFT.

Prototype

int LEFT

To view the source code for javax.swing SwingConstants LEFT.

Click Source Link

Document

Box-orientation constant used to specify the left side of a box.

Usage

From source file:gda.plots.SimplePlot.java

/**
 * Creates the JPopupMenu, overrides (but uses) the super class method adding items for the Magnification and
 * Logarithmic axes.// w  w w  .  java2s  .  co m
 * 
 * @param properties
 *            boolean if true appears on menu
 * @param save
 *            boolean if true appears on menu
 * @param print
 *            boolean if true appears on menu
 * @param zoom
 *            boolean if true appears on menu
 * @return the popup menu
 */
@Override
protected JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) {
    // Create the popup without the zooming parts
    JPopupMenu jpm = super.createPopupMenu(properties, false, print, false);

    // as the save function on the chartpanel doesn't remember its location,
    // we shall remove it and and create a new save option
    if (save) {
        jpm.add(new JSeparator());

        // The save button

        saveButton = new JMenuItem("Save As");
        saveButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                saveAs();
            }
        });

        jpm.add(saveButton);
    }

    jpm.add(new JSeparator());

    // This button toggles the data-type magnification
    magnifyDataButton = new JCheckBoxMenuItem("Magnify(Data)");
    magnifyDataButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setMagnifyingData(!isMagnifyingData());
        }
    });
    jpm.add(magnifyDataButton);

    jpm.add(new JSeparator());

    // The zoomButton toggles the value of zooming.
    zoomButton = new JCheckBoxMenuItem("Zoom");
    zoomButton.setHorizontalTextPosition(SwingConstants.LEFT);
    zoomButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setZooming(!isZooming());
        }
    });
    jpm.add(zoomButton);

    // The unZoomButton is not a toggle, it undoes the last zoom.
    unZoomButton = new JMenuItem("UnZoom");
    unZoomButton.setEnabled(false);
    unZoomButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            unZoom();
        }
    });
    jpm.add(unZoomButton);

    if (type == LINECHART) {
        jpm.add(new JSeparator());

        turboModeButton = new JCheckBoxMenuItem("Turbo Mode");
        turboModeButton.setHorizontalTextPosition(SwingConstants.LEFT);
        turboModeButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                setTurboMode(!isTurboMode());
            }
        });
        turboModeButton.setSelected(isTurboMode());
        jpm.add(turboModeButton);

        stripModeButton = new JCheckBoxMenuItem("StripChart Mode");
        stripModeButton.setHorizontalTextPosition(SwingConstants.LEFT);
        stripModeButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String widthStr = "";
                {
                    double width = lastDomainBoundsLeft != null ? lastDomainBoundsLeft.getLength()
                            : Double.MAX_VALUE;
                    widthStr = getXAxisNumberFormat().format(width);
                    widthStr = JOptionPane.showInputDialog(null,
                            "Enter the x strip width - clear for autorange", widthStr);
                    if (widthStr == null) //cancel
                        return;
                }
                Double newStripWidth = null;
                if (!widthStr.isEmpty()) {
                    try {
                        newStripWidth = Double.valueOf(widthStr);
                    } catch (Exception ex) {
                        logger.error(ex.getMessage(), ex);
                    }
                }
                setStripWidth(newStripWidth);
            }
        });
        stripModeButton.setSelected(isStripMode());
        jpm.add(stripModeButton);

        xLimitsButton = new JCheckBoxMenuItem("Fix X Axis Limits");
        xLimitsButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String minStr = "";
                {
                    double min = lastDomainBoundsLeft != null ? lastDomainBoundsLeft.getLowerBound()
                            : Double.MAX_VALUE;
                    minStr = getXAxisNumberFormat().format(min);
                    minStr = JOptionPane.showInputDialog(null, "Enter the min x value - clear for autorange",
                            minStr);
                    if (minStr == null) //cancel
                        return;

                }
                String maxStr = "";
                if (!minStr.isEmpty()) {
                    double max = lastDomainBoundsLeft != null ? lastDomainBoundsLeft.getUpperBound()
                            : -Double.MAX_VALUE;
                    maxStr = getXAxisNumberFormat().format(max);
                    maxStr = JOptionPane.showInputDialog(null, "Enter the max x value - clear for autorange",
                            maxStr);
                    if (maxStr == null) //cancel
                        return;
                }
                Range newBounds = null;
                if (!maxStr.isEmpty() && !minStr.isEmpty()) {
                    try {
                        newBounds = new Range(Double.valueOf(minStr), Double.valueOf(maxStr));
                    } catch (Exception ex) {
                        logger.error(ex.getMessage(), ex);
                    }
                }
                setDomainBounds(newBounds);
            }
        });
        xLimitsButton.setSelected(false);
        jpm.add(xLimitsButton);

    }

    jpm.add(new JSeparator());

    xLogLinButton = new JMenuItem("Logarithmic X axis");
    xLogLinButton.setEnabled(true);
    xLogLinButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setXAxisLogarithmic(!isXAxisLogarithmic());
        }
    });
    jpm.add(xLogLinButton);

    yLogLinButton = new JMenuItem("Logarithmic Y axis");
    yLogLinButton.setEnabled(true);
    yLogLinButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setYAxisLogarithmic(!isYAxisLogarithmic());
        }
    });
    jpm.add(yLogLinButton);

    y2LogLinButton = new JMenuItem("Logarithmic Y2 axis");
    y2LogLinButton.setEnabled(false);
    y2LogLinButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setYAxisTwoLogarithmic(!isYAxisTwoLogarithmic());
        }
    });

    jpm.add(y2LogLinButton);

    jpm.add(new JSeparator());

    // Adding a new button to allow the user to select the formatting they
    // want on the x and y axis
    xFormatButton = new JMenuItem("X Axis Format");
    xFormatButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String Format = getXAxisNumberFormat().format(0.0);
            String input = JOptionPane.showInputDialog(null,
                    "Enter the new formatting for the X axis, of the form 0.0000E00", Format);
            // try forcing this into some objects
            try {
                setScientificXAxis(new DecimalFormat(input));
            } catch (Exception err) {
                logger.error("Could not use this format due to {}", e);
            }
        }
    });
    jpm.add(xFormatButton);

    // Adding a new button to allow the user to select the formatting they
    // want on the x and y axis
    yFormatButton = new JMenuItem("Y Axis Format");
    yFormatButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String Format = getYAxisNumberFormat().format(0.0);
            String input = JOptionPane.showInputDialog(null,
                    "Enter the new formatting for the Y axis, of the form 0.0000E00", Format);
            // try forcing this into some objects
            try {
                setScientificYAxis(new DecimalFormat(input));
            } catch (Exception err) {
                logger.error("Could not use this format due to {}", e);
            }
        }
    });
    jpm.add(yFormatButton);

    // The zoomButton toggles the value of zooming.
    xAxisVerticalTicksButton = new JCheckBoxMenuItem("Vertical X Ticks");
    xAxisVerticalTicksButton.setHorizontalTextPosition(SwingConstants.LEFT);
    xAxisVerticalTicksButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setVerticalXAxisTicks(xAxisVerticalTicksButton.isSelected());
        }
    });
    jpm.add(xAxisVerticalTicksButton);

    return jpm;
}

From source file:com.rapidminer.gui.viewer.metadata.AttributeStatisticsPanel.java

/**
 * Updates the charts./*from w ww  .ja  v  a 2  s  .  co m*/
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private void updateCharts() {
    for (int i = 0; i < listOfChartPanels.size(); i++) {
        JPanel panel = listOfChartPanels.get(i);
        panel.removeAll();
        final ChartPanel chartPanel = new ChartPanel(getModel().getChartOrNull(i)) {

            private static final long serialVersionUID = -6953213567063104487L;

            @Override
            public Dimension getPreferredSize() {
                return DIMENSION_CHART_PANEL_ENLARGED;
            }
        };
        chartPanel.setPopupMenu(null);
        chartPanel.setBackground(COLOR_TRANSPARENT);
        chartPanel.setOpaque(false);
        chartPanel.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
        panel.add(chartPanel, BorderLayout.CENTER);

        JPanel openChartPanel = new JPanel(new GridBagLayout());
        openChartPanel.setOpaque(false);

        GridBagConstraints gbc = new GridBagConstraints();
        gbc.anchor = GridBagConstraints.CENTER;
        gbc.fill = GridBagConstraints.NONE;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;

        JButton openChartButton = new JButton(OPEN_CHART_ACTION);
        openChartButton.setOpaque(false);
        openChartButton.setContentAreaFilled(false);
        openChartButton.setBorderPainted(false);
        openChartButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
        openChartButton.setHorizontalAlignment(SwingConstants.LEFT);
        openChartButton.setHorizontalTextPosition(SwingConstants.LEFT);
        openChartButton.setIcon(null);
        Font font = openChartButton.getFont();
        Map attributes = font.getAttributes();
        attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
        openChartButton.setFont(font.deriveFont(attributes).deriveFont(10.0f));

        openChartPanel.add(openChartButton, gbc);

        panel.add(openChartPanel, BorderLayout.SOUTH);
        panel.revalidate();
        panel.repaint();
    }
}

From source file:edu.harvard.i2b2.query.ui.QueryConceptTreePanel.java

/** This method is called from within the constructor to
 * initialize the form./*www . j  a  v a 2 s.  co  m*/
 */
private void initComponents() {
    jScrollPane1 = new javax.swing.JScrollPane();
    jClearButton = new javax.swing.JButton();
    jConstrainButton = new javax.swing.JButton();
    jExcludeButton = new javax.swing.JButton();
    jOccurrenceButton = new javax.swing.JButton();
    jNameLabel = new javax.swing.JLabel();
    jHintLabel = new javax.swing.JLabel();

    setLayout(null);

    QueryConceptTreeNodeData tmpData = new QueryConceptTreeNodeData();
    tmpData.name("working ......");
    tmpData.tooltip("A root node");
    tmpData.visualAttribute("FAO");
    top = new DefaultMutableTreeNode(tmpData);
    //top = new DefaultMutableTreeNode("Root Node");
    treeModel = new DefaultTreeModel(top);
    //treeModel.addTreeModelListener(new MyTreeModelListener());

    jTree1 = new JTree(treeModel);

    jTree1.setDragEnabled(true);
    jTree1.setEditable(true);
    //jTree1.getSelectionModel().setSelectionMode
    //        (TreeSelectionModel.SINGLE_TREE_SELECTION);
    //jTree1.setShowsRootHandles(true);
    //JScrollPane treeView = new JScrollPane(jTree1);
    jTree1.setRootVisible(false);
    jTree1.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    jTree1.setCellRenderer(new MyRenderer());
    ToolTipManager.sharedInstance().registerComponent(jTree1);

    setBorder(javax.swing.BorderFactory.createEtchedBorder());
    add(jScrollPane1);
    //jScrollPane1.setBounds(0, 40, 180, 200);

    jClearButton.setFont(new java.awt.Font("Tahoma", 1, 10));
    jClearButton.setText("X");
    jClearButton.setToolTipText("Clear all items from panel");
    jClearButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    jClearButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
    jClearButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
    if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
        jClearButton.setMargin(new java.awt.Insets(-10, -15, -10, -20));
    }
    jClearButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jClearButtonActionPerformed(evt);
        }
    });

    add(jClearButton);
    jClearButton.setBounds(160, 0, 18, 20);

    jConstrainButton.setText("Dates");
    jConstrainButton.setToolTipText("Constrain group by dates");
    jConstrainButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
    jConstrainButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
    //jConstrainButton.setMargin(new java.awt.Insets(-10, -15, -10,-20));
    if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
        jConstrainButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        //jConstrainButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
        jConstrainButton.setMargin(new java.awt.Insets(-10, -15, -10, -20));
    }

    jConstrainButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jConstrainButtonActionPerformed(evt);
        }
    });

    add(jConstrainButton);
    jConstrainButton.setBounds(0, 20, 40, 21);

    jOccurrenceButton.setText("Occurs > 0x");
    jOccurrenceButton.setToolTipText("Set occurrence times");
    jOccurrenceButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jOccurrenceButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jOccurrenceButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
    if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
        jOccurrenceButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jOccurrenceButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jOccurrenceButton.setMargin(new java.awt.Insets(-10, -10, -10, -10));
    }
    jOccurrenceButton.setIconTextGap(0);
    jOccurrenceButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jOccurrenceButtonActionPerformed(evt);
        }
    });
    jOccurrenceButton.setBounds(40, 20, 90, 21);
    add(jOccurrenceButton);

    //jExcludeButton.setMnemonic('E');
    jExcludeButton.setText("Exclude");
    jExcludeButton.setToolTipText("Exclude all items in group");
    jExcludeButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jExcludeButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jExcludeButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
    if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
        jExcludeButton.setMargin(new java.awt.Insets(-10, -15, -10, -20));
        jExcludeButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    }
    jExcludeButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jExcludeButtonActionPerformed(evt);
        }
    });
    add(jExcludeButton);
    jExcludeButton.setBounds(130, 20, 48, 21);

    jNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jNameLabel.setText("Group 1");
    jNameLabel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jNameLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    add(jNameLabel);
    jNameLabel.setBounds(0, 0, 160, 20);
    jNameLabel.setTransferHandler(new GroupLabelTextHandler());
    jNameLabel.addMouseListener(new DragMouseAdapter());
    jNameLabel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
        public void mouseMoved(java.awt.event.MouseEvent evt) {
            jNameLabelMouseMoved(evt);
            //System.out.println("mouse x: "+evt.getX()+" y: "+evt.getY());
            //System.out.println("name label x: "+jNameLabel.getX()+" width: "+
            //   jNameLabel.getWidth()+" y: "            
            //   +jNameLabel.getY()+" height "+jNameLabel.getHeight());
        }

    });
    jNameLabel.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseExited(java.awt.event.MouseEvent evt) {
            jNameLabelMouseExited(evt);
        }

    });

    jTree1.addTreeExpansionListener(this);
    jTree1.setTransferHandler(new TextHandler());
    add(jScrollPane1);
    jScrollPane1.setViewportView(jTree1);
    //jTree1.setToolTipText("Double click on a folder to view the items inside");
    //jScrollPane1.getViewport().setToolTipText("Double click on a folder to view the items inside");
    jScrollPane1.setBounds(0, 40, 180, 120);
    //jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    //jTree1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
    //   public void mouseMoved(java.awt.event.MouseEvent evt) {
    //       jScrollPane1MouseMoved(evt);
    //   }

    //@Override
    //public void mouseDragged(MouseEvent e) {
    //    jScrollPane1MouseMoved(e);
    //}

    //});
    //jTree1.addMouseListener(new java.awt.event.MouseAdapter() {
    //   public void mouseExited(java.awt.event.MouseEvent evt) {
    //       jScrollPane1MouseExited(evt);
    //   }

    //@Override
    //public void mouseEntered(MouseEvent e) {

    //    jScrollPane1MouseEntered(e);
    //}

    //});

    jHintLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jHintLabel.setText(
            "<html><center>Drag terms from Navigate, <br>" + "<left>Find and Workplace into this group");
    //jHintLabel.getFont();
    jHintLabel.setFont(new Font("SansSerif", Font.PLAIN, 9));
    //jHintLabel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    jHintLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jHintLabel.setVerticalAlignment(javax.swing.SwingConstants.CENTER);
    //jHintLabel.setBackground(Color.WHITE);
    //jHintLabel.setForeground(Color.WHITE);
    add(jHintLabel);
    jHintLabel.setBounds(0, 120, 180, 30);
}

From source file:erigo.ctstream.CTstream.java

/**
 * Pop up the GUI/*from  www . j a  v a  2 s.c  om*/
 * 
 * This method should be run in the event-dispatching thread.
 * 
 * The GUI is created in one of two modes depending on whether Shaped
 * windows are supported on the platform:
 * 
 * 1. If Shaped windows are supported then guiPanel (the container to
 *    which all other components are added) is RED and capturePanel is
 *    inset a small amount to this panel so that the RED border is seen
 *    around the outer edge.  A componentResized() method is defined
 *    which creates the hollowed out region that was capturePanel.
 * 2. If Shaped windows are not supported then guiPanel is transparent
 *    and capturePanel is translucent.  In this case, the user can't
 *    "reach through" capturePanel to interact with GUIs on the other
 *    side.
 * 
 * @param  bShapedWindowSupportedI  Does the underlying GraphicsDevice support the
 *                            PERPIXEL_TRANSPARENT translucency that is
 *                            required for Shaped windows?
 */
private void createAndShowGUI(boolean bShapedWindowSupportedI) {

    // No window decorations for translucent/transparent windows
    // (see note below)
    // JFrame.setDefaultLookAndFeelDecorated(true);

    //
    // Create GUI components
    //
    GridBagLayout framegbl = new GridBagLayout();
    guiFrame = new JFrame("CTstream");
    // To support a translucent window, the window must be undecorated
    // See notes in the class header up above about this; also see
    // http://alvinalexander.com/source-code/java/how-create-transparenttranslucent-java-jframe-mac-os-x
    guiFrame.setUndecorated(true);
    // Use MouseMotionListener to implement our own simple "window manager" for moving and resizing the window
    guiFrame.addMouseMotionListener(this);
    guiFrame.setBackground(new Color(0, 0, 0, 0));
    guiFrame.getContentPane().setBackground(new Color(0, 0, 0, 0));
    GridBagLayout gbl = new GridBagLayout();
    guiPanel = new JPanel(gbl);
    // if Shaped windows are supported, make guiPanel red;
    // otherwise make it transparent
    if (bShapedWindowSupportedI) {
        guiPanel.setBackground(Color.RED);
    } else {
        guiPanel.setBackground(new Color(0, 0, 0, 0));
    }
    guiFrame.setFont(new Font("Dialog", Font.PLAIN, 12));
    guiPanel.setFont(new Font("Dialog", Font.PLAIN, 12));
    GridBagLayout controlsgbl = new GridBagLayout();
    // *** controlsPanel contains the UI controls at the top of guiFrame
    controlsPanel = new JPanel(controlsgbl);
    controlsPanel.setBackground(new Color(211, 211, 211, 255));
    startStopButton = new JButton("Start");
    startStopButton.addActionListener(this);
    startStopButton.setBackground(Color.GREEN);
    continueButton = new JButton("Continue");
    continueButton.addActionListener(this);
    continueButton.setEnabled(false);
    screencapCheck = new JCheckBox("screen", bScreencap);
    screencapCheck.setBackground(controlsPanel.getBackground());
    screencapCheck.addActionListener(this);
    webcamCheck = new JCheckBox("camera", bWebcam);
    webcamCheck.setBackground(controlsPanel.getBackground());
    webcamCheck.addActionListener(this);
    audioCheck = new JCheckBox("audio", bAudio);
    audioCheck.setBackground(controlsPanel.getBackground());
    audioCheck.addActionListener(this);
    textCheck = new JCheckBox("text", bText);
    textCheck.setBackground(controlsPanel.getBackground());
    textCheck.addActionListener(this);
    JLabel fpsLabel = new JLabel("images/sec", SwingConstants.LEFT);
    fpsCB = new JComboBox<Double>(FPS_VALUES);
    int tempIndex = Arrays.asList(FPS_VALUES).indexOf(new Double(framesPerSec));
    fpsCB.setSelectedIndex(tempIndex);
    fpsCB.addActionListener(this);
    // The popup doesn't display over the transparent region;
    // therefore, just display a few rows to keep it within controlsPanel
    fpsCB.setMaximumRowCount(3);
    JLabel imgQualLabel = new JLabel("image qual", SwingConstants.LEFT);
    // The slider will use range 0 - 1000
    imgQualSlider = new JSlider(JSlider.HORIZONTAL, 0, 1000, (int) (imageQuality * 1000.0));
    // NOTE: The JSlider's initial width was too large, so I'd like to set its preferred size
    //       to try and constrain it some; also need to set its minimum size at the same time,
    //       or else when the user makes the GUI frame smaller, the JSlider would pop down to
    //       a really small minimum size.
    imgQualSlider.setPreferredSize(new Dimension(120, 30));
    imgQualSlider.setMinimumSize(new Dimension(120, 30));
    imgQualSlider.setBackground(controlsPanel.getBackground());
    includeMouseCursorCheck = new JCheckBox("Include mouse cursor in screen capture", bIncludeMouseCursor);
    includeMouseCursorCheck.setBackground(controlsPanel.getBackground());
    includeMouseCursorCheck.addActionListener(this);
    changeDetectCheck = new JCheckBox("Change detect", bChangeDetect);
    changeDetectCheck.setBackground(controlsPanel.getBackground());
    changeDetectCheck.addActionListener(this);
    fullScreenCheck = new JCheckBox("Full Screen", bFullScreen);
    fullScreenCheck.setBackground(controlsPanel.getBackground());
    fullScreenCheck.addActionListener(this);
    previewCheck = new JCheckBox("Preview", bPreview);
    previewCheck.setBackground(controlsPanel.getBackground());
    previewCheck.addActionListener(this);
    // Specify a small size for the text area, so that we can shrink down the UI w/o the scrollbars popping up
    textArea = new JTextArea(3, 10);
    // Add a Document listener to the JTextArea; this is how we will listen for changes to the document
    docChangeListener = new DocumentChangeListener(this);
    textArea.getDocument().addDocumentListener(docChangeListener);
    textScrollPane = new JScrollPane(textArea);
    // *** capturePanel
    capturePanel = new JPanel();
    if (!bShapedWindowSupportedI) {
        // Only make capturePanel translucent (ie, semi-transparent) if we aren't doing the Shaped window option
        capturePanel.setBackground(new Color(0, 0, 0, 16));
    } else {
        capturePanel.setBackground(new Color(0, 0, 0, 0));
    }
    capturePanel.setPreferredSize(new Dimension(500, 400));
    boolean bMacOS = false;
    String OS = System.getProperty("os.name", "generic").toLowerCase();
    if ((OS.indexOf("mac") >= 0) || (OS.indexOf("darwin") >= 0)) {
        bMacOS = true;
    }
    // Only have the CTstream UI stay on top of all other windows
    // if bStayOnTop is true (set by command line flag).  This is needed
    // for the Mac, because on that platform the user can't "reach through"
    // the capture frame to windows behind it.
    if (bStayOnTop) {
        guiFrame.setAlwaysOnTop(true);
    }

    //
    // Add components to the GUI
    //

    int row = 0;

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0;
    gbc.weighty = 0;

    //
    // First row: the controls panel
    //
    //  Add some extra horizontal padding around controlsPanel so the panel has some extra room
    // if we are running in web camera mode.
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 100;
    gbc.weighty = 0;
    Utility.add(guiPanel, controlsPanel, gbl, gbc, 0, row, 1, 1);
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0;
    gbc.weighty = 0;
    ++row;

    // Add controls to the controls panel
    int panelrow = 0;
    // (i) Start/Continue buttons
    GridBagLayout panelgbl = new GridBagLayout();
    JPanel subPanel = new JPanel(panelgbl);
    GridBagConstraints panelgbc = new GridBagConstraints();
    panelgbc.anchor = GridBagConstraints.WEST;
    panelgbc.fill = GridBagConstraints.NONE;
    panelgbc.weightx = 0;
    panelgbc.weighty = 0;
    subPanel.setBackground(controlsPanel.getBackground());
    panelgbc.insets = new Insets(0, 0, 0, 5);
    Utility.add(subPanel, startStopButton, panelgbl, panelgbc, 0, 0, 1, 1);
    panelgbc.insets = new Insets(0, 0, 0, 0);
    Utility.add(subPanel, continueButton, panelgbl, panelgbc, 1, 0, 1, 1);
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets = new Insets(5, 0, 0, 0);
    Utility.add(controlsPanel, subPanel, controlsgbl, gbc, 0, panelrow, 1, 1);
    ++panelrow;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;
    // (ii) select DataStreams to turn on
    panelgbl = new GridBagLayout();
    subPanel = new JPanel(panelgbl);
    panelgbc = new GridBagConstraints();
    panelgbc.anchor = GridBagConstraints.WEST;
    panelgbc.fill = GridBagConstraints.NONE;
    panelgbc.weightx = 0;
    panelgbc.weighty = 0;
    subPanel.setBackground(controlsPanel.getBackground());
    panelgbc.insets = new Insets(0, 0, 0, 0);
    Utility.add(subPanel, screencapCheck, panelgbl, panelgbc, 0, 0, 1, 1);
    Utility.add(subPanel, webcamCheck, panelgbl, panelgbc, 1, 0, 1, 1);
    Utility.add(subPanel, audioCheck, panelgbl, panelgbc, 2, 0, 1, 1);
    Utility.add(subPanel, textCheck, panelgbl, panelgbc, 3, 0, 1, 1);
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets = new Insets(0, 0, 0, 0);
    Utility.add(controlsPanel, subPanel, controlsgbl, gbc, 0, panelrow, 1, 1);
    ++panelrow;
    // (iii) images/sec control
    panelgbl = new GridBagLayout();
    subPanel = new JPanel(panelgbl);
    panelgbc = new GridBagConstraints();
    panelgbc.anchor = GridBagConstraints.WEST;
    panelgbc.fill = GridBagConstraints.NONE;
    panelgbc.weightx = 0;
    panelgbc.weighty = 0;
    subPanel.setBackground(controlsPanel.getBackground());
    panelgbc.insets = new Insets(2, 0, 0, 0);
    Utility.add(subPanel, fpsLabel, panelgbl, panelgbc, 0, 0, 1, 1);
    panelgbc.insets = new Insets(2, 10, 0, 10);
    Utility.add(subPanel, fpsCB, panelgbl, panelgbc, 1, 0, 1, 1);
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.anchor = GridBagConstraints.CENTER;
    Utility.add(controlsPanel, subPanel, controlsgbl, gbc, 0, panelrow, 1, 1);
    ++panelrow;
    // (iv) image quality slider
    panelgbl = new GridBagLayout();
    subPanel = new JPanel(panelgbl);
    panelgbc = new GridBagConstraints();
    panelgbc.anchor = GridBagConstraints.WEST;
    panelgbc.fill = GridBagConstraints.NONE;
    panelgbc.weightx = 0;
    panelgbc.weighty = 0;
    subPanel.setBackground(controlsPanel.getBackground());
    JLabel sliderLabelLow = new JLabel("Low", SwingConstants.LEFT);
    JLabel sliderLabelHigh = new JLabel("High", SwingConstants.LEFT);
    panelgbc.insets = new Insets(-5, 0, 0, 0);
    Utility.add(subPanel, imgQualLabel, panelgbl, panelgbc, 0, 0, 1, 1);
    panelgbc.insets = new Insets(-5, 5, 0, 5);
    Utility.add(subPanel, sliderLabelLow, panelgbl, panelgbc, 1, 0, 1, 1);
    panelgbc.insets = new Insets(0, 0, 0, 0);
    Utility.add(subPanel, imgQualSlider, panelgbl, panelgbc, 2, 0, 1, 1);
    panelgbc.insets = new Insets(-5, 5, 0, 0);
    Utility.add(subPanel, sliderLabelHigh, panelgbl, panelgbc, 3, 0, 1, 1);
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.anchor = GridBagConstraints.CENTER;
    Utility.add(controlsPanel, subPanel, controlsgbl, gbc, 0, panelrow, 1, 1);
    ++panelrow;
    // (v) Include mouse cursor in screen capture image?
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.insets = new Insets(0, 15, 5, 15);
    Utility.add(controlsPanel, includeMouseCursorCheck, controlsgbl, gbc, 0, panelrow, 1, 1);
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0;
    gbc.weighty = 0;
    ++panelrow;
    // (vi) Change detect / Full screen / Preview checkboxes
    panelgbl = new GridBagLayout();
    subPanel = new JPanel(panelgbl);
    panelgbc = new GridBagConstraints();
    panelgbc.anchor = GridBagConstraints.WEST;
    panelgbc.fill = GridBagConstraints.NONE;
    panelgbc.weightx = 0;
    panelgbc.weighty = 0;
    subPanel.setBackground(controlsPanel.getBackground());
    panelgbc.insets = new Insets(0, 0, 0, 0);
    Utility.add(subPanel, changeDetectCheck, panelgbl, panelgbc, 0, 0, 1, 1);
    Utility.add(subPanel, fullScreenCheck, panelgbl, panelgbc, 1, 0, 1, 1);
    Utility.add(subPanel, previewCheck, panelgbl, panelgbc, 2, 0, 1, 1);
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets = new Insets(-5, 0, 3, 0);
    Utility.add(controlsPanel, subPanel, controlsgbl, gbc, 0, panelrow, 1, 1);
    ++panelrow;
    // (vii) text field for the TextStream
    /*
    panelgbl = new GridBagLayout();
    subPanel = new JPanel(panelgbl);
    panelgbc = new GridBagConstraints();
    panelgbc.anchor = GridBagConstraints.CENTER;
    panelgbc.fill = GridBagConstraints.HORIZONTAL;
    panelgbc.weightx = 100;
    panelgbc.weighty = 100;
    subPanel.setBackground(controlsPanel.getBackground());
    panelgbc.insets = new Insets(0, 0, 0, 0);
    Utility.add(subPanel, textScrollPane, panelgbl, panelgbc, 1, 0, 1, 1);
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 100;
    gbc.weighty = 100;
    gbc.insets = new Insets(0, 15, 3, 15);
    Utility.add(controlsPanel, subPanel, controlsgbl, gbc, 0, panelrow, 2, 1);
    ++panelrow;
    */
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 100;
    gbc.weighty = 0;
    gbc.insets = new Insets(0, 15, 5, 15);
    Utility.add(controlsPanel, textScrollPane, controlsgbl, gbc, 0, panelrow, 1, 1);
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0;
    gbc.weighty = 0;
    ++panelrow;

    //
    // Second row: the translucent/transparent capture panel
    //
    if (bShapedWindowSupportedI) {
        // Doing the Shaped window; set capturePanel inside guiPanel
        // a bit so the red from guiPanel shows at the edges
        gbc.insets = new Insets(5, 5, 5, 5);
    } else {
        // No shaped window; have capturePanel fill the area
        gbc.insets = new Insets(0, 0, 0, 0);
    }
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 100;
    gbc.weighty = 100;
    Utility.add(guiPanel, capturePanel, gbl, gbc, 0, row, 1, 1);
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0;
    gbc.weighty = 0;
    ++row;

    //
    // Add guiPanel to guiFrame
    //
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 100;
    gbc.weighty = 100;
    gbc.insets = new Insets(0, 0, 0, 0);
    Utility.add(guiFrame, guiPanel, framegbl, gbc, 0, 0, 1, 1);

    //
    // Add menu
    //
    JMenuBar menuBar = createMenu();
    guiFrame.setJMenuBar(menuBar);

    //
    // If Shaped windows are supported, the region defined by capturePanel
    // will be "hollowed out" so that the user can reach through guiFrame
    // and interact with applications which are behind it.
    //
    // NOTE: This doesn't work on Mac OS (we've tried, but nothing seems
    //       to work to allow a user to reach through guiFrame to interact
    //       with windows behind).  May be a limitation or bug on Mac OS:
    //       https://bugs.openjdk.java.net/browse/JDK-8013450
    //
    if (bShapedWindowSupportedI) {
        guiFrame.addComponentListener(new ComponentAdapter() {
            // As the window is resized, the shape is recalculated here.
            @Override
            public void componentResized(ComponentEvent e) {
                // Create a rectangle to cover the entire guiFrame
                Area guiShape = new Area(new Rectangle(0, 0, guiFrame.getWidth(), guiFrame.getHeight()));
                // Create another rectangle to define the hollowed out region of capturePanel
                guiShape.subtract(new Area(new Rectangle(capturePanel.getX(), capturePanel.getY() + 23,
                        capturePanel.getWidth(), capturePanel.getHeight())));
                guiFrame.setShape(guiShape);
            }
        });
    }

    //
    // Final guiFrame configuration details and displaying the GUI
    //
    guiFrame.pack();

    guiFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    guiFrame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            exit(false);
        }
    });

    // Center on the screen
    guiFrame.setLocationRelativeTo(null);

    //
    // Set the taskbar/dock icon; note that Mac OS has its own way of doing it
    //
    if (bMacOS) {
        try {
            // JPW 2018/02/02: changed how to load images to work under Java 9
            InputStream imageInputStreamLarge = getClass().getClassLoader()
                    .getResourceAsStream("Icon_128x128.png");
            BufferedImage bufferedImageLarge = ImageIO.read(imageInputStreamLarge);
            /**
             *
             * Java 9 note: running the following code under Java 9 on a Mac will produce the following warning:
             *
             * WARNING: An illegal reflective access operation has occurred
             * WARNING: Illegal reflective access by erigo.ctstream.CTstream (file:/Users/johnwilson/CT_versions/compiled_under_V8/CTstream.jar) to method com.apple.eawt.Application.getApplication()
             * WARNING: Please consider reporting this to the maintainers of erigo.ctstream.CTstream
             * WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
             * WARNING: All illegal access operations will be denied in a future release
             *
             * This is because Java 9 has taken a step away from using reflection; see see the section titled
             * "Illegal Access To Internal APIs" at https://blog.codefx.org/java/java-9-migration-guide/.
             *
             * A good fix (but only available in Java 9+) is to use the following:
             *
             *     java.awt.Taskbar taskbar = java.awt.Taskbar.getTaskbar();
             *     taskbar.setIconImage(bufferedImageLarge);
             *
             * Could use reflection to make calls in class com.apple.eawt.Application; for example, see
             * Bertil Chapuis' "dockicon.java" example code at https://gist.github.com/bchapuis/1562406
             *
             * For now, we just won't do dock icons under Mac OS.
             *
             **/
        } catch (Exception excepI) {
            System.err.println("Exception thrown trying to set icon: " + excepI);
        }
    } else {
        // The following has been tested under Windows 10 and Ubuntu 12.04 LTS
        try {
            // JPW 2018/02/02: changed how to load images to work under Java 9
            InputStream imageInputStreamLarge = getClass().getClassLoader()
                    .getResourceAsStream("Icon_128x128.png");
            BufferedImage bufferedImageLarge = ImageIO.read(imageInputStreamLarge);
            InputStream imageInputStreamMed = getClass().getClassLoader().getResourceAsStream("Icon_64x64.png");
            BufferedImage bufferedImageMed = ImageIO.read(imageInputStreamMed);
            InputStream imageInputStreamSmall = getClass().getClassLoader()
                    .getResourceAsStream("Icon_32x32.png");
            BufferedImage bufferedImageSmall = ImageIO.read(imageInputStreamSmall);
            List<BufferedImage> iconList = new ArrayList<BufferedImage>();
            iconList.add(bufferedImageLarge);
            iconList.add(bufferedImageMed);
            iconList.add(bufferedImageSmall);
            guiFrame.setIconImages(iconList);
        } catch (Exception excepI) {
            System.err.println("Exception thrown trying to set icon: " + excepI);
        }
    }

    ctSettings = new CTsettings(this, guiFrame);

    guiFrame.setVisible(true);

}

From source file:edu.ku.brc.af.ui.forms.ViewFactory.java

protected boolean createItem(final DBTableInfo parentTableInfo, final DBTableChildIFace childInfo,
        final MultiView parent, final ViewDefIFace viewDef, final FormValidator validator,
        final ViewBuilderIFace viewBldObj, final AltViewIFace.CreationMode mode,
        final HashMap<String, JLabel> labelsForHash, final Object currDataObj, final FormCellIFace cell,
        final boolean isEditOnCreateOnly, final int rowInx, final BuildInfoStruct bi) {
    bi.compToAdd = null;/*from w  ww .ja v a 2s.  com*/
    bi.compToReg = null;
    bi.doAddToValidator = true;
    bi.doRegControl = true;

    DBRelationshipInfo relInfo = childInfo instanceof DBRelationshipInfo ? (DBRelationshipInfo) childInfo
            : null;

    if (isEditOnCreateOnly) {
        EditViewCompSwitcherPanel evcsp = new EditViewCompSwitcherPanel(cell);
        bi.compToAdd = evcsp;
        bi.compToReg = evcsp;

        if (validator != null) {
            //DataChangeNotifier dcn = validator.createDataChangeNotifer(cell.getIdent(), evcsp, null);
            DataChangeNotifier dcn = validator.hookupComponent(evcsp, cell.getIdent(), UIValidator.Type.Changed,
                    null, false);
            evcsp.setDataChangeNotifier(dcn);
        }

    } else if (cell.getType() == FormCellIFace.CellType.label) {
        FormCellLabel cellLabel = (FormCellLabel) cell;

        String lblStr = cellLabel.getLabel();
        if (cellLabel.isRecordObj()) {
            JComponent riComp = viewBldObj.createRecordIndentifier(lblStr, cellLabel.getIcon());
            bi.compToAdd = riComp;

        } else {
            String lStr = "  ";
            int align = SwingConstants.RIGHT;
            boolean useColon = StringUtils.isNotEmpty(cellLabel.getLabelFor());

            if (lblStr.equals("##")) {
                //lStr = "  ";
                bi.isDerivedLabel = true;
                cellLabel.setDerived(true);

            } else {
                String alignProp = cellLabel.getProperty("align");
                if (StringUtils.isNotEmpty(alignProp)) {
                    if (alignProp.equals("left")) {
                        align = SwingConstants.LEFT;

                    } else if (alignProp.equals("center")) {
                        align = SwingConstants.CENTER;

                    } else {
                        align = SwingConstants.RIGHT;
                    }
                } else if (useColon) {
                    align = SwingConstants.RIGHT;
                } else {
                    align = SwingConstants.LEFT;
                }

                if (isNotEmpty(lblStr)) {
                    if (useColon) {
                        lStr = lblStr + ":";
                    } else {
                        lStr = lblStr;
                    }
                } else {
                    lStr = "  ";
                }
            }

            if (lStr.indexOf(LF) > -1) {
                lStr = "<html>" + StringUtils.replace(lStr, LF, "<br>") + "</html>";
            }
            JLabel lbl = createLabel(lStr, align);
            String colorStr = cellLabel.getProperty("fg");
            if (StringUtils.isNotEmpty(colorStr)) {
                lbl.setForeground(UIHelper.parseRGB(colorStr));
            }
            labelsForHash.put(cellLabel.getLabelFor(), lbl);
            bi.compToAdd = lbl;
            viewBldObj.addLabel(cellLabel, lbl);
        }

        bi.doAddToValidator = false;
        bi.doRegControl = false;

    } else if (cell.getType() == FormCellIFace.CellType.field) {
        FormCellField cellField = (FormCellField) cell;

        bi.isRequired = bi.isRequired || cellField.isRequired()
                || (childInfo != null && childInfo.isRequired());

        DBFieldInfo fieldInfo = childInfo instanceof DBFieldInfo ? (DBFieldInfo) childInfo : null;
        if (fieldInfo != null && fieldInfo.isHidden()) {
            FormDevHelper.appendLocalizedFormDevError("ViewFactory.FORM_FIELD_HIDDEN", cellField.getIdent(),
                    cellField.getName(), viewDef.getName());
        } else {

            if (fieldInfo != null && fieldInfo.isHidden()) {
                FormDevHelper.appendLocalizedFormDevError("ViewFactory.FORM_REL_HIDDEN", cellField.getIdent(),
                        cellField.getName(), viewDef.getName());
            }
        }

        FormCellField.FieldType uiType = cellField.getUiType();

        // Check to see if there is a PickList and get it if there is
        PickListDBAdapterIFace adapter = null;

        String pickListName = cellField.getPickListName();
        if (childInfo != null && StringUtils.isEmpty(pickListName) && fieldInfo != null) {
            pickListName = fieldInfo.getPickListName();
        }

        if (isNotEmpty(pickListName)) {
            adapter = PickListDBAdapterFactory.getInstance().create(pickListName, false);

            if (adapter == null || adapter.getPickList() == null) {
                FormDevHelper.appendFormDevError("PickList Adapter [" + pickListName + "] cannot be null!");
                return false;
            }
        }

        /*if (uiType == FormCellFieldIFace.FieldType.text)
        {
        String weblink = cellField.getProperty("weblink");
        if (StringUtils.isNotEmpty(weblink))
        {
            String name = cellField.getProperty("name");
            if (StringUtils.isNotEmpty(name) && name.equals("WebLink"))
            {
                uiType
            }
        }
        }*/

        // The Default Display for combox is dsptextfield, except when there is a TableBased PickList
        // At the time we set the display we don't want to go get the picklist to find out. So we do it
        // here after we have the picklist and actually set the change into the cellField
        // because it uses the value to determine whether to convert the value into a text string 
        // before setting it.
        if (mode == AltViewIFace.CreationMode.VIEW) {
            if (uiType == FormCellFieldIFace.FieldType.combobox
                    && cellField.getDspUIType() != FormCellFieldIFace.FieldType.textpl) {
                if (adapter != null)// && adapter.isTabledBased())
                {
                    uiType = FormCellFieldIFace.FieldType.textpl;
                    cellField.setDspUIType(uiType);

                } else {
                    uiType = cellField.getDspUIType();
                }
            } else {
                uiType = cellField.getDspUIType();
            }
        } else if (uiType == FormCellField.FieldType.querycbx) {
            if (AppContextMgr.isSecurityOn()) {
                DBTableInfo tblInfo = childInfo != null
                        ? DBTableIdMgr.getInstance()
                                .getByShortClassName(childInfo.getDataClass().getSimpleName())
                        : null;
                if (tblInfo != null) {
                    PermissionSettings perm = tblInfo.getPermissions();
                    if (perm != null) {
                        //PermissionSettings.dumpPermissions("QCBX: "+tblInfo.getShortClassName(), perm.getOptions());
                        if (perm.isViewOnly() || !perm.canView()) {
                            uiType = FormCellField.FieldType.textfieldinfo;
                        }
                    }
                }
            }
        }

        Class<?> fieldClass = childInfo != null ? childInfo.getDataClass() : null;
        String uiFormatName = cellField.getUIFieldFormatterName();

        if (mode == AltViewIFace.CreationMode.EDIT && uiType == FormCellField.FieldType.text
                && fieldClass != null) {
            if (fieldClass == String.class && fieldInfo != null) {
                // check whether there's a formatter defined for this field in the schema
                if (fieldInfo.getFormatter() != null) {
                    uiFormatName = fieldInfo.getFormatter().getName();
                    uiType = FormCellField.FieldType.formattedtext;
                }
            } else if (fieldClass == Integer.class || fieldClass == Long.class || fieldClass == Short.class
                    || fieldClass == Byte.class || fieldClass == Double.class || fieldClass == Float.class
                    || fieldClass == BigDecimal.class) {
                //log.debug(cellField.getName()+"  is being changed to NUMERIC");
                uiType = FormCellField.FieldType.formattedtext;
                uiFormatName = "Numeric" + fieldClass.getSimpleName();
            }
        }

        // Create the UI Component

        boolean isReq = cellField.isRequired() || (fieldInfo != null && fieldInfo.isRequired())
                || (relInfo != null && relInfo.isRequired());
        cellField.setRequired(isReq);

        switch (uiType) {
        case text:

            bi.compToAdd = createTextField(validator, cellField, fieldInfo, isReq, adapter);
            bi.doAddToValidator = validator == null; // might already added to validator
            break;

        case formattedtext: {
            Class<?> tableClass = null;
            try {
                tableClass = Class.forName(viewDef.getClassName());
            } catch (Exception ex) {
            }

            JComponent tfStart = createFormattedTextField(validator, cellField, tableClass,
                    fieldInfo != null ? fieldInfo.getLength() : 0, uiFormatName,
                    mode == AltViewIFace.CreationMode.VIEW, isReq,
                    cellField.getPropertyAsBoolean("alledit", false));
            bi.compToAdd = tfStart;
            if (cellField.getPropertyAsBoolean("series", false)) {
                JComponent tfEnd = createFormattedTextField(validator, cellField, tableClass,
                        fieldInfo != null ? fieldInfo.getLength() : 0, uiFormatName,
                        mode == AltViewIFace.CreationMode.VIEW, isReq,
                        cellField.getPropertyAsBoolean("alledit", false));

                // Make sure we register it like a plugin not a regular control
                SeriesProcCatNumPlugin plugin = new SeriesProcCatNumPlugin((ValFormattedTextFieldIFace) tfStart,
                        (ValFormattedTextFieldIFace) tfEnd);
                bi.compToAdd = plugin.getUIComponent();
                viewBldObj.registerPlugin(cell, plugin);
                bi.doRegControl = false;
            }
            bi.doAddToValidator = validator == null; // might already added to validator
            break;
        }
        case label:
            JLabel label = createLabel("", SwingConstants.LEFT);
            bi.compToAdd = label;
            break;

        case dsptextfield:
            if (StringUtils.isEmpty(cellField.getPickListName())) {
                JTextField text = UIHelper.createTextField(cellField.getTxtCols());
                changeTextFieldUIForDisplay(text, cellField.getPropertyAsBoolean("transparent", false));
                bi.compToAdd = text;
            } else {
                bi.compToAdd = createTextField(validator, cellField, fieldInfo, isReq, adapter);
                bi.doAddToValidator = validator == null; // might already added to validator
            }
            break;

        case textfieldinfo:
            bi.compToAdd = createTextFieldWithInfo(cellField, parent);
            break;

        case image:
            bi.compToAdd = createImageDisplay(cellField, mode, validator);
            bi.doAddToValidator = (validator != null);
            break;

        case url:
            BrowserLauncherBtn blb = new BrowserLauncherBtn(cellField.getProperty("title"));
            bi.compToAdd = blb;
            bi.doAddToValidator = false;

            break;

        case combobox:
            bi.compToAdd = createValComboBox(validator, cellField, adapter, isReq);
            bi.doAddToValidator = validator != null; // might already added to validator
            break;

        case checkbox: {
            String lblStr = cellField.getLabel();
            if (lblStr.equals("##")) {
                bi.isDerivedLabel = true;
                cellField.setDerived(true);
            }
            ValCheckBox checkbox = new ValCheckBox(lblStr, isReq,
                    cellField.isReadOnly() || mode == AltViewIFace.CreationMode.VIEW);
            if (validator != null) {
                DataChangeNotifier dcn = validator.createDataChangeNotifer(cellField.getIdent(), checkbox,
                        validator.createValidator(checkbox, UIValidator.Type.Changed));
                checkbox.addActionListener(dcn);
                checkbox.addItemListener(dcn);
            }
            bi.compToAdd = checkbox;
            break;
        }

        case tristate: {
            String lblStr = cellField.getLabel();
            if (lblStr.equals("##")) {
                bi.isDerivedLabel = true;
                cellField.setDerived(true);
            }
            ValTristateCheckBox tristateCB = new ValTristateCheckBox(lblStr, isReq,
                    cellField.isReadOnly() || mode == AltViewIFace.CreationMode.VIEW);
            if (validator != null) {
                DataChangeNotifier dcn = validator.createDataChangeNotifer(cellField.getIdent(), tristateCB,
                        null);
                tristateCB.addActionListener(dcn);
            }
            bi.compToAdd = tristateCB;
            break;
        }

        case spinner: {
            String minStr = cellField.getProperty("min");
            int min = StringUtils.isNotEmpty(minStr) ? Integer.parseInt(minStr) : 0;

            String maxStr = cellField.getProperty("max");
            int max = StringUtils.isNotEmpty(maxStr) ? Integer.parseInt(maxStr) : 0;

            ValSpinner spinner = new ValSpinner(min, max, isReq,
                    cellField.isReadOnly() || mode == AltViewIFace.CreationMode.VIEW);
            if (validator != null) {
                DataChangeNotifier dcn = validator.createDataChangeNotifer(cellField.getIdent(), spinner,
                        validator.createValidator(spinner, UIValidator.Type.Changed));
                spinner.addChangeListener(dcn);
            }
            bi.compToAdd = spinner;
            break;
        }

        case password:
            bi.compToAdd = createPasswordField(validator, cellField, isReq);
            bi.doAddToValidator = validator == null; // might already added to validator
            break;

        case dsptextarea:
            bi.compToAdd = createDisplayTextArea(cellField);
            break;

        case textarea: {
            JTextArea ta = createTextArea(validator, cellField, isReq, fieldInfo);
            JScrollPane scrollPane = new JScrollPane(ta);
            scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            scrollPane.setVerticalScrollBarPolicy(
                    UIHelper.isMacOS() ? ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
                            : ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
            ta.setLineWrap(true);
            ta.setWrapStyleWord(true);

            bi.doAddToValidator = validator == null; // might already added to validator
            bi.compToReg = ta;
            bi.compToAdd = scrollPane;
            break;
        }

        case textareabrief: {
            String title = "";
            DBTableInfo ti = DBTableIdMgr.getInstance().getByClassName(viewDef.getClassName());
            if (ti != null) {
                DBFieldInfo fi = ti.getFieldByName(cellField.getName());
                if (fi != null) {
                    title = fi.getTitle();
                }
            }

            ValTextAreaBrief txBrief = createTextAreaBrief(validator, cellField, isReq, fieldInfo);
            txBrief.setTitle(title);

            bi.doAddToValidator = validator == null; // might already added to validator
            bi.compToReg = txBrief;
            bi.compToAdd = txBrief.getUIComponent();
            break;
        }

        case browse: {
            JTextField textField = createTextField(validator, cellField, null, isReq, null);
            if (textField instanceof ValTextField) {
                ValBrowseBtnPanel bbp = new ValBrowseBtnPanel((ValTextField) textField,
                        cellField.getPropertyAsBoolean("dirsonly", false),
                        cellField.getPropertyAsBoolean("forinput", true));
                String fileFilter = cellField.getProperty("filefilter");
                String fileFilterDesc = cellField.getProperty("filefilterdesc");
                String defaultExtension = cellField.getProperty("defaultExtension");
                if (fileFilter != null && fileFilterDesc != null) {
                    bbp.setUseNativeFileDlg(false);
                    bbp.setFileFilter(new FileNameExtensionFilter(fileFilterDesc, fileFilter));
                    bbp.setDefaultExtension(defaultExtension);
                    //bbp.setNativeDlgFilter(new FileNameExtensionFilter(fileFilterDesc, fileFilter));
                }
                bi.compToAdd = bbp;

            } else {
                BrowseBtnPanel bbp = new BrowseBtnPanel(textField,
                        cellField.getPropertyAsBoolean("dirsonly", false),
                        cellField.getPropertyAsBoolean("forinput", true));
                bi.compToAdd = bbp;
            }
            break;
        }

        case querycbx: {
            ValComboBoxFromQuery cbx = createQueryComboBox(validator, cellField, isReq,
                    cellField.getPropertyAsBoolean("adjustquery", true));
            cbx.setMultiView(parent);
            cbx.setFrameTitle(cellField.getProperty("title"));

            bi.compToAdd = cbx;
            bi.doAddToValidator = validator == null; // might already added to validator
            break;
        }

        case list: {
            JList list = createList(validator, cellField, isReq);

            JScrollPane scrollPane = new JScrollPane(list);
            scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            scrollPane.setVerticalScrollBarPolicy(
                    UIHelper.isMacOS() ? ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
                            : ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

            bi.doAddToValidator = validator == null;
            bi.compToReg = list;
            bi.compToAdd = scrollPane;
            break;
        }

        case colorchooser: {
            ColorChooser colorChooser = new ColorChooser(Color.BLACK);
            if (validator != null) {
                DataChangeNotifier dcn = validator.createDataChangeNotifer(cellField.getName(), colorChooser,
                        null);
                colorChooser.addPropertyChangeListener("setValue", dcn);
            }
            //setControlSize(colorChooser);
            bi.compToAdd = colorChooser;

            break;
        }

        case button:
            JButton btn = createFormButton(cellField, cellField.getProperty("title"));
            bi.compToAdd = btn;
            break;

        case progress:
            bi.compToAdd = createProgressBar(0, 100);
            break;

        case plugin:
            UIPluginable uip = createPlugin(parent, validator, cellField,
                    mode == AltViewIFace.CreationMode.VIEW, isReq);
            if (uip != null) {
                bi.compToAdd = uip.getUIComponent();
                viewBldObj.registerPlugin(cell, uip);
            } else {
                bi.compToAdd = new JPanel();
                log.error("Couldn't create UIPlugin [" + cellField.getName() + "] ID:" + cellField.getIdent());
            }
            bi.doRegControl = false;
            break;

        case textpl:
            JTextField txt = new TextFieldFromPickListTable(adapter, cellField.getTxtCols());
            changeTextFieldUIForDisplay(txt, cellField.getPropertyAsBoolean("transparent", false));
            bi.compToAdd = txt;
            break;

        default:
            FormDevHelper.appendFormDevError("Don't recognize uitype=[" + uiType + "]");

        } // switch

    } else if (cell.getType() == FormCellIFace.CellType.separator) {
        // still have compToAdd = null;
        FormCellSeparatorIFace fcs = (FormCellSeparatorIFace) cell;
        String collapsableName = fcs.getCollapseCompName();

        String label = fcs.getLabel();
        if (StringUtils.isEmpty(label) || label.equals("##")) {
            String className = fcs.getProperty("forclass");
            if (StringUtils.isNotEmpty(className)) {
                DBTableInfo ti = DBTableIdMgr.getInstance().getByShortClassName(className);
                if (ti != null) {
                    label = ti.getTitle();
                }
            }
        }
        Component sep = viewBldObj.createSeparator(label);
        if (isNotEmpty(collapsableName)) {
            CollapsableSeparator collapseSep = new CollapsableSeparator(sep, false, null);
            if (bi.collapseSepHash == null) {
                bi.collapseSepHash = new HashMap<CollapsableSeparator, String>();
            }
            bi.collapseSepHash.put(collapseSep, collapsableName);
            sep = collapseSep;

        }
        bi.doRegControl = cell.getName().length() > 0;
        bi.compToAdd = (JComponent) sep;
        bi.doRegControl = StringUtils.isNotEmpty(cell.getIdent());
        bi.doAddToValidator = false;

    } else if (cell.getType() == FormCellIFace.CellType.command) {
        FormCellCommand cellCmd = (FormCellCommand) cell;
        JButton btn = createFormButton(cell, cellCmd.getLabel());
        if (cellCmd.getCommandType().length() > 0) {
            btn.addActionListener(new CommandActionWrapper(
                    new CommandAction(cellCmd.getCommandType(), cellCmd.getAction(), "")));
        }
        bi.doAddToValidator = false;
        bi.compToAdd = btn;

    } else if (cell.getType() == FormCellIFace.CellType.iconview) {
        FormCellSubView cellSubView = (FormCellSubView) cell;

        String subViewName = cellSubView.getViewName();

        ViewIFace subView = AppContextMgr.getInstance().getView(cellSubView.getViewSetName(), subViewName);
        if (subView != null) {
            if (parent != null) {
                int options = MultiView.VIEW_SWITCHER
                        | (MultiView.isOptionOn(parent.getCreateOptions(), MultiView.IS_NEW_OBJECT)
                                ? MultiView.IS_NEW_OBJECT
                                : MultiView.NO_OPTIONS);

                options |= cellSubView.getPropertyAsBoolean("nosep", false) ? MultiView.DONT_USE_EMBEDDED_SEP
                        : 0;
                options |= cellSubView.getPropertyAsBoolean("nosepmorebtn", false)
                        ? MultiView.NO_MORE_BTN_FOR_SEP
                        : 0;

                MultiView multiView = new MultiView(parent, cellSubView.getName(), subView,
                        parent.getCreateWithMode(), options, null);
                parent.addChildMV(multiView);
                multiView.setClassToCreate(getClassToCreate(parent, cell));

                log.debug("[" + cell.getType() + "] [" + cell.getName() + "] col: " + bi.colInx + " row: "
                        + rowInx + " colspan: " + cell.getColspan() + " rowspan: " + cell.getRowspan());
                viewBldObj.addSubView(cellSubView, multiView, bi.colInx, rowInx, cellSubView.getColspan(), 1);
                viewBldObj.closeSubView(cellSubView);
                bi.curMaxRow = rowInx;
                bi.colInx += cell.getColspan() + 1;
            } else {
                log.error("buildFormView - parent is NULL for subview [" + subViewName + "]");
            }

        } else {
            log.error("buildFormView - Could find subview's with ViewSet[" + cellSubView.getViewSetName()
                    + "] ViewName[" + subViewName + "]");
        }
        // still have compToAdd = null;
        bi.colInx += 2;

    } else if (cell.getType() == FormCellIFace.CellType.subview) {
        FormCellSubView cellSubView = (FormCellSubView) cell;
        String subViewName = cellSubView.getViewName();
        ViewIFace subView = AppContextMgr.getInstance().getView(cellSubView.getViewSetName(), subViewName);

        if (subView != null) {
            // Check to see this view should be "flatten" meaning we are creating a grid from a form
            if (!viewBldObj.shouldFlatten()) {
                if (parent != null) {
                    ViewIFace parentView = parent.getView();
                    Properties props = cellSubView.getProperties();

                    boolean isSingle = cellSubView.isSingleValueFromSet();
                    boolean isACollection = false;

                    try {
                        Class<?> cls = Class.forName(parentView.getClassName());
                        Field fld = getFieldFromDotNotation(cellSubView, cls);
                        if (fld != null) {
                            isACollection = Collection.class.isAssignableFrom(fld.getType());
                        } else {
                            log.error("Couldn't find field [" + cellSubView.getName() + "] in class ["
                                    + parentView.getClassName() + "]");
                        }
                    } catch (Exception ex) {
                        log.error("Couldn't find field [" + cellSubView.getName() + "] in class ["
                                + parentView.getClassName() + "]");
                        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ViewFactory.class, ex);
                    }

                    if (isSingle) {
                        isACollection = true;
                    }

                    boolean useNoScrollbars = UIHelper.getProperty(props, "noscrollbars", false);
                    //Assume RecsetController will always be handled correctly for one-to-one
                    boolean hideResultSetController = relInfo == null ? false
                            : relInfo.getType().equals(DBRelationshipInfo.RelationshipType.ZeroOrOne);
                    /*XXX bug #9497: boolean canEdit = true;
                    boolean addAddBtn = isEditOnCreateOnly && relInfo != null;
                    if (AppContextMgr.isSecurityOn()) {
                    DBTableInfo tblInfo = childInfo != null ? DBTableIdMgr.getInstance().getByShortClassName(childInfo.getDataClass().getSimpleName()) : null;
                    if (tblInfo != null) {
                        PermissionSettings perm = tblInfo.getPermissions();
                        if (perm != null) {
                            //XXX whoa. What about view perms???
                           //if (perm.isViewOnly() || !perm.canView()) {
                            if (!perm.canModify()) {
                               canEdit = false;
                            }
                        }
                    }
                    }*/

                    int options = (isACollection && !isSingle ? MultiView.RESULTSET_CONTROLLER
                            : MultiView.IS_SINGLE_OBJ)
                            | MultiView.VIEW_SWITCHER
                            | (MultiView.isOptionOn(parent.getCreateOptions(), MultiView.IS_NEW_OBJECT)
                                    ? MultiView.IS_NEW_OBJECT
                                    : MultiView.NO_OPTIONS)
                            |
                            /* XXX bug #9497:(mode == AltViewIFace.CreationMode.EDIT && canEdit ? MultiView.IS_EDITTING : MultiView.NO_OPTIONS) |
                            (useNoScrollbars ? MultiView.NO_SCROLLBARS : MultiView.NO_OPTIONS)
                            //| (addAddBtn ? MultiView.INCLUDE_ADD_BTN : MultiView.NO_OPTIONS)
                            ; */

                            (mode == AltViewIFace.CreationMode.EDIT ? MultiView.IS_EDITTING
                                    : MultiView.NO_OPTIONS)
                            | (useNoScrollbars ? MultiView.NO_SCROLLBARS : MultiView.NO_OPTIONS)
                            | (hideResultSetController ? MultiView.HIDE_RESULTSET_CONTROLLER
                                    : MultiView.NO_OPTIONS);
                    //MultiView.printCreateOptions("HERE", options);

                    options |= cellSubView.getPropertyAsBoolean("nosep", false)
                            ? MultiView.DONT_USE_EMBEDDED_SEP
                            : 0;
                    options |= cellSubView.getPropertyAsBoolean("nosepmorebtn", false)
                            ? MultiView.NO_MORE_BTN_FOR_SEP
                            : 0;
                    options |= cellSubView.getPropertyAsBoolean("collapse", false)
                            ? MultiView.COLLAPSE_SEPARATOR
                            : 0;

                    if (!(isACollection && !isSingle)) {
                        options &= ~MultiView.ADD_SEARCH_BTN;
                    } else {
                        options |= cellSubView.getPropertyAsBoolean("addsearch", false)
                                ? MultiView.ADD_SEARCH_BTN
                                : 0;
                    }

                    //MultiView.printCreateOptions("_______________________________", parent.getCreateOptions());
                    //MultiView.printCreateOptions("_______________________________", options);
                    boolean useBtn = UIHelper.getProperty(props, "btn", false);
                    if (useBtn) {
                        SubViewBtn.DATA_TYPE dataType;
                        if (isSingle) {
                            dataType = SubViewBtn.DATA_TYPE.IS_SINGLESET_ITEM;

                        } else if (isACollection) {
                            dataType = SubViewBtn.DATA_TYPE.IS_SET;
                        } else {
                            dataType = cellSubView.getName().equals("this") ? SubViewBtn.DATA_TYPE.IS_THIS
                                    : SubViewBtn.DATA_TYPE.IS_SET;
                        }

                        SubViewBtn subViewBtn = getInstance().createSubViewBtn(parent, cellSubView, subView,
                                dataType, options, props, getClassToCreate(parent, cell), mode);
                        subViewBtn.setHelpContext(props.getProperty("hc", null));

                        bi.doAddToValidator = false;
                        bi.compToAdd = subViewBtn;

                        String visProp = cell.getProperty("visible");
                        if (StringUtils.isNotEmpty(visProp) && visProp.equalsIgnoreCase("false")
                                && bi.compToAdd != null) {
                            bi.compToAdd.setVisible(false);
                        }

                        try {
                            addControl(validator, viewBldObj, rowInx, cell, bi);

                        } catch (java.lang.IndexOutOfBoundsException ex) {
                            String msg = "Error adding control type: `" + cell.getType() + "` id: `"
                                    + cell.getIdent() + "` name: `" + cell.getName() + "` on row: " + rowInx
                                    + " column: " + bi.colInx + "\n" + ex.getMessage();
                            UIRegistry.showError(msg);
                            return false;
                        }

                        bi.doRegControl = false;
                        bi.compToAdd = null;

                    } else {

                        Color bgColor = getBackgroundColor(props, parent.getBackground());

                        //log.debug(cellSubView.getName()+"  "+UIHelper.getProperty(props, "addsearch", false));
                        if (UIHelper.getProperty(props, "addsearch", false)) {
                            options |= MultiView.ADD_SEARCH_BTN;
                        }

                        if (UIHelper.getProperty(props, "addadd", false)) {
                            options |= MultiView.INCLUDE_ADD_BTN;
                        }

                        //MultiView.printCreateOptions("SUBVIEW", options);
                        MultiView multiView = new MultiView(parent, cellSubView.getName(), subView,
                                parent.getCreateWithMode(), cellSubView.getDefaultAltViewType(), options,
                                bgColor, cellSubView);
                        multiView.setClassToCreate(getClassToCreate(parent, cell));
                        setBorder(multiView, cellSubView.getProperties());

                        parent.addChildMV(multiView);

                        //log.debug("["+cell.getType()+"] ["+cell.getName()+"] col: "+bi.colInx+" row: "+rowInx+" colspan: "+cell.getColspan()+" rowspan: "+cell.getRowspan());
                        viewBldObj.addSubView(cellSubView, multiView, bi.colInx, rowInx,
                                cellSubView.getColspan(), 1);
                        viewBldObj.closeSubView(cellSubView);

                        Viewable viewable = multiView.getCurrentView();
                        if (viewable != null) {
                            if (viewable instanceof TableViewObj) {
                                ((TableViewObj) viewable).setVisibleRowCount(cellSubView.getTableRows());
                            }
                            if (viewable.getValidator() != null && childInfo != null) {
                                viewable.getValidator().setRequired(childInfo.isRequired());
                            }
                        }
                        bi.colInx += cell.getColspan() + 1;
                    }
                    bi.curMaxRow = rowInx;

                    //if (hasColor)
                    //{
                    //    setMVBackground(multiView, multiView.getBackground());
                    //}

                } else {
                    log.error("buildFormView - parent is NULL for subview [" + subViewName + "]");
                    bi.colInx += 2;
                }
            } else {
                //log.debug("["+cell.getType()+"] ["+cell.getName()+"] col: "+bi.colInx+" row: "+rowInx+" colspan: "+cell.getColspan()+" rowspan: "+cell.getRowspan());
                viewBldObj.addSubView(cellSubView, parent, bi.colInx, rowInx, cellSubView.getColspan(), 1);

                AltViewIFace altView = subView.getDefaultAltView();
                DBTableInfo sbTableInfo = DBTableIdMgr.getInstance().getByClassName(subView.getClassName());
                ViewDefIFace altsViewDef = (ViewDefIFace) altView.getViewDef();

                if (altsViewDef instanceof FormViewDefIFace) {
                    FormViewDefIFace fvd = (FormViewDefIFace) altsViewDef;
                    processRows(sbTableInfo, parent, viewDef, validator, viewBldObj, altView.getMode(),
                            labelsForHash, currDataObj, fvd.getRows());

                } else if (altsViewDef == null) {
                    // This error is bad enough to have it's own dialog
                    String msg = String.format("The Altview '%s' has a null ViewDef!", altView.getName());
                    FormDevHelper.appendFormDevError(msg);
                    UIRegistry.showError(msg);
                }

                viewBldObj.closeSubView(cellSubView);
                bi.colInx += cell.getColspan() + 1;
            }

        } else {
            log.error("buildFormView - Could find subview's with ViewSet[" + cellSubView.getViewSetName()
                    + "] ViewName[" + subViewName + "]");
        }
        // still have compToAdd = null;

    } else if (cell.getType() == FormCellIFace.CellType.statusbar) {
        bi.compToAdd = new JStatusBar();
        bi.doRegControl = true;
        bi.doAddToValidator = false;

    } else if (cell.getType() == FormCellIFace.CellType.panel) {
        bi.doRegControl = false;
        bi.doAddToValidator = false;

        cell.setIgnoreSetGet(true);

        FormCellPanel cellPanel = (FormCellPanel) cell;
        PanelViewable.PanelType panelType = PanelViewable.getType(cellPanel.getPanelType());

        if (panelType == PanelViewable.PanelType.Panel) {
            PanelViewable panelViewable = new PanelViewable(viewBldObj, cellPanel);

            processRows(parentTableInfo, parent, viewDef, validator, panelViewable, mode, labelsForHash,
                    currDataObj, cellPanel.getRows());

            panelViewable.setVisible(cellPanel.getPropertyAsBoolean("visible", true));

            setBorder(panelViewable, cellPanel.getProperties());
            if (parent != null) {
                Color bgColor = getBackgroundColor(cellPanel.getProperties(), parent.getBackground());
                if (bgColor != null && bgColor != parent.getBackground()) {
                    panelViewable.setOpaque(true);
                    panelViewable.setBackground(bgColor);
                }
            }

            bi.compToAdd = panelViewable;
            bi.doRegControl = true;
            bi.compToReg = panelViewable;

        } else if (panelType == PanelViewable.PanelType.ButtonBar) {
            bi.compToAdd = PanelViewable.buildButtonBar(processRows(viewBldObj, cellPanel.getRows()));

        } else {
            FormDevHelper.appendFormDevError("Panel Type is not implemented.");
            return false;
        }
    }

    String visProp = cell.getProperty("visible");
    if (StringUtils.isNotEmpty(visProp) && visProp.equalsIgnoreCase("false") && bi.compToAdd != null) {
        bi.compToAdd.setVisible(false);
    }

    return true;
}

From source file:edu.harvard.i2b2.query.ui.ConceptTreePanel.java

/**
 * This method is called from within the constructor to initialize the form.
 *//* ww w .j a  va  2s  .  c  o  m*/
private void initComponents() {
    jScrollPane1 = new javax.swing.JScrollPane();
    jClearButton = new javax.swing.JButton();
    jConstrainButton = new javax.swing.JButton();
    jExcludeButton = new javax.swing.JButton();
    jOccurrenceButton = new javax.swing.JButton();
    jNameLabel = new javax.swing.JLabel();
    jHintLabel = new javax.swing.JLabel();

    setLayout(null);

    QueryConceptTreeNodeData tmpData = new QueryConceptTreeNodeData();
    tmpData.name("working ......");
    tmpData.tooltip("A root node");
    tmpData.visualAttribute("FAO");
    top = new DefaultMutableTreeNode(tmpData);
    // top = new DefaultMutableTreeNode("Root Node");
    treeModel = new DefaultTreeModel(top);
    // treeModel.addTreeModelListener(new MyTreeModelListener());

    jTree1 = new JTree(treeModel);

    jTree1.setDragEnabled(true);
    jTree1.setEditable(true);
    // jTree1.getSelectionModel().setSelectionMode
    // (TreeSelectionModel.SINGLE_TREE_SELECTION);
    // jTree1.setShowsRootHandles(true);
    // JScrollPane treeView = new JScrollPane(jTree1);
    jTree1.setRootVisible(false);
    jTree1.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    jTree1.setCellRenderer(new MyRenderer());
    ToolTipManager.sharedInstance().registerComponent(jTree1);

    setBorder(javax.swing.BorderFactory.createEtchedBorder());
    add(jScrollPane1);
    // jScrollPane1.setBounds(0, 40, 180, 200);

    jClearButton.setFont(new java.awt.Font("Tahoma", 1, 10));
    jClearButton.setText("X");
    jClearButton.setToolTipText("Clear all items from panel");
    jClearButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    jClearButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
    jClearButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
    if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
        jClearButton.setMargin(new java.awt.Insets(-10, -15, -10, -20));
    }
    jClearButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jClearButtonActionPerformed(evt);
        }
    });

    add(jClearButton);
    jClearButton.setBounds(160, 0, 18, 20);

    jConstrainButton.setText("Dates");
    jConstrainButton.setToolTipText("Constrain group by dates");
    jConstrainButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
    jConstrainButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
    // jConstrainButton.setMargin(new java.awt.Insets(-10, -15, -10,-20));
    if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
        jConstrainButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        // jConstrainButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
        jConstrainButton.setMargin(new java.awt.Insets(-10, -15, -10, -20));
    }

    jConstrainButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jConstrainButtonActionPerformed(evt);
        }
    });

    add(jConstrainButton);
    jConstrainButton.setBounds(0, 20, 40, 21);

    jOccurrenceButton.setText("Occurs > 0x");
    jOccurrenceButton.setToolTipText("Set occurrence times");
    jOccurrenceButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jOccurrenceButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jOccurrenceButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
    if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
        jOccurrenceButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jOccurrenceButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jOccurrenceButton.setMargin(new java.awt.Insets(-10, -10, -10, -10));
    }
    jOccurrenceButton.setIconTextGap(0);
    jOccurrenceButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jOccurrenceButtonActionPerformed(evt);
        }
    });
    jOccurrenceButton.setBounds(40, 20, 90, 21);
    add(jOccurrenceButton);

    // jExcludeButton.setMnemonic('E');
    jExcludeButton.setText("Exclude");
    jExcludeButton.setToolTipText("Exclude all items in group");
    jExcludeButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jExcludeButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jExcludeButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
    if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
        jExcludeButton.setMargin(new java.awt.Insets(-10, -15, -10, -20));
        jExcludeButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    }
    jExcludeButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jExcludeButtonActionPerformed(evt);
        }
    });
    add(jExcludeButton);
    jExcludeButton.setBounds(130, 20, 48, 21);

    jNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jNameLabel.setText("Group 1");
    jNameLabel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jNameLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    add(jNameLabel);
    jNameLabel.setBounds(0, 0, 160, 20);
    jNameLabel.setTransferHandler(new GroupLabelTextHandler());
    jNameLabel.addMouseListener(new DragMouseAdapter());
    jNameLabel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
        public void mouseMoved(java.awt.event.MouseEvent evt) {
            jNameLabelMouseMoved(evt);
            // System.out.println("mouse x: "+evt.getX()+" y: "+evt.
            // getY());
            // System.out.println("name label x: "+jNameLabel.getX()+
            // " width: "+
            // jNameLabel.getWidth()+" y: "
            // +jNameLabel.getY()+" height "+jNameLabel.getHeight());
        }

    });
    jNameLabel.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseExited(java.awt.event.MouseEvent evt) {
            jNameLabelMouseExited(evt);
        }

    });

    jTree1.addTreeExpansionListener(this);
    jTree1.setTransferHandler(new TextHandler());
    add(jScrollPane1);
    jScrollPane1.setViewportView(jTree1);
    // jTree1.setToolTipText(
    // "Double click on a folder to view the items inside");
    // jScrollPane1.getViewport().setToolTipText(
    // "Double click on a folder to view the items inside");
    jScrollPane1.setBounds(0, 40, 180, 120);
    // jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(new
    // java.awt.Color(0, 0, 0)));
    // jTree1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter()
    // {
    // public void mouseMoved(java.awt.event.MouseEvent evt) {
    // jScrollPane1MouseMoved(evt);
    // }

    // @Override
    // public void mouseDragged(MouseEvent e) {
    // jScrollPane1MouseMoved(e);
    // }

    // });
    // jTree1.addMouseListener(new java.awt.event.MouseAdapter() {
    // public void mouseExited(java.awt.event.MouseEvent evt) {
    // jScrollPane1MouseExited(evt);
    // }

    // @Override
    // public void mouseEntered(MouseEvent e) {

    // jScrollPane1MouseEntered(e);
    // }

    // });

    jHintLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jHintLabel.setText(
            "<html><center>Drag terms from Navigate, <br>" + "<left>Find and Workplace into this group");
    // jHintLabel.getFont();
    jHintLabel.setFont(new Font("SansSerif", Font.PLAIN, 9));
    // jHintLabel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    jHintLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jHintLabel.setVerticalAlignment(javax.swing.SwingConstants.CENTER);
    // jHintLabel.setBackground(Color.WHITE);
    // jHintLabel.setForeground(Color.WHITE);
    add(jHintLabel);
    jHintLabel.setBounds(0, 120, 180, 30);
}

From source file:display.ANNFileFilter.java

License:asdf

Yanng() {
    JPanel toolBars;/*ww w . j  av a 2 s. c om*/
    JMenuBar menuBar;
    JToolBar utilBar, fileBar;
    JButton toJava, runner, trainer, modify, getTraininger, inputer, newwer, saver, saveAser, loader, helper;
    JMenu file;
    final JMenu util;
    JMenu help;

    ImageIcon IJava, IRun, ITrain, IModify, INew, ISave, ILoad, IGetTrainingSet, IGetInput, ISaveAs;

    //initialize main window
    mainWindow = new JFrame("YANNG - Yet Another Neural Network (simulator) Generator");
    mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainWindow.setLayout(new BorderLayout());
    mainWindow.setSize(675, 525);
    mainWindow.setIconImage(new ImageIcon(ClassLoader.getSystemResource("display/icons/logo.png")).getImage());
    loadingImage = new ImageIcon(ClassLoader.getSystemResource("display/icons/loading.gif"));

    path = new Vector<String>();
    net = new Vector<NeuralNetwork>();
    oneNet = new Vector<JPanel>();
    tabPanel = new Vector<JPanel>();
    readOut = new Vector<JTextArea>();
    readOutLocale = new Vector<JScrollPane>();
    loadingBar = new Vector<JLabel>();
    title = new Vector<JLabel>();
    close = new Vector<JButton>();
    netName = new Vector<StringBuffer>();
    netKind = new Vector<StringBuffer>();

    resultsPane = new JTabbedPane();

    mainWindow.add(resultsPane);

    toolBars = new JPanel();
    toolBars.setLayout(new FlowLayout(FlowLayout.LEFT));

    //create utilities toolbar with 3 buttons
    utilBar = new JToolBar("Utilities");
    IRun = new ImageIcon(new ImageIcon(ClassLoader.getSystemResource("display/icons/running.png")).getImage()
            .getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH));
    ITrain = new ImageIcon(new ImageIcon(ClassLoader.getSystemResource("display/icons/training.png")).getImage()
            .getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH));
    IModify = new ImageIcon(new ImageIcon(ClassLoader.getSystemResource("display/icons/modifyNet.png"))
            .getImage().getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH));
    IGetTrainingSet = new ImageIcon(
            new ImageIcon(ClassLoader.getSystemResource("display/icons/trainingSet.png")).getImage()
                    .getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH));
    IGetInput = new ImageIcon(new ImageIcon(ClassLoader.getSystemResource("display/icons/input.png")).getImage()
            .getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH));
    //set the icons/tooltips for the utilitiy bar    
    runner = new JButton(IRun);
    runner.setToolTipText(
            "<html>Run  the  Current  Neural   Network<br>Once Through with the Current Input</html>");

    trainer = new JButton(ITrain);
    trainer.setToolTipText(
            "<html>Train the Network with the Current<br>Configuration  and  Training  Set</html>");

    modify = new JButton(IModify);
    modify.setToolTipText("<html>Modify the Network<br>for Fun and Profit</html>");

    getTraininger = new JButton(IGetTrainingSet);
    getTraininger.setToolTipText("Get Training Set from File");

    inputer = new JButton(IGetInput);
    inputer.setToolTipText("Get Input Set from File");

    utilBar.add(inputer);
    utilBar.add(runner);
    utilBar.add(getTraininger);
    utilBar.add(trainer);
    utilBar.add(modify);

    //create file toolbar
    fileBar = new JToolBar("file");
    ISaveAs = new ImageIcon(new ImageIcon(ClassLoader.getSystemResource("display/icons/saveAs.png")).getImage()
            .getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH));
    INew = new ImageIcon(new ImageIcon(ClassLoader.getSystemResource("display/icons/new.png")).getImage()
            .getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH));
    ISave = new ImageIcon(new ImageIcon(ClassLoader.getSystemResource("display/icons/save.png")).getImage()
            .getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH));
    ILoad = new ImageIcon(new ImageIcon(ClassLoader.getSystemResource("display/icons/load.png")).getImage()
            .getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH));
    IJava = new ImageIcon(new ImageIcon(ClassLoader.getSystemResource("display/icons/toJava.png")).getImage()
            .getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH));

    newwer = new JButton(INew);
    newwer.setToolTipText("Create New Neural Network");

    saver = new JButton(ISave);
    saver.setToolTipText("Save Current Network Configuration");

    saveAser = new JButton(ISaveAs);
    saveAser.setToolTipText("Save Network As");

    loader = new JButton(ILoad);
    loader.setToolTipText("Load Network Configuration from File");

    toJava = new JButton(IJava);
    toJava.setToolTipText("Export Network to Java Project");

    fileBar.add(newwer);
    fileBar.add(loader);
    fileBar.add(saver);
    fileBar.add(saveAser);
    fileBar.add(toJava);
    toolBars.add(fileBar);
    toolBars.add(utilBar);
    mainWindow.add(toolBars, BorderLayout.NORTH);

    //create a menubar with three menus on it
    menuBar = new JMenuBar();
    file = new JMenu("File");
    util = new JMenu("Utilities");
    help = new JMenu("Help");

    //add menu items for file menu
    load = new JMenuItem("Load Network Configuration");
    newNet = new JMenuItem("New Network");
    saveAs = new JMenuItem("Save Network As");
    save = new JMenuItem("Save Current Configuration");
    exportNet = new JMenuItem("Export Network to Java Project");
    exportOutput = new JMenuItem("Export Output to Text File");
    file.add(load);
    file.add(newNet);
    file.addSeparator();
    file.add(saveAs);
    file.add(save);
    file.addSeparator();
    file.add(exportNet);
    file.add(exportOutput);
    menuBar.add(file);

    //add menu items for utilities menu
    changeConfig = new JMenuItem("Modify Network Settings");
    getInput = new JMenuItem("Get Input From File");
    getTraining = new JMenuItem("Get Training Set From File");
    run = new JMenuItem("Run");
    train = new JMenuItem("Train");
    getColorMap = new JMenuItem("View Color Map");
    getColorMap.setVisible(false);
    util.add(changeConfig);
    util.addSeparator();
    util.add(getInput);
    util.add(getTraining);
    util.addSeparator();
    util.add(run);
    util.add(train);
    menuBar.add(util);

    //add menu items for help menu
    quickStart = new JMenuItem("Quick Start Guide");
    searchHelp = new JMenuItem("Programming with Yanng");
    about = new JMenuItem("License");
    links = new JMenuItem("<html>Links to Resources<br>about Neural Networks</html>");
    help.add(quickStart);
    help.addSeparator();
    help.add(searchHelp);
    help.addSeparator();
    help.add(about);
    help.addSeparator();
    help.add(links);
    menuBar.add(help);

    mainWindow.setJMenuBar(menuBar);

    //opens the quickstart guide
    quickStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            try {
                File myFile = new File(URLDecoder
                        .decode(ClassLoader.getSystemResource("ann/quick-start.pdf").getFile(), "UTF-8"));
                Desktop.getDesktop().open(myFile);
            } catch (IOException ex) {
                try {
                    Runtime.getRuntime().exec("xdg-open ./yanng/src/ann/quick-start.pdf");
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(mainWindow,
                            "Your desktop is not supported by java,\ngo to yanng/src/ann/quick-start.pdf to view the technical manual.",
                            "Desktop not Supported", JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    });

    links.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            try {
                File myFile = new File(
                        URLDecoder.decode(ClassLoader.getSystemResource("ann/links.pdf").getFile(), "UTF-8"));
                Desktop.getDesktop().open(myFile);
            } catch (IOException ex) {
                try {
                    Runtime.getRuntime().exec("xdg-open ./yanng/src/ann/links.pdf");
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(mainWindow,
                            "Your desktop is not supported by java,\ngo to yanng/src/ann/links.pdf to view the technical manual.",
                            "Desktop not Supported", JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    });

    //Displays license information
    about.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            JTextArea x = new JTextArea("Copyright [2015] [Sam Findler and Michael Scott]\n" + "\n"
                    + "Licensed under the Apache License, Version 2.0 (the \"License\");\n"
                    + "you may not use this file except in compliance with the License.\n"
                    + "You may obtain a copy of the License at\n" + "\n"
                    + "http://www.apache.org/licenses/LICENSE-2.0\n" + "\n"
                    + "Unless required by applicable law or agreed to in writing, software\n"
                    + "distributed under the License is distributed on an \"AS IS\" BASIS,\n"
                    + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
                    + "See the License for the specific language governing permissions and\n"
                    + "limitations under the License.");
            JDialog aboutDialog = new JDialog(mainWindow, "License", true);
            aboutDialog.setSize(500, 250);
            aboutDialog.setLayout(new FlowLayout());
            aboutDialog.add(x);
            x.setEditable(false);
            aboutDialog.setVisible(true);
        }
    });

    //opens the more technical user guide
    searchHelp.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            try {
                File myFile = new File(URLDecoder
                        .decode(ClassLoader.getSystemResource("ann/technical-manual.pdf").getFile(), "UTF-8"));
                Desktop.getDesktop().open(myFile);
            } catch (IOException ex) {
                try {
                    Runtime.getRuntime().exec("xdg-open ./yanng/src/ann/technical-manual.pdf");
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(mainWindow,
                            "Your desktop is not supported by java,\ngo to yanng/src/ann/technical-manual.pdf to view the technical manual.",
                            "Desktop not Supported", JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    });
    //class trains the neural network in the background while the loading bar displays, then prints out the output/connections listings/average error to the readOut pane
    class Trainer extends SwingWorker<NeuralNetwork, Object> {
        protected NeuralNetwork doInBackground() {
            net.get(resultsPane.getSelectedIndex()).trainNet();
            setProgress(1);
            return net.get(resultsPane.getSelectedIndex());
        }

        public void done() {
            if (resultsPane.getTabCount() != 0
                    && netKind.get(resultsPane.getSelectedIndex()).toString().equals("Feed Forward Network")) {
                if (Double.isNaN(net.get(resultsPane.getSelectedIndex()).getAverageError()))
                    JOptionPane.showMessageDialog(mainWindow, "Training Set Formatted Incorrectly",
                            "Formatting Error", JOptionPane.ERROR_MESSAGE);
                else {
                    printConnections();
                    readOut.get(resultsPane.getSelectedIndex()).append(
                            "Results of Training " + netName.get(resultsPane.getSelectedIndex()) + ":\n\n");
                    printOutput();
                    readOut.get(resultsPane.getSelectedIndex()).append("Average Error = "
                            + net.get(resultsPane.getSelectedIndex()).getAverageError() + "\n\n");
                    loadingBar.get(resultsPane.getSelectedIndex()).setVisible(false);
                    JOptionPane.showMessageDialog(mainWindow,
                            "<html>If the Input is not displaying as expected, chances are the input was inproperly formatted.<br>See help for more details<html>");
                }
            } else if (resultsPane.getTabCount() != 0
                    && netKind.get(resultsPane.getSelectedIndex()).toString().equals("Self-Organizing Map")) {
                readOut.get(resultsPane.getSelectedIndex()).append("\nUpdated Untrained Map:\n");
                printInitMap();
                loadingBar.get(resultsPane.getSelectedIndex()).setVisible(false);
                JOptionPane.showMessageDialog(mainWindow,
                        "<html>If the Input is not displaying as expected, chances are the input was inproperly formatted.<br>See help for more details<html>");
            }
        }

    }
    //starts the training class when train is pressed in the utilities menu
    train.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {

            if (resultsPane.getTabCount() != 0) {
                if (net.get(resultsPane.getSelectedIndex()).getTrainingSet() != null) {
                    loadingBar.get(resultsPane.getSelectedIndex()).setText(
                            "<html><font color = rgb(160,0,0)>Training</font> <font color = rgb(0,0,248)>net...</font></html>");
                    loadingBar.get(resultsPane.getSelectedIndex()).setVisible(true);
                    (thisTrainer = new Trainer()).execute();
                } else
                    JOptionPane.showMessageDialog(mainWindow, "No Input Set Specified", "Empty Signifier Error",
                            JOptionPane.ERROR_MESSAGE);
            }

            else
                JOptionPane.showMessageDialog(mainWindow, "Can't Train Nonexistent Neural Network",
                        "Existential Error", JOptionPane.ERROR_MESSAGE);
        }
    });
    //associates the toolbar button with the jump rope guy with the training button on the utilities menu
    trainer.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            for (ActionListener a : train.getActionListeners()) {
                a.actionPerformed(ae);
            }
        }
    });

    //runs through one set of inputs and prints the results to the readOut pane  
    run.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (resultsPane.getTabCount() != 0
                    && netKind.get(resultsPane.getSelectedIndex()).toString().equals("Feed Forward Network")) {
                if (net.get(resultsPane.getSelectedIndex()).getInputSet() != null) {
                    net.get(resultsPane.getSelectedIndex()).runNet();
                    if (Double.isNaN(net.get(resultsPane.getSelectedIndex()).getAverageError()))
                        JOptionPane.showMessageDialog(mainWindow, "Training Set Formatted Incorrectly",
                                "Formatting Error", JOptionPane.ERROR_MESSAGE);
                    else {
                        readOut.get(resultsPane.getSelectedIndex()).append("Results of Running through Network "
                                + netName.get(resultsPane.getSelectedIndex()) + ":\n\n");
                        printOutput();
                        System.out.println("Results:");
                        for (int i = 0; i < net.get(resultsPane.getSelectedIndex())
                                .getOutputSet().length; i++) {
                            System.out.println("\n   Output of Input Vector " + i + ":");
                            for (int j = 0; j < net.get(resultsPane.getSelectedIndex())
                                    .getOutputSet()[i].length; j++) {
                                System.out.println("      Output Node " + j + " = "
                                        + net.get(resultsPane.getSelectedIndex()).getOutputSet()[i][j]);
                            }
                        }
                        JOptionPane.showMessageDialog(mainWindow,
                                "<html>If the Input is not displaying as expected, chances are the input was inproperly formatted.<br>See help for more details<html>");
                    }
                } else
                    JOptionPane.showMessageDialog(mainWindow, "No Input Set Specified", "Empty Signifier Error",
                            JOptionPane.ERROR_MESSAGE);
            } else if (resultsPane.getTabCount() != 0
                    && netKind.get(resultsPane.getSelectedIndex()).toString().equals("Self-Organizing Map")) {
                if (net.get(resultsPane.getSelectedIndex()).getInputValues() != null) {
                    loadingBar.get(resultsPane.getSelectedIndex()).setText(
                            "<html><font color = rgb(160,0,0)>Training</font> <font color = rgb(0,0,248)>net...</font></html>");
                    loadingBar.get(resultsPane.getSelectedIndex()).setVisible(true);
                    (thisTrainer = new Trainer()).execute();
                } else
                    JOptionPane.showMessageDialog(mainWindow, "No Input Set Specified", "Empty Signifier Error",
                            JOptionPane.ERROR_MESSAGE);
            } else
                JOptionPane.showMessageDialog(mainWindow, "Can't Run Nonexistent Neural Network",
                        "Existential Error", JOptionPane.ERROR_MESSAGE);
        }
    });

    runner.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            for (ActionListener a : run.getActionListeners()) {
                a.actionPerformed(ae);
            }
        }
    });

    //the following code is for the getTraining button under utilities
    getTrainingSet = new JFileChooser();
    getTrainingSet.setFileFilter(new TrainingFileFilter());

    getTraining.addActionListener(new ActionListener() {
        //this method/class gets a training set (tsv/csv file) and parse it through the neural network.  Kind of test that the file is formatted correctly, but if the data is wrong, there isn't much it can do.
        public void actionPerformed(ActionEvent ae) {
            if (resultsPane.getTabCount() != 0
                    && netKind.get(resultsPane.getSelectedIndex()).toString().equals("Feed Forward Network")) {
                int result;
                result = getTrainingSet.showOpenDialog(mainWindow);
                if (result == JFileChooser.APPROVE_OPTION)
                    if (getTrainingSet.getSelectedFile().getName().endsWith(".csv")
                            || getTrainingSet.getSelectedFile().getName().endsWith(".tsv")
                            || getTrainingSet.getSelectedFile().getName().endsWith(".txt"))
                        if (net.get(resultsPane.getSelectedIndex())
                                .parseTrainingSet(getTrainingSet.getSelectedFile()))
                            JOptionPane.showMessageDialog(mainWindow,
                                    "<html>Method gives no Garuntee that this File is Formatted Correctly<br>(see help for more details)</html>",
                                    "Formatting Warning", JOptionPane.WARNING_MESSAGE);
                        else
                            JOptionPane.showMessageDialog(mainWindow,
                                    "File Mismatch with Network Configuration", "Correspondence Error",
                                    JOptionPane.ERROR_MESSAGE);
                    else {
                        JOptionPane.showMessageDialog(mainWindow, "Wrong File Type", "Category Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                else {
                    JOptionPane.showMessageDialog(mainWindow, "No File Selected", "Absence Warning",
                            JOptionPane.WARNING_MESSAGE);
                }
            } else if (resultsPane.getTabCount() != 0
                    && netKind.get(resultsPane.getSelectedIndex()).toString().equals("Self-Organizing Map")) {
                int result;
                result = getTrainingSet.showOpenDialog(mainWindow);
                if (result == JFileChooser.APPROVE_OPTION)
                    if (getTrainingSet.getSelectedFile().getName().endsWith(".csv")
                            || getTrainingSet.getSelectedFile().getName().endsWith(".tsv")
                            || getTrainingSet.getSelectedFile().getName().endsWith(".txt"))
                        if (net.get(resultsPane.getSelectedIndex())
                                .parseTrainingSet(getTrainingSet.getSelectedFile())) {
                            JOptionPane.showMessageDialog(mainWindow,
                                    "<html>Method gives no Garuntee that this File is Formatted Correctly<br>(see help for more details)</html>",
                                    "Formatting Warning", JOptionPane.WARNING_MESSAGE);
                            readOut.get(resultsPane.getSelectedIndex()).append("\nUpdated Untrained Map:\n");
                            printInitMap();
                        } else
                            JOptionPane.showMessageDialog(mainWindow,
                                    "File Mismatch with Network Configuration", "Correspondence Error",
                                    JOptionPane.ERROR_MESSAGE);
                    else {
                        JOptionPane.showMessageDialog(mainWindow, "Wrong File Type", "Category Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                else {
                    JOptionPane.showMessageDialog(mainWindow, "No File Selected", "Absence Warning",
                            JOptionPane.WARNING_MESSAGE);
                }
            } else {
                JOptionPane.showMessageDialog(mainWindow, "Can't Train Nonexistent Neural Network",
                        "Existential Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    getTraininger.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            for (ActionListener a : getTraining.getActionListeners()) {
                a.actionPerformed(ae);
            }
        }
    });

    //this ends the getTraining section of the code   

    getInput.addActionListener(new ActionListener() {
        //this method/class gets an input set (tsv/csv file) and parses it through the neural network.  Somewhat tests that the file is formatted correctly, but cannot give a garuntee.
        public void actionPerformed(ActionEvent ae) {
            if (resultsPane.getTabCount() != 0) {
                int result;
                result = getTrainingSet.showOpenDialog(mainWindow);
                if (result == JFileChooser.APPROVE_OPTION)
                    if (getTrainingSet.getSelectedFile().getName().endsWith(".csv")
                            || getTrainingSet.getSelectedFile().getName().endsWith(".tsv")
                            || getTrainingSet.getSelectedFile().getName().endsWith(".txt"))
                        if (net.get(resultsPane.getSelectedIndex())
                                .parseInputSet(getTrainingSet.getSelectedFile())) {
                            JOptionPane.showMessageDialog(mainWindow,
                                    "<html>Method gives no Garuntee that this File is Formatted Correctly<br>(see help for more details)</html>",
                                    "Formatting Warning", JOptionPane.WARNING_MESSAGE);
                            if (netKind.get(resultsPane.getSelectedIndex()).toString()
                                    .equals("Self-Organizing Map"))
                                printInitMap();
                        } else
                            JOptionPane.showMessageDialog(mainWindow,
                                    "File Mismatch with Network Configuration", "Correspondence Error",
                                    JOptionPane.ERROR_MESSAGE);
                    else
                        JOptionPane.showMessageDialog(mainWindow, "Wrong File Type", "Category Error",
                                JOptionPane.ERROR_MESSAGE);
                else
                    JOptionPane.showMessageDialog(mainWindow, "No File Selected", "Absence Warning",
                            JOptionPane.WARNING_MESSAGE);
            } else {
                JOptionPane.showMessageDialog(mainWindow, "Can't train nonexistent network",
                        "Existential Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    //opens and displays a color map of a SOM
    getColorMap.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (resultsPane.getTabCount() != 0) {
                if (netKind.get(resultsPane.getSelectedIndex()).toString().equals("Self-Organizing Map")) {
                    MapNode[][] map;

                    map = net.get(resultsPane.getSelectedIndex()).getMapArray();

                    int lValue = net.get(resultsPane.getSelectedIndex()).getLatticeValue();

                    int inputDimensions = net.get(resultsPane.getSelectedIndex()).getInputDimensions();

                    int[][] colorValues = new int[(lValue * lValue)][3];

                    double dMax = net.get(resultsPane.getSelectedIndex()).getDataMax();
                    double dMin = net.get(resultsPane.getSelectedIndex()).getDataMin();

                    int count = 0;

                    for (int i = 0; i < lValue; i++) {
                        for (int j = 0; j < lValue; j++) {
                            for (int k = 0; k < 3; k++) {
                                Vector tempVec = map[i][j].getWeights();
                                if (inputDimensions % 3 == 0) {
                                    colorValues[count][k] = Integer.parseInt(String.valueOf((Math.round(255
                                            * (Double.parseDouble(String.valueOf(tempVec.elementAt(k))))))));
                                }
                                if (inputDimensions % 3 == 1) {
                                    if (k == 0)
                                        colorValues[count][k] = 0;
                                    if (k == 1) {
                                        colorValues[count][k] = Integer
                                                .parseInt(String.valueOf((Math.round(255 * (Double
                                                        .parseDouble(String.valueOf(tempVec.elementAt(0))))))));
                                    }
                                    if (k == 2)
                                        colorValues[count][k] = 0;
                                }
                                if (inputDimensions % 3 == 2) {
                                    if (k == 2) {
                                        colorValues[count][k] = 0;
                                    } else
                                        colorValues[count][k] = Integer
                                                .parseInt(String.valueOf((Math.round(255 * (Double
                                                        .parseDouble(String.valueOf(tempVec.elementAt(k))))))));
                                }
                            }
                            count++;
                        }
                    }

                    JFrame frame = new JFrame();

                    frame.setTitle("Color Map");
                    frame.setPreferredSize(new Dimension(525, 500));
                    frame.add(new DrawPanel(colorValues, lValue));
                    frame.pack();
                    frame.setVisible(true);
                }

                else {
                    JOptionPane.showMessageDialog(mainWindow,
                            "This Feauture is only available for Self-Organizing Maps", "Not a Som Error",
                            JOptionPane.ERROR_MESSAGE);
                }
            } else {
                JOptionPane.showMessageDialog(mainWindow, "Network does not exist", "Existential Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    inputer.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            for (ActionListener a : getInput.getActionListeners())
                a.actionPerformed(ae);
        }
    });

    getNet = new JFileChooser();
    getNet.setFileFilter(new ANNFileFilter());

    //saves the net, or opens save as dialog if net is not saved yet
    save.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (resultsPane.getTabCount() != 0) {
                if (!path.get(resultsPane.getSelectedIndex()).equals("")) {
                    net.get(resultsPane.getSelectedIndex())
                            .save(new File(path.get(resultsPane.getSelectedIndex())));
                }

                else {
                    for (ActionListener a : saveAs.getActionListeners()) {
                        a.actionPerformed(ae);
                    }
                }
            } else {
                JOptionPane.showMessageDialog(mainWindow, "Can't save NonExistent Neural Network",
                        "Existential Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    saver.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            for (ActionListener a : save.getActionListeners()) {
                a.actionPerformed(ae);
            }
        }
    });

    //opens dialog for saving the net
    saveAs.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (resultsPane.getTabCount() != 0) {
                int result, override;
                String tempName;
                result = getNet.showSaveDialog(mainWindow);
                if (result == JFileChooser.APPROVE_OPTION)
                    if ((new File(tempName = getNet.getSelectedFile().getName())).exists()
                            || (new File(tempName + ".ffn")).exists() || (new File(tempName + ".som")).exists()
                            || (new File(tempName + ".hfn")).exists()) {
                        override = JOptionPane.showConfirmDialog(mainWindow,
                                tempName + " already exists, do you want to override?", "File Exists",
                                JOptionPane.YES_NO_OPTION);
                        if (override == JOptionPane.YES_OPTION) {
                            if (net.get(resultsPane.getSelectedIndex()).save(getNet.getSelectedFile())) {
                                if (tempName.endsWith(".ffn") || tempName.endsWith(".som")) {
                                    netName.set(resultsPane.getSelectedIndex(), new StringBuffer(tempName));
                                    title.get(resultsPane.getSelectedIndex()).setText(tempName + " ");
                                } else if (netKind.get(resultsPane.getSelectedIndex()).toString()
                                        .equals("Feed Forward Network")) {
                                    netName.set(resultsPane.getSelectedIndex(),
                                            new StringBuffer(tempName + ".ffn"));
                                    title.get(resultsPane.getSelectedIndex()).setText(tempName + ".ffn ");
                                } else if (netKind.get(resultsPane.getSelectedIndex()).toString()
                                        .equals("Self-Organizing Map")) {
                                    netName.set(resultsPane.getSelectedIndex(),
                                            new StringBuffer(tempName + ".som"));
                                    title.get(resultsPane.getSelectedIndex()).setText(tempName + ".som ");
                                }
                                path.set(resultsPane.getSelectedIndex(), getNet.getSelectedFile().getPath());

                            } else
                                JOptionPane.showMessageDialog(mainWindow, "Could not save file", "File Error",
                                        JOptionPane.ERROR_MESSAGE);
                        }
                    } else {
                        if (net.get(resultsPane.getSelectedIndex()).save(getNet.getSelectedFile())) {
                            if (tempName.endsWith(".ffn") || tempName.endsWith(".som")
                                    || tempName.endsWith(".hfn")) {
                                netName.set(resultsPane.getSelectedIndex(), new StringBuffer(tempName));
                                title.get(resultsPane.getSelectedIndex()).setText(tempName + " ");
                            } else if (netKind.get(resultsPane.getSelectedIndex()).toString()
                                    .equals("Feed Forward Network")) {
                                netName.set(resultsPane.getSelectedIndex(),
                                        new StringBuffer(tempName + ".ffn"));
                                title.get(resultsPane.getSelectedIndex()).setText(tempName + ".ffn ");
                            } else if (netKind.get(resultsPane.getSelectedIndex()).toString()
                                    .equals("Self-Organizing Map")) {
                                netName.set(resultsPane.getSelectedIndex(),
                                        new StringBuffer(tempName + ".som"));
                                title.get(resultsPane.getSelectedIndex()).setText(tempName + ".som ");
                                path.set(resultsPane.getSelectedIndex(), getNet.getSelectedFile().getPath());
                            }
                        } else
                            JOptionPane.showMessageDialog(mainWindow, "Could not save file", "File Error",
                                    JOptionPane.ERROR_MESSAGE);
                    }
            } else {
                JOptionPane.showMessageDialog(mainWindow, "Nothing to Save", "Existetial Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    saveAser.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            for (ActionListener a : saveAs.getActionListeners()) {
                a.actionPerformed(ae);
            }
        }
    });

    //loads a net
    load.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            int result;
            boolean test = true;
            String tempName;
            result = getNet.showOpenDialog(mainWindow);
            if (result == JFileChooser.APPROVE_OPTION) {
                tempName = getNet.getSelectedFile().getName();
                for (StringBuffer names : netName) {
                    if (names.toString().equals(tempName))
                        test = false;
                }
                if (test != false) {
                    //creates and sets the network configuration
                    if (tempName.endsWith(".ffn")) {
                        net.add(new FullyConnectedFeedForwardNet());
                    }
                    if (tempName.endsWith(".som")) {
                        net.add(new SelfOrganizingMap());
                    }
                    if (net.get(openNets).load(getNet.getSelectedFile()))
                        try {
                            //adds a close button to the top corner of each tab
                            title.add(new JLabel(tempName + " "));
                            close.add(new JButton("X"));
                            close.get(openNets).setActionCommand(tempName);
                            close.get(openNets)
                                    .setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
                            close.get(openNets).setMargin(new Insets(0, 0, 0, 0));
                            tabPanel.add(new JPanel(new GridBagLayout()));
                            tabPanel.get(openNets).setOpaque(false);
                            GridBagConstraints grid = new GridBagConstraints();
                            grid.fill = GridBagConstraints.HORIZONTAL;
                            grid.gridx = 0;
                            grid.gridy = 0;
                            grid.weightx = 1;
                            tabPanel.get(openNets).add(title.get(openNets), grid);
                            grid.gridx = 1;
                            grid.gridy = 0;
                            grid.weightx = 0;
                            tabPanel.get(openNets).add(close.get(openNets), grid);

                            //adds a loading bar
                            loadingBar.add(new JLabel("", loadingImage, SwingConstants.CENTER));
                            loadingBar.get(openNets).setHorizontalTextPosition(SwingConstants.LEFT);
                            loadingBar.get(openNets).setVisible(false);

                            path.add(getNet.getSelectedFile().getPath());

                            netKind.add(new StringBuffer(netType.getSelectedItem().toString()));
                            netName.add(new StringBuffer(tempName));
                            oneNet.add(new JPanel());
                            oneNet.get(openNets).setLayout(new GridBagLayout());
                            GridBagConstraints constraints = new GridBagConstraints();
                            constraints.fill = GridBagConstraints.BOTH;

                            //creates the readOut space and formats it so that the scroll pane/text changes size with the window, reserves space for the loading bar
                            readOut.add(new JTextArea(""));
                            readOutLocale.add(new JScrollPane(readOut.get(openNets)));
                            readOut.get(openNets).setEditable(false);
                            constraints.gridx = 0;
                            constraints.gridy = 0;
                            constraints.weighty = 1.0;
                            constraints.weightx = 1.0;
                            constraints.gridwidth = 2;
                            constraints.ipady = 90;
                            oneNet.get(openNets).add(readOutLocale.get(openNets), constraints);
                            constraints.fill = GridBagConstraints.HORIZONTAL;
                            constraints.gridx = 0;
                            constraints.gridy = 1;
                            constraints.ipady = 0;
                            constraints.gridwidth = 2;
                            constraints.anchor = GridBagConstraints.PAGE_END;

                            //add everythign to the tabbed pane
                            oneNet.get(openNets).add(loadingBar.get(openNets), constraints);
                            resultsPane.addTab(netName.get(openNets).toString(), oneNet.get(openNets));
                            resultsPane.setTabComponentAt(openNets, tabPanel.get(openNets));

                            //display the starting configuration of the network
                            readOut.get(openNets).append("Network: " + netName.get(openNets) + "\n\n");
                            resultsPane.setSelectedIndex(openNets++);
                            if (tempName.endsWith(".ffn"))
                                printConnections();
                            if (tempName.endsWith(".som")) {
                                readOut.get(resultsPane.getSelectedIndex()).append("\nUpdated Map:\n");
                                printInitMap();
                            }

                            //unfortunately difficult way that I made to add the close button functionality to close a tab
                            //it works, but there has to be a better way to do this
                            close.get(resultsPane.getSelectedIndex()).addActionListener(new ActionListener() {
                                public void actionPerformed(final ActionEvent ae) {
                                    int result;
                                    result = 0;
                                    for (StringBuffer names : netName) {
                                        if (ae.getActionCommand().equals(names.toString())) {
                                            result = JOptionPane.showConfirmDialog(createFFN,
                                                    "<html>Exiting Without Saving can Cause you to Lose your Progress<br>Are you sure you want to Continue?</html>",
                                                    "Close Network", JOptionPane.OK_CANCEL_OPTION);
                                            resultsPane.setSelectedIndex(netName.indexOf(names));
                                        }
                                    }
                                    if (result == JOptionPane.OK_OPTION) {
                                        net.remove(resultsPane.getSelectedIndex());
                                        oneNet.remove(resultsPane.getSelectedIndex());
                                        readOutLocale.remove(resultsPane.getSelectedIndex());
                                        readOut.remove(resultsPane.getSelectedIndex());
                                        loadingBar.remove(resultsPane.getSelectedIndex());
                                        tabPanel.remove(resultsPane.getSelectedIndex());
                                        title.remove(resultsPane.getSelectedIndex());
                                        close.remove(resultsPane.getSelectedIndex());
                                        netName.remove(resultsPane.getSelectedIndex());
                                        resultsPane.remove(resultsPane.getSelectedIndex());
                                        openNets--;
                                    }
                                }
                            });
                        } catch (Error e) {
                            JOptionPane.showMessageDialog(mainWindow, "File Formatted Incorrectly",
                                    "Formatting Error", JOptionPane.ERROR_MESSAGE);
                        }
                    else {
                        //if file was unable to load, remove the newly created neural network and display an error message
                        net.remove(openNets);
                        JOptionPane.showMessageDialog(mainWindow, "File Formatted Incorrectly",
                                "Formatting Error", JOptionPane.ERROR_MESSAGE);
                    }
                }

                else {
                    JOptionPane.showMessageDialog(mainWindow, "File Already Open", "Duality Error",
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    });

    //associates the load toolbar button with load from the file menu
    loader.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            for (ActionListener a : load.getActionListeners())
                a.actionPerformed(ae);
        }
    });

    textFileChooser = new JFileChooser();
    textFileChooser.setFileFilter(new TextFileFilter());

    //exports all text from readout to a text file
    exportOutput.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (resultsPane.getTabCount() != 0) {
                int result;
                result = textFileChooser.showSaveDialog(mainWindow);
                if (result == JFileChooser.APPROVE_OPTION) {
                    if (textFileChooser.getSelectedFile().exists()
                            || (new File(textFileChooser.getSelectedFile().getPath() + ".txt")).exists()) {
                        result = JOptionPane.showConfirmDialog(mainWindow,
                                "The File you have selected already Exists, do you want to Overwrite it?",
                                "File Exits", JOptionPane.YES_NO_OPTION);
                        if (result == JOptionPane.YES_OPTION) {
                            try {
                                if (textFileChooser.getSelectedFile().getPath().endsWith(".txt"))
                                    FileUtils.writeStringToFile(textFileChooser.getSelectedFile(),
                                            readOut.get(resultsPane.getSelectedIndex()).getText());
                                else
                                    FileUtils.writeStringToFile(
                                            new File(textFileChooser.getSelectedFile().getPath() + ".txt"),
                                            readOut.get(resultsPane.getSelectedIndex()).getText());
                                JOptionPane.showMessageDialog(mainWindow, "Succesfully wrote readout to file");
                            } catch (Exception e) {
                                JOptionPane.showMessageDialog(mainWindow, "Could not write to file", "Error",
                                        JOptionPane.ERROR_MESSAGE);
                            }
                        }
                    } else {
                        try {
                            if (textFileChooser.getSelectedFile().getPath().endsWith(".txt"))
                                FileUtils.writeStringToFile(textFileChooser.getSelectedFile(),
                                        readOut.get(resultsPane.getSelectedIndex()).getText());
                            else
                                FileUtils.writeStringToFile(
                                        new File(textFileChooser.getSelectedFile().getPath() + ".txt"),
                                        readOut.get(resultsPane.getSelectedIndex()).getText());
                            JOptionPane.showMessageDialog(mainWindow, "Succesfully wrote readout to file");
                        } catch (Exception e) {
                            JOptionPane.showMessageDialog(mainWindow, "Could not write to file", "Error",
                                    JOptionPane.ERROR_MESSAGE);
                        }
                    }
                }
            } else {
                JOptionPane.showMessageDialog(mainWindow, "Nothing to Export", "Existential Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    projectFileChooser = new JFileChooser();
    projectFileChooser.setFileFilter(new ProjectFileFilter());

    //exports a neural network to a java/android project
    exportNet.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            int result, override, override2;
            String tempName;
            String templateFile;
            String directory;
            String path;
            if (resultsPane.getTabCount() != 0) {
                result = projectFileChooser.showSaveDialog(mainWindow);
                if (result == JFileChooser.APPROVE_OPTION) {
                    path = projectFileChooser.getSelectedFile().getPath();
                    directory = projectFileChooser.getSelectedFile().getPath().substring(0,
                            projectFileChooser.getSelectedFile().getPath().lastIndexOf(File.separator));
                    tempName = projectFileChooser.getSelectedFile().getName();
                    if (projectFileChooser.getSelectedFile().exists()
                            || (new File(directory, tempName + ".java")).exists()) {
                        override = JOptionPane.showConfirmDialog(mainWindow,
                                "Java Class File" + tempName + " already exists, do you want to overwrite it?",
                                "File Exists", JOptionPane.YES_NO_OPTION);
                        if (override == JOptionPane.YES_OPTION) {
                            try {
                                if (!(new File(directory, "ann")).exists())
                                    FileUtils.copyDirectoryToDirectory(
                                            FileUtils.toFile(ClassLoader.getSystemResource("ann/")),
                                            new File(directory));
                                if (netKind.get(resultsPane.getSelectedIndex()).toString()
                                        .equals("Feed Forward Network")) {
                                    templateFile = FileUtils.readFileToString(FileUtils
                                            .toFile(ClassLoader.getSystemResource("ann/FFNTemplate.txt")));
                                    templateFile = templateFile.replaceAll("yourpackagename",
                                            (new File(directory)).getName());
                                    templateFile = templateFile.replaceAll("YourProjectName",
                                            projectFileChooser.getSelectedFile().getName());
                                    if (netName.get(resultsPane.getSelectedIndex()).toString().endsWith(".ffn"))
                                        templateFile = templateFile.replaceAll("networkName",
                                                (new File(directory)).getName() + File.separator + netName
                                                        .get(resultsPane.getSelectedIndex()).toString());
                                    else
                                        templateFile = templateFile.replaceAll("networkName",
                                                (new File(directory)).getName() + File.separator
                                                        + netName.get(resultsPane.getSelectedIndex()).toString()
                                                        + ".ffn");
                                    if (path.indexOf('.') > 0) {
                                        FileUtils.writeStringToFile(
                                                new File(path.substring(0, path.lastIndexOf('.')) + ".java"),
                                                templateFile);
                                    } else
                                        FileUtils.writeStringToFile(new File(path + ".java"), templateFile);
                                    if ((new File(directory,
                                            (tempName = netName.get(resultsPane.getSelectedIndex())
                                                    .toString()))).exists()
                                            || (new File(directory, tempName + ".ffn")).exists()) {
                                        override2 = JOptionPane.showConfirmDialog(mainWindow,
                                                "Neural Network " + tempName
                                                        + " already exists, do you want to overwrite it?",
                                                "File Exists", JOptionPane.YES_NO_OPTION);
                                        if (override2 == JOptionPane.YES_OPTION)
                                            if (net.get(resultsPane.getSelectedIndex())
                                                    .save(new File(directory + File.separator + tempName))) {
                                                JOptionPane.showMessageDialog(mainWindow, "Network Exported to "
                                                        + (new File(directory)).getName());
                                            } else {
                                                JOptionPane.showMessageDialog(mainWindow,
                                                        "Couldn't save neural network to file, the rest of the project is exported",
                                                        "Write Error", JOptionPane.ERROR_MESSAGE);
                                            }
                                    } else {
                                        if (net.get(resultsPane.getSelectedIndex())
                                                .save(new File(directory + File.separator + tempName))) {
                                            JOptionPane.showMessageDialog(mainWindow,
                                                    "Network Exported to " + (new File(directory)).getName());
                                        } else {
                                            JOptionPane.showMessageDialog(mainWindow,
                                                    "Couldn't save neural network to file, the rest of the project is exported",
                                                    "Write Error", JOptionPane.ERROR_MESSAGE);
                                        }
                                    }
                                } else if (netKind.get(resultsPane.getSelectedIndex()).toString()
                                        .equals("Self-Organizing Map")) {
                                    templateFile = FileUtils.readFileToString(FileUtils
                                            .toFile(ClassLoader.getSystemResource("ann/SOMTemplate.txt")));
                                    templateFile = templateFile.replaceAll("yourpackagename",
                                            (new File(directory)).getName());
                                    templateFile = templateFile.replaceAll("YourProjectName",
                                            projectFileChooser.getSelectedFile().getName());
                                    if (netName.get(resultsPane.getSelectedIndex()).toString().endsWith(".som"))
                                        templateFile = templateFile.replaceAll("networkName",
                                                (new File(directory)).getName() + File.separator + netName
                                                        .get(resultsPane.getSelectedIndex()).toString());
                                    else
                                        templateFile = templateFile.replaceAll("networkName",
                                                (new File(directory)).getName() + File.separator
                                                        + netName.get(resultsPane.getSelectedIndex()).toString()
                                                        + ".som");
                                    if (path.indexOf('.') > 0) {
                                        FileUtils.writeStringToFile(
                                                new File(path.substring(0, path.lastIndexOf('.')) + ".java"),
                                                templateFile);
                                    } else
                                        FileUtils.writeStringToFile(new File(path + ".java"), templateFile);
                                    if ((new File(directory,
                                            (tempName = netName.get(resultsPane.getSelectedIndex())
                                                    .toString()))).exists()
                                            || (new File(directory, tempName + ".som")).exists()) {
                                        override2 = JOptionPane.showConfirmDialog(mainWindow,
                                                "Neural Network " + tempName
                                                        + " already exists, do you want to overwrite it?",
                                                "File Exists", JOptionPane.YES_NO_OPTION);
                                        if (override2 == JOptionPane.YES_OPTION)
                                            if (net.get(resultsPane.getSelectedIndex())
                                                    .save(new File(directory + File.separator + tempName))) {
                                                JOptionPane.showMessageDialog(mainWindow, "Network Exported to "
                                                        + (new File(directory)).getName());
                                            } else {
                                                JOptionPane.showMessageDialog(mainWindow,
                                                        "Couldn't save neural network to file, the rest of the project is exported",
                                                        "Write Error", JOptionPane.ERROR_MESSAGE);
                                            }
                                    } else {
                                        if (net.get(resultsPane.getSelectedIndex())
                                                .save(new File(directory + File.separator + tempName))) {
                                            JOptionPane.showMessageDialog(mainWindow,
                                                    "Network Exported to " + (new File(directory)).getName());
                                        } else {
                                            JOptionPane.showMessageDialog(mainWindow,
                                                    "Couldn't save neural network to file, the rest of the project is exported",
                                                    "Write Error", JOptionPane.ERROR_MESSAGE);
                                        }
                                    }
                                }
                            } catch (IOException io) {
                                System.out.println(io);
                            }

                        }
                    } else {
                        try {
                            if (!(new File(directory, "ann")).exists())
                                FileUtils.copyDirectoryToDirectory(
                                        FileUtils.toFile(ClassLoader.getSystemResource("ann/")),
                                        new File(directory));
                            if (netKind.get(resultsPane.getSelectedIndex()).toString()
                                    .equals("Feed Forward Network")) {
                                templateFile = FileUtils.readFileToString(
                                        FileUtils.toFile(ClassLoader.getSystemResource("ann/FFNTemplate.txt")));
                                templateFile = templateFile.replaceAll("yourpackagename",
                                        (new File(directory)).getName());
                                templateFile = templateFile.replaceAll("YourProjectName",
                                        projectFileChooser.getSelectedFile().getName());
                                if (netName.get(resultsPane.getSelectedIndex()).toString().endsWith(".ffn"))
                                    templateFile = templateFile.replaceAll("networkName",
                                            (new File(directory)).getName() + File.separator
                                                    + netName.get(resultsPane.getSelectedIndex()).toString());
                                else
                                    templateFile = templateFile.replaceAll("networkName",
                                            (new File(directory)).getName() + File.separator
                                                    + netName.get(resultsPane.getSelectedIndex()).toString()
                                                    + ".ffn");
                                if (path.indexOf('.') > 0) {
                                    FileUtils.writeStringToFile(
                                            new File(path.substring(0, path.lastIndexOf('.')) + ".java"),
                                            templateFile);
                                } else
                                    FileUtils.writeStringToFile(new File(path + ".java"), templateFile);
                                if ((new File(directory + File.separator
                                        + (tempName = netName.get(resultsPane.getSelectedIndex()).toString())))
                                                .exists()
                                        || (new File(directory + File.separator + tempName + ".ffn"))
                                                .exists()) {
                                    override2 = JOptionPane.showConfirmDialog(mainWindow,
                                            "Neural Network " + tempName
                                                    + " already exists, do you want to overwrite it?",
                                            "File Exists", JOptionPane.YES_NO_OPTION);
                                    if (override2 == JOptionPane.YES_OPTION)
                                        if (net.get(resultsPane.getSelectedIndex())
                                                .save(new File(directory + File.separator + tempName))) {
                                            JOptionPane.showMessageDialog(mainWindow,
                                                    "Network Exported to " + (new File(directory)).getName());
                                        } else {
                                            JOptionPane.showMessageDialog(mainWindow,
                                                    "Couldn't save neural network to file, the rest of the project is exported",
                                                    "Write Error", JOptionPane.ERROR_MESSAGE);
                                        }
                                } else {
                                    if (net.get(resultsPane.getSelectedIndex())
                                            .save(new File(directory + File.separator + tempName))) {
                                        JOptionPane.showMessageDialog(mainWindow,
                                                "Network Exported to " + (new File(directory)).getName());
                                    } else {
                                        JOptionPane.showMessageDialog(mainWindow,
                                                "Couldn't save neural network to file, the rest of the project is exported",
                                                "Write Error", JOptionPane.ERROR_MESSAGE);
                                    }
                                }
                            } else if (netKind.get(resultsPane.getSelectedIndex()).toString()
                                    .equals("Self-Organizing Map")) {
                                templateFile = FileUtils.readFileToString(
                                        FileUtils.toFile(ClassLoader.getSystemResource("ann/SOMTemplate.txt")));
                                templateFile = templateFile.replaceAll("yourpackagename",
                                        (new File(directory)).getName());
                                templateFile = templateFile.replaceAll("YourProjectName",
                                        projectFileChooser.getSelectedFile().getName());
                                if (netName.get(resultsPane.getSelectedIndex()).toString().endsWith(".som"))
                                    templateFile = templateFile.replaceAll("networkName",
                                            (new File(directory)).getName() + File.separator
                                                    + netName.get(resultsPane.getSelectedIndex()).toString());
                                else
                                    templateFile = templateFile.replaceAll("networkName",
                                            (new File(directory)).getName() + File.separator
                                                    + netName.get(resultsPane.getSelectedIndex()).toString()
                                                    + ".som");
                                if (path.indexOf('.') > 0) {
                                    FileUtils.writeStringToFile(
                                            new File(path.substring(0, path.lastIndexOf('.')) + ".java"),
                                            templateFile);
                                } else
                                    FileUtils.writeStringToFile(new File(path + ".java"), templateFile);
                                if ((new File(directory,
                                        (tempName = netName.get(resultsPane.getSelectedIndex()).toString())))
                                                .exists()
                                        || (new File(directory, tempName + ".som")).exists()) {
                                    override2 = JOptionPane.showConfirmDialog(mainWindow,
                                            "Neural Network " + tempName
                                                    + " already exists, do you want to overwrite it?",
                                            "File Exists", JOptionPane.YES_NO_OPTION);
                                    if (override2 == JOptionPane.YES_OPTION)
                                        if (net.get(resultsPane.getSelectedIndex())
                                                .save(new File(directory + File.separator + tempName))) {
                                            JOptionPane.showMessageDialog(mainWindow,
                                                    "Network Exported to " + (new File(directory)).getName());
                                        } else {
                                            JOptionPane.showMessageDialog(mainWindow,
                                                    "Couldn't save neural network to file, the rest of the project is exported",
                                                    "Write Error", JOptionPane.ERROR_MESSAGE);
                                        }
                                } else {
                                    if (net.get(resultsPane.getSelectedIndex())
                                            .save(new File(directory + File.separator + tempName))) {
                                        JOptionPane.showMessageDialog(mainWindow,
                                                "Network Exported to " + (new File(directory)).getName());
                                    } else {
                                        JOptionPane.showMessageDialog(mainWindow,
                                                "Couldn't save neural network to file, the rest of the project is exported",
                                                "Write Error", JOptionPane.ERROR_MESSAGE);
                                    }
                                }
                            }
                        } catch (IOException io) {
                            System.out.println(io);
                        }
                    }
                }
            } else {
                JOptionPane.showMessageDialog(mainWindow, "Can't Export NonExistent Neural Network",
                        "Existential Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    toJava.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            for (ActionListener a : exportNet.getActionListeners())
                a.actionPerformed(ae);
        }
    });

    //settings menu
    changeConfig.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (resultsPane.getTabCount() != 0
                    && netKind.get(resultsPane.getSelectedIndex()).toString().equals("Feed Forward Network")) {

                modifyFFNDialog = new JDialog(mainWindow, "Network Settings", true);
                modifyFFNDialog.setSize(500, 500);
                modifyFFNDialog.setLayout(new GridBagLayout());
                GridBagConstraints asdf = new GridBagConstraints();
                asdf.gridwidth = 5;
                asdf.gridheight = 1;
                asdf.gridx = 0;
                asdf.gridy = 0;
                asdf.fill = GridBagConstraints.HORIZONTAL;
                modifyFFNDialog.add(new JSeparator(), asdf);
                asdf.gridwidth = 5;
                asdf.gridheight = 15;
                asdf.weightx = 1.0;
                asdf.weighty = 1.0;
                asdf.gridx = 0;
                asdf.gridy = 1;
                asdf.fill = GridBagConstraints.BOTH;
                settings = new JTextArea();
                settings.setEditable(false);
                settings.setBorder(BorderFactory.createEtchedBorder());
                modifyFFNDialog.add(settings, asdf);
                asdf.fill = GridBagConstraints.HORIZONTAL;
                asdf.gridwidth = 5;
                asdf.gridheight = 1;
                asdf.gridx = 0;
                asdf.gridy = 16;
                modifyFFNDialog.add(new JSeparator(), asdf);
                asdf.gridwidth = 2;
                asdf.gridx = 7;
                asdf.gridy = 0;
                modifyFFNDialog.add(new JSeparator(), asdf);
                asdf.fill = GridBagConstraints.NONE;
                asdf.gridx = 7;
                asdf.gridy = 1;
                learningRateL = new JLabel("Set Learning Rate:");
                modifyFFNDialog.add(learningRateL, asdf);
                asdf.gridx = 7;
                asdf.gridy = 2;
                asdf.fill = GridBagConstraints.HORIZONTAL;
                learningRateTF = new JFormattedTextField(new NumberFormatter(NumberFormat.getNumberInstance()));
                learningRateTF.setText("");
                modifyFFNDialog.add(learningRateTF, asdf);
                asdf.fill = GridBagConstraints.NONE;
                asdf.gridx = 7;
                asdf.gridy = 3;
                momentumL = new JLabel("Set Momentum:");
                modifyFFNDialog.add(momentumL, asdf);
                asdf.gridx = 7;
                asdf.gridy = 4;
                asdf.fill = GridBagConstraints.HORIZONTAL;
                momentumTF = new JFormattedTextField(new NumberFormatter(NumberFormat.getNumberInstance()));
                momentumTF.setText("");
                modifyFFNDialog.add(momentumTF, asdf);
                asdf.gridx = 7;
                asdf.gridy = 5;
                modifyFFNDialog.add(new JSeparator(), asdf);
                asdf.fill = GridBagConstraints.NONE;
                /*asdf.gridwidth = 2;
                asdf.gridheight = 1;
                asdf.gridx = 7;
                asdf.gridy = 6;
                setNoise = new JLabel("Use Noise: ");
                modifyFFNDialog.add(setNoise, asdf);
                asdf.gridx = 7;
                asdf.gridy = 7;
                asdf.gridwidth = 1;
                noiseOn = new JRadioButton("yes");
                noiseOff = new JRadioButton("no");
                noiseGroup = new ButtonGroup();
                noiseGroup.add(noiseOn);
                noiseGroup.add(noiseOff);
                modifyFFNDialog.add(noiseOn,asdf);
                asdf.gridx = 8;
                asdf.gridy = 7;
                modifyFFNDialog.add(noiseOff,asdf);
                asdf.gridx = 7;
                asdf.gridy = 8;
                asdf.gridwidth = 2;
                setNoiseRange = new JButton("Set Noise Range");
                modifyFFNDialog.add(setNoiseRange,asdf);
                asdf.gridx = 7;
                asdf.gridy = 9;
                setNoiseTiming = new JButton("Set Noise Timing");
                modifyFFNDialog.add(setNoiseTiming,asdf);*/
                asdf.gridx = 7;
                asdf.gridy = 10;
                asdf.fill = GridBagConstraints.HORIZONTAL;
                modifyFFNDialog.add(new JSeparator(), asdf);
                asdf.fill = GridBagConstraints.NONE;
                asdf.gridx = 7;
                asdf.gridy = 11;
                setTrainingStyle = new JLabel("Set Training Style:");
                modifyFFNDialog.add(setTrainingStyle, asdf);
                asdf.gridx = 7;
                asdf.gridy = 12;
                asdf.gridwidth = 1;
                batchOn = new JRadioButton("batch");
                onlineOn = new JRadioButton("online");
                batchGroup = new ButtonGroup();
                batchGroup.add(batchOn);
                batchGroup.add(onlineOn);
                modifyFFNDialog.add(batchOn, asdf);
                asdf.gridx = 8;
                modifyFFNDialog.add(onlineOn, asdf);
                asdf.gridx = 7;
                asdf.gridy = 13;
                asdf.gridwidth = 2;
                asdf.fill = GridBagConstraints.HORIZONTAL;
                modifyFFNDialog.add(new JSeparator(), asdf);
                asdf.fill = GridBagConstraints.NONE;
                asdf.gridx = 7;
                asdf.gridy = 14;
                modifyBiases = new JButton("Modify Biases");
                modifyFFNDialog.add(modifyBiases, asdf);
                asdf.gridx = 7;
                asdf.gridy = 15;
                trainingCompletionButton = new JButton("Modify End Condition");
                modifyFFNDialog.add(trainingCompletionButton, asdf);
                asdf.fill = GridBagConstraints.HORIZONTAL;
                asdf.gridy = 16;
                modifyFFNDialog.add(new JSeparator(), asdf);
                asdf.fill = GridBagConstraints.NONE;
                asdf.gridwidth = 1;
                asdf.gridx = 3;
                asdf.gridy = 17;
                asdf.anchor = GridBagConstraints.PAGE_END;
                modifyFFN = new JButton("OK");
                modifyFFNDialog.add(modifyFFN, asdf);
                asdf.gridx = 7;
                cancelModifyFFN = new JButton("Cancel");
                modifyFFNDialog.add(cancelModifyFFN, asdf);
                settings.setText("");
                settings.append(
                        "\n\n\n\nLearning Rate: " + net.get(resultsPane.getSelectedIndex()).getLearningRate());
                settings.append("\n\nMomentum: " + net.get(resultsPane.getSelectedIndex()).getMomentum());
                settings.append("\n\nTraining Style: ");
                if (net.get(resultsPane.getSelectedIndex()).getBatchvOnline()) {
                    settings.append("batch");
                    batchOn.setSelected(true);
                } else {
                    settings.append("online");
                    onlineOn.setSelected(true);
                }
                settings.append("\n\nTraining End Condition: ");
                if (net.get(resultsPane.getSelectedIndex()).getUseIteration()) {
                    settings.append("Iterative");
                    settings.append(
                            "\n\nIterations: " + net.get(resultsPane.getSelectedIndex()).getIterations());
                } else {
                    settings.append("Ideal Error");
                    settings.append(
                            "\n\nIdeal Error: " + net.get(resultsPane.getSelectedIndex()).getIdealError());
                }

                //expiremental feature, needs work on the back end to be properly implemented   
                modifyBiases.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        JButton addBiases, removeBiases;

                        biasesDialog = new JDialog(modifyFFNDialog, "Set Biases");
                        biasesDialog.setSize(200, 46);
                        biasesDialog.setLayout(new GridLayout(2, 1));
                        addBiases = new JButton("Add Bias");
                        removeBiases = new JButton("Remove Bias");

                        biasesDialog.add(addBiases);
                        biasesDialog.add(removeBiases);

                        addBiases.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent ae) {
                                JLabel howManyBiasLayersLabel, whatBiasNodeLabel, whatBiasValueLabel;
                                final JFormattedTextField howManyBiasLayers, whatBiasNode, whatBiasValue;
                                JButton addBiasOK, addBiasCancel;
                                biasesDialog.setVisible(false);
                                addBiasDialog = new JDialog(modifyFFNDialog, "Add Bias");
                                addBiasDialog.setSize(756, 90);
                                addBiasDialog.setLayout(new GridLayout(4, 2));
                                howManyBiasLayersLabel = new JLabel("What Layer will get the Bias?");
                                howManyBiasLayers = new JFormattedTextField(
                                        new NumberFormatter(NumberFormat.getIntegerInstance()));
                                whatBiasNodeLabel = new JLabel("Which Node will get the Bias?");
                                whatBiasNode = new JFormattedTextField(
                                        new NumberFormatter(NumberFormat.getIntegerInstance()));
                                whatBiasValueLabel = new JLabel("What Value will the Bias have?");
                                whatBiasValue = new JFormattedTextField(
                                        new NumberFormatter(NumberFormat.getInstance()));
                                addBiasOK = new JButton("OK");
                                addBiasCancel = new JButton("Cancel");
                                addBiasDialog.add(howManyBiasLayersLabel);
                                addBiasDialog.add(howManyBiasLayers);
                                addBiasDialog.add(whatBiasNodeLabel);
                                addBiasDialog.add(whatBiasNode);
                                addBiasDialog.add(whatBiasValueLabel);
                                addBiasDialog.add(whatBiasValue);
                                addBiasDialog.add(addBiasOK);
                                addBiasDialog.add(addBiasCancel);

                                addBiasOK.addActionListener(new ActionListener() {
                                    public void actionPerformed(ActionEvent ae) {
                                        if (!howManyBiasLayers.getText().equals("")
                                                && !whatBiasNode.getText().equals("")
                                                && !whatBiasValue.getText().equals("")) {
                                            addBiasDialog.setVisible(false);
                                            if (net.get(resultsPane.getSelectedIndex()).addBias(
                                                    Integer.parseInt(howManyBiasLayers.getText()) - 1,
                                                    Integer.parseInt(whatBiasNode.getText()) - 1,
                                                    Double.parseDouble(whatBiasValue.getText()))) {
                                            } else {
                                                JOptionPane.showMessageDialog(modifyFFNDialog,
                                                        "Existential Error", "Invalid Node for Bias",
                                                        JOptionPane.ERROR_MESSAGE);
                                            }
                                        } else {
                                            JOptionPane.showMessageDialog(modifyFFNDialog, "Form Error",
                                                    "Form not completed", JOptionPane.ERROR_MESSAGE);
                                        }
                                    }
                                });
                                addBiasCancel.addActionListener(new ActionListener() {
                                    public void actionPerformed(ActionEvent ae) {
                                        addBiasDialog.setVisible(false);
                                    }
                                });

                                addBiasDialog.setVisible(true);
                            }
                        });

                        removeBiases.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent ae) {
                                JLabel howManyBiasLayersLabel, whatBiasNodeLabel;
                                final JFormattedTextField howManyBiasLayers, whatBiasNode;
                                JButton addBiasOK, addBiasCancel;
                                biasesDialog.setVisible(false);
                                removeBiasDialog = new JDialog(modifyFFNDialog, "Remove Bias");
                                removeBiasDialog.setSize(756, 90);
                                removeBiasDialog.setLayout(new GridLayout(3, 2));
                                howManyBiasLayersLabel = new JLabel("What Layer will lose the Bias?");
                                howManyBiasLayers = new JFormattedTextField(
                                        new NumberFormatter(NumberFormat.getIntegerInstance()));
                                whatBiasNodeLabel = new JLabel("Which Node will get the Bias?");
                                whatBiasNode = new JFormattedTextField(
                                        new NumberFormatter(NumberFormat.getIntegerInstance()));
                                addBiasOK = new JButton("OK");
                                addBiasCancel = new JButton("Cancel");
                                removeBiasDialog.add(howManyBiasLayersLabel);
                                removeBiasDialog.add(howManyBiasLayers);
                                removeBiasDialog.add(whatBiasNodeLabel);
                                removeBiasDialog.add(whatBiasNode);
                                removeBiasDialog.add(addBiasOK);
                                removeBiasDialog.add(addBiasCancel);

                                addBiasOK.addActionListener(new ActionListener() {
                                    public void actionPerformed(ActionEvent ae) {
                                        if (!howManyBiasLayers.getText().equals("")
                                                && !whatBiasNode.getText().equals("")) {
                                            addBiasDialog.setVisible(false);
                                            if (net.get(resultsPane.getSelectedIndex()).removeBias(
                                                    Integer.parseInt(howManyBiasLayers.getText()) - 1,
                                                    Integer.parseInt(whatBiasNode.getText()) - 1)) {
                                            } else {
                                                JOptionPane.showMessageDialog(modifyFFNDialog,
                                                        "Existential Error", "Invalid Node for Bias",
                                                        JOptionPane.ERROR_MESSAGE);
                                            }
                                        } else {
                                            JOptionPane.showMessageDialog(modifyFFNDialog, "Form Error",
                                                    "Form not completed", JOptionPane.ERROR_MESSAGE);
                                        }
                                    }
                                });
                                addBiasCancel.addActionListener(new ActionListener() {
                                    public void actionPerformed(ActionEvent ae) {
                                        addBiasDialog.setVisible(false);
                                    }
                                });

                                removeBiasDialog.setVisible(true);
                            }
                        });

                        biasesDialog.setVisible(true);

                    }
                });

                trainingCompletionButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        final JDialog iterationsDialog;
                        JLabel numberOfIterationsLabel;
                        final JFormattedTextField numberOfIterations;
                        JButton iterationsOK, iterationsCancel;
                        iterationsDialog = new JDialog(modifyFFNDialog, "Set Iterations");
                        iterationsDialog.setSize(765, 75);
                        iterationsDialog.setLayout(new GridLayout(2, 2));
                        numberOfIterationsLabel = new JLabel("How Many Iterations do you want to Train?");
                        numberOfIterations = new JFormattedTextField(
                                new NumberFormatter(NumberFormat.getIntegerInstance()));
                        iterationsOK = new JButton("OK");
                        iterationsCancel = new JButton("Cancel");
                        iterationsDialog.add(numberOfIterationsLabel);
                        iterationsDialog.add(numberOfIterations);
                        iterationsDialog.add(iterationsOK);
                        iterationsDialog.add(iterationsCancel);
                        iterationsOK.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent ae) {
                                if (!numberOfIterations.getText().equals("")) {
                                    iterationsDialog.setVisible(false);
                                    if (net.get(resultsPane.getSelectedIndex())
                                            .setIterations(Integer.parseInt(numberOfIterations.getText()))) {
                                        settings.setText("");
                                        settings.append("\n\n\n\nLearning Rate: "
                                                + net.get(resultsPane.getSelectedIndex()).getLearningRate());
                                        settings.append("\n\nMomentum: "
                                                + net.get(resultsPane.getSelectedIndex()).getMomentum());
                                        settings.append("\n\nTraining Style: ");
                                        if (net.get(resultsPane.getSelectedIndex()).getBatchvOnline()) {
                                            settings.append("batch");
                                            batchOn.setSelected(true);
                                        } else {
                                            settings.append("online");
                                            onlineOn.setSelected(true);
                                        }
                                        settings.append("\n\nTraining End Condition: ");
                                        if (net.get(resultsPane.getSelectedIndex()).getUseIteration()) {
                                            settings.append("Iterative");
                                            settings.append("\n\nIterations: "
                                                    + net.get(resultsPane.getSelectedIndex()).getIterations());
                                        } else {
                                            settings.append("Ideal Error");
                                            settings.append("\n\nIdeal Error: "
                                                    + net.get(resultsPane.getSelectedIndex()).getIdealError());
                                        }
                                        modifyFFNDialog.setVisible(true);
                                    } else {
                                        JOptionPane.showMessageDialog(modifyFFNDialog,
                                                "Invalid Number of Iterations", "Math Error",
                                                JOptionPane.ERROR_MESSAGE);
                                    }
                                } else {
                                    JOptionPane.showMessageDialog(iterationsDialog, "Field not filled out",
                                            "Form Error", JOptionPane.ERROR_MESSAGE);
                                }
                            }
                        });
                        iterationsCancel.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent ae) {
                                iterationsDialog.setVisible(false);
                            }
                        });
                        iterationsDialog.setVisible(true);
                    }
                });

                modifyFFN.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        if (!learningRateTF.getText().equals("")) {
                            net.get(resultsPane.getSelectedIndex())
                                    .setLearningRate(Double.parseDouble(learningRateTF.getText()));
                            learningRateTF.setText("");
                        }
                        if (!momentumTF.getText().equals("")) {
                            net.get(resultsPane.getSelectedIndex())
                                    .setMomentum(Double.parseDouble(momentumTF.getText()));
                            momentumTF.setText("");
                        }
                        if (batchOn.isSelected()) {
                            net.get(resultsPane.getSelectedIndex()).setBatchvOnline(true);
                        } else {
                            net.get(resultsPane.getSelectedIndex()).setBatchvOnline(false);
                        }

                        modifyFFNDialog.setVisible(false);
                    }
                });

                learningRateTF.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        if (learningRateTF.getText() != "") {
                            net.get(resultsPane.getSelectedIndex())
                                    .setLearningRate(Double.parseDouble(learningRateTF.getText()));
                        }
                        settings.setText("");
                        settings.append("\n\n\n\nLearning Rate: "
                                + net.get(resultsPane.getSelectedIndex()).getLearningRate());
                        settings.append(
                                "\n\nMomentum: " + net.get(resultsPane.getSelectedIndex()).getMomentum());
                        settings.append("\n\nTraining Style: ");

                        if (net.get(resultsPane.getSelectedIndex()).getBatchvOnline()) {
                            settings.append("batch");
                            batchOn.setSelected(true);
                        } else {
                            settings.append("online");
                            onlineOn.setSelected(true);
                        }
                        settings.append("\n\nTraining End Condition: ");
                        if (net.get(resultsPane.getSelectedIndex()).getUseIteration()) {
                            settings.append("Iterative");
                            settings.append("\n\nIterations: "
                                    + net.get(resultsPane.getSelectedIndex()).getIterations());
                        } else {
                            settings.append("Ideal Error");
                            settings.append("\n\nIdeal Error: "
                                    + net.get(resultsPane.getSelectedIndex()).getIdealError());
                        }
                        modifyFFNDialog.setVisible(true);
                    }
                });
                momentumTF.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        if (momentumTF.getText() != "") {
                            net.get(resultsPane.getSelectedIndex())
                                    .setMomentum(Double.parseDouble(momentumTF.getText()));
                        }
                        settings.setText("");
                        settings.append("\n\n\n\nLearning Rate: "
                                + net.get(resultsPane.getSelectedIndex()).getLearningRate());
                        settings.append(
                                "\n\nMomentum: " + net.get(resultsPane.getSelectedIndex()).getMomentum());
                        settings.append("\n\nTraining Style: ");
                        if (net.get(resultsPane.getSelectedIndex()).getBatchvOnline()) {
                            settings.append("batch");
                            batchOn.setSelected(true);
                        } else {
                            settings.append("online");
                            onlineOn.setSelected(true);
                        }
                        settings.append("\n\nTraining End Condition: ");
                        if (net.get(resultsPane.getSelectedIndex()).getUseIteration()) {
                            settings.append("Iterative");
                            settings.append("\n\nIterations: "
                                    + net.get(resultsPane.getSelectedIndex()).getIterations());
                        } else {
                            settings.append("Ideal Error");
                            settings.append("\n\nIdeal Error: "
                                    + net.get(resultsPane.getSelectedIndex()).getIdealError());
                        }
                        modifyFFNDialog.setVisible(true);
                    }
                });
                cancelModifyFFN.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        modifyFFNDialog.setVisible(false);
                    }
                });
                modifyFFNDialog.setVisible(true);
            }
            if (resultsPane.getTabCount() != 0
                    && netKind.get(resultsPane.getSelectedIndex()).toString().equals("Self-Organizing Map")) {
                modifySOMDialog = new JDialog(mainWindow, "Network Settings", true);
                modifySOMDialog.setSize(500, 400);
                modifySOMDialog.setLayout(new GridBagLayout());
                GridBagConstraints asdf = new GridBagConstraints();
                asdf.gridwidth = 5;
                asdf.gridheight = 1;
                asdf.gridx = 0;
                asdf.gridy = 0;
                asdf.fill = GridBagConstraints.HORIZONTAL;
                modifySOMDialog.add(new JSeparator(), asdf);
                asdf.gridwidth = 5;
                asdf.gridheight = 15;
                asdf.weightx = 1.0;
                asdf.weighty = 1.0;
                asdf.gridx = 0;
                asdf.gridy = 1;
                asdf.fill = GridBagConstraints.BOTH;
                settings = new JTextArea();
                settings.setEditable(false);
                settings.setBorder(BorderFactory.createEtchedBorder());
                modifySOMDialog.add(settings, asdf);
                asdf.fill = GridBagConstraints.HORIZONTAL;
                asdf.gridwidth = 5;
                asdf.gridheight = 1;
                asdf.gridx = 0;
                asdf.gridy = 16;
                modifySOMDialog.add(new JSeparator(), asdf);
                asdf.gridwidth = 2;
                asdf.gridx = 7;
                asdf.gridy = 0;
                modifySOMDialog.add(new JSeparator(), asdf);
                asdf.fill = GridBagConstraints.NONE;
                asdf.gridx = 7;
                asdf.gridy = 1;
                mIterationL = new JLabel("Set Number of Iterations:");
                modifySOMDialog.add(mIterationL, asdf);
                asdf.gridx = 7;
                asdf.gridy = 2;
                asdf.fill = GridBagConstraints.HORIZONTAL;
                mIterationTF = new JFormattedTextField(new NumberFormatter(NumberFormat.getIntegerInstance()));
                mIterationTF.setText("");
                modifySOMDialog.add(mIterationTF, asdf);
                asdf.fill = GridBagConstraints.NONE;
                asdf.gridx = 7;
                asdf.gridy = 3;
                mLRL = new JLabel("Set Learning Rate (0-1):");
                modifySOMDialog.add(mLRL, asdf);
                asdf.gridx = 7;
                asdf.gridy = 4;
                asdf.fill = GridBagConstraints.HORIZONTAL;
                mLRTF = new JFormattedTextField(new NumberFormatter(NumberFormat.getNumberInstance()));
                mLRTF.setText("");
                modifySOMDialog.add(mLRTF, asdf);
                asdf.fill = GridBagConstraints.NONE;
                asdf.gridx = 7;
                asdf.gridy = 5;
                mMaxL = new JLabel("Set Data Maximum:");
                modifySOMDialog.add(mMaxL, asdf);
                asdf.gridx = 7;
                asdf.gridy = 6;
                asdf.fill = GridBagConstraints.HORIZONTAL;
                mMaxTF = new JFormattedTextField(new NumberFormatter(NumberFormat.getNumberInstance()));
                mMaxTF.setText("");
                modifySOMDialog.add(mMaxTF, asdf);
                asdf.fill = GridBagConstraints.NONE;
                asdf.gridx = 7;
                asdf.gridy = 7;
                mMinL = new JLabel("Set Data Minimum:");
                modifySOMDialog.add(mMinL, asdf);
                asdf.gridx = 7;
                asdf.gridy = 8;
                asdf.fill = GridBagConstraints.HORIZONTAL;
                mMinTF = new JFormattedTextField(new NumberFormatter(NumberFormat.getNumberInstance()));
                mMinTF.setText("");
                modifySOMDialog.add(mMinTF, asdf);
                asdf.fill = GridBagConstraints.HORIZONTAL;
                asdf.gridy = 16;
                modifySOMDialog.add(new JSeparator(), asdf);
                asdf.fill = GridBagConstraints.NONE;
                asdf.gridwidth = 1;
                asdf.gridx = 3;
                asdf.gridy = 17;
                asdf.anchor = GridBagConstraints.PAGE_END;
                modifySOM = new JButton("OK");
                modifySOMDialog.add(modifySOM, asdf);
                asdf.gridx = 7;
                cancelModifySOM = new JButton("Cancel");
                modifySOMDialog.add(cancelModifySOM, asdf);
                settings.setText("");
                settings.append("\n\nNumber of Iterations: "
                        + net.get(resultsPane.getSelectedIndex()).getNumIterations());
                settings.append(
                        "\n\nLearning Rate: " + net.get(resultsPane.getSelectedIndex()).getLearningRate());
                settings.append("\n\nData Maximum: " + net.get(resultsPane.getSelectedIndex()).getDataMax());
                settings.append("\n\nData Minimum: " + net.get(resultsPane.getSelectedIndex()).getDataMin());

                mIterationTF.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        if (mIterationTF.getText() != "") {
                            net.get(resultsPane.getSelectedIndex())
                                    .setNumIterations(Integer.parseInt(mIterationTF.getText()));

                            settings.setText("");
                            settings.append("\n\nNumber of Iterations: "
                                    + net.get(resultsPane.getSelectedIndex()).getNumIterations());
                            settings.append("\n\nLearning Rate: "
                                    + net.get(resultsPane.getSelectedIndex()).getLearningRate());
                            settings.append("\n\nData Maximum: "
                                    + net.get(resultsPane.getSelectedIndex()).getDataMax());
                            settings.append("\n\nData Minimum: "
                                    + net.get(resultsPane.getSelectedIndex()).getDataMin());
                        }
                    }
                });

                mLRTF.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        if ((mLRTF.getText() != "") && ((Double.parseDouble(mLRTF.getText())) <= 1.0)) {
                            net.get(resultsPane.getSelectedIndex())
                                    .setLearningRate(Double.parseDouble(mLRTF.getText()));

                            settings.setText("");
                            settings.append("\n\nNumber of Iterations: "
                                    + net.get(resultsPane.getSelectedIndex()).getNumIterations());
                            settings.append("\n\nLearning Rate: "
                                    + net.get(resultsPane.getSelectedIndex()).getLearningRate());
                            settings.append("\n\nData Maximum: "
                                    + net.get(resultsPane.getSelectedIndex()).getDataMax());
                            settings.append("\n\nData Minimum: "
                                    + net.get(resultsPane.getSelectedIndex()).getDataMin());
                        } else {
                            JOptionPane.showMessageDialog(mLRTF, "Pick a number from 0 - 1", "Incorrect Value",
                                    JOptionPane.ERROR_MESSAGE);
                            mLRTF.setText("");
                        }
                    }
                });

                mMaxTF.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        if ((mMaxTF.getText() != "") && (((Double.parseDouble(mMaxTF.getText())) > net
                                .get(resultsPane.getSelectedIndex()).getDataMin()))) {
                            net.get(resultsPane.getSelectedIndex())
                                    .setDataMax(Double.parseDouble(mMaxTF.getText()));

                            settings.setText("");
                            settings.append("\n\nNumber of Iterations: "
                                    + net.get(resultsPane.getSelectedIndex()).getNumIterations());
                            settings.append("\n\nLearning Rate: "
                                    + net.get(resultsPane.getSelectedIndex()).getLearningRate());
                            settings.append("\n\nData Maximum: "
                                    + net.get(resultsPane.getSelectedIndex()).getDataMax());
                            settings.append("\n\nData Minimum: "
                                    + net.get(resultsPane.getSelectedIndex()).getDataMin());
                        } else {
                            JOptionPane.showMessageDialog(mMaxTF, "Max value must be greater than Min value",
                                    "Incorrect Value", JOptionPane.ERROR_MESSAGE);
                            mMaxTF.setText("");
                        }
                    }
                });

                mMinTF.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        if ((mMinTF.getText() != "") && ((Double.parseDouble(mMinTF.getText())) < net
                                .get(resultsPane.getSelectedIndex()).getDataMax())) {
                            net.get(resultsPane.getSelectedIndex())
                                    .setDataMin(Double.parseDouble(mMinTF.getText()));

                            settings.setText("");
                            settings.append("\n\nNumber of Iterations: "
                                    + net.get(resultsPane.getSelectedIndex()).getNumIterations());
                            settings.append("\n\nLearning Rate: "
                                    + net.get(resultsPane.getSelectedIndex()).getLearningRate());
                            settings.append("\n\nData Maximum: "
                                    + net.get(resultsPane.getSelectedIndex()).getDataMax());
                            settings.append("\n\nData Minimum: "
                                    + net.get(resultsPane.getSelectedIndex()).getDataMin());
                        } else {
                            JOptionPane.showMessageDialog(mMinTF, "Min value must be less than Max value",
                                    "Incorrect Value", JOptionPane.ERROR_MESSAGE);
                            mMinTF.setText("");
                        }
                    }
                });

                modifySOM.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        boolean error = false;
                        if (!("".equals(mIterationTF.getText()))) {
                            net.get(resultsPane.getSelectedIndex())
                                    .setNumIterations(Integer.parseInt(mIterationTF.getText()));
                        }
                        if (!("".equals(mLRTF.getText()))) {
                            if ((Double.parseDouble(mLRTF.getText())) > 1.0) {
                                error = true;
                                mLRTF.setText("");
                            } else
                                net.get(resultsPane.getSelectedIndex())
                                        .setLearningRate(Double.parseDouble(mLRTF.getText()));
                        }
                        if (!("".equals(mMaxTF.getText()))) {
                            if (((Double.parseDouble(mMaxTF.getText())) < net
                                    .get(resultsPane.getSelectedIndex()).getDataMin())) {
                                error = true;
                                mMaxTF.setText("");
                            } else
                                net.get(resultsPane.getSelectedIndex())
                                        .setDataMax(Double.parseDouble(mMaxTF.getText()));
                        }
                        if (!("".equals(mMinTF.getText()))) {
                            if ((Double.parseDouble(mMinTF.getText())) > net.get(resultsPane.getSelectedIndex())
                                    .getDataMax()) {
                                error = true;
                                mMinTF.setText("");
                            } else
                                net.get(resultsPane.getSelectedIndex())
                                        .setDataMin(Double.parseDouble(mMinTF.getText()));
                        }

                        if (error == true) {
                            JOptionPane.showMessageDialog(modifySOMDialog,
                                    "One or more fields have incorrect values", "Incorrect Value",
                                    JOptionPane.ERROR_MESSAGE);
                        } else {
                            modifySOMDialog.setVisible(false);
                            readOut.get(resultsPane.getSelectedIndex()).append("\nUpdated Map:\n");
                            printInitMap();
                        }

                    }
                });

                cancelModifySOM.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        modifySOMDialog.setVisible(false);
                    }
                });

                modifySOMDialog.setVisible(true);
            }
        }

    });

    modify.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            for (ActionListener a : changeConfig.getActionListeners()) {
                a.actionPerformed(ae);
            }
        }
    });

    //The following code is for the newNet button under file:

    //create a dialog to be activated when "New Network" is pressed in the file menu
    newDialog = new JDialog(mainWindow, "New Network", true);
    newDialog.setSize(375, 100);
    newDialog.setLayout(new GridLayout(3, 2)); //going to change the layout to GridBagLayout for better customization

    name = new JLabel("Network Name:");
    newName = new JTextField(10);
    type = new JLabel("Type of Network:");
    netTypes = new String[] { "Feed Forward Network", "Self-Organizing Map" };
    netType = new JComboBox<String>(netTypes);
    netType.setSelectedItem("Feed Forward Network");
    createNewNet = new JButton("create");
    cancelNew = new JButton("cancel");
    newDialog.add(name);
    newDialog.add(newName);
    newDialog.add(type);
    newDialog.add(netType);
    newDialog.add(createNewNet);
    newDialog.add(cancelNew);

    //utilities for a second dialog(Feed Forward Network) in the process of creating a new network   
    number = new JLabel("Enter the number of layers you want for your network:");
    howManyLayers = new JFormattedTextField(new NumberFormatter(NumberFormat.getIntegerInstance()));
    createFFNArchitecture = new JButton("OK");
    cancelFFN = new JButton("Cancel");

    howManyNodes = new JFormattedTextField(new NumberFormatter(NumberFormat.getIntegerInstance()));
    createFFN = new JButton("OK");
    cancelNodes = new JButton("Cancel");

    //Written by Michael Scott
    somLattice = new JLabel("   Lattice number for your Map:");
    somLatticeField = new JFormattedTextField(new NumberFormatter(NumberFormat.getIntegerInstance()));
    somLatticeField.setFocusLostBehavior(1);
    somMax = new JLabel("   Maximum value of your input (if known):");
    somMaxField = new JFormattedTextField(new NumberFormatter(NumberFormat.getInstance()));
    somMaxField.setFocusLostBehavior(1);
    somMin = new JLabel("   Minimum value of your input (if known):");
    somMinField = new JFormattedTextField(new NumberFormatter(NumberFormat.getInstance()));
    somMinField.setFocusLostBehavior(1);
    somDim = new JLabel("   Node Dimensions:");
    somDimField = new JFormattedTextField(new NumberFormatter(NumberFormat.getIntegerInstance()));
    somDimField.setFocusLostBehavior(1);
    createSOM = new JButton("OK");
    cancelSOM = new JButton("Cancel");

    //displays the newDialog window when newNet is pressed
    newNet.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {

            newDialog.setVisible(true);
        }
    });

    newwer.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            newDialog.setVisible(true);
        }
    });

    //makes hitting enter in the text box do the same thing as clicking "create"
    newName.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            for (ActionListener a : createNewNet.getActionListeners()) {
                a.actionPerformed(ae);
            }
        }
    });

    //when create net is pressed, this reads the selections from the newNet dialog and creates the approriate next dialog
    createNewNet.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            int test;
            test = 0;
            for (StringBuffer names : netName) {
                if (names.toString().equals(newName.getText()))
                    test = 1;
            }
            if (test == 0)
                if (!newName.getText().equals("")) {
                    if (netType.getSelectedIndex() == 0) { //if the net selected is Feed Forward, create and display the prompt for a feed forward network
                        newDialog.setVisible(false);
                        fFNDialog = new JDialog(mainWindow, newName.getText(), true);
                        fFNDialog.setSize(919, 65);
                        fFNDialog.setLayout(new GridLayout(2, 2));
                        fFNDialog.add(number);
                        fFNDialog.add(howManyLayers);
                        fFNDialog.add(createFFNArchitecture);
                        fFNDialog.add(cancelFFN);
                        fFNDialog.setVisible(true);
                    }
                    //Written by Michael Scott
                    if (netType.getSelectedIndex() == 1) {
                        newDialog.setVisible(false);
                        sOMDialog = new JDialog(mainWindow, newName.getText(), true);
                        sOMDialog.setSize(500, 180);
                        sOMDialog.setLayout(new GridLayout(5, 2));
                        sOMDialog.add(somLattice);
                        sOMDialog.add(somLatticeField);
                        sOMDialog.add(somDim);
                        sOMDialog.add(somDimField);
                        sOMDialog.add(somMax);
                        sOMDialog.add(somMaxField);
                        sOMDialog.add(somMin);
                        sOMDialog.add(somMinField);
                        sOMDialog.add(createSOM);
                        sOMDialog.add(cancelSOM);
                        sOMDialog.setVisible(true);

                    }
                } else
                    JOptionPane.showMessageDialog(createNewNet, "Network must have a Name",
                            "Namelessness Error", JOptionPane.ERROR_MESSAGE);
            else {
                JOptionPane.showMessageDialog(createNewNet, "Network " + newName.getText() + " already exists",
                        "Existential Naming Error", JOptionPane.ERROR_MESSAGE);
                newName.setText("");
            }
        }

    });
    //beginning of section about creating Feed Forward Networks   
    //cancel clears the name field and hides the newDialog dialog
    cancelNew.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            newDialog.setVisible(false);
            newName.setText("");
        }
    });

    //makes hitting enter the same as clicking "ok"
    howManyLayers.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            for (ActionListener a : createFFNArchitecture.getActionListeners()) {
                a.actionPerformed(ae);
            }
        }
    });

    //create a prompt for the first layer to determine how many nodes will go into the first layer
    createFFNArchitecture.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (!howManyLayers.getText().equals("")
                    && (layers = Integer.parseInt(howManyLayers.getText())) > 1) {
                nodeConfiguration = new int[layers]; //create an array to hold the node configuration that will be passed to the Net constructor
                layer = 1; //create a variable to hold the current layer the prompt series is on
                numberofNodes = new JLabel("How many nodes do you want in layer " + layer + "?");
                fFNDialog.setVisible(false);
                howManyNodesDialog = new JDialog(mainWindow, newName.getText(), true);
                howManyNodesDialog.setSize(919, 65);
                howManyNodesDialog.setLayout(new GridLayout(2, 2));
                howManyNodesDialog.add(numberofNodes);
                howManyNodesDialog.add(howManyNodes);
                howManyNodesDialog.add(createFFN);
                howManyNodesDialog.add(cancelNodes);
                howManyNodesDialog.setVisible(true);
            } else {
                //if the string is not valid, pop up an error message
                JOptionPane.showMessageDialog(fFNDialog,
                        "<html>Number Out of Bounds<br>Please Enter a Number Greater than 1</html>",
                        "Out of Bounds", JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    //runs each time ok is pressed, until all the layers have a vaule for the number of nodes in the layer
    createFFN.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (!howManyNodes.getText().equals("")
                    && (nodeConfiguration[layer - 1] = Integer.parseInt(howManyNodes.getText())) > 0) {
                if (layer == layers) {
                    try {
                        //adds a close button to the top corner of each tab
                        title.add(new JLabel(newName.getText() + " "));
                        close.add(new JButton("X"));
                        close.get(openNets).setActionCommand(newName.getText());
                        close.get(openNets).setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
                        close.get(openNets).setMargin(new Insets(0, 0, 0, 0));
                        tabPanel.add(new JPanel(new GridBagLayout()));
                        tabPanel.get(openNets).setOpaque(false);
                        GridBagConstraints grid = new GridBagConstraints();
                        grid.fill = GridBagConstraints.HORIZONTAL;
                        grid.gridx = 0;
                        grid.gridy = 0;
                        grid.weightx = 1;
                        tabPanel.get(openNets).add(title.get(openNets), grid);
                        grid.gridx = 1;
                        grid.gridy = 0;
                        grid.weightx = 0;
                        tabPanel.get(openNets).add(close.get(openNets), grid);

                        //adds a loading bar
                        loadingBar.add(new JLabel("", loadingImage, SwingConstants.CENTER));
                        loadingBar.get(openNets).setHorizontalTextPosition(SwingConstants.LEFT);
                        loadingBar.get(openNets).setVisible(false);
                        //creates and sets the network configuration
                        net.add(new FullyConnectedFeedForwardNet(nodeConfiguration));

                        netKind.add(new StringBuffer(netType.getSelectedItem().toString()));
                        netName.add(new StringBuffer(newName.getText()));
                        oneNet.add(new JPanel());
                        oneNet.get(openNets).setLayout(new GridBagLayout());
                        GridBagConstraints constraints = new GridBagConstraints();
                        constraints.fill = GridBagConstraints.BOTH;

                        //creates the readOut space and formats it so that the scroll pane/text changes size with the window, reserves space for the loading bar
                        readOut.add(new JTextArea(""));
                        readOutLocale.add(new JScrollPane(readOut.get(openNets)));
                        readOut.get(openNets).setEditable(false);
                        constraints.gridx = 0;
                        constraints.gridy = 0;
                        constraints.weighty = 1.0;
                        constraints.weightx = 1.0;
                        constraints.gridwidth = 2;
                        constraints.ipady = 90;
                        oneNet.get(openNets).add(readOutLocale.get(openNets), constraints);
                        constraints.fill = GridBagConstraints.HORIZONTAL;
                        constraints.gridx = 0;
                        constraints.gridy = 1;
                        constraints.ipady = 0;
                        constraints.gridwidth = 2;
                        constraints.anchor = GridBagConstraints.PAGE_END;

                        //add everythign to the tabbed pane
                        oneNet.get(openNets).add(loadingBar.get(openNets), constraints);
                        resultsPane.addTab(netName.get(openNets).toString(), oneNet.get(openNets));
                        resultsPane.setTabComponentAt(openNets, tabPanel.get(openNets));

                        path.add("");

                        //display the starting configuration of the network
                        readOut.get(openNets).append("Network: " + netName.get(openNets) + "\n\n");
                        resultsPane.setSelectedIndex(openNets++);
                        printConnections();

                        //erases all the text in the setup fields and closes the window
                        howManyNodes.setValue(null);
                        howManyLayers.setText("");
                        newName.setText("");
                        howManyNodesDialog.setVisible(false);

                        //unfortunately difficult way that I made to add the close button functionality to close a tab
                        //it works, but there has to be a better way to do this
                        close.get(resultsPane.getSelectedIndex()).addActionListener(new ActionListener() {
                            public void actionPerformed(final ActionEvent ae) {
                                int result;
                                result = 0;
                                for (StringBuffer names : netName) {
                                    if (ae.getActionCommand().equals(names.toString())) {
                                        result = JOptionPane.showConfirmDialog(createFFN,
                                                "<html>Exiting Without Saving can Cause you to Lose your Progress<br>Are you sure you want to Continue?</html>",
                                                "Close Network", JOptionPane.OK_CANCEL_OPTION);
                                        resultsPane.setSelectedIndex(netName.indexOf(names));
                                    }
                                }
                                if (result == JOptionPane.OK_OPTION) {
                                    net.remove(resultsPane.getSelectedIndex());
                                    oneNet.remove(resultsPane.getSelectedIndex());
                                    readOutLocale.remove(resultsPane.getSelectedIndex());
                                    readOut.remove(resultsPane.getSelectedIndex());
                                    loadingBar.remove(resultsPane.getSelectedIndex());
                                    tabPanel.remove(resultsPane.getSelectedIndex());
                                    title.remove(resultsPane.getSelectedIndex());
                                    close.remove(resultsPane.getSelectedIndex());
                                    netName.remove(resultsPane.getSelectedIndex());
                                    resultsPane.remove(resultsPane.getSelectedIndex());
                                    openNets--;
                                }
                            }
                        });
                    } catch (OutOfMemoryError e) {
                        JOptionPane.showMessageDialog(mainWindow,
                                "<html>Net too Large for Memory.<br>Try Closing some of the Nets.</html>",
                                "Memory Error", JOptionPane.ERROR_MESSAGE);
                    }
                } else {
                    layer++;
                    howManyNodes.setText("");
                    numberofNodes.setText("How many nodes do you want in layer " + layer + "?");
                }

            } else {
                JOptionPane.showMessageDialog(createFFN,
                        "<html>Number Out of Bounds<br>Please Enter a Number Greater than 0", "Out of Bounds",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    //makes hitting enter in text box the same as clicking ok
    howManyNodes.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            for (ActionListener a : createFFN.getActionListeners()) {
                a.actionPerformed(ae);
            }
        }
    });

    //cancels the node prompt
    cancelNodes.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            newName.setText("");
            howManyLayers.setText("");
            howManyNodes.setText("");
            howManyNodesDialog.setVisible(false);
        }
    });

    //cancel clears both name fields so far filled in the series of dialogs and hides the dialog
    cancelFFN.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            newName.setText("");
            howManyLayers.setText("");
            fFNDialog.setVisible(false);
        }
    });
    //end of section about creating FFNs
    //end of section about newNet   

    //Method to create a SOM
    createSOM.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (somLatticeField.getText().equals("") || somDimField.getText().equals("")) {
                JOptionPane.showMessageDialog(createSOM, "<html>Empty Field<br>Please Fill All Fields",
                        "Empty Field", JOptionPane.ERROR_MESSAGE);
            } else {
                if (somMaxField.getText().equals(""))
                    somMaxField.setText("100");
                if (somMinField.getText().equals(""))
                    somMinField.setText("0");
                if (Double.parseDouble(somMaxField.getText().replace(",", "")) < Double
                        .parseDouble(somMinField.getText().replace(",", ""))) {
                    JOptionPane.showMessageDialog(createSOM, "MIN GREATER THAN MAX!!!!", "Stupidity Error",
                            JOptionPane.ERROR_MESSAGE);
                }

                try {
                    //adds a close button to the top corner of each tab
                    title.add(new JLabel(newName.getText() + " "));
                    close.add(new JButton("X"));
                    close.get(openNets).setActionCommand(newName.getText());
                    close.get(openNets).setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
                    close.get(openNets).setMargin(new Insets(0, 0, 0, 0));
                    tabPanel.add(new JPanel(new GridBagLayout()));
                    tabPanel.get(openNets).setOpaque(false);
                    GridBagConstraints grid = new GridBagConstraints();
                    grid.fill = GridBagConstraints.HORIZONTAL;
                    grid.gridx = 0;
                    grid.gridy = 0;
                    grid.weightx = 1;
                    tabPanel.get(openNets).add(title.get(openNets), grid);
                    grid.gridx = 1;
                    grid.gridy = 0;
                    grid.weightx = 0;
                    tabPanel.get(openNets).add(close.get(openNets), grid);

                    //adds a loading bar
                    loadingBar.add(new JLabel("", loadingImage, SwingConstants.CENTER));
                    loadingBar.get(openNets).setHorizontalTextPosition(SwingConstants.LEFT);
                    loadingBar.get(openNets).setVisible(false);
                    //creates and sets the network configuration
                    net.add(new SelfOrganizingMap());

                    netKind.add(new StringBuffer(netType.getSelectedItem().toString()));
                    netName.add(new StringBuffer(newName.getText()));
                    oneNet.add(new JPanel());
                    oneNet.get(openNets).setLayout(new GridBagLayout());
                    GridBagConstraints constraints = new GridBagConstraints();
                    constraints.fill = GridBagConstraints.BOTH;

                    //creates the readOut space and formats it so that the scroll pane/text changes size with the window, reserves space for the loading bar
                    readOut.add(new JTextArea(""));
                    readOutLocale.add(new JScrollPane(readOut.get(openNets)));
                    readOut.get(openNets).setEditable(false);
                    constraints.gridx = 0;
                    constraints.gridy = 0;
                    constraints.weighty = 1.0;
                    constraints.weightx = 1.0;
                    constraints.gridwidth = 2;
                    constraints.ipady = 90;
                    oneNet.get(openNets).add(readOutLocale.get(openNets), constraints);
                    constraints.fill = GridBagConstraints.HORIZONTAL;
                    constraints.gridx = 0;
                    constraints.gridy = 1;
                    constraints.ipady = 0;
                    constraints.gridwidth = 2;
                    constraints.anchor = GridBagConstraints.PAGE_END;

                    //add everythign to the tabbed pane
                    oneNet.get(openNets).add(loadingBar.get(openNets), constraints);
                    resultsPane.addTab(netName.get(openNets).toString(), oneNet.get(openNets));
                    resultsPane.setTabComponentAt(openNets, tabPanel.get(openNets));

                    path.add("");

                    //display the starting configuration of the network
                    readOut.get(openNets).append("Network: " + netName.get(openNets) + "\n\n");
                    resultsPane.setSelectedIndex(openNets++);
                    try {
                        net.get(resultsPane.getSelectedIndex())
                                .setLatticeValue(Integer.parseInt(somLatticeField.getText().replace(",", "")));
                        net.get(resultsPane.getSelectedIndex())
                                .setDataMax(Double.parseDouble(somMaxField.getText().replace(",", "")));
                        net.get(resultsPane.getSelectedIndex())
                                .setDataMin(Double.parseDouble(somMinField.getText().replace(",", "")));
                        net.get(resultsPane.getSelectedIndex())
                                .setInputDimensions(Integer.parseInt(somDimField.getText().replace(",", "")));
                        net.get(resultsPane.getSelectedIndex()).runNet();
                        readOut.get(resultsPane.getSelectedIndex()).append("Initial Untrained Map:\n");
                        printInitMap();

                        if (!getColorMap.isVisible()) {
                            util.addSeparator();
                            util.add(getColorMap);
                            getColorMap.setVisible(true);
                        }

                        //erases all the text in the setup fields and closes the window
                        newName.setText("");
                        somLatticeField.setText("");
                        somDimField.setText("");
                        somMaxField.setText("");
                        somMinField.setText("");
                        sOMDialog.setVisible(false);

                        //unfortunately difficult way that I made to add the close button functionality to close a tab
                        //it works, but there has to be a better way to do this
                        close.get(resultsPane.getSelectedIndex()).addActionListener(new ActionListener() {
                            public void actionPerformed(final ActionEvent ae) {
                                int result;
                                result = 0;
                                for (StringBuffer names : netName) {
                                    if (ae.getActionCommand().equals(names.toString())) {
                                        result = JOptionPane.showConfirmDialog(createSOM,
                                                "<html>Exiting Without Saving can Cause you to Lose your Progress<br>Are you sure you want to Continue?</html>",
                                                "Close Network", JOptionPane.OK_CANCEL_OPTION);
                                        resultsPane.setSelectedIndex(netName.indexOf(names));
                                    }
                                }
                                if (result == JOptionPane.OK_OPTION) {
                                    net.remove(resultsPane.getSelectedIndex());
                                    oneNet.remove(resultsPane.getSelectedIndex());
                                    readOutLocale.remove(resultsPane.getSelectedIndex());
                                    readOut.remove(resultsPane.getSelectedIndex());
                                    loadingBar.remove(resultsPane.getSelectedIndex());
                                    tabPanel.remove(resultsPane.getSelectedIndex());
                                    title.remove(resultsPane.getSelectedIndex());
                                    close.remove(resultsPane.getSelectedIndex());
                                    netName.remove(resultsPane.getSelectedIndex());
                                    resultsPane.remove(resultsPane.getSelectedIndex());
                                    openNets--;
                                }
                            }
                        });
                    } catch (Exception e) {
                        net.remove(resultsPane.getSelectedIndex());
                        oneNet.remove(resultsPane.getSelectedIndex());
                        readOutLocale.remove(resultsPane.getSelectedIndex());
                        readOut.remove(resultsPane.getSelectedIndex());
                        loadingBar.remove(resultsPane.getSelectedIndex());
                        tabPanel.remove(resultsPane.getSelectedIndex());
                        title.remove(resultsPane.getSelectedIndex());
                        close.remove(resultsPane.getSelectedIndex());
                        netName.remove(resultsPane.getSelectedIndex());
                        resultsPane.remove(resultsPane.getSelectedIndex());
                        openNets--;
                        JOptionPane.showMessageDialog(sOMDialog, "Numbers too large to parse", "Parse error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                } catch (OutOfMemoryError e) {
                    JOptionPane.showMessageDialog(mainWindow,
                            "<html>Net too Large for Memory.<br>Try Closing some of the Nets.</html>",
                            "Memory Error", JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    });

    cancelSOM.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            newName.setText("");
            somLatticeField.setText("");
            somMaxField.setText("");
            somMinField.setText("");
            sOMDialog.setVisible(false);
        }
    });

    //end of SOM creation
    mainWindow.setVisible(true);
}

From source file:br.com.jinsync.view.FrmJInSync.java

private void loadLayoutTableFile() {

    int i = 0;//  w w w.  ja  v  a2s . c o  m

    tableFile.setModel(tableFileModel);

    DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
    rightRenderer.setHorizontalAlignment(SwingConstants.RIGHT);

    DefaultTableCellRenderer leftRenderer = new DefaultTableCellRenderer();
    leftRenderer.setHorizontalAlignment(SwingConstants.LEFT);

    for (i = 0; i < defField.size(); i++) {
        if (defField.get(i).equals("Zoned Decimal") || defField.get(i).equals("Binary")
                || defField.get(i).equals("Packed Decimal")) {
            tableFile.getColumnModel().getColumn(i).setCellRenderer(rightRenderer);
        } else {
            tableFile.getColumnModel().getColumn(i).setCellRenderer(leftRenderer);
        }
    }

    for (i = 0; i < columnNamesFile.length; i++) {
        int teste = columnNamesFile[i].length();
        if (teste == 3) {
            teste = 5;
        }
        tableFile.getColumnModel().getColumn(i).setPreferredWidth(teste * 8);
    }

    tableFile.getTableHeader().setReorderingAllowed(false);
    tableFile.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    scrFile.setViewportView(tableFile);

}

From source file:de.bwravencl.controllerbuddy.gui.Main.java

private void updateOverlayAlignment(final Rectangle maxWindowBounds) {
    final var inLowerHalf = overlayFrame.getY() + overlayFrame.getHeight() / 2 < maxWindowBounds.height / 2;

    overlayFrame.remove(labelCurrentMode);
    overlayFrame.add(labelCurrentMode, inLowerHalf ? BorderLayout.PAGE_START : BorderLayout.PAGE_END);

    var alignment = SwingConstants.RIGHT;
    var flowLayoutAlignment = FlowLayout.RIGHT;
    if (overlayFrame.getX() + overlayFrame.getWidth() / 2 < maxWindowBounds.width / 2) {
        alignment = SwingConstants.LEFT;
        flowLayoutAlignment = FlowLayout.LEFT;
    }//from   ww w .  ja v  a 2 s  . co  m

    labelCurrentMode.setHorizontalAlignment(alignment);

    indicatorPanelFlowLayout.setAlignment(flowLayoutAlignment);
    indicatorPanel.invalidate();

    overlayFrame.setBackground(TRANSPARENT);
    overlayFrame.pack();
}

From source file:edu.ku.brc.ui.UIHelper.java

/**
 * @param table/*from  ww w  .  ja  va2  s. c  om*/
 * @param model
 * @return
 */
public static JTable autoResizeColWidth(final JTable table, final DefaultTableModel model) {
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setModel(model);

    int margin = 5;

    DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel();

    int preferredWidthTotal = 0;
    int renderedWidthTotal = 0;
    int[] colWidths = new int[table.getColumnCount()];
    for (int i = 0; i < table.getColumnCount(); i++) {
        int vColIndex = i;
        TableColumn col = colModel.getColumn(vColIndex);
        int width = 0;

        // Get width of column header
        TableCellRenderer renderer = col.getHeaderRenderer();

        if (renderer == null) {
            renderer = table.getTableHeader().getDefaultRenderer();
        }

        Component comp = renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false, false, 0,
                0);

        width = comp.getPreferredSize().width;

        // Get maximum width of column data
        for (int r = 0; r < table.getRowCount(); r++) {
            renderer = table.getCellRenderer(r, vColIndex);
            comp = renderer.getTableCellRendererComponent(table, table.getValueAt(r, vColIndex), false, false,
                    r, vColIndex);
            width = Math.max(width, comp.getPreferredSize().width);
        }

        // Add margin
        width += 2 * margin;

        preferredWidthTotal += col.getPreferredWidth();
        colWidths[i] = width;

        renderedWidthTotal += width;
    }

    if (renderedWidthTotal > preferredWidthTotal) {
        for (int i = 0; i < table.getColumnCount(); i++) {
            colModel.getColumn(i).setPreferredWidth(colWidths[i]);
        }
    }

    ((DefaultTableCellRenderer) table.getTableHeader().getDefaultRenderer())
            .setHorizontalAlignment(SwingConstants.LEFT);

    // table.setAutoCreateRowSorter(true);
    table.getTableHeader().setReorderingAllowed(false);

    return table;
}