Example usage for java.awt GridBagConstraints NORTHWEST

List of usage examples for java.awt GridBagConstraints NORTHWEST

Introduction

In this page you can find the example usage for java.awt GridBagConstraints NORTHWEST.

Prototype

int NORTHWEST

To view the source code for java.awt GridBagConstraints NORTHWEST.

Click Source Link

Document

Put the component at the top-left corner of its display area.

Usage

From source file:algorithm.QRCodeWatermarking.java

/**
 * Creates the GUI that is used to configure this algorithm.
 */// www .  jav  a  2 s .c  o  m
private void createConfigurationGui() {
    initButtons();
    panel = new GUIPanel();
    panel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.gridwidth = 2;
    panel.add(new JLabel("<html><h2>QR-code options</h2></html>"), constraints);
    constraints.gridy++;
    constraints.gridwidth = 1;
    panel.add(new JLabel("QR-code size: "), constraints);
    constraints.gridx++;
    sizeField.setText("200");
    panel.add(sizeField, constraints);
    constraints.gridwidth = 2;
    constraints.gridx = 0;
    constraints.gridy++;
    constraints.gridy++;
    constraints.gridx = 0;
    constraints.gridwidth = 1;
    panel.add(new JLabel("Select output file format:"), constraints);
    constraints.gridx++;
    panel.add(imageFormatBox, constraints);
    constraints.gridx = 0;
    constraints.gridy++;

    // separate file:
    constraints.gridwidth = 2;
    panel.add(falseEncapsulate, constraints);
    constraints.gridy++;
    constraints.gridy++;

    // add to carrier:
    panel.add(trueEncapsulate, constraints);
    constraints.gridy++;

    JTextArea infoArea = new JTextArea();
    infoArea.setText("" + "\nPlease note: "
            + "\n- The QR-code will be created from the first payload file, if the dataset has more than one payload files, and added to each carrier file. "
            + "All other payload files will be ignored, if this option is selected."
            + "\n- Carrier files need to be one of the following file types:"
            + "\n\tpng, jpeg, jp2, jpg, bmp, gif" + "\n- All carrier files of other file formats are ignored."
            + "\n- The QR-code pixel size should exceed the carrier image size in no dimension."
            + "\n- If the size of the selected payload file is too big to create a QR-code from it, you will get an error message."
            + "\n\n" + "Options for adding the QR-code to the carrier images:");
    infoArea.setEditable(false);
    infoArea.setLineWrap(true);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1;
    panel.add(infoArea, constraints);
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridy++;
    panel.add(new JLabel("On which image position should the barcode be added?"), constraints);
    constraints.gridy++;
    constraints.gridwidth = 1;
    panel.add(new JLabel("X :"), constraints);
    constraints.gridx++;
    xPositionField.setText("0");
    panel.add(xPositionField, constraints);
    constraints.gridx = 0;
    constraints.gridy++;
    panel.add(new JLabel("Y :"), constraints);
    constraints.gridx++;
    yPositionField.setText("0");
    panel.add(yPositionField, constraints);
    constraints.gridx = 0;
    constraints.gridy++;
    constraints.gridy++;
    panel.add(messageLabel, constraints);
}

From source file:edu.harvard.mcz.imagecapture.PositionTemplateEditor.java

/**
 * This method initializes jPanel   //from  www .  j a va  2 s . c  om
 *    
 * @return javax.swing.JPanel   
 */
