Java Code Examples for javax.swing.JTextField#setText()

The following examples show how to use javax.swing.JTextField#setText() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Populate.
 *
 * @param dataSourceProperties the data source properties
 */
/* (non-Javadoc)
 * @see com.sldeditor.datasource.connector.DataSourceConnectorInterface#populate(com.sldeditor.datasource.impl.DataSourceProperties)
 */
@Override
public void populate(DataSourcePropertiesInterface dataSourceProperties)
{
    if(dataSourceProperties != null)
    {
        for(String fieldName : textFieldMap.keySet())
        {
            JTextField textField = textFieldMap.get(fieldName);

            Map<String,String> properties = dataSourceProperties.getAllConnectionProperties();

            textField.setText(properties.get(fieldName));
        }
    }
}
 
Example 2
Source Project: raccoon4   File: ImportAppBuilder.java    License: Apache License 2.0 6 votes vote down vote up
public ImportAppBuilder() {
	scan = new JButton(loadIcon("/icons/famfam/icons/folder_magnify.png"));
	scan.setToolTipText(Messages.getString(ID + ".scan.short_description"));
	imprt = new JButton(loadIcon("/icons/famfam/icons/folder_add.png"));
	imprt.setToolTipText(Messages.getString(ID + ".imprt.short_description"));
	list = new JList<Candidate>();
	profile = new JComboBox<PlayProfile>();
	progress = new JTextField();
	groupsPanel = new GroupsPanel();
	progress.setEditable(false);
	titleStrip = new TitleStrip(Messages.getString(ID
			.concat(".titlestrip.title")), Messages.getString(ID
			.concat(".titlestrip.subtitle")), new ImageIcon(getClass().getResource(
			"/icons/appicon.png")));
	progress.setText(Messages.getString(ID.concat(".howto")));
	imprt.setEnabled(false);
}
 
Example 3
Source Project: opensim-gui   File: ScaleFactorsPanel.java    License: Apache License 2.0 6 votes vote down vote up
private void updateManualScaleFields() {
   internalChange = true;
   if(getSelectedRowCount()==0) {
      for(JTextField field : manualScaleXYZ) field.setText("");
      manualScaleUniformCheckBox.setSelected(false);
   } else {
      for(int i=0; i<3; i++) {
         if(tableModel.isSameManualScale(getSelectedRows(),i)) {
            double manualScale = tableModel.getManualScale(getSelectedRows()[0],i);
            manualScaleXYZ[i].setText(numFormat.format(manualScale));
         } else manualScaleXYZ[i].setText("");
      }
      boolean uniform = manualScaleXYZ[0].getText().equals(manualScaleXYZ[1].getText()) && 
                        manualScaleXYZ[0].getText().equals(manualScaleXYZ[2].getText());
      manualScaleUniformCheckBox.setSelected(uniform);
   }
   internalChange = false;
}
 
Example 4
private void initMethodAndRequestTypeFields(DCMethod method, JTextField methodField, JComboBox requestType, String requestTypeDefault)
{
  if (method!=null)
  {
    String methodKey = method.getRequestType()+": "+method.getName();
    if (!methodMap.containsKey(methodKey))
    {
      methodMap.put(methodKey, method);             
    }
    methodField.setText(method.getName());
    if (requestType!=null)
    {
      requestType.setSelectedItem(method.getRequestType());        
    }
  }
  else
  {
    methodField.setText(null);      
    if (requestType!=null)
    {
      requestType.setSelectedItem(requestTypeDefault);
    }
  }
}
 
Example 5
private void createBoundFields ()
{
    // Allocate bound fields (2 per check)
    final int checkNb = suite.getChecks().size();
    bounds = new JTextField[checkNb][];

    for (int ic = 0; ic < checkNb; ic++) {
        Check<C> check = suite.getChecks().get(ic);
        bounds[ic] = new JTextField[2];

        for (int i = 0; i <= 1; i++) {
            JTextField field = new JTextField(FIELD_WIDTH);
            field.setHorizontalAlignment(JTextField.CENTER);
            bounds[ic][i] = field;

            Constant.Double constant = (i == 0) ? check.getLowConstant()
                    : check.getHighConstant();

            field.setText(textOf(constant.getValue()));
            field.setToolTipText(
                    "<html>" + constant.getName() + "<br/>"
                    + constant.getDescription() + "</html>");
        }
    }
}
 
