javax.swing.JTextField Java Examples

The following examples show how to use javax.swing.JTextField. 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
Source File: MiscSettingsDialog.java    From sc2gears with Apache License 2.0 6 votes vote down vote up
public void storeSetting() {
	if ( component instanceof JSpinner )
		Settings.set( settingKey, ( (JSpinner) component ).getValue() );
	else if ( component instanceof JSlider )
		Settings.set( settingKey, ( (JSlider) component ).getValue() );
	else if ( component instanceof JTextField )
		Settings.set( settingKey, ( (JTextField) component ).getText() );
	else if ( component instanceof JCheckBox )
		Settings.set( settingKey, ( (JCheckBox) component ).isSelected() );
	else if ( component instanceof JComboBox ) {
		Settings.set( settingKey, ( (JComboBox< ? >) component ).getSelectedIndex() );
		final JComboBox< ? > comboBox = (JComboBox< ? >) component;
		if ( comboBox.isEditable() ) // It's a pre-defined list combo box
			Settings.set( settingKey, comboBox.getSelectedItem() );				
		else                         // Normal combo box
			Settings.set( settingKey, comboBox.getSelectedIndex() );				
	}
}
 
Example #2
Source File: OperationDialog.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void setInputComponent() {
    this.label = makeLabel();
    if (type == ModelType.BOOLEAN && !expressionsAllowed) {
        this.valueComponent = new JCheckBox(makeLabelString(false));
        this.valueComponent.setToolTipText(description);
        this.label = new JLabel(); // checkbox doesn't need a label
    } else if (type == ModelType.UNDEFINED) {
        JLabel jLabel = new JLabel();
        this.valueComponent = jLabel;
    } else if (props.get("allowed").isDefined()) {
        JComboBox comboBox = makeJComboBox(props.get("allowed").asList());
        this.valueComponent = comboBox;
    } else if (type == ModelType.LIST) {
        ListEditor listEditor = new ListEditor(OperationDialog.this);
        this.valueComponent = listEditor;
    } else if (type == ModelType.BYTES) {
        this.valueComponent = new BrowsePanel(OperationDialog.this);
    } else {
        JTextField textField = new JTextField(30);
        this.valueComponent = textField;
    }
}
 
Example #3
Source File: SingleEntryDialog.java    From nanoleaf-desktop with MIT License 6 votes vote down vote up
public SingleEntryDialog(Component parent, String entryLabel,
		String buttonLabel, ActionListener buttonListener)
{
	super();
	
	entry = new JTextField(entryLabel);
	entry.setForeground(Color.WHITE);
	entry.setBackground(Color.DARK_GRAY);
	entry.setBorder(new LineBorder(Color.GRAY));
	entry.setCaretColor(Color.WHITE);
	entry.setFont(new Font("Tahoma", Font.PLAIN, 22));
	entry.addFocusListener(new TextFieldFocusListener(entry));
	contentPanel.add(entry, "cell 0 1, grow, gapx 2 2");
	
	JButton btnConfirm = new ModernButton(buttonLabel);
	btnConfirm.setFont(new Font("Tahoma", Font.PLAIN, 18));
	btnConfirm.addActionListener(buttonListener);
	contentPanel.add(btnConfirm, "cell 0 3, alignx center");
	
	JLabel spacer = new JLabel(" ");
	contentPanel.add(spacer, "cell 0 4");
	
	finalize(parent);
	
	btnConfirm.requestFocus();
}
 
Example #4
Source File: AdminPropertiesPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void chooseFile(JTextField txtField) {
    JFileChooser chooser = new JFileChooser();
    
    chooser.setCurrentDirectory(null);
    chooser.setFileSelectionMode (JFileChooser.FILES_ONLY);
    
    String path = txtField.getText().trim();
    if (path != null && path.length() > 0) {
        chooser.setSelectedFile(new File(path));
    } else if (recentDirectory != null) {
        chooser.setCurrentDirectory(new File(recentDirectory));
    }
    
    
    if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) {
        return;
    }
    
    File selectedFile = chooser.getSelectedFile();
    recentDirectory = selectedFile.getParentFile().getAbsolutePath();
    txtField.setText(selectedFile.getAbsolutePath());
}
 