private JPanel getJPanel() {
    if (jPanel == null) {
        GridBagConstraints gridBagConstraints24 = new GridBagConstraints();
        gridBagConstraints24.fill = GridBagConstraints.BOTH;
        gridBagConstraints24.gridy = 10;
        gridBagConstraints24.weightx = 1.0;
        gridBagConstraints24.anchor = GridBagConstraints.WEST;
        gridBagConstraints24.gridx = 1;
        GridBagConstraints gridBagConstraints113 = new GridBagConstraints();
        gridBagConstraints113.gridx = 0;
        gridBagConstraints113.anchor = GridBagConstraints.EAST;
        gridBagConstraints113.gridy = 10;
        jLabel9 = new JLabel();
        jLabel9.setText("Taxon Name Barcode");
        GridBagConstraints gridBagConstraints23 = new GridBagConstraints();
        gridBagConstraints23.fill = GridBagConstraints.BOTH;
        gridBagConstraints23.gridy = 13;
        gridBagConstraints23.weightx = 1.0;
        gridBagConstraints23.anchor = GridBagConstraints.WEST;
        gridBagConstraints23.gridx = 1;
        GridBagConstraints gridBagConstraints112 = new GridBagConstraints();
        gridBagConstraints112.gridx = 0;
        gridBagConstraints112.gridy = 13;
        GridBagConstraints gridBagConstraints22 = new GridBagConstraints();
        gridBagConstraints22.fill = GridBagConstraints.BOTH;
        gridBagConstraints22.gridy = 12;
        gridBagConstraints22.weightx = 1.0;
        gridBagConstraints22.anchor = GridBagConstraints.WEST;
        gridBagConstraints22.gridx = 1;
        GridBagConstraints gridBagConstraints111 = new GridBagConstraints();
        gridBagConstraints111.gridx = 0;
        gridBagConstraints111.gridy = 12;
        GridBagConstraints gridBagConstraints110 = new GridBagConstraints();
        gridBagConstraints110.gridx = 1;
        gridBagConstraints110.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints110.gridwidth = 1;
        gridBagConstraints110.anchor = GridBagConstraints.NORTH;
        gridBagConstraints110.gridy = 14;
        jLabelFeedback = new JLabel();
        jLabelFeedback.setText(" ");
        GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
        gridBagConstraints21.fill = GridBagConstraints.BOTH;
        gridBagConstraints21.gridy = 0;
        gridBagConstraints21.weightx = 2.0;
        gridBagConstraints21.anchor = GridBagConstraints.NORTHWEST;
        gridBagConstraints21.gridx = 1;
        GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
        gridBagConstraints13.gridx = 0;
        gridBagConstraints13.anchor = GridBagConstraints.NORTHEAST;
        gridBagConstraints13.gridy = 0;
        jLabel8 = new JLabel();
        jLabel8.setText("ImageFile");
        GridBagConstraints gridBagConstraints18 = new GridBagConstraints();
        gridBagConstraints18.fill = GridBagConstraints.BOTH;
        gridBagConstraints18.gridy = 9;
        gridBagConstraints18.weightx = 1.0;
        gridBagConstraints18.anchor = GridBagConstraints.WEST;
        gridBagConstraints18.gridx = 1;
        GridBagConstraints gridBagConstraints17 = new GridBagConstraints();
        gridBagConstraints17.fill = GridBagConstraints.BOTH;
        gridBagConstraints17.gridy = 8;
        gridBagConstraints17.weightx = 1.0;
        gridBagConstraints17.anchor = GridBagConstraints.WEST;
        gridBagConstraints17.gridx = 1;
        GridBagConstraints gridBagConstraints16 = new GridBagConstraints();
        gridBagConstraints16.fill = GridBagConstraints.BOTH;
        gridBagConstraints16.gridy = 7;
        gridBagConstraints16.weightx = 1.0;
        gridBagConstraints16.anchor = GridBagConstraints.WEST;
        gridBagConstraints16.gridx = 1;
        GridBagConstraints gridBagConstraints15 = new GridBagConstraints();
        gridBagConstraints15.fill = GridBagConstraints.BOTH;
        gridBagConstraints15.gridy = 6;
        gridBagConstraints15.weightx = 1.0;
        gridBagConstraints15.anchor = GridBagConstraints.WEST;
        gridBagConstraints15.gridx = 1;
        GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
        gridBagConstraints14.fill = GridBagConstraints.BOTH;
        gridBagConstraints14.gridy = 5;
        gridBagConstraints14.weightx = 1.0;
        gridBagConstraints14.anchor = GridBagConstraints.WEST;
        gridBagConstraints14.gridx = 1;
        GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
        gridBagConstraints12.fill = GridBagConstraints.BOTH;
        gridBagConstraints12.gridy = 3;
        gridBagConstraints12.weightx = 1.0;
        gridBagConstraints12.anchor = GridBagConstraints.WEST;
        gridBagConstraints12.gridx = 1;
        GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
        gridBagConstraints11.gridx = 0;
        gridBagConstraints11.anchor = GridBagConstraints.EAST;
        gridBagConstraints11.gridy = 9;
        jLabel7 = new JLabel();
        jLabel7.setText("Specimen");
        jLabel7.setForeground(Color.ORANGE);
        GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
        gridBagConstraints10.gridx = 0;
        gridBagConstraints10.anchor = GridBagConstraints.EAST;
        gridBagConstraints10.gridy = 8;
        jLabel6 = new JLabel();
        jLabel6.setText("Tray Labels");
        jLabel6.setForeground(Color.CYAN);
        GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
        gridBagConstraints9.gridx = 0;
        gridBagConstraints9.anchor = GridBagConstraints.EAST;
        gridBagConstraints9.gridy = 7;
        jLabel5 = new JLabel();
        jLabel5.setText("Pin Labels");
        jLabel5.setForeground(Color.MAGENTA);
        GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
        gridBagConstraints8.gridx = 0;
        gridBagConstraints8.anchor = GridBagConstraints.EAST;
        gridBagConstraints8.insets = new Insets(0, 3, 0, 0);
        gridBagConstraints8.gridy = 6;
        jLabel4 = new JLabel();
        jLabel4.setText("Taxon Name Label");
        jLabel4.setForeground(Color.BLUE);
        GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
        gridBagConstraints7.gridx = 0;
        gridBagConstraints7.anchor = GridBagConstraints.EAST;
        gridBagConstraints7.gridy = 5;
        jLabel3 = new JLabel();
        jLabel3.setText("Barcode");
        jLabel3.setForeground(Color.RED);
        GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
        gridBagConstraints6.gridx = 0;
        gridBagConstraints6.anchor = GridBagConstraints.EAST;
        gridBagConstraints6.gridy = 3;
        jLabel2 = new JLabel();
        jLabel2.setText("Image Size");
        GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
        gridBagConstraints5.fill = GridBagConstraints.BOTH;
        gridBagConstraints5.gridy = 2;
        gridBagConstraints5.weightx = 1.0;
        gridBagConstraints5.anchor = GridBagConstraints.WEST;
        gridBagConstraints5.gridx = 1;
        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
        gridBagConstraints4.fill = GridBagConstraints.BOTH;
        gridBagConstraints4.gridy = 1;
        gridBagConstraints4.weightx = 1.0;
        gridBagConstraints4.anchor = GridBagConstraints.WEST;
        gridBagConstraints4.gridx = 1;
        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.gridx = 0;
        gridBagConstraints2.anchor = GridBagConstraints.EAST;
        gridBagConstraints2.gridy = 2;
        jLabel1 = new JLabel();
        jLabel1.setText("Name");
        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.gridx = 0;
        gridBagConstraints1.anchor = GridBagConstraints.EAST;
        gridBagConstraints1.gridy = 1;
        jLabel = new JLabel();
        jLabel.setText("Template ID");
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 11;
        jPanel = new JPanel();
        jPanel.setLayout(new GridBagLayout());
        jPanel.add(getJButtonSave(), gridBagConstraints);
        jPanel.add(jLabel, gridBagConstraints1);
        jPanel.add(jLabel1, gridBagConstraints2);
        jPanel.add(getJTextFieldTemplateId(), gridBagConstraints4);
        jPanel.add(getJTextFieldName(), gridBagConstraints5);
        jPanel.add(jLabel2, gridBagConstraints6);
        jPanel.add(jLabel3, gridBagConstraints7);
        jPanel.add(jLabel4, gridBagConstraints8);
        jPanel.add(jLabel5, gridBagConstraints9);
        jPanel.add(jLabel6, gridBagConstraints10);
        jPanel.add(jLabel7, gridBagConstraints11);
        jPanel.add(getJTextField2(), gridBagConstraints12);
        jPanel.add(getJTextField3(), gridBagConstraints14);
        jPanel.add(getJTextField4(), gridBagConstraints15);
        jPanel.add(getJTextField5(), gridBagConstraints16);
        jPanel.add(getJTextField6(), gridBagConstraints17);
        jPanel.add(getJTextField7(), gridBagConstraints18);
        jPanel.add(jLabel8, gridBagConstraints13);
        jPanel.add(getJTextField8(), gridBagConstraints21);
        jPanel.add(jLabelFeedback, gridBagConstraints110);
        jPanel.add(getJButton(), gridBagConstraints111);
        jPanel.add(getJTextFieldBarcodeScan(), gridBagConstraints22);
        jPanel.add(getJButton1(), gridBagConstraints112);
        jPanel.add(getJTextField(), gridBagConstraints23);
        jPanel.add(jLabel9, gridBagConstraints113);
        jPanel.add(getJTextField9(), gridBagConstraints24);
    }
    return jPanel;
}

From source file:de.codesourcery.jasm16.ide.ui.utils.UIUtils.java