Example 6
public
void
focusLost(FocusEvent event)
{
  JTextField field = (JTextField)event.getSource();

  field.setText(UI_DATE_FORMAT.format(getDate(field)));
}
 
Example 7
protected Object edit(Object o) {
    JTextField f = new JTextField(20);
    if(o != null) {
        f.setText((String)o);
    }
    if(showEditDialog(f)) {
        return f.getText();
    }
    return o;
}
 
Example 8
void addUserNameBan(final JTextField addField, final Component button, final JTable table) {
  final String newBannedUserName = addField.getText().trim();
  bannedUsernamesTabModel.addUsernameBan(newBannedUserName);

  ((DefaultTableModel) table.getModel())
      .addRow(new String[] {newBannedUserName, Instant.now().toString(), "Remove"});
  ButtonColumn.attachButtonColumn(table, 2, removeButtonListener());

  addField.setText("");
  button.setEnabled(false);
}
 
Example 9
@SuppressForbidden(reason = "JFilechooser#getSelectedFile() returns java.io.File")
private void browseDirectory(JTextField tf) {
  JFileChooser fc = new JFileChooser(new File(tf.getText()));
  fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  fc.setFileHidingEnabled(false);
  int retVal = fc.showOpenDialog(dialog);
  if (retVal == JFileChooser.APPROVE_OPTION) {
    File dir = fc.getSelectedFile();
    tf.setText(dir.getAbsolutePath());
  }
}
 
Example 10
Source Project: jdal   File: AccessorsTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testTextFieldAccessor() {
	JTextField field = new JTextField();
	TextComponentAccessor accessor = new TextComponentAccessor(field);
	accessor.addControlChangeListener(this);
	field.setText(TEST_STRING);
	assertEquals(TEST_STRING, field.getText());
	assertEquals(TEST_STRING, accessor.getControlValue());
	assertTrue(listened);
	listened = false;
}
 
Example 11
@Override
public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, int row, int column) {
    Component c = super.getTableCellEditorComponent(table, "", isSelected, row, column);
    JTextField jtf = (JTextField) c;
    initialValue = getValueAsTimestamp(value);
    jtf.setText(dateFormat.format(initialValue));
    if (suppressEditorBorder) {
        jtf.setBorder(BorderFactory.createEmptyBorder());
    }
    return c;
}
 
Example 12
@SuppressWarnings("deprecation")
@Override
public Component getComponent(int width, int height) throws IOException {
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));

	chartDataset = new DefaultXYDataset();
	X = createData();
	chartDataset.addSeries("points", X);
	final double[][] lineData = computeLineData();
	chartDataset.addSeries("line", lineData);

	chart = ChartFactory.createXYLineChart(null, "x", "y", chartDataset, PlotOrientation.VERTICAL,
			false, false, false);
	((XYLineAndShapeRenderer) chart.getXYPlot().getRenderer()).setSeriesLinesVisible(0, false);
	((XYLineAndShapeRenderer) chart.getXYPlot().getRenderer()).setSeriesShapesVisible(0, true);
	((NumberAxis) chart.getXYPlot().getDomainAxis()).setRange(-5, 5);
	((NumberAxis) chart.getXYPlot().getRangeAxis()).setRange(-10, 10);

	((XYLineAndShapeRenderer) chart.getXYPlot().getRenderer()).setStroke(new BasicStroke(2.5f));

	chartContainer = new ImageContainer(chart.createBufferedImage(width, height / 2));
	base.add(chartContainer);

	final JPanel bottomPane = new JPanel();
	bottomPane.setPreferredSize(new Dimension(width, height / 2));
	base.add(bottomPane);

	final JPanel controlsdata = new JPanel();
	controlsdata.setLayout(new BoxLayout(controlsdata, BoxLayout.X_AXIS));
	bottomPane.add(controlsdata);
	final JButton button = new JButton("Go");
	controlsdata.add(button);

	button.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			button.setEnabled(false);
			base.requestFocus();
			new Thread(AbstractGradientDescentDemo.this).start();
		}
	});

	paramsField = new JTextField(20);
	paramsField.setOpaque(false);
	paramsField.setFont(Font.decode("Monaco-24"));
	paramsField.setHorizontalAlignment(JTextField.CENTER);
	paramsField.setEditable(false);
	paramsField.setBorder(null);
	paramsField.setText(String.format("%2.2f, %2.2f", params[0], params[1]));
	controlsdata.add(paramsField);

	errorDataset = new DefaultXYDataset();
	errorSeries = new double[][] { { 0 }, { computeError() } };
	errorDataset.addSeries("data", errorSeries);
	errorChart = ChartFactory.createXYLineChart("Error over time",
			"Iteration", "Error", errorDataset,
			PlotOrientation.VERTICAL,
			false, false, false);
	((NumberAxis) errorChart.getXYPlot().getDomainAxis()).setRange(0, 1);
	((NumberAxis) errorChart.getXYPlot().getRangeAxis()).setRange(0, computeError());
	errorContainer = new ImageContainer(errorChart.createBufferedImage((width - 5) / 2, (height - 5) / 2));
	bottomPane.add(errorContainer);

	return base;
}
 