Example #5
Source File: SwingNullableSpinner.java    From atdl4j with MIT License 6 votes vote down vote up
private NumberEditorNull(JSpinner spinner, DecimalFormat format) {
	super(spinner);
	if (!(spinner.getModel() instanceof SpinnerNumberModelNull)) {
		return;
	}
	
	SpinnerNumberModelNull model = (SpinnerNumberModelNull) spinner.getModel();
	NumberFormatter formatter = new NumberEditorFormatterNull(model, format);
	DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter);
	JFormattedTextField ftf = getTextField();
	ftf.setEditable(true);
	ftf.setFormatterFactory(factory);
	ftf.setHorizontalAlignment(JTextField.RIGHT);
	
	try {
		String maxString = formatter.valueToString(model.getMinimum());
		String minString = formatter.valueToString(model.getMaximum());
		ftf.setColumns(Math.max(maxString.length(), minString.length()));
	}
	catch (ParseException e) {
		// TBD should throw a chained error here
	}
}
 
Example #6
Source File: EjbFacadeVisualPanel2.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public EjbFacadeVisualPanel2(Project project, WizardDescriptor wizard) {
    this.wizard = wizard;
    this.project = project;
    initComponents();
    packageComboBoxEditor = ((JTextField) packageComboBox.getEditor().getEditorComponent());
    packageComboBoxEditor.getDocument().addDocumentListener(this);

    handleCheckboxes();

    J2eeProjectCapabilities projectCap = J2eeProjectCapabilities.forProject(project);
    if (projectCap.isEjb31LiteSupported()){
        boolean serverSupportsEJB31 = ProjectUtil.getSupportedProfiles(project).contains(Profile.JAVA_EE_6_FULL) ||
                ProjectUtil.getSupportedProfiles(project).contains(Profile.JAVA_EE_7_FULL) ||
                ProjectUtil.getSupportedProfiles(project).contains(Profile.JAVA_EE_8_FULL);
        if (!projectCap.isEjb31Supported() && !serverSupportsEJB31){
            remoteCheckBox.setVisible(false);
            remoteCheckBox.setEnabled(false);
        }
    } else {
        localCheckBox.setSelected(true);
    }

    updateInProjectCombo(false);
}
 
Example #7
Source File: SqlLoader.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
private void doLoad() {
	try {
		if (!input.getText().trim().isEmpty()) {
			throw new RuntimeException("Cannot load if text entered");
		}

		JPanel pan = new JPanel(new GridLayout(2, 2));
		pan.add(new JLabel("JDBC Driver Class"));
		JTextField f1 = new JTextField("com.mysql.jdbc.Driver");
		pan.add(f1);
		JTextField f2 = new JTextField("jdbc:mysql://localhost/buzzbuilder?user=root&password=whasabi");
		pan.add(new JLabel("JDBC Connection String"));
		pan.add(f2);
		int i = JOptionPane.showConfirmDialog(null, pan);
		if (i != JOptionPane.OK_OPTION) {
			return;
		}

		Class.forName(f1.getText().trim());
		conn = DriverManager.getConnection(f2.getText().trim());
		populate();
	} catch (ClassNotFoundException | RuntimeException | SQLException ex) {
		ex.printStackTrace();
		handleError(ex.getLocalizedMessage());
	}
}
 
Example #8
Source File: JComboBoxJavaElement.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Override
public boolean marathon_select(final String value) {
    final String text = JComboBoxOptionJavaElement.stripHTMLTags(value);
    int selectedItem = findMatch(value, new Predicate() {
        @Override
        public boolean isValid(JComboBoxOptionJavaElement e) {
            if (!text.equals(e.getAttribute("text"))) {
                return false;
            }
            return true;
        }
    });
    if (selectedItem == -1) {
        if (((JComboBox) getComponent()).isEditable()) {
            ((JTextField) ((JComboBox) getComponent()).getEditor().getEditorComponent()).setText(value);
            return true;
        }
        return false;
    }
    ((JComboBox) getComponent()).setSelectedIndex(selectedItem);
    return true;
}
 
Example #9
Source File: PropertyPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Creates new form PropertyPanel */
public PropertyPanel(PropertiesPanel.PropertiesParamHolder propParam, boolean add, String propName, String propValue) {
    initComponents();
    provider = propParam.getProvider();
    // The comb box only contains the property names that are not defined yet when adding
    if (add) {
        nameComboBox.setModel(new DefaultComboBoxModel(Util.getAvailPropNames(provider, propParam.getPU()).toArray(new String[]{})));
    } else {
        nameComboBox.setModel(new DefaultComboBoxModel(Util.getPropsNamesExceptGeneral(provider).toArray(new String[]{})));
        nameComboBox.setSelectedItem(propName);
    }

    valueTextField = new JTextField();
    valueComboBox = new JComboBox();

    // Add the appropriate component for the value 
    String selectedPropName = (String) nameComboBox.getSelectedItem();
    addValueComponent(selectedPropName, propValue);

    nameComboBox.addActionListener((ActionListener) this);

    // Disable the name combo box for editing
    nameComboBox.setEnabled(add);
}
 