protected static final GridBagConstraints constraints(int x, int y, boolean remainderHoriz,
        boolean remainderVert, int fill) {
    final GridBagConstraints cnstrs = new GridBagConstraints();
    cnstrs.anchor = GridBagConstraints.NORTHWEST;
    cnstrs.weightx = 1.0d;// w ww . j  a  v a 2 s  .  co  m
    cnstrs.weighty = 1.0d;
    cnstrs.fill = fill;
    cnstrs.gridheight = remainderVert ? GridBagConstraints.REMAINDER : 1;
    cnstrs.gridwidth = remainderHoriz ? GridBagConstraints.REMAINDER : 1;
    cnstrs.gridx = x;
    cnstrs.gridy = y;
    cnstrs.insets = new Insets(10, 2, 10, 2); // top,left,bottom,right
    return cnstrs;
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java

private void initTextArea(JPanel centerPanel) {
    GridBagConstraints constraints = new GridBagConstraints();

    editorPane.setContentType("text/html");
    editorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
    editorPane.setCaretPosition(0);/*from ww w .j av  a  2 s  .co m*/
    editorPane.setEditorKit(new SIPCommHTMLEditorKit(this));
    editorPane.getDocument().addUndoableEditListener(this);
    editorPane.getDocument().addDocumentListener(this);
    editorPane.addKeyListener(this);
    editorPane.addMouseListener(this);
    editorPane.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    editorPane.setDragEnabled(true);
    editorPane.setTransferHandler(new ChatTransferHandler(chatPanel));

    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

    scrollPane.setOpaque(false);
    scrollPane.getViewport().setOpaque(false);
    scrollPane.setBorder(null);

    scrollPane.setViewportView(editorPane);

    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 2;
    constraints.gridy = 0;
    constraints.weightx = 1f;
    constraints.weighty = 1f;
    constraints.gridheight = 1;
    constraints.gridwidth = 1;
    constraints.insets = new Insets(0, 0, 0, 0);
    centerPanel.add(scrollPane, constraints);
}

From source file:com.googlecode.libautocaptcha.tools.VodafoneItalyTool.java

private void initFrame() {
    frame = new JFrame();
    frame.setTitle("libautocaptcha vodafone.it tool");
    frame.setBounds(100, 100, 450, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    frame.getContentPane().add(tabbedPane, BorderLayout.CENTER);

    JPanel setupPanel = new JPanel();
    FlowLayout flowLayout = (FlowLayout) setupPanel.getLayout();
    flowLayout.setAlignment(FlowLayout.LEFT);
    tabbedPane.addTab("Setup", null, setupPanel, null);

    JPanel setupFormPanel = new JPanel();
    setupPanel.add(setupFormPanel);/*  w w w  . j  av a2s .  co  m*/
    GridBagLayout gbl_setupFormPanel = new GridBagLayout();
    gbl_setupFormPanel.columnWidths = new int[] { 150, 250 };
    gbl_setupFormPanel.rowHeights = new int[] { 0, 0, 0 };
    gbl_setupFormPanel.columnWeights = new double[] { 0.0, 1.0 };
    gbl_setupFormPanel.rowWeights = new double[] { 0.0, 0.0, 0.0 };
    setupFormPanel.setLayout(gbl_setupFormPanel);

    JLabel usernameLabel = new JLabel("Username");
    GridBagConstraints gbc_usernameLabel = new GridBagConstraints();
    gbc_usernameLabel.anchor = GridBagConstraints.WEST;
    gbc_usernameLabel.fill = GridBagConstraints.VERTICAL;
    gbc_usernameLabel.insets = new Insets(0, 0, 5, 5);
    gbc_usernameLabel.gridx = 0;
    gbc_usernameLabel.gridy = 0;
    setupFormPanel.add(usernameLabel, gbc_usernameLabel);
    usernameField = new JTextField();
    GridBagConstraints gbc_usernameField = new GridBagConstraints();
    gbc_usernameField.fill = GridBagConstraints.BOTH;
    gbc_usernameField.insets = new Insets(0, 0, 5, 0);
    gbc_usernameField.gridx = 1;
    gbc_usernameField.gridy = 0;
    setupFormPanel.add(usernameField, gbc_usernameField);
    usernameField.setColumns(10);

    JLabel passwordLabel = new JLabel("Password");
    GridBagConstraints gbc_passwordLabel = new GridBagConstraints();
    gbc_passwordLabel.anchor = GridBagConstraints.WEST;
    gbc_passwordLabel.fill = GridBagConstraints.VERTICAL;
    gbc_passwordLabel.insets = new Insets(0, 0, 5, 5);
    gbc_passwordLabel.gridx = 0;
    gbc_passwordLabel.gridy = 1;
    setupFormPanel.add(passwordLabel, gbc_passwordLabel);
    passwordField = new JPasswordField();
    GridBagConstraints gbc_passwordField = new GridBagConstraints();
    gbc_passwordField.fill = GridBagConstraints.BOTH;
    gbc_passwordField.insets = new Insets(0, 0, 5, 0);
    gbc_passwordField.gridx = 1;
    gbc_passwordField.gridy = 1;
    setupFormPanel.add(passwordField, gbc_passwordField);
    passwordField.setColumns(10);

    JLabel receiverLabel = new JLabel("Mobile number");
    GridBagConstraints gbc_receiverLabel = new GridBagConstraints();
    gbc_receiverLabel.fill = GridBagConstraints.VERTICAL;
    gbc_receiverLabel.anchor = GridBagConstraints.WEST;
    gbc_receiverLabel.insets = new Insets(0, 0, 5, 5);
    gbc_receiverLabel.gridx = 0;
    gbc_receiverLabel.gridy = 2;
    setupFormPanel.add(receiverLabel, gbc_receiverLabel);

    receiverField = new JTextField();
    GridBagConstraints gbc_receiverField = new GridBagConstraints();
    gbc_receiverField.insets = new Insets(0, 0, 5, 0);
    gbc_receiverField.fill = GridBagConstraints.BOTH;
    gbc_receiverField.gridx = 1;
    gbc_receiverField.gridy = 2;
    setupFormPanel.add(receiverField, gbc_receiverField);
    receiverField.setColumns(10);

    JPanel backgroundPanel = new JPanel();
    FlowLayout flowLayout_1 = (FlowLayout) backgroundPanel.getLayout();
    flowLayout_1.setAlignment(FlowLayout.LEFT);
    tabbedPane.addTab("Background", null, backgroundPanel, null);

    JPanel backgroundFormPanel = new JPanel();
    backgroundPanel.add(backgroundFormPanel);
    GridBagLayout gbl_backgroundFormPanel = new GridBagLayout();
    gbl_backgroundFormPanel.columnWidths = new int[] { 150, 50, 100, 0 };
    gbl_backgroundFormPanel.rowHeights = new int[] { 0, 25, 0 };
    gbl_backgroundFormPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
    gbl_backgroundFormPanel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
    backgroundFormPanel.setLayout(gbl_backgroundFormPanel);

    JLabel numberLabel = new JLabel("Number of CAPTCHAs");
    GridBagConstraints gbc_numberLabel = new GridBagConstraints();
    gbc_numberLabel.anchor = GridBagConstraints.WEST;
    gbc_numberLabel.insets = new Insets(0, 0, 5, 5);
    gbc_numberLabel.gridx = 0;
    gbc_numberLabel.gridy = 0;
    backgroundFormPanel.add(numberLabel, gbc_numberLabel);

    numberField = new JTextField();
    numberField.setText("5");
    GridBagConstraints gbc_numberField = new GridBagConstraints();
    gbc_numberField.anchor = GridBagConstraints.WEST;
    gbc_numberField.insets = new Insets(0, 0, 5, 5);
    gbc_numberField.gridx = 1;
    gbc_numberField.gridy = 0;
    backgroundFormPanel.add(numberField, gbc_numberField);
    numberField.setColumns(3);

    JButton numberButton = new JButton("Download");
    numberButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int counter = 0;

            do {
                BufferedImage captcha = downloadCAPTCHA();
                if (captcha != null) {
                    try {
                        int number = new File(tempFolder.getAbsolutePath()).listFiles().length;
                        File file = new File(tempFolder.getAbsolutePath() + "/background_" + number + ".png");
                        ImageIO.write(captcha, "png", file);
                        Thread.sleep(2500);
                    } catch (Exception x) {
                        x.printStackTrace();
                    }
                }
            } while (++counter < Integer.valueOf(numberField.getText()));

            Image background = loadBackground();
            if (background != null) {
                backgroundImage.setIcon(new ImageIcon(background));
            }
        }
    });
    GridBagConstraints gbc_numberButton = new GridBagConstraints();
    gbc_numberButton.anchor = GridBagConstraints.NORTHWEST;
    gbc_numberButton.insets = new Insets(0, 0, 5, 0);
    gbc_numberButton.gridx = 2;
    gbc_numberButton.gridy = 0;
    backgroundFormPanel.add(numberButton, gbc_numberButton);

    JLabel backgroundLabel = new JLabel("Current background");
    GridBagConstraints gbc_backgroundLabel = new GridBagConstraints();
    gbc_backgroundLabel.anchor = GridBagConstraints.WEST;
    gbc_backgroundLabel.insets = new Insets(0, 0, 0, 5);
    gbc_backgroundLabel.gridx = 0;
    gbc_backgroundLabel.gridy = 1;
    backgroundFormPanel.add(backgroundLabel, gbc_backgroundLabel);

    backgroundImage = new JLabel("");
    GridBagConstraints gbc_backgroundImage = new GridBagConstraints();
    gbc_backgroundImage.anchor = GridBagConstraints.WEST;
    gbc_backgroundImage.gridwidth = 2;
    gbc_backgroundImage.insets = new Insets(0, 0, 0, 5);
    gbc_backgroundImage.gridx = 1;
    gbc_backgroundImage.gridy = 1;
    backgroundFormPanel.add(backgroundImage, gbc_backgroundImage);

    JPanel trainingPanel = new JPanel();
    tabbedPane.addTab("Training", null, trainingPanel, null);
    GridBagLayout gbl_trainingPanel = new GridBagLayout();
    gbl_trainingPanel.columnWidths = new int[] { 437, 0 };
    gbl_trainingPanel.rowHeights = new int[] { 0, 0, 0 };
    gbl_trainingPanel.columnWeights = new double[] { 0.0, Double.MIN_VALUE };
    gbl_trainingPanel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
    trainingPanel.setLayout(gbl_trainingPanel);

    trainingLoadPanel = new JPanel();
    GridBagConstraints gbc_trainingLoadPanel = new GridBagConstraints();
    gbc_trainingLoadPanel.anchor = GridBagConstraints.NORTHWEST;
    gbc_trainingLoadPanel.insets = new Insets(0, 0, 5, 0);
    gbc_trainingLoadPanel.gridx = 0;
    gbc_trainingLoadPanel.gridy = 0;
    trainingPanel.add(trainingLoadPanel, gbc_trainingLoadPanel);
    trainingLoadPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));

    JButton trainingLoadButton = new JButton("Download");
    trainingLoadButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            trainingCaptcha = downloadCAPTCHA();
            if (trainingCaptcha != null) {
                trainingCaptchaImage.setIcon(new ImageIcon(trainingCaptcha));
                List<Image> glyphs = loadGlyphs(trainingCaptcha);
                for (int g = 0; g < 5; ++g) {
                    trainingGlyphImage[g].setIcon(null);
                    trainingGlyphField[g].setText("");
                }
                for (int g = 0; g < glyphs.size() && g < 5; ++g) {
                    trainingGlyph[g] = glyphs.get(g);
                    trainingGlyphImage[g].setIcon(new ImageIcon(trainingGlyph[g]));
                }
                trainingLoadPanel.invalidate();
                trainingSavePanel.invalidate();
            }
        }
    });
    trainingLoadPanel.add(trainingLoadButton);

    trainingCaptchaImage = new JLabel("");
    trainingLoadPanel.add(trainingCaptchaImage);

    trainingSavePanel = new JPanel();
    GridBagConstraints gbc_trainingSavePanel = new GridBagConstraints();
    gbc_trainingSavePanel.insets = new Insets(0, 5, 0, 0);
    gbc_trainingSavePanel.anchor = GridBagConstraints.NORTHWEST;
    gbc_trainingSavePanel.gridx = 0;
    gbc_trainingSavePanel.gridy = 1;
    trainingPanel.add(trainingSavePanel, gbc_trainingSavePanel);
    GridBagLayout gbl_trainingSavePanel = new GridBagLayout();
    gbl_trainingSavePanel.columnWidths = new int[] { 25, 25, 25, 25, 25, 0, 0 };
    gbl_trainingSavePanel.rowHeights = new int[] { 25, 0, 0 };
    gbl_trainingSavePanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
    gbl_trainingSavePanel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
    trainingSavePanel.setLayout(gbl_trainingSavePanel);

    trainingGlyph = new Image[5];
    trainingGlyphImage = new JLabel[5];
    trainingGlyphField = new JTextField[5];

    trainingGlyphImage[0] = new JLabel("");
    GridBagConstraints gbc_glyphImage0 = new GridBagConstraints();
    gbc_glyphImage0.anchor = GridBagConstraints.NORTHWEST;
    gbc_glyphImage0.insets = new Insets(0, 0, 5, 5);
    gbc_glyphImage0.gridx = 0;
    gbc_glyphImage0.gridy = 0;
    trainingGlyphImage[0].setBorder(BorderFactory.createLineBorder(Color.GRAY, 2));
    trainingSavePanel.add(trainingGlyphImage[0], gbc_glyphImage0);

    trainingGlyphImage[1] = new JLabel("");
    GridBagConstraints gbc_glyphImage1 = new GridBagConstraints();
    gbc_glyphImage1.anchor = GridBagConstraints.NORTHWEST;
    gbc_glyphImage1.insets = new Insets(0, 0, 5, 5);
    gbc_glyphImage1.gridx = 1;
    gbc_glyphImage1.gridy = 0;
    trainingGlyphImage[1].setBorder(BorderFactory.createLineBorder(Color.GRAY, 2));
    trainingSavePanel.add(trainingGlyphImage[1], gbc_glyphImage1);

    trainingGlyphImage[2] = new JLabel("");
    GridBagConstraints gbc_glyphImage2 = new GridBagConstraints();
    gbc_glyphImage2.anchor = GridBagConstraints.NORTHWEST;
    gbc_glyphImage2.insets = new Insets(0, 0, 5, 5);
    gbc_glyphImage2.gridx = 2;
    gbc_glyphImage2.gridy = 0;
    trainingGlyphImage[2].setBorder(BorderFactory.createLineBorder(Color.GRAY, 2));
    trainingSavePanel.add(trainingGlyphImage[2], gbc_glyphImage2);

    trainingGlyphImage[3] = new JLabel("");
    GridBagConstraints gbc_glyphImage3 = new GridBagConstraints();
    gbc_glyphImage3.anchor = GridBagConstraints.NORTHWEST;
    gbc_glyphImage3.insets = new Insets(0, 0, 5, 5);
    gbc_glyphImage3.gridx = 3;
    gbc_glyphImage3.gridy = 0;
    trainingGlyphImage[3].setBorder(BorderFactory.createLineBorder(Color.GRAY, 2));
    trainingSavePanel.add(trainingGlyphImage[3], gbc_glyphImage3);

    trainingGlyphImage[4] = new JLabel("");
    GridBagConstraints gbc_glyphImage4 = new GridBagConstraints();
    gbc_glyphImage4.insets = new Insets(0, 0, 5, 5);
    gbc_glyphImage4.anchor = GridBagConstraints.NORTHWEST;
    gbc_glyphImage4.gridx = 4;
    gbc_glyphImage4.gridy = 0;
    trainingGlyphImage[4].setBorder(BorderFactory.createLineBorder(Color.GRAY, 2));
    trainingSavePanel.add(trainingGlyphImage[4], gbc_glyphImage4);

    JButton trainingSaveButton = new JButton("Train");
    trainingSaveButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            for (int g = 0; g < 5; ++g) {
                String s = trainingGlyphField[g].getText();
                if (s.length() == 1) {
                    char c = Character.toUpperCase(s.charAt(0));
                    net.sourceforge.javaocr.Image glyph = convertImage(trainingGlyph[g]);
                    grayFilter.process(glyph);
                    ThresholdFilter thresholdFilter = new ThresholdFilter(0, FG, BG);
                    thresholdFilter.process(glyph);
                    train(glyph, c);
                }
                trainingGlyphField[g].setText("");
            }

            for (Map.Entry<Character, Cluster> m : clusters.entrySet()) {
                System.out.println("****************************************");
                System.out.print(" character:  ");
                //          int samples = ((EuclidianDistanceCluster) m.getValue()).getAmountSamples();
                int samples = ((SigmaWeightedEuclidianDistanceCluster) m.getValue()).getAmountSamples();
                for (int s = 0; s < samples; ++s)
                    System.out.print(m.getKey());
                System.out.println();
                double[] c = m.getValue().center();
                for (int i = 0; i < c.length; ++i)
                    System.out.println(" centroid[" + i + "]: " + c[i]);
            }

            System.out.println("****************************************");
            System.out.println("TOTAL CLUSTERS: " + clusters.size());
        }
    });
    GridBagConstraints gbc_trainingSaveButton = new GridBagConstraints();
    gbc_trainingSaveButton.gridheight = 2;
    gbc_trainingSaveButton.insets = new Insets(0, 0, 5, 0);
    gbc_trainingSaveButton.gridx = 5;
    gbc_trainingSaveButton.gridy = 0;
    trainingSavePanel.add(trainingSaveButton, gbc_trainingSaveButton);

    trainingGlyphField[0] = new JTextField();
    GridBagConstraints gbc_glyphField0 = new GridBagConstraints();
    gbc_glyphField0.fill = GridBagConstraints.HORIZONTAL;
    gbc_glyphField0.anchor = GridBagConstraints.NORTHWEST;
    gbc_glyphField0.insets = new Insets(0, 0, 0, 5);
    gbc_glyphField0.gridx = 0;
    gbc_glyphField0.gridy = 1;
    trainingSavePanel.add(trainingGlyphField[0], gbc_glyphField0);
    trainingGlyphField[0].setColumns(2);

    trainingGlyphField[1] = new JTextField();
    GridBagConstraints gbc_glyphField1 = new GridBagConstraints();
    gbc_glyphField1.fill = GridBagConstraints.HORIZONTAL;
    gbc_glyphField1.anchor = GridBagConstraints.NORTHWEST;
    gbc_glyphField1.insets = new Insets(0, 0, 0, 5);
    gbc_glyphField1.gridx = 1;
    gbc_glyphField1.gridy = 1;
    trainingSavePanel.add(trainingGlyphField[1], gbc_glyphField1);
    trainingGlyphField[1].setColumns(2);

    trainingGlyphField[2] = new JTextField();
    GridBagConstraints gbc_glyphField2 = new GridBagConstraints();
    gbc_glyphField2.fill = GridBagConstraints.HORIZONTAL;
    gbc_glyphField2.anchor = GridBagConstraints.NORTHWEST;
    gbc_glyphField2.insets = new Insets(0, 0, 0, 5);
    gbc_glyphField2.gridx = 2;
    gbc_glyphField2.gridy = 1;
    trainingSavePanel.add(trainingGlyphField[2], gbc_glyphField2);
    trainingGlyphField[2].setColumns(2);

    trainingGlyphField[3] = new JTextField();
    GridBagConstraints gbc_glyphField3 = new GridBagConstraints();
    gbc_glyphField3.fill = GridBagConstraints.HORIZONTAL;
    gbc_glyphField3.anchor = GridBagConstraints.NORTHWEST;
    gbc_glyphField3.insets = new Insets(0, 0, 0, 5);
    gbc_glyphField3.gridx = 3;
    gbc_glyphField3.gridy = 1;
    trainingSavePanel.add(trainingGlyphField[3], gbc_glyphField3);
    trainingGlyphField[3].setColumns(2);

    trainingGlyphField[4] = new JTextField();
    GridBagConstraints gbc_glyphField4 = new GridBagConstraints();
    gbc_glyphField4.insets = new Insets(0, 0, 0, 5);
    gbc_glyphField4.fill = GridBagConstraints.HORIZONTAL;
    gbc_glyphField4.anchor = GridBagConstraints.NORTHWEST;
    gbc_glyphField4.gridx = 4;
    gbc_glyphField4.gridy = 1;
    trainingSavePanel.add(trainingGlyphField[4], gbc_glyphField4);
    trainingGlyphField[4].setColumns(2);

    JPanel testingPanel = new JPanel();
    tabbedPane.addTab("Testing", null, testingPanel, null);
    GridBagLayout gbl_testingPanel = new GridBagLayout();
    gbl_testingPanel.columnWidths = new int[] { 437, 0 };
    gbl_testingPanel.rowHeights = new int[] { 0, 0, 0, 0 };
    gbl_testingPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_testingPanel.rowWeights = new double[] { 0.0, 0.0, 1.0, Double.MIN_VALUE };
    testingPanel.setLayout(gbl_testingPanel);

    testingLoadPanel = new JPanel();
    GridBagConstraints gbc_testingLoadPanel = new GridBagConstraints();
    gbc_testingLoadPanel.anchor = GridBagConstraints.NORTHWEST;
    gbc_testingLoadPanel.insets = new Insets(0, 0, 5, 0);
    gbc_testingLoadPanel.gridx = 0;
    gbc_testingLoadPanel.gridy = 0;
    testingPanel.add(testingLoadPanel, gbc_testingLoadPanel);
    testingLoadPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));

    JButton testingLoadButton = new JButton("Download");
    testingLoadButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            testingCaptcha = downloadCAPTCHA();
            if (testingCaptcha != null) {
                testingCaptchaImage.setIcon(new ImageIcon(testingCaptcha));
                List<Image> glyphs = loadGlyphs(testingCaptcha);
                for (int g = 0; g < 5; ++g) {
                    testingGlyphImage[g].setIcon(null);
                    testingGlyphField[g].setText("");
                }
                for (int g = 0; g < glyphs.size() && g < 5; ++g) {
                    testingGlyph[g] = glyphs.get(g);
                    testingGlyphImage[g].setIcon(new ImageIcon(testingGlyph[g]));
                }
                testingLoadPanel.invalidate();
                testingSavePanel.invalidate();
            }
        }
    });
    testingLoadPanel.add(testingLoadButton);

    testingCaptchaImage = new JLabel("");
    testingLoadPanel.add(testingCaptchaImage);

    testingSavePanel = new JPanel();
    GridBagConstraints gbc_testingSavePanel = new GridBagConstraints();
    gbc_testingSavePanel.insets = new Insets(0, 5, 5, 0);
    gbc_testingSavePanel.anchor = GridBagConstraints.NORTHWEST;
    gbc_testingSavePanel.gridx = 0;
    gbc_testingSavePanel.gridy = 1;
    testingPanel.add(testingSavePanel, gbc_testingSavePanel);
    GridBagLayout gbl_testingSavePanel = new GridBagLayout();
    gbl_testingSavePanel.columnWidths = new int[] { 25, 25, 25, 25, 25, 0, 0 };
    gbl_testingSavePanel.rowHeights = new int[] { 25, 0, 0 };
    gbl_testingSavePanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
    gbl_testingSavePanel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
    testingSavePanel.setLayout(gbl_testingSavePanel);

    testingGlyph = new Image[5];
    testingGlyphImage = new JLabel[5];
    testingGlyphField = new JTextField[5];

    testingGlyphImage[0] = new JLabel("");
    GridBagConstraints gbc_testingGlyphImage0 = new GridBagConstraints();
    gbc_testingGlyphImage0.anchor = GridBagConstraints.NORTHWEST;
    gbc_testingGlyphImage0.insets = new Insets(0, 0, 5, 5);
    gbc_testingGlyphImage0.gridx = 0;
    gbc_testingGlyphImage0.gridy = 0;
    testingGlyphImage[0].setBorder(BorderFactory.createLineBorder(Color.GRAY, 2));
    testingSavePanel.add(testingGlyphImage[0], gbc_testingGlyphImage0);

    testingGlyphImage[1] = new JLabel("");
    GridBagConstraints gbc_testingGlyphImage1 = new GridBagConstraints();
    gbc_testingGlyphImage1.anchor = GridBagConstraints.NORTHWEST;
    gbc_testingGlyphImage1.insets = new Insets(0, 0, 5, 5);
    gbc_testingGlyphImage1.gridx = 1;
    gbc_testingGlyphImage1.gridy = 0;
    testingGlyphImage[1].setBorder(BorderFactory.createLineBorder(Color.GRAY, 2));
    testingSavePanel.add(testingGlyphImage[1], gbc_testingGlyphImage1);

    testingGlyphImage[2] = new JLabel("");
    GridBagConstraints gbc_testingGlyphImage2 = new GridBagConstraints();
    gbc_testingGlyphImage2.anchor = GridBagConstraints.NORTHWEST;
    gbc_testingGlyphImage2.insets = new Insets(0, 0, 5, 5);
    gbc_testingGlyphImage2.gridx = 2;
    gbc_testingGlyphImage2.gridy = 0;
    testingGlyphImage[2].setBorder(BorderFactory.createLineBorder(Color.GRAY, 2));
    testingSavePanel.add(testingGlyphImage[2], gbc_testingGlyphImage2);

    testingGlyphImage[3] = new JLabel("");
    GridBagConstraints gbc_testingGlyphImage3 = new GridBagConstraints();
    gbc_testingGlyphImage3.anchor = GridBagConstraints.NORTHWEST;
    gbc_testingGlyphImage3.insets = new Insets(0, 0, 5, 5);
    gbc_testingGlyphImage3.gridx = 3;
    gbc_testingGlyphImage3.gridy = 0;
    testingGlyphImage[3].setBorder(BorderFactory.createLineBorder(Color.GRAY, 2));
    testingSavePanel.add(testingGlyphImage[3], gbc_testingGlyphImage3);

    testingGlyphImage[4] = new JLabel("");
    GridBagConstraints gbc_testingGlyphImage4 = new GridBagConstraints();
    gbc_testingGlyphImage4.insets = new Insets(0, 0, 5, 5);
    gbc_testingGlyphImage4.anchor = GridBagConstraints.NORTHWEST;
    gbc_testingGlyphImage4.gridx = 4;
    gbc_testingGlyphImage4.gridy = 0;
    testingGlyphImage[4].setBorder(BorderFactory.createLineBorder(Color.GRAY, 2));
    testingSavePanel.add(testingGlyphImage[4], gbc_testingGlyphImage4);

    JButton testingSaveButton = new JButton("Save and test");
    testingSaveButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String text = "";
            for (int g = 0; g < 5; ++g) {
                String s = testingGlyphField[g].getText();
                if (s.length() == 1)
                    text += s.toUpperCase();
                trainingGlyphField[g].setText("");
            }

            if (text.length() != 5)
                return;

            try {
                File file = new File(tempFolder.getAbsolutePath() + "/captcha_" + text + ".png");
                ImageIO.write(testingCaptcha, "png", file);
            } catch (IOException x) {
                x.printStackTrace();
            }

            testingViewArea.setText(loadStatistics());
        }
    });
    GridBagConstraints gbc_testingSaveButton = new GridBagConstraints();
    gbc_testingSaveButton.gridheight = 2;
    gbc_testingSaveButton.insets = new Insets(0, 0, 5, 0);
    gbc_testingSaveButton.gridx = 5;
    gbc_testingSaveButton.gridy = 0;
    testingSavePanel.add(testingSaveButton, gbc_testingSaveButton);

    testingGlyphField[0] = new JTextField();
    GridBagConstraints gbc_testingGlyphField0 = new GridBagConstraints();
    gbc_testingGlyphField0.fill = GridBagConstraints.HORIZONTAL;
    gbc_testingGlyphField0.anchor = GridBagConstraints.NORTHWEST;
    gbc_testingGlyphField0.insets = new Insets(0, 0, 0, 5);
    gbc_testingGlyphField0.gridx = 0;
    gbc_testingGlyphField0.gridy = 1;
    testingSavePanel.add(testingGlyphField[0], gbc_testingGlyphField0);
    testingGlyphField[0].setColumns(2);

    testingGlyphField[1] = new JTextField();
    GridBagConstraints gbc_testingGlyphField1 = new GridBagConstraints();
    gbc_testingGlyphField1.fill = GridBagConstraints.HORIZONTAL;
    gbc_testingGlyphField1.anchor = GridBagConstraints.NORTHWEST;
    gbc_testingGlyphField1.insets = new Insets(0, 0, 0, 5);
    gbc_testingGlyphField1.gridx = 1;
    gbc_testingGlyphField1.gridy = 1;
    testingSavePanel.add(testingGlyphField[1], gbc_testingGlyphField1);
    testingGlyphField[1].setColumns(2);

    testingGlyphField[2] = new JTextField();
    GridBagConstraints gbc_testingGlyphField2 = new GridBagConstraints();
    gbc_testingGlyphField2.fill = GridBagConstraints.HORIZONTAL;
    gbc_testingGlyphField2.anchor = GridBagConstraints.NORTHWEST;
    gbc_testingGlyphField2.insets = new Insets(0, 0, 0, 5);
    gbc_testingGlyphField2.gridx = 2;
    gbc_testingGlyphField2.gridy = 1;
    testingSavePanel.add(testingGlyphField[2], gbc_testingGlyphField2);
    testingGlyphField[2].setColumns(2);

    testingGlyphField[3] = new JTextField();
    GridBagConstraints gbc_testingGlyphField3 = new GridBagConstraints();
    gbc_testingGlyphField3.fill = GridBagConstraints.HORIZONTAL;
    gbc_testingGlyphField3.anchor = GridBagConstraints.NORTHWEST;
    gbc_testingGlyphField3.insets = new Insets(0, 0, 0, 5);
    gbc_testingGlyphField3.gridx = 3;
    gbc_testingGlyphField3.gridy = 1;
    testingSavePanel.add(testingGlyphField[3], gbc_testingGlyphField3);
    testingGlyphField[3].setColumns(2);

    testingGlyphField[4] = new JTextField();
    GridBagConstraints gbc_testingGlyphField4 = new GridBagConstraints();
    gbc_testingGlyphField4.insets = new Insets(0, 0, 0, 5);
    gbc_testingGlyphField4.fill = GridBagConstraints.HORIZONTAL;
    gbc_testingGlyphField4.anchor = GridBagConstraints.NORTHWEST;
    gbc_testingGlyphField4.gridx = 4;
    gbc_testingGlyphField4.gridy = 1;
    testingSavePanel.add(testingGlyphField[4], gbc_testingGlyphField4);

    JPanel testingViewPanel = new JPanel();
    GridBagConstraints gbc_testingViewPanel = new GridBagConstraints();
    gbc_testingViewPanel.fill = GridBagConstraints.HORIZONTAL;
    gbc_testingViewPanel.anchor = GridBagConstraints.NORTHWEST;
    gbc_testingViewPanel.gridx = 0;
    gbc_testingViewPanel.gridy = 2;
    testingPanel.add(testingViewPanel, gbc_testingViewPanel);
    GridBagLayout gbl_testingViewPanel = new GridBagLayout();
    gbl_testingViewPanel.columnWidths = new int[] { 330, 0 };
    gbl_testingViewPanel.rowHeights = new int[] { 75, 0 };
    gbl_testingViewPanel.columnWeights = new double[] { 0.0, Double.MIN_VALUE };
    gbl_testingViewPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
    testingViewPanel.setLayout(gbl_testingViewPanel);

    testingViewArea = new JTextArea();
    testingViewArea.setRows(5);
    testingViewArea.setColumns(30);
    GridBagConstraints gbc_testingViewArea = new GridBagConstraints();
    gbc_testingViewArea.fill = GridBagConstraints.BOTH;
    gbc_testingViewArea.anchor = GridBagConstraints.NORTHWEST;
    gbc_testingViewArea.gridx = 0;
    gbc_testingViewArea.gridy = 0;
    testingViewPanel.add(testingViewArea, gbc_testingViewArea);
    testingGlyphField[4].setColumns(2);

    JPanel outputPanel = new JPanel();
    FlowLayout flowLayout2 = (FlowLayout) outputPanel.getLayout();
    flowLayout2.setAlignment(FlowLayout.LEFT);
    tabbedPane.addTab("Output", null, outputPanel, null);

    JPanel outputFormPanel = new JPanel();
    outputPanel.add(outputFormPanel);
    GridBagLayout gbl_outputFormPanel = new GridBagLayout();
    gbl_outputFormPanel.columnWidths = new int[] { 150, 250 };
    gbl_outputFormPanel.rowHeights = new int[] { 0 };
    gbl_outputFormPanel.columnWeights = new double[] { 0.0, 1.0 };
    gbl_outputFormPanel.rowWeights = new double[] { 0.0 };
    outputFormPanel.setLayout(gbl_outputFormPanel);

    JLabel javaLabel = new JLabel("Output .java file");
    GridBagConstraints gbc_javaLabel = new GridBagConstraints();
    gbc_javaLabel.anchor = GridBagConstraints.WEST;
    gbc_javaLabel.fill = GridBagConstraints.VERTICAL;
    gbc_javaLabel.insets = new Insets(0, 0, 5, 5);
    gbc_javaLabel.gridx = 0;
    gbc_javaLabel.gridy = 0;
    outputFormPanel.add(javaLabel, gbc_javaLabel);

    javaField = new JTextField();
    javaField.addFocusListener(new FocusListener() {
        public void focusLost(FocusEvent e) {
            javaField.removeFocusListener(this);
        }

        public void focusGained(FocusEvent e) {
            JFileChooser chooser = new JFileChooser(outFolderName);
            chooser.setSelectedFile(new File(outFileName));
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            if (chooser.showDialog(frame, "Save .java file") == JFileChooser.APPROVE_OPTION) {
                javaField.setText(chooser.getSelectedFile().getAbsolutePath());

                try {
                    PrintWriter output = new PrintWriter(
                            new FileWriter(chooser.getSelectedFile().getAbsolutePath()));
                    output.println("package com.googlecode.libautocaptcha.decoder.data;");
                    output.println("import net.sourceforge.javaocr.plugin.cluster.Cluster;");
                    output.println("import net.sourceforge.javaocr.plugin.cluster.MahalanobisDistanceCluster;");
                    output.println("public class VodafoneItalyData {");

                    output.println("  public static final int[] " + BACKGROUND_FIELD + " = ");
                    output.print("    new int[] { ");
                    for (int y = 0; y < HEIGHT; ++y)
                        for (int x = 0; x < WIDTH; ++x)
                            output.print(background.get(x, y) + ", ");
                    output.println("};");

                    output.println("  public static final char[] " + CHARACTERS_FIELD + " = ");
                    output.print("    new char[] { ");
                    for (Character c : clusters.keySet())
                        output.print("'" + c + "', ");
                    output.println("};");

                    output.println("  public static final Cluster[] " + CLUSTERS_FIELD + " = ");
                    output.print("    new MahalanobisDistanceCluster[] { ");
                    for (Cluster c : clusters.values()) {
                        output.print("new MahalanobisDistanceCluster(new double[] { ");
                        double[] mx = ((MahalanobisDistanceCluster) c).getMx();
                        for (double i : mx)
                            output.print(i + ", ");
                        output.print("}, new double[][] { ");
                        double[][] invcov = ((MahalanobisDistanceCluster) c).getInvcov();
                        for (double[] row : invcov) {
                            output.print("new double[] { ");
                            for (double i : row)
                                output.print(i + ", ");
                            output.print("}, ");
                        }
                        output.print("}), ");
                    }
                    output.println("};");

                    output.println("}");
                    output.close();
                } catch (IOException x) {
                    x.printStackTrace();
                }
            }
        }
    });
    GridBagConstraints gbc_javaField = new GridBagConstraints();
    gbc_javaField.fill = GridBagConstraints.BOTH;
    gbc_javaField.insets = new Insets(0, 0, 5, 0);
    gbc_javaField.gridx = 1;
    gbc_javaField.gridy = 0;
    outputFormPanel.add(javaField, gbc_javaField);
    javaField.setColumns(10);

    JPanel statusPanel = new JPanel();
    frame.getContentPane().add(statusPanel, BorderLayout.SOUTH);
    GridBagLayout gbl_statusPanel = new GridBagLayout();
    gbl_statusPanel.columnWidths = new int[] { 150, 0, 0 };
    gbl_statusPanel.rowHeights = new int[] { 14, 0 };
    gbl_statusPanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    gbl_statusPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
    statusPanel.setLayout(gbl_statusPanel);

    statusBar = new JProgressBar();
    GridBagConstraints gbc_statusBar = new GridBagConstraints();
    gbc_statusBar.insets = new Insets(0, 0, 0, 5);
    gbc_statusBar.gridx = 0;
    gbc_statusBar.gridy = 0;
    statusPanel.add(statusBar, gbc_statusBar);

    statusLabel = new JLabel("");
    GridBagConstraints gbc_statusLabel = new GridBagConstraints();
    gbc_statusLabel.fill = GridBagConstraints.HORIZONTAL;
    gbc_statusLabel.gridx = 1;
    gbc_statusLabel.gridy = 0;
    statusPanel.add(statusLabel, gbc_statusLabel);
}

