Example usage for java.awt.event MouseEvent getClickCount

List of usage examples for java.awt.event MouseEvent getClickCount

Introduction

In this page you can find the example usage for java.awt.event MouseEvent getClickCount.

Prototype

public int getClickCount() 

Source Link

Document

Returns the number of mouse clicks associated with this event.

Usage

From source file:view.MainWindow.java

private void jtOpenedDocumentsMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jtOpenedDocumentsMousePressed
    if (evt.getClickCount() == 2) {
        if (openedFile != null && jtOpenedDocuments.getRowCount() > 0
                && jtOpenedDocuments.getSelectionRows().length != 1) {
            //TreePath treePath = evt.getOldLeadSelectionPath();
            //jtOpenedDocuments.setSelectionPath(treePath);
        } else {//from w  ww .  ja  va 2s.co  m
            if (null == jtOpenedDocuments.getSelectionPath()) {
                return;
            }
            // 1 ficheiro seleccionado
            String selectedFile = "";
            Object[] paths = jtOpenedDocuments.getSelectionPath().getPath();
            for (int i = 1; i < paths.length; i++) {
                selectedFile += paths[i];
                if (i + 1 < paths.length) {
                    selectedFile += File.separator;
                }
            }
            File file = new File(selectedFile);
            if (file.exists() && file.isFile() && selectedFile.endsWith(".pdf")) {
                ctrl.openDocument(file.getAbsolutePath());
                workspacePanel.setDocument(ctrl.getDocument());
                openedFile = file;
            } else if (file.exists() && file.isDirectory() && null != file.list()) {
                if (0 < file.list().length) {
                    loadFolder(file, true);
                }
            }
        }
    }
}

From source file:SwingGlassExample.java

private void redispatchMouseEvent(MouseEvent e) {
    boolean inButton = false;
    boolean inMenuBar = false;
    Point glassPanePoint = e.getPoint();
    Component component = null;//from ww w  .j av a2s  .c  om
    Container container = contentPane;
    Point containerPoint = SwingUtilities.convertPoint(this, glassPanePoint, contentPane);
    int eventID = e.getID();

    if (containerPoint.y < 0) {
        inMenuBar = true;
        container = menuBar;
        containerPoint = SwingUtilities.convertPoint(this, glassPanePoint, menuBar);
        testForDrag(eventID);
    }

    //XXX: If the event is from a component in a popped-up menu,
    //XXX: then the container should probably be the menu's
    //XXX: JPopupMenu, and containerPoint should be adjusted
    //XXX: accordingly.
    component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x, containerPoint.y);

    if (component == null) {
        return;
    } else {
        inButton = true;
        testForDrag(eventID);
    }

    if (inMenuBar || inButton || inDrag) {
        Point componentPoint = SwingUtilities.convertPoint(this, glassPanePoint, component);
        component.dispatchEvent(new MouseEvent(component, eventID, e.getWhen(), e.getModifiers(),
                componentPoint.x, componentPoint.y, e.getClickCount(), e.isPopupTrigger()));
    }
}

From source file:com.puzzle.gui.MainFrame.java

private void jDialog1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jDialog1MouseClicked
    // TODO add your handling code here:
    if (evt.getClickCount() == 2 && evt.getButton() == MouseEvent.BUTTON1) {
        if (jDialog1.getSize().width < 900) {
            jDialog1.setSize(Toolkit.getDefaultToolkit().getScreenSize().width,
                    Toolkit.getDefaultToolkit().getScreenSize().height);
            jDialog1.setLocationRelativeTo(null);
        } else {/*from  w w w  .  j a va 2 s  .  co  m*/
            jDialog1.setSize(800, 540);
            jDialog1.setLocationRelativeTo(null);
        }

    }

}

From source file:com.puzzle.gui.MainFrame.java