Example #10
Source File: SettingsFrame.java    From FoxTelem with GNU General Public License v3.0 6 votes vote down vote up
private JTextField addSettingsRow(JPanel column, int length, String name, String tip, String value) {
		JPanel panel = new JPanel();
		column.add(panel);
		panel.setLayout(new GridLayout(1,2,5,5));
		JLabel lblDisplayModuleFont = new JLabel(name);
		lblDisplayModuleFont.setToolTipText(tip);
		panel.add(lblDisplayModuleFont);
		JTextField textField = new JTextField(value);
		panel.add(textField);
		textField.setColumns(length);
		textField.addActionListener(this);
		textField.addFocusListener(this);

//		column.add(new Box.Filler(new Dimension(10,5), new Dimension(10,5), new Dimension(10,5)));

		return textField;
	
	}
 
Example #11
Source File: Test6968363.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void run() {
    if (this.frame == null) {
        Thread.setDefaultUncaughtExceptionHandler(this);
        this.frame = new JFrame(getClass().getSimpleName());
        this.frame.add(NORTH, new JLabel("Copy Paste a HINDI text into the field below"));
        this.frame.add(SOUTH, new JTextField(new MyDocument(), "\u0938", 10));
        this.frame.pack();
        this.frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        this.frame.setLocationRelativeTo(null);
        this.frame.setVisible(true);
    } else {
        this.frame.dispose();
        this.frame = null;
    }
}
 
Example #12
Source File: MyMenuBar.java    From JByteMod-Beta with GNU General Public License v2.0 6 votes vote down vote up
protected void searchLDC() {
	final JPanel panel = new JPanel(new BorderLayout(5, 5));
	final JPanel input = new JPanel(new GridLayout(0, 1));
	final JPanel labels = new JPanel(new GridLayout(0, 1));
	panel.add(labels, "West");
	panel.add(input, "Center");
	panel.add(new JLabel(JByteMod.res.getResource("big_string_warn")), "South");
	labels.add(new JLabel(JByteMod.res.getResource("find")));
	JTextField cst = new JTextField();
	input.add(cst);
	JCheckBox exact = new JCheckBox(JByteMod.res.getResource("exact"));
	JCheckBox regex = new JCheckBox("Regex");
	JCheckBox snstv = new JCheckBox(JByteMod.res.getResource("case_sens"));
	labels.add(exact);
	labels.add(regex);
	input.add(snstv);
	input.add(new JPanel());
	if (JOptionPane.showConfirmDialog(this.jbm, panel, "Search LDC", JOptionPane.OK_CANCEL_OPTION,
			JOptionPane.PLAIN_MESSAGE, searchIcon) == JOptionPane.OK_OPTION && !cst.getText().isEmpty()) {
		jbm.getSearchList().searchForConstant(cst.getText(), exact.isSelected(), snstv.isSelected(), regex.isSelected());
	}
}
 
Example #13
Source File: SBOLDescriptorPanel2.java    From iBioSim with Apache License 2.0 6 votes vote down vote up
public void constructPanel(Set<String> sbolFilePaths) {
	
	idText = new JTextField("", 40);
	nameText = new JTextField("", 40);
	descriptionText = new JTextField("", 40);
	saveFilePaths = new LinkedList<String>(sbolFilePaths);
	saveFilePaths.add("Save to New File");
	saveFileIDBox = new JComboBox();
	for (String saveFilePath : saveFilePaths) {
		saveFileIDBox.addItem(GlobalConstants.getFilename(saveFilePath));
	}
	
	add(new JLabel("SBOL ComponentDefinition ID:"));
	add(idText);
	add(new JLabel("SBOL ComponentDefinition Name:"));
	add(nameText);
	add(new JLabel("SBOL ComponentDefinition Description:"));
	add(descriptionText);
}
 
Example #14
Source File: UserInputTypeValidation.java    From binnavi with Apache License 2.0 5 votes vote down vote up
/**
 * Determines whether the given text field represents a valid type name and that the corresponding
 * does not already exist.
 *
 * @param parent The component that is used as a parent to display error messages.
 * @param typeManager The type manager that holds the type system.
 * @param name The text field that needs to be validated.
 * @return True iff the name does not already exist and is a valid type name.
 */