From source file:com.sec.ose.osi.ui.frm.main.identification.patternmatch.JPanPatternMatchMain.java

/**
 * This method initializes jPanel   /*from w w w  .  j a v  a 2 s  .  c  o  m*/
 *    
 * @return javax.swing.JPanel   
 */
private JPanel getJPanelTop() {
    if (jPanelTop == null) {
        GridBagConstraints gridBagConstraints91 = new GridBagConstraints();
        gridBagConstraints91.gridx = 0;
        gridBagConstraints91.anchor = GridBagConstraints.WEST;
        gridBagConstraints91.gridy = 1;
        GridBagConstraints gridBagConstraints31 = new GridBagConstraints();
        gridBagConstraints31.gridx = 0;
        gridBagConstraints31.gridwidth = 2;
        gridBagConstraints31.anchor = GridBagConstraints.WEST;
        gridBagConstraints31.insets = new Insets(0, 40, 0, 0);
        gridBagConstraints31.gridy = 3;
        GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
        gridBagConstraints9.anchor = GridBagConstraints.WEST;
        gridBagConstraints9.gridx = 1;
        gridBagConstraints9.gridy = 4;
        gridBagConstraints9.weighty = 0.0;
        gridBagConstraints9.insets = new Insets(3, 10, 0, 0);
        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.anchor = GridBagConstraints.NORTHWEST;
        gridBagConstraints2.gridx = 0;
        gridBagConstraints2.gridy = 4;
        gridBagConstraints2.weightx = 0.0;
        gridBagConstraints2.weighty = 0.0;
        gridBagConstraints2.insets = new Insets(0, 0, 0, 0);
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
        gridBagConstraints.gridx = -1;
        gridBagConstraints.gridy = -1;
        gridBagConstraints.weightx = 0.0;
        gridBagConstraints.weighty = 0.0;
        gridBagConstraints.gridwidth = 2;
        jPanelTop = new JPanel();
        jPanelTop.setLayout(new GridBagLayout());
        jPanelTop.add(getJRadioButtonNotContain(), gridBagConstraints);
        jPanelTop.add(getJRadioButtonIKnow(), gridBagConstraints2);
        jPanelTop.add(getJButton(), gridBagConstraints9);
        jPanelTop.add(getJPanelThirdTitle(), gridBagConstraints91);
    }
    return jPanelTop;
}