private void jTable3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable3MouseClicked
    // TODO add your handling code here:
    if (evt.getClickCount() == 2 && evt.getButton() == MouseEvent.BUTTON1) {
        int rowNumber = this.jTable3.getSelectedRow();
        String fileName = (String) this.jTable3.getValueAt(rowNumber, 1);

        String content = null;/*  w w  w . java2  s . c  om*/
        try {
            content = org.apache.commons.io.FileUtils.readFileToString(new File(fileName), "UTF-8");
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        //              String ll=this.readXML(workpath,ff);
        this.jDialog1.setTitle(fileName);
        //??

        textArea.setText(content);
        textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML);
        textArea.setCodeFoldingEnabled(true);
        textArea.setAutoscrolls(true);
        //            textArea.setBackground(Color.black);
        textArea.setEditable(false);
        //             textArea.setVisible(true);
        this.jPanel6.add(sp);

        this.jDialog1.setLocationRelativeTo(this);
        this.jDialog1.setVisible(true);
    } //GEN-LAST:event_jTable3MouseClicked
}

From source file:com.puzzle.gui.MainFrame.java

private void jTable4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable4MouseClicked
    // TODO add your handling code here:
    if (evt.getClickCount() == 2 && evt.getButton() == MouseEvent.BUTTON1) {
        int rowNumber = this.jTable4.getSelectedRow();
        String fileName = (String) this.jTable4.getValueAt(rowNumber, 1);

        String content = null;/*from  w  w w.  ja  v a 2s .co m*/
        try {
            content = org.apache.commons.io.FileUtils.readFileToString(new File(fileName), "UTF-8");
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        //              String ll=this.readXML(workpath,ff);
        this.jDialog1.setTitle(fileName);
        //??

        textArea.setText(content);
        textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML);
        textArea.setCodeFoldingEnabled(true);
        textArea.setAutoscrolls(true);
        //            textArea.setBackground(Color.black);
        textArea.setEditable(false);
        //             textArea.setVisible(true);
        this.jPanel6.add(sp);

        this.jDialog1.setLocationRelativeTo(this);
        this.jDialog1.setVisible(true);
    }
}

From source file:com.puzzle.gui.MainFrame.java

private void jTable2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable2MouseClicked
    // TODO add your handling code here:
    if (evt.getClickCount() == 2 && evt.getButton() == MouseEvent.BUTTON1) {
        int rowNumber = this.jTable2.getSelectedRow();
        String fileName = (String) this.jTable2.getValueAt(rowNumber, 1);

        String content = null;/*from w  ww.j av  a  2  s .  co m*/
        try {
            content = org.apache.commons.io.FileUtils.readFileToString(new File(fileName), "UTF-8");
        } catch (IOException ex) {
            ex.printStackTrace();
            return;
        }
        //              String ll=this.readXML(workpath,ff);
        this.jDialog1.setTitle(fileName);
        //??
        textArea.setText(content);
        textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML);
        textArea.setCodeFoldingEnabled(true);
        textArea.setAutoscrolls(true);
        //            textArea.setBackground(Color.black);
        textArea.setEditable(false);
        //             textArea.setVisible(true);
        this.jPanel6.add(sp);

        this.jDialog1.setLocationRelativeTo(this);
        this.jDialog1.setVisible(true);
    }

}

From source file:com.puzzle.gui.MainFrame.java

private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
    // TODO add your handling code here:
    if (evt.getClickCount() == 2 && evt.getButton() == MouseEvent.BUTTON1) {
        int rowNumber = this.jTable1.getSelectedRow();
        String fileName = (String) this.jTable1.getValueAt(rowNumber, 1);
        String[] names = fileName.split("\\\\");
        String ff = names[names.length - 1];
        fileName = FileDto.getSingleInstance().fileSendBakPath + File.separator + DateUtil.getCurrDateMM()
                + File.separator + ff;
        String content = null;//w  w w .ja  v a  2s . c o  m
        try {
            content = org.apache.commons.io.FileUtils.readFileToString(new File(fileName), "UTF-8");
        } catch (IOException ex) {
            ex.printStackTrace();
            return;
        }
        //              String ll=this.readXML(workpath,ff);
        this.jDialog1.setTitle(fileName);
        //??
        textArea.setText(content);
        textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML);
        textArea.setCodeFoldingEnabled(true);
        textArea.setAutoscrolls(true);
        //            textArea.setBackground(Color.black);
        textArea.setEditable(false);
        //             textArea.setVisible(true);
        this.jPanel6.add(sp);

        this.jDialog1.setLocationRelativeTo(this);
        this.jDialog1.setVisible(true);
    }
}