Example 13
Source Project: FoxTelem   File: CameraTab.java    License: GNU General Public License v3.0 4 votes vote down vote up
protected void addBottomFilter() {
		JLabel displayNumber1 = new JLabel("Displaying last");
		displayNumber2 = new JTextField();
		displayNumber2.setColumns(4);
		JLabel displayNumber3 = new JLabel("images decoded");
		displayNumber1.setFont(new Font("SansSerif", Font.PLAIN, 10));
		displayNumber3.setFont(new Font("SansSerif", Font.PLAIN, 10));
		displayNumber1.setBorder(new EmptyBorder(5, 2, 5, 10) ); // top left bottom right
		displayNumber3.setBorder(new EmptyBorder(5, 2, 5, 10) ); // top left bottom right
		//displayNumber2.setMinimumSize(new Dimension(50, 14));
		//displayNumber2.setMaximumSize(new Dimension(50, 14));
		displayNumber2.setText(Integer.toString(maxThumbnails));
		displayNumber2.addActionListener(this);
		bottomPanel.add(displayNumber1);
		bottomPanel.add(displayNumber2);
		bottomPanel.add(displayNumber3);
		
		lblFromReset = new JLabel("   from Reset  ");
		lblFromReset.setFont(new Font("SansSerif", Font.PLAIN, 10));
		bottomPanel.add(lblFromReset);
		
		textFromReset = new JTextField();
		bottomPanel.add(textFromReset);
		textFromReset.setText(Integer.toString(START_RESET));

		textFromReset.setColumns(8);
		textFromReset.addActionListener(this);
		textFromReset.addFocusListener(this);
		
		lblFromUptime = new JLabel("   from Uptime  ");
		lblFromUptime.setFont(new Font("SansSerif", Font.PLAIN, 10));
		bottomPanel.add(lblFromUptime);
		
		textFromUptime = new JTextField();
		bottomPanel.add(textFromUptime);

		textFromUptime.setText(Long.toString(START_UPTIME));
		textFromUptime.setColumns(8);
//		textFromUptime.setPreferredSize(new Dimension(50,14));
		textFromUptime.addActionListener(this);
		textFromUptime.addFocusListener(this);
		
	}
 