From source file:io.gameover.utilities.pixeleditor.Pixelizer.java

public JPanel getColorPanel() {
    if (this.colorPanel == null) {
        this.colorPanel = new JPanel(new GridBagLayout());
        this.colorPanel.add(getColorChooser(), LayoutUtils.xyi(1, 1, 0d, 0d, new Insets(5, 5, 5, 5)));
        GridBagConstraints gbc = LayoutUtils.xyi(1, 2, 0d, 1d, new Insets(5, 5, 5, 5));
        gbc.anchor = GridBagConstraints.NORTHWEST;
        this.colorPanel.add(getColorsPanel(), gbc);
    }//from w w w. ja  va2  s  .  c o m
    return colorPanel;
}

From source file:finale.year.stage.main.Authentification.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*from   w  w  w . j a v a  2 s .co  m*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
// Generated using JFormDesigner Evaluation license - unknown
private void initComponents() {
    innerPanel = new JPanel();
    emailField = new JTextField();
    rememberMe = new JCheckBox();
    logInBtn = new JButton();
    passWord = new JPasswordField();
    signUpBtn = new JButton();
    forgotBtn = new JButton();
    userIcon = new JLabel();
    passwordIcon = new JLabel();
    errorStatusBar = new JLabel();

    //======== this ========

    // JFormDesigner evaluation mark
    setBorder(
            new javax.swing.border.CompoundBorder(
                    new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
                            "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,
                            javax.swing.border.TitledBorder.BOTTOM,
                            new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.red),
                    getBorder()));
    addPropertyChangeListener(new java.beans.PropertyChangeListener() {
        public void propertyChange(java.beans.PropertyChangeEvent e) {
            if ("border".equals(e.getPropertyName()))
                throw new RuntimeException();
        }
    });

    setLayout(new GridBagLayout());

    //======== innerPanel ========
    {
        innerPanel.setBorder(new EtchedBorder());

        //---- emailField ----
        emailField.setText("Email");
        emailField.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                emailFieldActionPerformed(e);
            }
        });

        //---- rememberMe ----
        rememberMe.setText("Remember me");
        rememberMe.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                rememberMeActionPerformed(e);
            }
        });

        //---- logInBtn ----
        logInBtn.setText("Log In");
        logInBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                logInBtnActionPerformed(e);
            }
        });

        //---- passWord ----
        passWord.setText("password");

        //---- signUpBtn ----
        signUpBtn.setText("Sign Up");
        signUpBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                signUpBtnActionPerformed(e);
            }
        });

        //---- forgotBtn ----
        forgotBtn.setText("Forgot Password?");
        forgotBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                forgotBtnActionPerformed(e);
            }
        });

        //---- userIcon ----
        userIcon.setIcon(new ImageIcon(getClass().getResource("/Resources/glyphicons_user.png")));

        //---- passwordIcon ----
        passwordIcon.setIcon(new ImageIcon(getClass().getResource("/Resources/glyphicons_lock.png")));

        GroupLayout innerPanelLayout = new GroupLayout(innerPanel);
        innerPanel.setLayout(innerPanelLayout);
        innerPanelLayout.setHorizontalGroup(innerPanelLayout.createParallelGroup().addGroup(innerPanelLayout
                .createSequentialGroup()
                .addGroup(innerPanelLayout.createParallelGroup()
                        .addGroup(innerPanelLayout.createSequentialGroup().addGap(106, 106, 106)
                                .addComponent(forgotBtn))
                        .addGroup(innerPanelLayout.createSequentialGroup().addGap(73, 73, 73)
                                .addGroup(innerPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                                        .addComponent(userIcon, GroupLayout.PREFERRED_SIZE, 45,
                                                GroupLayout.PREFERRED_SIZE)
                                        .addComponent(passwordIcon, GroupLayout.PREFERRED_SIZE, 45,
                                                GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(innerPanelLayout
                                        .createParallelGroup(GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(passWord).addComponent(emailField,
                                                GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE)))
                        .addGroup(innerPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
                                .addGroup(innerPanelLayout.createSequentialGroup().addGap(106, 106, 106)
                                        .addComponent(rememberMe)
                                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,
                                                GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(logInBtn, GroupLayout.PREFERRED_SIZE, 79,
                                                GroupLayout.PREFERRED_SIZE))
                                .addGroup(innerPanelLayout.createSequentialGroup().addGap(375, 375, 375)
                                        .addComponent(signUpBtn, GroupLayout.PREFERRED_SIZE, 79,
                                                GroupLayout.PREFERRED_SIZE)))
                        .addGroup(innerPanelLayout.createSequentialGroup().addGap(218, 218, 218)
                                .addComponent(errorStatusBar)))
                .addContainerGap(100, Short.MAX_VALUE)));
        innerPanelLayout.setVerticalGroup(innerPanelLayout.createParallelGroup().addGroup(innerPanelLayout
                .createSequentialGroup().addContainerGap().addComponent(errorStatusBar).addGap(30, 30, 30)
                .addGroup(innerPanelLayout.createParallelGroup()
                        .addComponent(userIcon, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE)
                        .addComponent(emailField, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE))
                .addGap(30, 30, 30)
                .addGroup(innerPanelLayout.createParallelGroup()
                        .addComponent(passwordIcon, GroupLayout.PREFERRED_SIZE, 38, GroupLayout.PREFERRED_SIZE)
                        .addComponent(passWord, GroupLayout.PREFERRED_SIZE, 38, GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(
                        innerPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(rememberMe, GroupLayout.PREFERRED_SIZE, 59,
                                        GroupLayout.PREFERRED_SIZE)
                                .addComponent(logInBtn))
                .addGap(6, 6, 6).addComponent(forgotBtn).addGap(6, 6, 6).addComponent(signUpBtn)
                .addContainerGap(69, Short.MAX_VALUE)));
    }
    add(innerPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE, new Insets(0, 0, 0, 0), -20, 4));
}

From source file:org.pentaho.reporting.engine.classic.core.modules.gui.pdf.PdfExportDialog.java

private JPanel createExportPanel() {
    final JButton btnSelect = new JButton(new ActionSelectFile(getResources()));
    final JLabel lblFileName = new JLabel(getResources().getString("pdfsavedialog.filename")); //$NON-NLS-1$
    final JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new GridBagLayout());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;/*from  w w  w . ja v  a  2  s.  c o m*/
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(3, 3, 1, 1);
    mainPanel.add(lblFileName, gbc);

    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1;
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.ipadx = 120;
    gbc.insets = new Insets(3, 1, 1, 1);
    mainPanel.add(txFilename, gbc);

    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.gridx = 2;
    gbc.gridy = 0;
    mainPanel.add(btnSelect, gbc);

    final JPanel advancedPaneCarrier = new JPanel();
    advancedPaneCarrier.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    advancedPaneCarrier.setLayout(new BorderLayout());
    advancedPaneCarrier.add(mainPanel, BorderLayout.NORTH);
    return advancedPaneCarrier;
}

From source file:com.sec.ose.osi.ui.dialog.setting.JPanProjectAnalysisSetting.java

/**
 * This method initializes jIntMainPanel   
 *    //from   w  ww .  j  a  v  a 2  s . com
 * @return javax.swing.JPanel   
 */
private JPanel getJIntMainPanel() {
    if (jIntMainPanel == null) {

        GridBagConstraints gridBagConstraintsSplit = new GridBagConstraints();
        gridBagConstraintsSplit.anchor = GridBagConstraints.NORTHWEST;
        gridBagConstraintsSplit.weighty = 1.0;
        gridBagConstraintsSplit.insets = new Insets(5, 5, 0, 5);
        gridBagConstraintsSplit.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraintsSplit.weightx = 1.0;

        GridBagConstraints gridBagConstraintsMonitor = new GridBagConstraints();
        gridBagConstraintsMonitor.anchor = GridBagConstraints.WEST;
        gridBagConstraintsMonitor.weighty = 1.0;
        gridBagConstraintsMonitor.insets = new Insets(5, 5, 0, 5);
        gridBagConstraintsMonitor.gridx = 0;
        gridBagConstraintsMonitor.gridy = 1;
        gridBagConstraintsMonitor.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraintsMonitor.weightx = 1.0;

        jIntMainPanel = new JPanel();
        jIntMainPanel.setLayout(new GridBagLayout());
        jIntMainPanel.setBorder(BorderFactory.createTitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION,
                TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
        jIntMainPanel.add(getJPanelProjectSplit(), gridBagConstraintsSplit);
        jIntMainPanel.add(getJPanelMonitorInterval(), gridBagConstraintsMonitor);
    }
    return jIntMainPanel;
}