當前位置: 首頁>>代碼示例>>Java>>正文


Java JTextField.getDocument方法代碼示例

本文整理匯總了Java中javax.swing.JTextField.getDocument方法的典型用法代碼示例。如果您正苦於以下問題:Java JTextField.getDocument方法的具體用法?Java JTextField.getDocument怎麽用?Java JTextField.getDocument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JTextField的用法示例。


在下文中一共展示了JTextField.getDocument方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTableCellEditorComponent

import javax.swing.JTextField; //導入方法依賴的package包/類
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
    if(document != null) {
        document.removeDocumentListener(listener);
    }
    JTextField editor = (JTextField) super.getTableCellEditorComponent(table, value, isSelected, row, column);
    document = editor.getDocument();
    listener = new CellEditorDocumentListener(table.getModel(), row, column);
    document.addDocumentListener(listener);
    return editor;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:JFXProjectProperties.java

示例2: initComponents

import javax.swing.JTextField; //導入方法依賴的package包/類
private void initComponents() {
	jrbOneShot = new JRadioButton("One Shot");
	jrbOneShot.setMnemonic(KeyEvent.VK_O);
	jrbOneShot.setActionCommand("One Shot");
	jrbOneShot.setSelected(true);
	jrbOneShot.addActionListener(this);
	
	jrbMonteCarlo = new JRadioButton("Monte-Carlo");
	jrbMonteCarlo.setMnemonic(KeyEvent.VK_M);
	jrbMonteCarlo.setActionCommand("Monte-Carlo");
	jrbMonteCarlo.addActionListener(this);
	
	buttonGroup = new ButtonGroup();
	buttonGroup.add(jrbOneShot); buttonGroup.add(jrbMonteCarlo);
	
	jlTimeUnits = new JLabel("Time units: ");
	jlMaxIterations = new JLabel("Max iterations: ");
	
	jlSelectExtensions = new JLabel("Select your report extension(s)");
	jcbExtensions = new ArrayList<JCheckBox>(6);
	jcbDocx = new JCheckBox("docx"); jcbExtensions.add(jcbDocx);
	jcbHtml = new JCheckBox("html"); jcbExtensions.add(jcbHtml);
	jcbPdf = new JCheckBox("pdf"); jcbExtensions.add(jcbPdf);
	jcbPptx = new JCheckBox("pptx"); jcbExtensions.add(jcbPptx);
	jcbOdt = new JCheckBox("odt"); jcbExtensions.add(jcbOdt);
	jcbXlsx = new JCheckBox("xlsx"); jcbExtensions.add(jcbXlsx);
	
	jcbPdf.setSelected(true);
	
	for(JCheckBox jcb : jcbExtensions) jcb.setEnabled(false);
	
	this.jlSelectModelingProject = new JLabel("Select your modeling project");
	this.jcbModelingProjects = new JComboBox<String>();
	
	// Retrieval of all user workspaces modeling projects
	for(String project : WorkspaceManager.getModelingProjects())
		this.jcbModelingProjects.addItem(project);
	this.jcbModelingProjects.setSelectedIndex(0);
	this.jcbModelingProjects.addActionListener(this);
	this.jcbModelingProjects.setEnabled(false);
	
	this.jlSelectReportTemplate = new JLabel("Select the report template you want to use");
	this.jcbReportTemplates = new JComboBox<String>();
	
	// Retrieval of all report templates of the selected project (the first one by default)
	for(String template : WorkspaceManager.getTemplates(this.jcbModelingProjects.getItemAt(0)))
		this.jcbReportTemplates.addItem(template);
	if(this.jcbReportTemplates.getModel().getSize() == 0)
		this.jcbReportTemplates.addItem("No report templates available !");
	this.jcbReportTemplates.setSelectedIndex(0);
	this.jcbReportTemplates.addActionListener(this);
	this.jcbReportTemplates.setEnabled(false);
	
	jtfTimeUnits = new JTextField("1000");
	PlainDocument docTimeUnits = (PlainDocument) jtfTimeUnits.getDocument();
    docTimeUnits.setDocumentFilter(new IntFilter());
    
    jtfMaxIterations = new JTextField("100");
    PlainDocument docMaxIterations = (PlainDocument) jtfMaxIterations.getDocument();
    docMaxIterations.setDocumentFilter(new IntFilter());
    // "One Shot" simulation selected by default
	jtfMaxIterations.setEnabled(false); 
    
	jtfTimeUnits.setColumns(5);
	jtfMaxIterations.setColumns(5);
	
	jbStart = new JButton("Start");
	jbStart.addActionListener(this);
	jbStop = new JButton("Stop");
	jbStop.addActionListener(this);
	jbStop.setEnabled(false);
	
	jpLoader = new PanelLoader("status bar", 100);
}
 
開發者ID:cetic,項目名稱:SimQRI,代碼行數:75,代碼來源:SimulationManagementWindow.java

示例3: SimpleBindExample

import javax.swing.JTextField; //導入方法依賴的package包/類
/**
 * Create the frame.
 */
public SimpleBindExample() {
	setTitle("Binder example");
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setBounds(100, 100, 450, 300);
	contentPane = new JPanel();
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
	
	JPanel panel = new JPanel();
	contentPane.add(panel);
	
	JLabel lblEnterTextHere = new JLabel("Enter text here (A)");
	panel.add(lblEnterTextHere);
	
	textField = new JTextField();
	panel.add(textField);
	textField.setColumns(10);

	/**
	 * Bind the text field to the ObservableString	
	 * This is a contrived example to simulate a model object updating.
	 * Binders can observe swing document models.
	 * ()->textField.getText() provides human edited text.
	 * (s)->ourString.setText(s) applies that text to the ObservableString.
	 * the textFeild's Document is listened to for changes.
	 */
	new Binder<String>(()->textField.getText(),(s)->ourString.setText(s),textField.getDocument());
	
	JPanel panel_1 = new JPanel();
	contentPane.add(panel_1);
	
	JLabel lblOrHere = new JLabel("(A) Ends up here");
	panel_1.add(lblOrHere);
	
	textField_1 = new JTextField();
	panel_1.add(textField_1);
	textField_1.setColumns(10);
	contentPane.add(panel_2);
	
	JLabel lblPressEnterHere = new JLabel("Press enter in this field to pass the string to (A)");
	panel_2.add(lblPressEnterHere);
	
	textField_eventLinked = new JTextField();
	panel_2.add(textField_eventLinked);
	textField_eventLinked.setColumns(10);
	
	/**
	 * Binders can be ActionListners for text fields, menu items and Buttons.
	 */
	ActionListener l = new Binder<String>(()->textField_eventLinked.getText(),(text)->ourString.setText(text));
	
	textField_eventLinked.addActionListener(l);
	
	JButton btnOrPressThis = new JButton("Or press this button");
	panel_2.add(btnOrPressThis);

	btnOrPressThis.addActionListener(l);
	/**
	 * Here is the Binder being used
	 * Bind ourString to the textField.
	 * ourString->getText() provides a String
	 * textField.setText(text) consumes a String.
	 * ourString is the observable ( to trigger the Binder on data changes. )
	 */
	new Binder<String>(()->ourString.getText(),(text)->textField_1.setText(text),ourString);
}
 
開發者ID:williscroft,項目名稱:binder,代碼行數:71,代碼來源:SimpleBindExample.java


注:本文中的javax.swing.JTextField.getDocument方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。