Example 14
private void initialize() {
	this.setLayout(null);
	this.setBorder(new TitledBorder(UIManager
			.getBorder("TitledBorder.border"), I18N
			.getHtmlText("PanelPlayer.border.text"), TitledBorder.LEADING,
			TitledBorder.TOP, null, null));
	this.setBounds(46, 220, 305, 111);
	this.setBackground(parent.getBackground());

	// Width
	JLabel lblWitdh = new JLabel(
			I18N.getHtmlText("PanelPlayer.lblWidth.text"));
	lblWitdh.setBounds(10, 26, 140, 20);
	this.add(lblWitdh);
	sizePx = new JTextField();
	sizePx.setColumns(10);
	sizePx.setBounds(150, 26, 60, 20);
	String savedWitdth = parent.getPreferences().get("width",
			parent.getProperties().getProperty("width"));
	sizePx.setText(savedWitdth);
	this.add(sizePx);
	JLabel lblPx = new JLabel(I18N.getHtmlText("PanelPlayer.lblPx.text"));
	lblPx.setBounds(215, 26, 40, 20);
	this.add(lblPx);

	// Font
	JLabel lblFont = new JLabel(
			I18N.getHtmlText("PanelPlayer.lblFont.text"));
	lblFont.setBounds(10, 50, 140, 20);
	this.add(lblFont);
	fontComboBox = new JComboBox<String>();
	fontComboBox.setBounds(150, 49, 150, 20);
	fontComboBox.setModel(new DefaultComboBoxModel<String>(Font
			.getFontList()));
	fontComboBox.setCursor(parent.getCursor());

	String savedFont = parent.getPreferences().get("font",
			parent.getProperties().getProperty("selectedFont"));
	if (savedFont != null) {
		fontComboBox.setSelectedItem(savedFont);
	}
	this.add(fontComboBox);

	// Size
	JLabel lblSize = new JLabel(
			I18N.getHtmlText("PanelPlayer.lblSize.text"));
	lblSize.setBounds(10, 73, 140, 20);
	this.add(lblSize);
	sizeComboBox = new JComboBox<String>();

	// VLC: Very small: 17pt - Small: 20pt
	// Normal: 22pt - Big: 29pt - Very big: 58pt
	sizeComboBox.setModel(new DefaultComboBoxModel<String>(Font
			.getWidthList()));
	sizeComboBox.setBounds(150, 72, 60, 20);
	sizeComboBox.setCursor(parent.getCursor());
	String savedSize = parent.getPreferences().get("size",
			parent.getProperties().getProperty("selectedSizeIndex"));
	if (savedSize != null) {
		sizeComboBox.setSelectedIndex(Integer.parseInt(savedSize));
	}
	this.add(sizeComboBox);
	JLabel lblPt = new JLabel(I18N.getHtmlText("PanelPlayer.lblPt.text"));
	lblPt.setBounds(215, 72, 40, 20);
	this.add(lblPt);

	// Help
	JButton buttonHelpSub = new JButton(new ImageIcon(
			ClassLoader.getSystemResource("img/help.png")));
	buttonHelpSub.setBounds(273, 16, 22, 22);
	buttonHelpSub.setCursor(parent.getCursor());
	buttonHelpSub.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			HelpPlayerDialog helpPlayerDialog = parent.getHelpPlayer();
			if (helpPlayerDialog == null) {
				helpPlayerDialog = new HelpPlayerDialog(parent, true);
			}
			helpPlayerDialog.setVisible();
		}
	});
	this.add(buttonHelpSub);

	// Borders (for debug purposes)
	if (log.isTraceEnabled()) {
		Border border = BorderFactory.createLineBorder(Color.black);
		lblWitdh.setBorder(border);
		lblFont.setBorder(border);
		lblSize.setBorder(border);
		lblPx.setBorder(border);
		lblPt.setBorder(border);
	}

}
 
Example 15
Source Project: binnavi   File: ErrorDialog.java    License: Apache License 2.0 4 votes vote down vote up
private void createGui() {
  final JPanel topPanel = new JPanel(new BorderLayout());

  final JPanel messagePanel = new JPanel(new BorderLayout());

  final JTextField messageField = new JTextField();
  messageField.setEditable(false);
  messageField.setText(message);
  messageField.setBackground(Color.WHITE);

  messagePanel.add(messageField);

  messagePanel.setBorder(new TitledBorder("Error Message"));

  topPanel.add(messagePanel, BorderLayout.NORTH);

  final JTabbedPane tabbedPane = new JTabbedPane();

  final JTextArea descriptionArea = new JTextArea();

  descriptionArea.setEditable(false);
  descriptionArea.setText(description);
  descriptionArea.setLineWrap(true);
  descriptionArea.setWrapStyleWord(true);

  tabbedPane.addTab("Description", descriptionArea);

  if (exception != null) {
    final JTextArea traceArea = new JTextArea();

    traceArea.setEditable(false);
    traceArea.setText(StackTrace.toString(exception.getStackTrace()));

    tabbedPane.addTab("Stack Trace", new JScrollPane(traceArea));
  }

  add(topPanel, BorderLayout.NORTH);
  add(tabbedPane);

  final JPanel bottomButtonPanel = new JPanel(new BorderLayout());
  final JPanel leftButtonPanelBottom = new JPanel();

  final JButton reportButton = new JButton(new ReportAction());
  reportButton.setMinimumSize(new Dimension(180, reportButton.getHeight()));

  leftButtonPanelBottom.add(reportButton);

  bottomButtonPanel.add(leftButtonPanelBottom, BorderLayout.WEST);

  final JPanel rightButtonPanelBottom = new JPanel();
  final JButton okButton = new JButton(new CloseButtonListener());
  getRootPane().setDefaultButton(okButton);
  rightButtonPanelBottom.add(okButton);
  bottomButtonPanel.add(rightButtonPanelBottom, BorderLayout.EAST);
  add(bottomButtonPanel, BorderLayout.SOUTH);
}
 
