本文整理汇总了Java中javax.swing.JTextField类的典型用法代码示例。如果您正苦于以下问题:Java JTextField类的具体用法?Java JTextField怎么用?Java JTextField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JTextField类属于javax.swing包,在下文中一共展示了JTextField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MessagePreferencesPanel
import javax.swing.JTextField; //导入依赖的package包/类
public MessagePreferencesPanel() {
setLayout(null);
refuseMessages = new JCheckBox("Refuse Messages");
refuseMessages.setSize(150, 25);
refuseMessages.setLocation(10, 25);
refuseMessages.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
updateEnabled();
}
});
add(refuseMessages);
denyMessageLabel = new JLabel("Refusal Message:");
denyMessageLabel.setSize(150, 25);
denyMessageLabel.setLocation(20, 50);
add(denyMessageLabel);
denyMessageText = new JTextField(REFUSAL_MESSAGE_DEFAULT);
denyMessageText.setSize(400, 25);
denyMessageText.setLocation(25, 75);
add(denyMessageText);
setSize(STD_XSIZE, STD_YSIZE);
}
示例2: getProbabilityComponents
import javax.swing.JTextField; //导入依赖的package包/类
/**
* Helper method to extract the probability components the dialog's components.
* These components are the probability labels and the probability TextFields.
* @return a Vector of probability related components
* @author Federico Dal Castello
*/
private Vector<Component> getProbabilityComponents() {
Vector<Component> probabilityComponents = new Vector<Component>();
Vector<Component> components = new Vector<Component>();
components.addAll(Arrays.asList(intervalPanels[1].getComponents()));
components.addAll(Arrays.asList(intervalPanels[2].getComponents()));
Iterator<Component> it = components.iterator();
while (it.hasNext()) {
Component comp = it.next();
if (comp instanceof JTextField) {
if (comp.getName().equals(PROBABILITY_INTERVAL_A) || comp.getName().equals(PROBABILITY_INTERVAL_B)) {
probabilityComponents.add(comp);
}
}
if (comp instanceof JLabel && ((JLabel) comp).getText().equals(PROBABILITY)) {
probabilityComponents.add(comp);
}
}
return probabilityComponents;
}
示例3: getPreferredSize
import javax.swing.JTextField; //导入依赖的package包/类
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
if (PREFERRED_HEIGHT == -1) {
GenericToolbar tb = new GenericToolbar();
tb.setBorder(getBorder());
tb.setBorderPainted(isBorderPainted());
tb.setRollover(isRollover());
tb.setFloatable(isFloatable());
Icon icon = Icons.getIcon(GeneralIcons.SAVE);
tb.add(new JButton("Button", icon)); // NOI18N
tb.add(new JToggleButton("Button", icon)); // NOI18N
tb.add(new JTextField("Text")); // NOI18N
JComboBox c = new JComboBox();
c.setEditor(new BasicComboBoxEditor());
c.setRenderer(new BasicComboBoxRenderer());
tb.add(c);
tb.addSeparator();
PREFERRED_HEIGHT = tb.getSuperPreferredSize().height;
}
dim.height = getParent() instanceof JToolBar ? 1 :
Math.max(dim.height, PREFERRED_HEIGHT);
return dim;
}
示例4: getTableCellEditorComponent
import javax.swing.JTextField; //导入依赖的package包/类
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
Component editComponent = null;
this.domainVector = ctsDialog.getDomainVector();
this.domainName = (String) value;
if (this.domainName!=null && this.domainName.equals(GeneralGraphSettings4MAS.DEFAULT_DOMAIN_SETTINGS_NAME)==true) {
JLabel jLabel = new JLabel(this.domainName);
editComponent = jLabel;
} else {
JTextField jTextField = new JTextField(this.domainName);
jTextField.setBorder(BorderFactory.createEmptyBorder());
jTextField.getDocument().addDocumentListener(this.getTextFieldDocumentListener());
editComponent = jTextField;
}
return editComponent;
}
示例5: Limpar_Campos_Tela
import javax.swing.JTextField; //导入依赖的package包/类
public static void Limpar_Campos_Tela(JPanel tela, Boolean bloquear_Componentes){
for (Component componente : tela.getComponents()) {
if (componente instanceof JPanel) {
Limpar_Campos_Tela((JPanel) componente,bloquear_Componentes);
}
if(componente instanceof JScrollPane){
JViewport viewport = ((JScrollPane)componente).getViewport();
JTable table = (JTable)viewport.getView();
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.getDataVector().removeAllElements();
model.fireTableDataChanged();
table.setEnabled(!bloquear_Componentes);
}
if (componente instanceof JTextField) {
((JTextField) componente).setText("");
((JTextField) componente).setEnabled(!bloquear_Componentes);
}
if (componente instanceof JFormattedTextField) {
((JFormattedTextField) componente).setText("");
((JFormattedTextField) componente).setEnabled(!bloquear_Componentes);
}
if(componente instanceof JButton){
((JButton) componente).setEnabled(!bloquear_Componentes);
}
}
}
示例6: DeptView
import javax.swing.JTextField; //导入依赖的package包/类
public DeptView(Controller controller) {
this.controller = controller;
frame = new JFrame();
namePanel = new JPanel(new GridLayout(1, 2, 0, 0));
managerPanel = new JPanel(new GridLayout(1, 2, 66, 0));
employeePanel = new JPanel(new GridLayout(1, 2, 30, 0));
subDeptPanel = new JPanel(new GridLayout(1, 2, 20, 0));
salaryPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 20, 0));
buttonPanel = new JPanel(new GridLayout(1, 3, 20, 0));
subDeptLabel = new JLabel();
salaryLabel = new JLabel();
cutButton = new JButton();
saveButton = new JButton();
okButton = new JButton();
cancelButton = new JButton();
nameField = new JTextField();
managerButton = new JButton();
employeeListModel = new DefaultListModel();
subDeptListModel = new DefaultListModel();
employeeList = new JList(employeeListModel);
subDeptList = new JList(subDeptListModel);
init();
}
示例7: setValueFromGUI
import javax.swing.JTextField; //导入依赖的package包/类
private void setValueFromGUI(final JTextField tf) {
final AbstractMultiBitRegisterCP embeddingCP = (AbstractMultiBitRegisterCP) tf.getParent();
embeddingCP.startEdit();
try {
embeddingCP.reg.setPartialValue(componentID, Integer.parseInt(tf.getText()));
embeddingCP.reg.setFileModified();
tf.setBackground(Color.white);
}
catch (final Exception ex) {
tf.selectAll();
tf.setBackground(Color.red);
log.warning(ex.toString());
}
finally {
embeddingCP.endEdit();
}
}
示例8: clickAction
import javax.swing.JTextField; //导入依赖的package包/类
public void clickAction(){
JTextField hours = new JTextField();
JTextField minutes = new JTextField();
JTextField seconds = new JTextField();
Object[] message = {
"Hours", hours,
"Minutes", minutes,
"Seconds",seconds
};
int option = JOptionPane.showConfirmDialog(null, message, "Time Limit", JOptionPane.OK_CANCEL_OPTION);
if (option == JOptionPane.OK_OPTION) {
try{
w.setTimeLimit(Integer.parseInt(hours.getText()),
Integer.parseInt(minutes.getText()),
Integer.parseInt(seconds.getText()),0);
}catch(Exception e){
w.setTimeLimit(Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE);
}
}
}
示例9: paintCrawler
import javax.swing.JTextField; //导入依赖的package包/类
public void paintCrawler(JPanel _panel) {
//Define all new Components GUI
JPanel crawlerPanel = new JPanel();
JPanel configPanel = new JPanel();
JButton crawl = new JButton(" Crawl ");
JTextField name = new JTextField(25);
name.setText("userNameID");
JButton random = new JButton("Random");
//Add action Listener
crawl.addActionListener(event -> crawlInfo(name.getText()));
// random.addActionListener();
//add to pane and manage layout
_panel.add(configPanel, BorderLayout.CENTER);
_panel.add(crawlerPanel, BorderLayout.SOUTH);
crawlerPanel.add(crawl);
configPanel.add(name);
crawlerPanel.add(random);
}
示例10: loadConnectionProps
import javax.swing.JTextField; //导入依赖的package包/类
private void loadConnectionProps(Properties props) {
if (props != null) {
for (Object key : props.keySet()) {
String propsKey = (String) key;
if (components.containsKey(propsKey)) {
JComponent component = components.get(propsKey);
String value = props.getProperty(propsKey);
if (component instanceof JTextField) {
((JTextField) component).setText(value);
} else if (component instanceof JComboBox) {
((JComboBox) component).setSelectedItem(value);
}
}
}
}
}
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:17,代码来源:ZooInspectorConnectionPropertiesDialog.java
示例11: createToolBar
import javax.swing.JTextField; //导入依赖的package包/类
private void createToolBar() {
searchBar = new JToolBar();
searchBar.setFloatable(false);
searchBar.setLayout(new BoxLayout(searchBar, BoxLayout.X_AXIS));
searchBar.setBorder(BorderFactory.createEtchedBorder());
JLabel searchLabel = new JLabel(Utils.getIconByResourceName("/ui/resources/search"));
searchField = new JTextField();
searchField.setActionCommand("SearchField");
searchField.addActionListener(this);
searchBar.add(searchLabel);
searchBar.add(new javax.swing.Box.Filler(new java.awt.Dimension(5, 0),
new java.awt.Dimension(5, 0),
new java.awt.Dimension(5, 32767)));
searchBar.add(searchField);
}
示例12: Test6505027
import javax.swing.JTextField; //导入依赖的package包/类
public Test6505027(JFrame main) {
Container container = main;
if (INTERNAL) {
JInternalFrame frame = new JInternalFrame();
frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
frame.setVisible(true);
JDesktopPane desktop = new JDesktopPane();
desktop.add(frame, new Integer(1));
container.add(desktop);
container = frame;
}
if (TERMINATE) {
this.table.putClientProperty(KEY, Boolean.TRUE);
}
TableColumn column = this.table.getColumn(COLUMNS[1]);
column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));
container.add(BorderLayout.NORTH, new JTextField());
container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
示例13: PropertyPanel
import javax.swing.JTextField; //导入依赖的package包/类
/** Creates new form PropertyPanel */
public PropertyPanel(String propCat, boolean add, SessionFactory sessionFactory, String propName, String propValue) {
initComponents();
// The comb box only contains the property names that are not defined yet when adding
if (add) {
nameComboBox.setModel(new DefaultComboBoxModel(Util.getAvailPropNames(propCat, sessionFactory)));
} else {
nameComboBox.setModel(new DefaultComboBoxModel(Util.getAllPropNames(propCat)));
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);
}
示例14: NameAndLocationPanel
import javax.swing.JTextField; //导入依赖的package包/类
/** Creates new NameAndLocationPanel */
public NameAndLocationPanel(final WizardDescriptor setting, final HTMLIterator.DataModel data) {
super(setting);
this.data = data;
initComponents();
initAccessibility();
putClientProperty("NewFileWizard_Title", getMessage("LBL_TCWizardTitle"));
DocumentListener dListener = new UIUtil.DocumentAdapter() {
public void insertUpdate(DocumentEvent e) {
if (checkValidity()) {
updateData();
}
}
};
txtPrefix.getDocument().addDocumentListener(dListener);
txtIcon.getDocument().addDocumentListener(dListener);
if (comPackageName.getEditor().getEditorComponent() instanceof JTextField) {
JTextField txt = (JTextField)comPackageName.getEditor().getEditorComponent();
txt.getDocument().addDocumentListener(dListener);
}
}
示例15: testOptions
import javax.swing.JTextField; //导入依赖的package包/类
/** Test Options
* - open Options window from main menu Tools|Options
* - select Editor category
* - select Fonts & Colors category
* - select Keymap category
* - select General category
* - pick Manual Proxy Setting
* - set Proxy Host to emea-proxy.uk.oracle.com
* - set Proxy Port to 80
* - click OK to confirm and close Options window
*/
public void testOptions() {
OptionsOperator optionsOper = OptionsOperator.invoke();
optionsOper.selectEditor();
optionsOper.selectFontAndColors();
optionsOper.selectKeymap();
optionsOper.selectGeneral();
// "Manual Proxy Setting"
String hTTPProxyLabel = Bundle.getStringTrimmed(
"org.netbeans.core.ui.options.general.Bundle", "CTL_Use_HTTP_Proxy");
new JRadioButtonOperator(optionsOper, hTTPProxyLabel).push();
// "HTTP Proxy:"
String proxyHostLabel = Bundle.getStringTrimmed(
"org.netbeans.core.ui.options.general.Bundle", "CTL_Proxy_Host");
JLabelOperator jloHost = new JLabelOperator(optionsOper, proxyHostLabel);
new JTextFieldOperator((JTextField) jloHost.getLabelFor()).setText("emea-proxy.uk.oracle.com"); // NOI18N
// "Port:"
String proxyPortLabel = Bundle.getStringTrimmed(
"org.netbeans.core.ui.options.general.Bundle", "CTL_Proxy_Port");
JLabelOperator jloPort = new JLabelOperator(optionsOper, proxyPortLabel);
new JTextFieldOperator((JTextField) jloPort.getLabelFor()).setText("80"); // NOI18N
optionsOper.ok();
}