当前位置: 首页>>代码示例>>Java>>正文


Java JTextField.setBackground方法代码示例

本文整理汇总了Java中javax.swing.JTextField.setBackground方法的典型用法代码示例。如果您正苦于以下问题:Java JTextField.setBackground方法的具体用法?Java JTextField.setBackground怎么用?Java JTextField.setBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTextField的用法示例。


在下文中一共展示了JTextField.setBackground方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateControls

import javax.swing.JTextField; //导入方法依赖的package包/类
private void updateControls(JTextField tf, JButton addButton, int state) {
    if (textBkColor == null) {
        textBkColor = tf.getBackground();
    }
    switch (state) {
        default:
            tf.setBackground(Color.pink);
            addButton.setEnabled(false);
            break;
        case -1:
            tf.setBackground(textBkColor);
            addButton.setEnabled(false);
            break;
        case 0:
            tf.setBackground(textBkColor);
            addButton.setEnabled(true);
            break;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:UseSpecificCatchCustomizer.java

示例2: incValueAndUpdateGUI

import javax.swing.JTextField; //导入方法依赖的package包/类
private void incValueAndUpdateGUI(int inc, final JTextField tf) {
	final AbstractMultiBitRegisterCP embeddingCP = (AbstractMultiBitRegisterCP) tf.getParent();

	embeddingCP.startEdit();
	try {
		embeddingCP.reg.setPartialValue(componentID, embeddingCP.reg.getPartialValue(componentID) + inc);
		embeddingCP.reg.setFileModified();
		tf.setBackground(Color.white);
	}
	catch (final Exception ex) {
		tf.selectAll();
		tf.setBackground(Color.red);
		log.warning(ex.toString());
	}
	finally {
		embeddingCP.endEdit();
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:19,代码来源:AbstractMultiBitRegisterCP.java

示例3: textFieldKeyReleased

import javax.swing.JTextField; //导入方法依赖的package包/类
private void textFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textFieldKeyReleased

        JTextField field = (JTextField) evt.getSource();

        try {
            Integer.parseInt(field.getText());
            field.setBackground(java.awt.Color.white);
            buttonDispense1.setEnabled(true);
            buttonDispense2.setEnabled(true);
        } catch (NumberFormatException ex) {
            field.setBackground(java.awt.Color.red);
            buttonDispense1.setEnabled(false);
            buttonDispense2.setEnabled(false);
        }

    }
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:17,代码来源:AsyncPump.java

示例4: addLine

import javax.swing.JTextField; //导入方法依赖的package包/类
/** Create a single-line entry box with the specified name, label,
 *  default value, and background color.  To control the width of
 *  the box, call setTextWidth() first.
 *  @param name The name used to identify the entry (when accessing
 *   the entry).
 *  @param label The label to attach to the entry.
 *  @param defaultValue Default value to appear in the entry box.
 *  @param background The background color.
 */
public void addLine(
        String name,
        String label,
        String defaultValue,
        Color background) {
    JLabel lbl = new JLabel(label + ": ");
    lbl.setBackground(_background);
    JTextField entryBox = new JTextField(defaultValue, _width);
    entryBox.setBackground(background);
    _addPair(name, lbl, entryBox, entryBox);

    // Add the listener last so that there is no notification
    // of the first value.
    entryBox.addActionListener(new QueryActionListener(name));

    // Add a listener for loss of focus.  When the entry gains
    // and then loses focus, listeners are notified of an update,
    // but only if the value has changed since the last notification.
    // FIXME: Unfortunately, Java calls this listener some random
    // time after the window has been closed.  It is not even a
    // a queued event when the window is closed.  Thus, we have
    // a subtle bug where if you enter a value in a line, do not
    // hit return, and then click on the X to close the window,
    // the value is restored to the original, and then sometime
    // later, the focus is lost and the entered value becomes
    // the value of the parameter.  I don't know of any workaround.
    entryBox.addFocusListener(new QueryFocusListener(name));
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:38,代码来源:Query.java

示例5: QueryFileChooser

import javax.swing.JTextField; //导入方法依赖的package包/类
public QueryFileChooser(
        String name,
        String defaultName,
        URI base,
        File startingDirectory,
        Color background) {
    super(BoxLayout.X_AXIS);
    _base = base;
    _startingDirectory = startingDirectory;
    _entryBox = new JTextField(defaultName, _width);
    _entryBox.setBackground(background);
    JButton button = new JButton("Browse");
    button.addActionListener(this);
    add(_entryBox);
    add(button);
    // Add the listener last so that there is no notification
    // of the first value.
    _entryBox.addActionListener(new QueryActionListener(name));

    // Add a listener for loss of focus.  When the entry gains
    // and then loses focus, listeners are notified of an update,
    // but only if the value has changed since the last notification.
    // FIXME: Unfortunately, Java calls this listener some random
    // time after the window has been closed.  It is not even a
    // a queued event when the window is closed.  Thus, we have
    // a subtle bug where if you enter a value in a line, do not
    // hit return, and then click on the X to close the window,
    // the value is restored to the original, and then sometime
    // later, the focus is lost and the entered value becomes
    // the value of the parameter.  I don't know of any workaround.
    _entryBox.addFocusListener(new QueryFocusListener(name));

    _name = name;
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:35,代码来源:Query.java

示例6: installUI

import javax.swing.JTextField; //导入方法依赖的package包/类
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    jtf = (JTextField) c;

    JTextField editor = jtf;

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();
    Font f = editor.getFont();
    if ((f == null) || (f instanceof UIResource)) {
        editor.setFont(uidefaults.getFont(prefix + ".font"));
    }

    Color bg = editor.getBackground();
    if ((bg == null) || (bg instanceof UIResource)) {
        editor.setBackground(uidefaults.getColor(prefix + ".background"));
    }

    Color fg = editor.getForeground();
    if ((fg == null) || (fg instanceof UIResource)) {
        editor.setForeground(uidefaults.getColor(prefix + ".foreground"));
    }

    Color color = editor.getCaretColor();
    if ((color == null) || (color instanceof UIResource)) {
        editor.setCaretColor(uidefaults.getColor(prefix + ".caretForeground"));
    }

    Color s = editor.getSelectionColor();
    if ((s == null) || (s instanceof UIResource)) {
        editor.setSelectionColor(uidefaults.getColor(prefix + ".selectionBackground"));
    }

    Color sfg = editor.getSelectedTextColor();
    if ((sfg == null) || (sfg instanceof UIResource)) {
        editor.setSelectedTextColor(uidefaults.getColor(prefix + ".selectionForeground"));
    }

    Color dfg = editor.getDisabledTextColor();
    if ((dfg == null) || (dfg instanceof UIResource)) {
        editor.setDisabledTextColor(uidefaults.getColor(prefix + ".inactiveForeground"));
    }

    Border b = editor.getBorder();
    if ((b == null) || (b instanceof UIResource)) {
        editor.setBorder(uidefaults.getBorder(prefix + ".border"));
    }

    Insets margin = editor.getMargin();
    if (margin == null || margin instanceof UIResource) {
        editor.setMargin(uidefaults.getInsets(prefix + ".margin"));
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:57,代码来源:XTextFieldPeer.java

示例7: setBgcolorField

import javax.swing.JTextField; //导入方法依赖的package包/类
public static void setBgcolorField(JTextField field) {
    Color c = Util.decodeColor(field.getText());
    field.setBackground(c);
    field.setForeground(new Color(~c.getRGB()));
}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:6,代码来源:Util.java

示例8: setBgcolorField

import javax.swing.JTextField; //导入方法依赖的package包/类
public static void setBgcolorField(JTextField field) {
    Color c = HtmlUtil.decodeColor(field.getText());
    field.setBackground(c);
    field.setForeground(new Color(~c.getRGB()));
}
 
开发者ID:ser316asu,项目名称:SER316-Dresden,代码行数:6,代码来源:HtmlUtil.java

示例9: createSaveToPanel

import javax.swing.JTextField; //导入方法依赖的package包/类
Box createSaveToPanel() {
	Box box = Box.createVerticalBox();
	box.setOpaque(false);
	box.setBorder(new EmptyBorder(10, 0, 0, 10));

	Box b = Box.createHorizontalBox();
	b.add(new JLabel(getString("TMP_DIR")));
	b.add(Box.createHorizontalGlue());
	box.add(b);

	Box box1 = Box.createHorizontalBox();
	box1.setBorder(new EmptyBorder(5, 0, 5, 0));

	txtTmpDir = new JTextField(15);
	txtTmpDir.setMaximumSize(new Dimension(
			txtTmpDir.getMaximumSize().width,
			txtTmpDir.getPreferredSize().height));
	txtTmpDir.setEditable(false);
	txtTmpDir.setBackground(Color.white);

	box1.add(txtTmpDir);

	box1.add(Box.createRigidArea(new Dimension(10, 10)));

	br1 = new JButton("...");
	br1.addActionListener(this);
	br1.setName("BR_TMP_DIR");
	box1.add(br1);

	box.add(box1);

	Box b2 = Box.createHorizontalBox();
	b2.add(new JLabel(getString("DST_DIR")));
	b2.add(Box.createHorizontalGlue());
	box.add(b2);

	Box box2 = Box.createHorizontalBox();
	box2.setBorder(new EmptyBorder(5, 0, 5, 0));

	txtDstDir = new JTextField(15);
	txtDstDir.setMaximumSize(new Dimension(
			txtDstDir.getMaximumSize().width,
			txtDstDir.getPreferredSize().height));
	txtDstDir.setEditable(false);

	box2.add(txtDstDir);

	box2.add(Box.createRigidArea(new Dimension(10, 10)));

	br2 = new JButton("...");
	br2.addActionListener(this);
	br2.setName("BR_DST_DIR");
	box2.add(br2);

	txtDstDir.setBackground(Color.white);

	box.add(box2);

	box.add(Box.createVerticalGlue());

	return box;
}
 
开发者ID:kmarius,项目名称:xdman,代码行数:63,代码来源:ConfigDialog.java

示例10: stylizeTextField

import javax.swing.JTextField; //导入方法依赖的package包/类
public void stylizeTextField(JTextField t){
	t.setFont(font_14_bold);
	t.setForeground(Color.BLACK);
	t.setBackground(Color.WHITE);
	t.setHorizontalAlignment(JTextField.CENTER);
}
 
开发者ID:kevingilboy,项目名称:COE1186,代码行数:7,代码来源:CtcGui.java

示例11: makeGraphicsPanel

import javax.swing.JTextField; //导入方法依赖的package包/类
public void makeGraphicsPanel() {
    	graphicPanel = new JPanel();
    	graphicPanel.setLayout(gbLayout);
    	
    	graphicOut2 = new JPanel();
    	graphicOut2.setLayout(new GridLayout(0,(int)((myPanel.getWidth()-60)/100.0),0,0));
        graphicOut2.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.RAISED, Color.black, Color.gray)));	   
        graphicOut = new JScrollPane();
//        graphicOut2.addMouseListener(new MouseEventClusterPanel());
        graphicOut.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.RAISED, Color.black, Color.gray)));	   

        graphicOut2.setPreferredSize(null);
        graphicOut.setBackground(null);
        graphicOut2.setBackground(null);
        graphicOut.getViewport().setPreferredSize(null);
        graphicOut.getViewport().setBackground(Color.white);
        graphicOut.getViewport().add(graphicOut2);
        gbConst.weightx = 1; gbConst.weighty = 1;
        gbConst.fill = GridBagConstraints.BOTH;
        addComponent(graphicOut,graphicPanel, 0,0,4,1);

        JPanel tmp = new JPanel();
        textAreaForBonds = new TextArea("Bonds of Selected Cluster :", 4, 65);
        textAreaForBonds.append("\n\n");
        textAreaForBonds.append("Weight of Selected Cluster : ");
        textAreaForBonds.setBackground(Color.white);
        textAreaForBonds.setEditable(false);
        tmp.add(textAreaForBonds);
        gbConst.weightx = 0; gbConst.weighty = 0;
        gbConst.fill = GridBagConstraints.BOTH;
        addComponent(tmp,graphicPanel, 1,0,3,1);

        JPanel textPanel = new JPanel(new GridLayout(2,0));
        textPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.RAISED, Color.black, Color.gray)));
        JTextField  jtf = new JTextField();
        jtf.setBackground(Color.lightGray);
        jtf.setText("Total Number of Cluster");
        jtf.setEditable(false);
        textPanel.add(jtf);
        totalNCluster = new JTextField();
        textPanel.add(totalNCluster);
        gbConst.weightx = 0; gbConst.weighty = 0;
        gbConst.fill = GridBagConstraints.BOTH;
        addComponent(textPanel,graphicPanel, 1,3,1,1);
        
        if(firstTimeDrawn) {
        	displayPanel.add("Cluster Diagram Graphics", graphicPanel); firstTimeDrawn= false;        
        } else {
        	displayPanel.remove(0);displayPanel.add(graphicPanel, "Cluster Diagram Graphics",  0);
        }
    }
 
开发者ID:etomica,项目名称:etomica,代码行数:52,代码来源:MyApplet.java


注:本文中的javax.swing.JTextField.setBackground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。