Example 16
@Test
public void testCreateEnumFromSelectionDupe() throws Exception {

	// make two test enums in the program name folder

	Category category = programNode.getCategory();
	DataTypeManager dataTypeManager = category.getDataTypeManager();

	int id = dataTypeManager.startTransaction("new enum 1");
	Enum enumm = new EnumDataType("Colors", 1);
	enumm.add("Red", 0);
	enumm.add("Green", 0x10);
	enumm.add("Blue", 0x20);

	category.addDataType(enumm, null);
	dataTypeManager.endTransaction(id, true);
	waitForTree();

	int id2 = dataTypeManager.startTransaction("new enum 2");
	Enum enumm2 = new EnumDataType("MoreColors", 1);
	enumm2.add("Purple", 0x30);
	enumm2.add("White", 0x40);
	enumm2.add("Yellow", 0x50);

	category.addDataType(enumm2, null);
	dataTypeManager.endTransaction(id2, true);
	waitForTree();

	int id3 = dataTypeManager.startTransaction("new enum 3");
	Enum enumm3 = new EnumDataType("myNewEnum", 1);
	enumm3.add("Purple", 0x30);
	enumm3.add("White", 0x40);
	enumm3.add("Yellow", 0x50);

	category.addDataType(enumm3, null);
	dataTypeManager.endTransaction(id3, true);
	waitForTree();

	program.flushEvents();
	waitForPostedSwingRunnables();

	DataTypeNode testEnumNode1 = (DataTypeNode) programNode.getChild("Colors");
	assertNotNull(testEnumNode1);

	DataTypeNode testEnumNode2 = (DataTypeNode) programNode.getChild("MoreColors");
	assertNotNull(testEnumNode2);

	expandNode(programNode);
	selectNodes(testEnumNode1, testEnumNode2);

	final DockingActionIf action = getAction(plugin, "Enum from Selection");
	assertNotNull(action);
	assertTrue(action.isEnabledForContext(provider.getActionContext(null)));
	assertTrue(action.isAddToPopup(provider.getActionContext(null)));

	executeOnSwingWithoutBlocking(new Runnable() {
		@Override
		public void run() {
			DataTypeTestUtils.performAction(action, tree);
		}
	});

	Window window = waitForWindow("Name new ENUM");
	assertNotNull(window);

	final JTextField tf = findComponent(window, JTextField.class);
	assertNotNull(tf);

	tf.setText("myNewEnum");
	pressButtonByText(window, "OK");

	Window window2 = waitForWindow("Duplicate ENUM Name");
	assertNotNull(window2);

	final JTextField tf2 = findComponent(window2, JTextField.class);
	assertNotNull(tf2);

	tf2.setText("myNewEnum2");
	pressButtonByText(window2, "OK");

	assertTrue(!window2.isShowing());
	waitForPostedSwingRunnables();

	DataTypeNode newEnumNode = (DataTypeNode) programNode.getChild("myNewEnum2");
	assertNotNull(newEnumNode);

}
 