From source file:org.openmicroscopy.shoola.agents.fsimporter.util.FileImportComponent.java

/** Initializes the components. */
private void initComponents() {
    actionMenuButton = new JButton();
    actionMenuButton.setVisible(false);/*from  w ww .j  a v a2 s.  c o  m*/
    actionMenuButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            JPopupMenu popup = createActionMenu();
            popup.show(actionMenuButton, 0, actionMenuButton.getHeight());
        }
    });

    adapter = new MouseAdapter() {

        /**
         * Views the image.
         * @see MouseListener#mousePressed(MouseEvent)
         */
        public void mousePressed(MouseEvent e) {
            if (e.getClickCount() == 1) {
                launchFullViewer();
            }
        }
    };

    setLayout(new FlowLayout(FlowLayout.LEFT));
    busyLabel = new JXBusyLabel(SIZE);
    busyLabel.setVisible(false);
    busyLabel.setBusy(false);

    cancelButton = new JButton("Cancel");
    cancelButton.setForeground(UIUtilities.HYPERLINK_COLOR);
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            cancelLoading();
        }
    });
    cancelButton.setVisible(true);

    namePane = new JPanel();
    namePane.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
    IconManager icons = IconManager.getInstance();
    Icon icon;
    if (getFile().isFile())
        icon = icons.getIcon(IconManager.IMAGE);
    else
        icon = icons.getIcon(IconManager.DIRECTORY);
    imageLabel = new ThumbnailLabel(icon);
    imageLabel.addPropertyChangeListener(this);
    imageLabels = new ArrayList<ThumbnailLabel>();
    ThumbnailLabel label;
    for (int i = 0; i < MAX_THUMBNAILS; i++) {
        label = new ThumbnailLabel();
        if (i == MAX_THUMBNAILS - 1) {
            Font f = label.getFont();
            label.setFont(f.deriveFont(f.getStyle(), f.getSize() - 2));
        }
        label.setVisible(false);
        label.addPropertyChangeListener(this);
        imageLabels.add(label);
    }
    fileNameLabel = new JLabel(getFile().getName());
    namePane.add(imageLabel);
    Iterator<ThumbnailLabel> j = imageLabels.iterator();
    while (j.hasNext()) {
        namePane.add(j.next());
    }
    namePane.add(Box.createHorizontalStrut(4));
    namePane.add(fileNameLabel);
    namePane.add(Box.createHorizontalStrut(10));
    resultLabel = new JLabel();
    statusLabel = new StatusLabel(importable.getFile());
    statusLabel.addPropertyChangeListener(this);
    image = null;
    refButton = cancelButton;
    refLabel = busyLabel;
}

From source file:mt.listeners.InteractiveRANSAC.java