public static boolean validateTypeName(
    final Component parent, final TypeManager typeManager, final JTextField name) {
  if (validateTypeName(typeManager, name)) {
    return true;
  } else {
    CMessageBox.showWarning(parent, String.format(
        "Unable to create empty or existing type."));
    return false;
  }
}
 
Example #15
Source File: TableExample.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates the connectionPanel, which will contain all the fields for
 * the connection information.
 */
public void createConnectionDialog() {
    // Create the labels and text fields.
    userNameLabel = new JLabel("User name: ", JLabel.RIGHT);
    userNameField = new JTextField("app");

    passwordLabel = new JLabel("Password: ", JLabel.RIGHT);
    passwordField = new JTextField("app");

    serverLabel = new JLabel("Database URL: ", JLabel.RIGHT);
    serverField = new JTextField("jdbc:derby://localhost:1527/sample");

    driverLabel = new JLabel("Driver: ", JLabel.RIGHT);
    driverField = new JTextField("org.apache.derby.jdbc.ClientDriver");


    connectionPanel = new JPanel(false);
    connectionPanel.setLayout(new BoxLayout(connectionPanel,
            BoxLayout.X_AXIS));

    JPanel namePanel = new JPanel(false);
    namePanel.setLayout(new GridLayout(0, 1));
    namePanel.add(userNameLabel);
    namePanel.add(passwordLabel);
    namePanel.add(serverLabel);
    namePanel.add(driverLabel);

    JPanel fieldPanel = new JPanel(false);
    fieldPanel.setLayout(new GridLayout(0, 1));
    fieldPanel.add(userNameField);
    fieldPanel.add(passwordField);
    fieldPanel.add(serverField);
    fieldPanel.add(driverField);

    connectionPanel.add(namePanel);
    connectionPanel.add(fieldPanel);
}
 
Example #16
Source File: DropAmountChooser.java    From stendhal with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the editable text field component of the spinner.
 *
 * @return text field
 */
private JTextField getTextField() {
	// There really seems to be no simpler way to do this
	JComponent editor = spinner.getEditor();
	if (editor instanceof JSpinner.DefaultEditor) {
		return ((JSpinner.DefaultEditor) editor).getTextField();
	} else {
		Logger.getLogger(DropAmountChooser.class).error("Unknown editor type", new Throwable());
		// This will not work, but at least it won't crash the client
		return new JTextField();
	}
}
 
Example #17
Source File: BrowserUnavailableDialogFactory.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Creates an uneditable JTextField with the given text
 *
 * @param text
 *            The content of the JTextField
 * @return
 */
private static JTextField makeTextField(String text) {
	JTextField urlField = new JTextField(text);
	urlField.setEditable(false);

	urlField.addFocusListener(new FocusAdapter() {

		@Override
		public void focusGained(java.awt.event.FocusEvent evt) {
			urlField.getCaret().setVisible(true);
			urlField.selectAll();
		}
	});
	return urlField;
}
 
Example #18
Source File: CommonSettingsDialog.java    From megamek with GNU General Public License v2.0 5 votes vote down vote up
private JPanel getAdvancedSettingsPanel() {
    JPanel p = new JPanel();

    String[] s = GUIPreferences.getInstance().getAdvancedProperties();
    AdvancedOptionData[] opts = new AdvancedOptionData[s.length];
    for (int i = 0; i < s.length; i++) {
        s[i] = s[i].substring(s[i].indexOf("Advanced") + 8, s[i].length());
        opts[i] = new AdvancedOptionData(s[i]);
    }
    Arrays.sort(opts);
    keys = new JList<>(opts);
    keys.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    keys.addListSelectionListener(this);
    keys.addMouseMotionListener(new MouseMotionAdapter() {
        @Override
        public void mouseMoved(MouseEvent e) {
            int index = keys.locationToIndex(e.getPoint());
            if (index > -1) {
                AdvancedOptionData dat = keys.getModel().getElementAt(index);
                if (dat.hasTooltipText()) {
                    keys.setToolTipText(dat.getTooltipText());
                } else {
                    keys.setToolTipText(null);
                }
            }
        }
    });
    p.add(keys);

    value = new JTextField(10);
    value.addFocusListener(this);
    p.add(value);

    return p;
}
 
