Example usage for java.awt TextField setEditable

List of usage examples for java.awt TextField setEditable

Introduction

In this page you can find the example usage for java.awt TextField setEditable.

Prototype

public synchronized void setEditable(boolean b) 

Source Link

Document

Sets the flag that determines whether or not this text component is editable.

Usage

From source file:gdsc.smlm.ij.plugins.PSFCalculator.java

private void disableEditing(TextField textField) {
    textField.setEditable(false);
    textField.setBackground(SystemColor.control);
}

From source file:de.biomedical_imaging.ij.steger.Lines_.java

@Override
public boolean dialogItemChanged(GenericDialog gd, AWTEvent e) {
    imp.setOverlay(null);//from  w  ww.  ja va2  s  . c  om
    boolean lwChanged = false;
    boolean contHighChanged = false;
    boolean contLowChanged = false;
    boolean darklineChanged = false;

    double lwCand = gd.getNextNumber();
    double diff = Math.abs(lwCand - lineWidth);
    if (diff > 0.0001) {
        lineWidth = lwCand;
        lwChanged = true;
    }
    double conCand = gd.getNextNumber();
    diff = Math.abs(conCand - contrastHigh);
    if (diff > 0.0001) {
        contrastHigh = conCand;
        contHighChanged = true;
    }

    conCand = gd.getNextNumber();
    diff = Math.abs(conCand - contrastLow);
    if (diff > 0.0001) {
        contrastLow = conCand;
        contLowChanged = true;
    }

    boolean darklineCand = gd.getNextBoolean();
    if (darklineCand != isDarkLine) {
        isDarkLine = darklineCand;
        darklineChanged = true;
    }

    doCorrectPosition = gd.getNextBoolean();
    doEstimateWidth = gd.getNextBoolean();
    doExtendLine = gd.getNextBoolean();
    showJunctionPoints = gd.getNextBoolean();
    showIDs = gd.getNextBoolean();
    verbose = gd.getNextBoolean();
    displayResults = gd.getNextBoolean();
    addToRoiManager = gd.getNextBoolean();
    overlapOption = OverlapOption.valueOf(gd.getNextChoice());
    if (lwChanged || contHighChanged || contLowChanged) {
        contrastOrLineWidthChangedOnce = true;
    }

    if (lwChanged || contHighChanged || contLowChanged || (darklineChanged && contrastOrLineWidthChangedOnce)) {
        double estimatedSigma = lineWidth / (2 * Math.sqrt(3)) + 0.5;
        TextField textSigma = (TextField) gd.getNumericFields().get(3);
        textSigma.setText("" + IJ.d2s(estimatedSigma, 2));
        textSigma.setEditable(true);
        double clow = contrastLow;
        if (isDarkLine) {
            clow = 255 - contrastHigh;
        }
        double estimatedLowerThresh = Math.floor(Math.abs(-2 * clow * (lineWidth / 2.0)
                / (Math.sqrt(2 * Math.PI) * estimatedSigma * estimatedSigma * estimatedSigma)
                * Math.exp(-((lineWidth / 2.0) * (lineWidth / 2.0)) / (2 * estimatedSigma * estimatedSigma))));
        TextField textLowThresh = (TextField) gd.getNumericFields().get(4);
        textLowThresh.setText("" + IJ.d2s(estimatedLowerThresh * 0.17, 2));
        textLowThresh.setEditable(true);
        double chigh = contrastHigh;
        if (isDarkLine) {
            chigh = 255 - contrastLow;
        }
        double estimatedUpperThresh = Math.floor(Math.abs(-2 * chigh * (lineWidth / 2.0)
                / (Math.sqrt(2 * Math.PI) * estimatedSigma * estimatedSigma * estimatedSigma)
                * Math.exp(-((lineWidth / 2.0) * (lineWidth / 2.0)) / (2 * estimatedSigma * estimatedSigma))));
        TextField textUppThresh = (TextField) gd.getNumericFields().get(5);
        textUppThresh.setText("" + IJ.d2s(estimatedUpperThresh * 0.17, 2));
        textUppThresh.setEditable(true);
    }
    sigma = gd.getNextNumber();
    lowerThresh = gd.getNextNumber();
    upperThresh = gd.getNextNumber();
    if (lowerThresh >= upperThresh || sigma < 0.4 || Double.isNaN(sigma + lowerThresh + upperThresh)) {
        return false;
    }

    isPreview = gd.isPreviewActive();

    return true;
}