public void CardTable() {
    this.lambdaSB = new Scrollbar(Scrollbar.HORIZONTAL, this.lambdaInt, 1, MIN_SLIDER, MAX_SLIDER + 1);

    maxSlopeSB.setValue(utility.Slicer.computeScrollbarPositionFromValue((float) maxSlope,
            (float) MIN_ABS_SLOPE, (float) MAX_ABS_SLOPE, scrollbarSize));

    maxDistSB.setValue(//  w w w . ja v a2 s  .  c o  m
            utility.Slicer.computeScrollbarPositionFromValue(maxDist, MIN_Gap, MAX_Gap, scrollbarSize));

    minInliersSB.setValue(utility.Slicer.computeScrollbarPositionFromValue(minInliers, MIN_Inlier, MAX_Inlier,
            scrollbarSize));
    maxErrorSB.setValue(
            utility.Slicer.computeScrollbarPositionFromValue(maxError, MIN_ERROR, MAX_ERROR, scrollbarSize));

    minSlopeSB.setValue(utility.Slicer.computeScrollbarPositionFromValue((float) minSlope,
            (float) MIN_ABS_SLOPE, (float) MAX_ABS_SLOPE, scrollbarSize));

    lambdaLabel = new Label("Linearity (fraction) = " + new DecimalFormat("#.##").format(lambda), Label.CENTER);
    maxErrorLabel = new Label("Maximum Error (px) = " + new DecimalFormat("#.##").format(maxError) + "      ",
            Label.CENTER);
    minInliersLabel = new Label(
            "Minimum No. of timepoints (tp) = " + new DecimalFormat("#.##").format(minInliers), Label.CENTER);
    maxDistLabel = new Label("Maximum Gap (tp) = " + new DecimalFormat("#.##").format(maxDist), Label.CENTER);

    minSlopeLabel = new Label("Min. Segment Slope (px/tp) = " + new DecimalFormat("#.##").format(minSlope),
            Label.CENTER);
    maxSlopeLabel = new Label("Max. Segment Slope (px/tp) = " + new DecimalFormat("#.##").format(maxSlope),
            Label.CENTER);
    maxResLabel = new Label(
            "MT is rescued if the start of event# i + 1 > start of event# i by px =  " + this.restolerance,
            Label.CENTER);

    CardLayout cl = new CardLayout();
    Object[] colnames = new Object[] { "Track File", "Growth velocity", "Shrink velocity", "Growth events",
            "Shrink events", "fcat", "fres", "Error" };

    Object[][] rowvalues = new Object[0][colnames.length];

    if (inputfiles != null) {
        rowvalues = new Object[inputfiles.length][colnames.length];
        for (int i = 0; i < inputfiles.length; ++i) {

            rowvalues[i][0] = inputfiles[i].getName();
        }
    }

    table = new JTable(rowvalues, colnames);

    table.setFillsViewportHeight(true);

    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    table.isOpaque();
    int size = 100;
    table.getColumnModel().getColumn(0).setPreferredWidth(size);
    table.getColumnModel().getColumn(1).setPreferredWidth(size);
    table.getColumnModel().getColumn(2).setPreferredWidth(size);
    table.getColumnModel().getColumn(3).setPreferredWidth(size);
    table.getColumnModel().getColumn(4).setPreferredWidth(size);
    table.getColumnModel().getColumn(5).setPreferredWidth(size);
    table.getColumnModel().getColumn(6).setPreferredWidth(size);
    table.getColumnModel().getColumn(7).setPreferredWidth(size);
    maxErrorField = new TextField(5);
    maxErrorField.setText(Float.toString(maxError));

    minInlierField = new TextField(5);
    minInlierField.setText(Float.toString(minInliers));

    maxGapField = new TextField(5);
    maxGapField.setText(Float.toString(maxDist));

    maxSlopeField = new TextField(5);
    maxSlopeField.setText(Float.toString(maxSlope));

    minSlopeField = new TextField(5);
    minSlopeField.setText(Float.toString(minSlope));

    maxErrorSB.setSize(new Dimension(SizeX, 20));
    minSlopeSB.setSize(new Dimension(SizeX, 20));
    minInliersSB.setSize(new Dimension(SizeX, 20));
    maxDistSB.setSize(new Dimension(SizeX, 20));
    maxSlopeSB.setSize(new Dimension(SizeX, 20));
    maxErrorField.setSize(new Dimension(SizeX, 20));
    minInlierField.setSize(new Dimension(SizeX, 20));
    maxGapField.setSize(new Dimension(SizeX, 20));
    minSlopeField.setSize(new Dimension(SizeX, 20));
    maxSlopeField.setSize(new Dimension(SizeX, 20));

    scrollPane = new JScrollPane(table);
    scrollPane.setMinimumSize(new Dimension(300, 200));
    scrollPane.setPreferredSize(new Dimension(300, 200));

    scrollPane.getViewport().add(table);
    scrollPane.setAutoscrolls(true);

    // Location
    panelFirst.setLayout(layout);
    panelSecond.setLayout(layout);
    PanelSavetoFile.setLayout(layout);
    PanelParameteroptions.setLayout(layout);
    Panelfunction.setLayout(layout);
    Panelslope.setLayout(layout);
    PanelCompileRes.setLayout(layout);
    PanelDirectory.setLayout(layout);

    panelCont.setLayout(cl);

    panelCont.add(panelFirst, "1");
    panelCont.add(panelSecond, "2");

    panelFirst.setName("Ransac fits for rates and frequency analysis");
    c.insets = new Insets(5, 5, 5, 5);
    c.anchor = GridBagConstraints.BOTH;
    c.ipadx = 35;

    inputLabelT = new Label("Compute length distribution at time: ");
    inputLabelTcont = new Label("(Press Enter to start computation) ");
    inputFieldT = new TextField(5);
    inputFieldT.setText("1");

    c.gridwidth = 10;
    c.gridheight = 10;
    c.gridy = 1;
    c.gridx = 0;

    String[] Method = { "Linear Function only", "Linearized Quadratic function", "Linearized Cubic function" };
    JComboBox<String> ChooseMethod = new JComboBox<String>(Method);

    final Checkbox findCatastrophe = new Checkbox("Detect Catastrophies", this.detectCatastrophe);
    final Checkbox findmanualCatastrophe = new Checkbox("Detect Catastrophies without fit",
            this.detectmanualCatastrophe);
    final Scrollbar minCatDist = new Scrollbar(Scrollbar.HORIZONTAL, this.minDistCatInt, 1, MIN_SLIDER,
            MAX_SLIDER + 1);
    final Scrollbar maxRes = new Scrollbar(Scrollbar.HORIZONTAL, this.restoleranceInt, 1, MIN_SLIDER,
            MAX_SLIDER + 1);
    final Label minCatDistLabel = new Label("Min. Catastrophy height (tp) = " + this.minDistanceCatastrophe,
            Label.CENTER);
    final Button done = new Button("Done");
    final Button batch = new Button("Save Parameters for Batch run");
    final Button cancel = new Button("Cancel");
    final Button Compile = new Button("Compute rates and freq. till current file");
    final Button AutoCompile = new Button("Auto Compute Velocity and Frequencies");
    final Button Measureserial = new Button("Select directory of MTrack generated files");
    final Button WriteLength = new Button("Compute length distribution at framenumber : ");
    final Button WriteStats = new Button("Compute lifetime and mean length distribution");
    final Button WriteAgain = new Button("Save Velocity and Frequencies to File");

    PanelDirectory.add(Measureserial, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelDirectory.add(scrollPane, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));
    PanelDirectory.setBorder(selectdirectory);
    PanelDirectory.setPreferredSize(new Dimension(SizeX, SizeY));
    panelFirst.add(PanelDirectory, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    SliderBoxGUI combomaxerror = new SliderBoxGUI(errorstring, maxErrorSB, maxErrorField, maxErrorLabel,
            scrollbarSize, maxError, MAX_ERROR);

    PanelParameteroptions.add(combomaxerror.BuildDisplay(), new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    SliderBoxGUI combomininlier = new SliderBoxGUI(inlierstring, minInliersSB, minInlierField, minInliersLabel,
            scrollbarSize, minInliers, MAX_Inlier);

    PanelParameteroptions.add(combomininlier.BuildDisplay(), new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    SliderBoxGUI combomaxdist = new SliderBoxGUI(maxgapstring, maxDistSB, maxGapField, maxDistLabel,
            scrollbarSize, maxDist, MAX_Gap);

    PanelParameteroptions.add(combomaxdist.BuildDisplay(), new GridBagConstraints(0, 3, 3, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelParameteroptions.add(ChooseMethod, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0,
            GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelParameteroptions.add(lambdaSB, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));
    PanelParameteroptions.add(lambdaLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelParameteroptions.setPreferredSize(new Dimension(SizeX, SizeY));
    PanelParameteroptions.setBorder(selectparam);
    panelFirst.add(PanelParameteroptions, new GridBagConstraints(3, 0, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    SliderBoxGUI combominslope = new SliderBoxGUI(minslopestring, minSlopeSB, minSlopeField, minSlopeLabel,
            scrollbarSize, (float) minSlope, (float) MAX_ABS_SLOPE);

    Panelslope.add(combominslope.BuildDisplay(), new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    SliderBoxGUI combomaxslope = new SliderBoxGUI(maxslopestring, maxSlopeSB, maxSlopeField, maxSlopeLabel,
            scrollbarSize, (float) maxSlope, (float) MAX_ABS_SLOPE);

    Panelslope.add(combomaxslope.BuildDisplay(), new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    Panelslope.add(findCatastrophe, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0, GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));
    Panelslope.add(findmanualCatastrophe, new GridBagConstraints(4, 4, 3, 1, 0.0, 0.0, GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));
    Panelslope.add(minCatDist, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0, GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));
    Panelslope.add(minCatDistLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 0.0, GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));
    Panelslope.setBorder(selectslope);
    Panelslope.setPreferredSize(new Dimension(SizeX, SizeY));

    panelFirst.add(Panelslope, new GridBagConstraints(3, 1, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelCompileRes.add(AutoCompile, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelCompileRes.add(WriteLength, new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelCompileRes.add(inputFieldT, new GridBagConstraints(3, 1, 3, 1, 0.1, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelCompileRes.add(WriteStats, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelCompileRes.setPreferredSize(new Dimension(SizeX, SizeY));

    PanelCompileRes.setBorder(compileres);

    panelFirst.add(PanelCompileRes, new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    if (inputfiles != null) {

        table.addMouseListener(new MouseAdapter() {

            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() >= 1) {

                    if (!jFreeChartFrame.isVisible())
                        jFreeChartFrame = Tracking.display(chart, new Dimension(500, 500));
                    JTable target = (JTable) e.getSource();
                    row = target.getSelectedRow();
                    // do some action if appropriate column
                    if (row > 0)
                        displayclicked(row);
                    else
                        displayclicked(0);
                }
            }
        });
    }

    maxErrorSB.addAdjustmentListener(new ErrorListener(this, maxErrorLabel, errorstring, MIN_ERROR, MAX_ERROR,
            scrollbarSize, maxErrorSB));

    minInliersSB.addAdjustmentListener(new MinInlierListener(this, minInliersLabel, inlierstring, MIN_Inlier,
            MAX_Inlier, scrollbarSize, minInliersSB));

    maxDistSB.addAdjustmentListener(
            new MaxDistListener(this, maxDistLabel, maxgapstring, MIN_Gap, MAX_Gap, scrollbarSize, maxDistSB));

    ChooseMethod.addActionListener(new FunctionItemListener(this, ChooseMethod));
    lambdaSB.addAdjustmentListener(new LambdaListener(this, lambdaLabel, lambdaSB));
    minSlopeSB.addAdjustmentListener(new MinSlopeListener(this, minSlopeLabel, minslopestring,
            (float) MIN_ABS_SLOPE, (float) MAX_ABS_SLOPE, scrollbarSize, minSlopeSB));

    maxSlopeSB.addAdjustmentListener(new MaxSlopeListener(this, maxSlopeLabel, maxslopestring,
            (float) MIN_ABS_SLOPE, (float) MAX_ABS_SLOPE, scrollbarSize, maxSlopeSB));
    findCatastrophe.addItemListener(
            new CatastrophyCheckBoxListener(this, findCatastrophe, minCatDistLabel, minCatDist));
    findmanualCatastrophe.addItemListener(
            new ManualCatastrophyCheckBoxListener(this, findmanualCatastrophe, minCatDistLabel, minCatDist));
    minCatDist.addAdjustmentListener(new MinCatastrophyDistanceListener(this, minCatDistLabel, minCatDist));
    Measureserial.addActionListener(new MeasureserialListener(this));
    Compile.addActionListener(new CompileResultsListener(this));
    AutoCompile.addActionListener(new AutoCompileResultsListener(this));
    WriteLength.addActionListener(new WriteLengthListener(this));
    WriteStats.addActionListener(new WriteStatsListener(this));
    WriteAgain.addActionListener(new WriteRatesListener(this));
    done.addActionListener(new FinishButtonListener(this, false));
    batch.addActionListener(new RansacBatchmodeListener(this));
    cancel.addActionListener(new FinishButtonListener(this, true));
    inputFieldT.addTextListener(new LengthdistroListener(this));

    maxSlopeField.addTextListener(new MaxSlopeLocListener(this, false));
    minSlopeField.addTextListener(new MinSlopeLocListener(this, false));
    maxErrorField.addTextListener(new ErrorLocListener(this, false));
    minInlierField.addTextListener(new MinInlierLocListener(this, false));
    maxGapField.addTextListener(new MaxDistLocListener(this, false));

    panelFirst.setVisible(true);
    functionChoice = 0;

    cl.show(panelCont, "1");

    Cardframe.add(panelCont, BorderLayout.CENTER);

    setFunction();
    Cardframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    Cardframe.pack();
    Cardframe.setVisible(true);
    Cardframe.pack();

}

From source file:edu.ku.brc.specify.tasks.subpane.wb.FormPane.java

/**
 * Creates all the UI form the Form. //ww w .  j  a v a  2  s .c o m
 */
protected void buildUI() {
    headers.addAll(workbench.getWorkbenchTemplate().getWorkbenchTemplateMappingItems());
    Collections.sort(headers);

    MouseAdapter clickable = new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            selectControl(e.getSource());
        }

        @Override
        public void mouseClicked(MouseEvent e) {
            selectedInputPanel = getInputPanel(e.getSource());
            controlPropsBtn.setEnabled(true);

            if (controlPropsDlg != null) {
                controlPropsDlg.setControl(selectedInputPanel);
            }

            if (e.getClickCount() == 2 && (controlPropsDlg == null || !controlPropsDlg.isVisible())) {
                UsageTracker.incrUsageCount("WB.FormPropsTool");
                showControlProps();
            }

        }
    };

    Point topLeftPnt = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE);

    final int LAYOUT_SPACING = 4;
    short maxY = 0;
    Vector<InputPanel> delayedLayout = new Vector<InputPanel>();
    int maxWidthOffset = 0;
    for (WorkbenchTemplateMappingItem wbtmi : headers) {
        // Create the InputPanel and make it draggable
        InputPanel panel = new InputPanel(wbtmi, wbtmi.getCaption(), createUIComp(wbtmi), this, clickable);

        Dimension size = panel.getPreferredSize();
        panel.setSize(size);
        panel.setPreferredSize(size);

        // Finds the largest label
        maxWidthOffset = Math.max(panel.getTextFieldOffset(), maxWidthOffset);

        int x = wbtmi.getXCoord();
        int y = wbtmi.getYCoord();
        if (y < topLeftPnt.y || (y == topLeftPnt.y && x < topLeftPnt.x)) {
            firstComp = panel.getComp();
            topLeftPnt.setLocation(x, y);
        }

        // Add it to the Form (drag canvas)
        uiComps.add(panel);
        add(panel);

        // NOTE: that the constructor sets the x,y storage from WorkbenchTemplateMappingItem object
        // so the ones with XCoord and YCoord set do not need to be positioned
        if (wbtmi.getXCoord() == null || wbtmi.getYCoord() == null || wbtmi.getXCoord() == -1
                || wbtmi.getYCoord() == -1) {
            delayedLayout.add(panel); // remember this for later once we know the Max Y

        } else {
            maxY = (short) Math.max(wbtmi.getYCoord() + size.height, maxY);
        }
    }

    // Now align the control by their text fields and skips the ones that have actual positions defined.
    // NOTE: We set the X,Y into the Mapping so that each item knows where it is, then if the user
    // drags and drop anything or save the template everyone knows where they are suppose to be
    // 
    int inx = 0;
    int maxX = 0;
    int y = maxY + LAYOUT_SPACING;
    for (InputPanel panel : uiComps) {
        WorkbenchTemplateMappingItem wbtmi = headers.get(inx);
        if (delayedLayout.contains(panel)) {
            int x = maxWidthOffset - panel.getTextFieldOffset();
            panel.setLocation(x, y);
            wbtmi.setXCoord((short) x);
            wbtmi.setYCoord((short) y);

            Dimension size = panel.getPreferredSize();
            y += size.height + LAYOUT_SPACING;

        }
        Rectangle r = panel.getBounds();
        maxX = Math.max(maxX, r.x + r.width);
        inx++;
    }

    initialSize = new Dimension(maxX, y);

    controlPropsBtn = createIconBtn("ControlEdit", IconManager.IconSize.NonStd, "WB_EDIT_CONTROL", false,
            new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    UsageTracker.getUsageCount("WBFormPropsTool");
                    showControlProps();
                }
            });

    addArrowTraversalKeys();
}