Example #19
Source File: WizardsTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Test new project wizard using generic WizardOperator. */
public void testGenericWizards() {
    // open new project wizard
    NewProjectWizardOperator npwo = NewProjectWizardOperator.invoke();
    npwo.selectCategory("Java Web");
    npwo.selectProject("Web Application");
    npwo.next();
    // create operator for next page
    WizardOperator wo = new WizardOperator("Web Application");
    JTextFieldOperator txtName = new JTextFieldOperator((JTextField) new JLabelOperator(wo, "Project Name:").getLabelFor());
    txtName.clearText();
    txtName.typeText("MyApp");
    wo.cancel();
}
 
Example #20
Source File: Demo.java    From Swing9patch with Apache License 2.0 5 votes vote down vote up
private void initGUI()
{
	// init components
	txtPhotoframeDialogWidth = new JTextField();
	txtPhotoframeDialogHeight = new JTextField();
	txtPhotoframeDialogWidth.setText("530");
	txtPhotoframeDialogHeight.setText("450");
	txtPhotoframeDialogWidth.setColumns(10);
	txtPhotoframeDialogHeight.setColumns(10);
	
	btnShowInFrame = new JButton("Show in new frame...");
	btnShowInFrame.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.blue));
	btnShowInFrame.setForeground(Color.white);
	btnHideTheFrame = new JButton("Hide the frame");
	btnHideTheFrame.setEnabled(false);
	
	panePhotoframe = createPhotoframe();
	panePhotoframe.add(
			new JLabel(new ImageIcon(org.jb2011.swing9patch.photoframe.Demo.class.getResource("imgs/girl.png")))
			, BorderLayout.CENTER);
	
	// init layout
	JPanel paneBtn = new JPanel(new FlowLayout(FlowLayout.CENTER));
	paneBtn.setBorder(BorderFactory.createEmptyBorder(12,0,0,0));
	paneBtn.add(new JLabel("Frame width:"));
	paneBtn.add(txtPhotoframeDialogWidth);
	paneBtn.add(new JLabel("Frame height:"));
	paneBtn.add(txtPhotoframeDialogHeight);
	paneBtn.add(btnShowInFrame);
	paneBtn.add(btnHideTheFrame);
	
	this.setBorder(BorderFactory.createEmptyBorder(12,20,10,20));
	this.add(panePhotoframe, BorderLayout.CENTER);
	this.add(paneBtn, BorderLayout.SOUTH);
	
	// drag panePhotoframe to move its parent window
	DragToMove.apply(new Component[]{panePhotoframe});
}
 
Example #21
Source File: FmtOptions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void addListener(JComponent jc) {
    if (jc instanceof JTextField) {
        JTextField field = (JTextField) jc;
        field.addActionListener(this);
        field.getDocument().addDocumentListener(this);
    } else if (jc instanceof JCheckBox) {
        JCheckBox checkBox = (JCheckBox) jc;
        checkBox.addActionListener(this);
    } else if (jc instanceof JComboBox) {
        JComboBox cb = (JComboBox) jc;
        cb.addActionListener(this);
    }
}
 
Example #22
Source File: UiUtils.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
private static JScrollPane getScrollableMessage(String msg) {
	JTextArea textArea = new JTextArea(msg);
	textArea.setLineWrap(true);
	textArea.setWrapStyleWord(true);
	textArea.setEditable(false);
	textArea.setMargin(new Insets(5, 5, 5, 5));
	textArea.setFont(new JTextField().getFont()); // dirty fix to use better font
	JScrollPane scrollPane = new JScrollPane();
	scrollPane.setPreferredSize(new Dimension(700, 150));
	scrollPane.getViewport().setView(textArea);
	return scrollPane;
}
 
Example #23
Source File: AddManagedBeanOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Tries to find null JTextField in this dialog.
 * @return JTextFieldOperator
 */
public JTextFieldOperator txtBeanName() {
    if (_txtBeanName == null) {
        _txtBeanName = new JTextFieldOperator((JTextField) lblBeanName().getLabelFor());
    }
    return _txtBeanName;
}
 
Example #24
Source File: EditCustomCategoryDialog.java    From tda with GNU Lesser General Public License v2.1 5 votes vote down vote up
private JPanel createNamePanel() {
    JPanel panel = new JPanel(new BorderLayout());
    name = new JTextField(30);
    JPanel innerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    innerPanel.add(new JLabel(ResourceManager.translate("customcategory.name.label")));
    innerPanel.add(name);
    panel.add(innerPanel, BorderLayout.CENTER);
    return(panel);
}
 