From source file:net.sf.freecol.FreeCol.java

public static void startYourAddition() throws FontFormatException, IOException {
    Frame mainFrame;/*w w w.ja va2s.c  o  m*/
    Frame mainFrame2;
    TextField t1;
    TextField t2;
    TextField t3;
    TextField t4;
    Frame mainFrame3 = new Frame("Haha, am i middle?");
    mainFrame = new Frame("Haha, am I right?!");
    mainFrame.setSize(400, 400);
    mainFrame.setLayout(null);

    t1 = new TextField("Enter here");
    t1.setBounds(160, 200, 150, 50);

    t2 = new TextField("What grade do we deserve?");
    t3 = new TextField("Enter here");
    t3.setBounds(160, 200, 150, 50);

    t4 = new TextField("What letter grade do we deserve?");
    Button b = new Button("click ----->");
    b.setBounds(30, 250, 130, 30);
    b.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            t2.setText("I think you meant 100");
        }
    });
    Button c = new Button("Submit");
    c.setBounds(150, 250, 80, 30);
    c.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            String in = t1.getText();
            if (in.equals("100")) {
                t1.setText("Correct");
                t1.setEditable(false);
                t1.setBackground(new Color(95, 216, 109));

                if (t3.getText().equals("Correct")) {
                    mainFrame3.setVisible(true);
                }
            } else {
                t1.setText("Wrong");
                t1.setBackground(new Color(214, 81, 96));
            }
        }
    });

    t2.setBounds(160, 0, 175, 100);
    t2.setEditable(false);

    mainFrame.add(b);
    mainFrame.add(c);
    mainFrame.add(t1);
    mainFrame.add(t2);

    mainFrame.setLocation(1280, 0);

    mainFrame.setVisible(true);

    ///////////////The left area below and above is right

    mainFrame2 = new Frame("Haha, am i left?");
    mainFrame2.setSize(400, 400);
    mainFrame2.setLayout(null);

    Button b2 = new Button("click ----->");
    b2.setBounds(30, 250, 130, 30);
    b2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            t4.setText("I think you meant A");
        }
    });
    Button c2 = new Button("Submit");
    c2.setBounds(150, 250, 80, 30);
    c2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            String in = t3.getText();
            if (in.equals("A")) {
                t3.setText("Correct");
                t3.setEditable(false);
                t3.setBackground(new Color(95, 216, 109));

                if (t1.getText().equals("Correct")) {
                    mainFrame3.setVisible(true);
                }

            } else {
                t3.setText("Wrong");
                t3.setBackground(new Color(214, 81, 96));
            }
        }
    });

    t4.setBounds(120, 0, 220, 100);
    t4.setEditable(false);

    mainFrame2.add(b2);
    mainFrame2.add(c2);
    mainFrame2.add(t3);
    mainFrame2.add(t4);

    mainFrame2.setVisible(true);

    //Overall correct

    mainFrame3.setSize(400, 400);
    mainFrame3.setLayout(null);
    mainFrame3.setLocation(640, 420);
    mainFrame3.setBackground(new Color(95, 216, 109));
    TextField t6 = new TextField("Soooooo give us an A!!!");
    t6.setBounds(160, 200, 200, 50);
    t6.setBackground(new Color(102, 136, 232));

    mainFrame3.add(t6);
}