Example 17
public JPanel getJasonConfigPanel() {
    JPanel pop = new JPanel();
    pop.setLayout(new BoxLayout(pop, BoxLayout.Y_AXIS));

    // jacamo home
    jacamoTF = new JTextField(35);
    JPanel jacamoHomePanel = new JPanel(new GridLayout(0,1));
    jacamoHomePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory
            .createEtchedBorder(), "JaCaMo", TitledBorder.LEFT, TitledBorder.TOP));
    JPanel jacamoJarPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    jacamoJarPanel.add(new JLabel("jacamo.jar location"));
    jacamoJarPanel.add(jacamoTF);
    jacamoJarPanel.add(createBrowseButton("jacamo.jar", jacamoTF));
    jacamoHomePanel.add(jacamoJarPanel);

    pop.add(jacamoHomePanel);


    // java home
    JPanel javaHomePanel = new JPanel();
    javaHomePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory
            .createEtchedBorder(), "Java Home", TitledBorder.LEFT, TitledBorder.TOP));
    javaHomePanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    javaHomePanel.add(new JLabel("Directory"));
    javaTF = new JTextField(35);
    javaHomePanel.add(javaTF);
    JButton setJava = new JButton("Browse");
    setJava.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                JFileChooser chooser = new JFileChooser(System.getProperty("user.dir"));
                 chooser.setDialogTitle("Select the Java JDK home directory");
                chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
                    String javaHome = (new File(chooser.getSelectedFile().getPath())).getCanonicalPath();
                    if (Config.checkJavaHomePath(javaHome)) {
                        javaTF.setText(javaHome);
                    } else {
                        JOptionPane.showMessageDialog(null, "The selected JDK home directory doesn't have the bin/javac file!");
                    }
                }
            } catch (Exception e) {}
        }
    });
    javaHomePanel.add(setJava);
    pop.add(javaHomePanel);

    // dot path
    //dotTF = new JTextField(35);
    //dotTF.setToolTipText("Dot is used to produce graphical representation of the organization. It can be installed from http://www.graphviz.org.");
    JPanel dotHomePanel = new JPanel(new GridLayout(0,1));
    dotHomePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory
            .createEtchedBorder(), "dot (optional)", TitledBorder.LEFT, TitledBorder.TOP));
    
    /*JPanel dotPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    dotPanel.add(new JLabel("program location"));
    dotPanel.add(dotTF);
    dotHomePanel.add(dotPanel);

    pop.add(dotHomePanel);*/

    initJacamoHome = userProperties.getProperty(Config.JACAMO_JAR);
    jacamoTF.setText(initJacamoHome);

    javaTF.setText(userProperties.getJavaHome());
    /*String v = userProperties.getDotPath();
    if (v == null) v = "";
    dotTF.setText(v);*/
    return pop;
}
 
Example 18
@Override
public Component getComponent(int width, int height) throws IOException {
	engine.getOptions().setDoubleInitialImage(false);

	final JPanel outer = new JPanel();
	outer.setOpaque(false);
	outer.setPreferredSize(new Dimension(width, height));
	outer.setLayout(new GridBagLayout());

	// the main panel
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));

	vc = new VideoCaptureComponent(320, 240);
	vc.getDisplay().getScreen().setPreferredSize(new Dimension(640, 240));

	vc.getDisplay().addVideoListener(this);
	base.add(vc);

	final JPanel controls1 = new JPanel();
	controls1.setOpaque(false);
	final JButton grab = new JButton("Grab");
	grab.setActionCommand("grab");
	grab.addActionListener(this);
	grab.setFont(FONT);
	controls1.add(grab);
	base.add(controls1);

	final JPanel controls = new JPanel();
	controls.setOpaque(false);
	final JLabel label = new JLabel("Threshold:");
	label.setFont(FONT);
	controls.add(label);
	final JSlider slider = new JSlider(0, 100000);
	matcher.setThreshold(slider.getValue());
	slider.setPreferredSize(new Dimension(slider.getPreferredSize().width + 250, slider.getPreferredSize().height));
	controls.add(slider);
	final JTextField tf = new JTextField(5);
	tf.setFont(FONT);
	tf.setEnabled(false);
	tf.setText(slider.getValue() + "");
	controls.add(tf);

	slider.addChangeListener(new ChangeListener() {
		@Override
		public void stateChanged(ChangeEvent e) {
			tf.setText(slider.getValue() + "");
			matcher.setThreshold(slider.getValue());
		}
	});

	base.add(controls);

	outer.add(base);

	return outer;
}
 
Example 19
private static void setTextInteger(JTextField field, int value)
{
    field.setText(Integer.toString(value));
}
 
Example 20
Source Project: Spark   File: TelephoneTextField.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Creates a new IconTextField with Icon.
 */
public TelephoneTextField() {
    setLayout(new GridBagLayout());

    setBackground(new Color(212, 223, 237));

    pad = new PhonePad();

    textField = new JTextField();

    textField.setBorder(null);
    setBorder(new JTextField().getBorder());


    imageComponent = new JLabel(PhoneRes.getImageIcon("ICON_NUMBERPAD_IMAGE"));

    add(imageComponent, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0));
    add(textField, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0));

    imageComponent.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            displayPad(e);
        }
    });

    textField.requestFocus();


    textField.setForeground((Color)UIManager.get("TextField.lightforeground"));
    textField.setText(textFieldText);

    textField.addFocusListener(this);
    textField.addMouseListener(this);
    textField.addKeyListener(this);
}