Example #25
Source File: WebDriverConfigGui.java    From jmeter-plugins-webdriver with Apache License 2.0 5 votes vote down vote up
private void createPacUrlProxy(JPanel panel, ButtonGroup group) {
    pacUrlProxy = new JRadioButton("Automatic proxy configuration URL");
    group.add(pacUrlProxy);
    panel.add(pacUrlProxy);

    pacUrlProxy.addItemListener(this);

    JPanel pacUrlPanel = new HorizontalPanel();
    pacUrl = new JTextField();
    pacUrl.setEnabled(false);
    pacUrlPanel.add(pacUrl, BorderLayout.CENTER);
    pacUrlPanel.setBorder(BorderFactory.createEmptyBorder(0, PROXY_FIELD_INDENT, 0, 0));
    panel.add(pacUrlPanel);
}
 
Example #26
Source File: XTextFieldEditor.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void  actionPerformed(ActionEvent e) {
    super.actionPerformed(e);
    if ((e.getSource() instanceof JMenuItem) ||
        (e.getSource() instanceof JTextField)) {
        fireEditingStopped();
    }
}
 
Example #27
Source File: GaussianFilterUI.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
@Override
public JPanel getOptionsPanel() {
    JTextField sigmaTextField = new JTextField("", 20);
    parameters.registerComponent(sigmaParam, sigmaTextField);
    //
    JPanel panel = new JPanel(new GridBagLayout());
    panel.add(new JLabel("Sigma [px]: "), GridBagHelper.leftCol());
    panel.add(sigmaTextField, GridBagHelper.rightCol());
    parameters.loadPrefs();
    return panel;
}
 
Example #28
Source File: SoundRecorderTest.java    From PolyGlot with MIT License 5 votes vote down vote up
@Test
public void testSoundRecordingSuite() {
    Assumptions.assumeFalse(GraphicsEnvironment.isHeadless());
    
    System.out.println("SoundRecorderTest.testSoundRecordingSuite");
    
    ImageIcon playButtonUp = PGTUtil.getButtonSizeIcon(new ImageIcon(getClass().getResource(PGTUtil.PLAY_BUTTON_UP)));
    ImageIcon playButtonDown = PGTUtil.getButtonSizeIcon(new ImageIcon(getClass().getResource(PGTUtil.PLAY_BUTTON_DOWN)));
    ImageIcon recordButtonUp = PGTUtil.getButtonSizeIcon(new ImageIcon(getClass().getResource(PGTUtil.RECORD_BUTTON_UP)));
    ImageIcon recordButtonDown = PGTUtil.getButtonSizeIcon(new ImageIcon(getClass().getResource(PGTUtil.RECORD_BUTTON_DOWN)));
    
    try {
        SoundRecorder recorder = new SoundRecorder(null);
        recorder.setButtons(new JButton(), new JButton(), playButtonUp, playButtonDown, recordButtonUp, recordButtonDown);
        recorder.setTimer(new JTextField());
        recorder.setSlider(new JSlider());
        recorder.beginRecording();
        Thread.sleep(1000);
        recorder.endRecording();
        byte[] sound = recorder.getSound();
        recorder.setSound(sound);
        recorder.playPause();
        assertTrue(recorder.isPlaying());
    } catch (Exception e) {
        fail(e);
    } 
}
 
Example #29
Source File: Utils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void stepSetDir(
    TestData data,
    String label,
    String dir
  )
{
  JFrameOperator installerMain = new JFrameOperator( MAIN_FRAME_TITLE );

  if( null == dir )
  {
    String sDefaultPath = new JTextFieldOperator( ( JTextField )( new JLabelOperator( installerMain, label ).getLabelFor( ) ) ).getText( );
    // Set default path to data
    data.SetDefaultPath( sDefaultPath );
  }
  else
  {
    try
    {
      new JTextFieldOperator( ( JTextField )( new JLabelOperator( installerMain, label ).getLabelFor( ) ) ).setText( ( new File( dir ) ).getCanonicalPath( ) );
    }
    catch( IOException ex )
    {
      ex.printStackTrace( );
    }
  }

  new JButtonOperator( installerMain, NEXT_BUTTON_LABEL ).push( );
}
 
Example #30
Source File: MarvinAttributesPanel.java    From marvinproject with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Adds TextField
 * @param id			component id.
 * @param attrID		attribute id.
 * @param attr			MarivnAttributes Object.
 */
public void addTextField(String id, String attrID, MarvinAttributes attr)
{
	JComponent comp = new JTextField(5);
	((JTextField)(comp)).setText(attr.get(attrID).toString());
	plugComponent(id, comp, attrID, attr, ComponentType.COMPONENT_TEXTFIELD);
}