Visually express setEditable(false)

Hello,
On the GUI I write, if a user clicks an a radio button, a text field must not be editable anymore. It works with setEditable(false) but it has no graphical effect.
So Is there a way to put the text field and its associate label in gray?
I searched the API and various doc, but found nothing.
Thanks for help
Thierry

Like setBackGround and setForeGround.

Similar Messages

  • SetEditable(false)

    Hai..
    I have a TextField called tf1
    based on the setEditable(false) method i have to do some code like this
    Is it possible to do like this ? or is there any other option to validate like this
    I am new to java
    please help me.
    Thanks in advance
    Yours
    Rajesh
    if (tf1==setEditable(false))
    System.out.println("Textfield is not Editable");
    else
    System.out.println("Textfield is Editable");
    }

    Rajesh
    Hi,
    The setEditable() method does not return a boolean. setEditable()
    is for setting a TextField editable.
    tf1.setEditable(true);
    isEditable() returns a boolean.
    tf1.isEditable() returns true if tf1 is editable, flase if tf1 is not editable.
    Deepak

  • Inserting Icons in JTextPane with setEditable=false

    Aloha!
    I'm working on this for years now, but i haven't found an acceptable solution yet.
    The problem: I have a JTextPane, where the user shall not be able to edit anything by clicking onto the JTextPane. So I have to setEditable=false. Now I want to insert an icon with insertIcon and therefore i have to setEditable = true. But for short time it's now possible for the user to click onto the screen and change the caretPosition, which must be prevented at all costs (because I'm working with the expected caretPosition of course)! This only happens when I try the brute force testing method, but it happens sometimes...
    So can someone give me a better solution than:
    setEditable = true;
    insertIcon(blahblah);
    setEditable = false;
    Thanks a lot for your attention,
    Holm

    To use HTML, you must use javax.swing.text.html.HTMLDocument instead of StyledDocument,
    Instead of StyleConstants, you must use javax.swing.text.html.HTML$Tag and javax.swing.text.html.HTML$Attribute.
    And you can use an HTMLEditorKit instead of DefaultEditorKit.
    this is an example of initialization:
    javax.swing.text.html.HTMLEditorKit htmlEditorKit = new javax.swing.text.html.HTMLEditorKit();
    javax.swing.text.html.HTMLDocument htmlDoc = (javax.swing.text.html.HTMLDocument)htmlEditorKit.createDefaultDocument();
    yourJTextPane.setEditorKit(htmlEditorKit);
    yourJTextPane.setDocument(htmlDoc);
    yourJTextPane.setEditable(true);
    yourJTextPane.setContentType("text/html");and you can use it by yourJTextPane.setText(HtmlCodeString)
    HTMLDocument and HTMLEditorKit allow you main modifications.
    thanks for duke dollars :)

  • Why doesn't calling setEditable(false) disable cursoring

    I want to have JFormattedTextField format my date fields for me. It does a good job of it, so why wouldn't I?
    I have a need to display a non-editable date for reference purposes. Unfortunately I discovered that the cursoring is still active when setEditable(false) is called. In order to prevent this, I have had to subclass DateFormatter in order to override getActions() to return null if I don't want incrementing. There are a number of problems with this:
    1) setEditable on JFormattedTextField should have been enough. If I don't want it editable, then I don't want cursoring. I would have thought that was obvious.
    2) Notwithstanding that, the correct method to override for incrementing is really getSupportsIncrement(), but this has no modifier, so is in the 'friendly' status, which means it can only be overridden in the package.
    3) While I can override getActions, this signature leaves itself open to have other actions than "increment" and "decrement" returned . That is, it works now, but if sun adds more actions to the list of actions returned by getActions(), then my override is broken.
    Is there a bug in there somewhere?
    Thanks, Andrew

    1) setEditable on JFormattedTextField should have
    been enough. If I don't want it editable, then I
    don't want cursoring. I would have thought that was
    obvious.Nope not really. What if the user wants to copy some text using the keyboard?

  • WebTest - VS2013 - Extract Regular Expression - Required=False

    I have an "Extract Regular Expression" that may or may not be able to extract a value. I set the property value of Required to False. The next block checks for the existence of that Context Parameter. If the Context Parameter is there, it does
    some work, if the Context Parameter is not there, it skips the condition.
    When I run my WebTest, it tells me that it passes the extraction rule but it never created the Context Parameter so the condition is skipped.
    If I set Required=True, everything works as expected.
    I remembered that there was a defect in VS2010 with the Required=False, so I added this Extraction Plug-In 
    [DisplayName("Extract Regular Expression Not Required")]
    [Description("Extract text matching a regex and add it to the test context. If no match is found, do not fail webtest. This gets around a VSTS bug where 'Required' property of the Extract Regular Expression rule is not honored.")]
    public class ExtractRegularExpressionNotRequired : ExtractRegularExpression
    public override void Extract(object sender, ExtractionEventArgs e)
    base.Extract(sender, e);
    e.Success = true;
    That too passes the regular expression but fails to create the Context Parameter.

    By setting the Required parameter to False, I am expecting that a Context Parameter does not get created if the regular expression is not found and that is does get created if the regular expression is found.
    So when I run my test, it tells me that the regular expression was found but my Context Parameter was not created. 
    When I created this webtest in VS2010, I found that there was a bug with the Extract Regular Expression when the Required property was False. This
    thread showed the code for a custom Extraction rule to fix the problem. When I run this webtest in VS2013, both the built-in Extract Regular Expression and the custom Extract Regular Expression Not Required are not creating the Context Parameter if the
    regex is found.
    Try this yourself:
    Create a webtest
    Add "Extract Regular Expression"
    Set the Regular expression to . (this will match any one character)
    Set the Requiredto False
    Set the Context Parameter Name to TEST
    Run the webtest
    Although the result from the extraction rule will be Passed, there is no Context Parameter TEST created. 
    If you create the custom Extract Regular Expression Not Required plugin, the same problem occurs.

  • RDB Odbc drivers and Visual Express 2005 !!!

    hi,
    i'm having troubles with MS Web Developper Express 2005 and RDB database ODBC driver 3102.
    When i try to declare a link to a dsn previously delared in ODBC manager (win xp sp2), i click the "test connection" then it's succesfull, but when i want to browse thru the tables within the rdb db, i receive the error : [HYC00][Oracle][ODBC] Optional feature not implemented...
    I tried to use the same dsn with MS Access and it works correctly.
    Any idea ?
    Thanks

    hi,
    i'm having troubles with MS Web Developper Express 2005 and RDB database ODBC driver 3102.
    When i try to declare a link to a dsn previously delared in ODBC manager (win xp sp2), i click the "test connection" then it's succesfull, but when i want to browse thru the tables within the rdb db, i receive the error : [HYC00][Oracle][ODBC] Optional feature not implemented...
    I tried to use the same dsn with MS Access and it works correctly.
    Any idea ?
    Thanks

  • Regular expression checker

    hi,
    i am new to regular expression. i would like to know if there is a tool to check regular expressions? the tool should based on the entered regular expression display the result.
    thanks

    import java.util.regex.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class JavaRegxTest extends JFrame implements ActionListener{
      JTextField regxInput, textInput;
      JButton doMatchButton, resetButton, exitButton;
      JTextArea resultsArea;
      public JavaRegxTest(){
        super("JavaRegxTest");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        Container cp = getContentPane();
        cp.setLayout(new GridLayout(2, 1));
        JPanel upPanel = new JPanel(new GridLayout(5, 1));
        upPanel.add(new JLabel("regular expression:   "));
        upPanel.add(regxInput = new JTextField(50));
        upPanel.add(new JLabel("sample text:          "));
        upPanel.add(textInput = new JTextField(50));
        JPanel buttonPanel = new JPanel(new GridLayout(1, 3));
        buttonPanel.add(resetButton = new JButton("RESET"));
        buttonPanel.add(doMatchButton = new JButton("MATCH"));
        buttonPanel.add(exitButton = new JButton("EXIT"));
        upPanel.add(buttonPanel);
        resetButton.addActionListener(this);
        doMatchButton.addActionListener(this);
        exitButton.addActionListener(this);
        resultsArea = new JTextArea(20, 60);
        resultsArea.setEditable(false);
        JScrollPane jsp = new JScrollPane(resultsArea);
        cp.add(upPanel);
        cp.add(jsp);
        setSize(550, 700);
        setVisible(true);
      public void actionPerformed(ActionEvent e){
        JButton btn = (JButton)(e.getSource());
        if (btn == exitButton){
          System.exit(0);
        else if (btn == resetButton){
          reset();
        else if (btn == doMatchButton){
          doMatch();
      /* clear text */
      void reset(){
        regxInput.setText("");
        textInput.setText("");
        resultsArea.setText("");
      /* display match results */
      void doMatch(){
        resultsArea.setText(resultsArea.getText() + "REGX=" + regxInput.getText()
         + "\n" + "TEXT=" + textInput.getText() + "\n");
        try{
          Pattern pat = Pattern.compile(regxInput.getText());
          String sampleText = textInput.getText();
          Matcher mat = pat.matcher(sampleText);
          int gc = mat.groupCount();
          for (int i = 0; i <= gc; ++i){ //for each capture group
            resultsArea.setText(resultsArea.getText()
             + "GROUP" + i + " : \n"); //GROUP0 == whole match
            while (mat.find()){ //display every matched parts
              resultsArea.setText(resultsArea.getText()
               + " " + mat.group(i) + "\n");
            mat.reset(sampleText); //go to next group
        catch(Exception e){
          resultsArea.setText(e.toString());
      public static void main(String[] args){
        JavaRegxTest jrt = new JavaRegxTest();
    }

  • In search of a spesific style/expression! Maybe you know the name of it?

    Hello fellow after-effects users,
    I've been seaching for the name of a spesific style/visual expression/grade for a long time now and maybe some one here can help me out finding the common name for it. Here are the common elements:
    * I think its trying to emulate a type of lens distortion.
    * With sometimes green, red and/or blue superimpositions in the edges.
    * Part of the image is blurred (in the edges of the image/vignette)
    Here is a couple of not necessarily good examples. But make notice of the edges in both pictures, displacing and changing color:
    Is there a common name for this effect?
    Thanks.

    Thank you ever so much for this!! Excactly what I was thinking about! Thank you and have a great new year.
    -Oz

  • JTextComponent - setEditable background color

    I have a subclass of JTextField. I am doing manipulations of the background color (red when validation failed). When the program sets the text field to be not editable I want the default disabled background color (transparent?) to be displayed.
    However, in some cases I am getting a background of white when it is disabled.
    What is setEditable doing to change the background from white to grey? If I have the background color set to RED how do I change it so that grey will be shown?
    Thanks,
    John

    I am trying to understand what setEditable does WRT the background color / transpanency. In the below code, when you press the button the first time, the background of the textfield becomes grey. If you press it again it becomes white. Is this because setEditable doesn't do anything if the field is already editable?
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.SwingUtilities;
    public class BackgroundTester extends JFrame {
         private static final long serialVersionUID = 1L;
         private JPanel jContentPane = null;
         private JPanel jPanel = null;
         private JTextField jTextField = null;
         private JButton jButton = null;
         private Color origBackColor = null;
          * This method initializes jPanel     
          * @return javax.swing.JPanel     
         private JPanel getJPanel() {
              if (jPanel == null) {
                   GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
                   gridBagConstraints2.gridx = 0;
                   gridBagConstraints2.gridy = 2;
                   GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
                   gridBagConstraints1.fill = GridBagConstraints.VERTICAL;
                   gridBagConstraints1.gridy = 1;
                   gridBagConstraints1.weightx = 1.0;
                   gridBagConstraints1.gridx = 0;
                   jPanel = new JPanel();
                   jPanel.setLayout(new GridBagLayout());
                   jPanel.add(getJTextField(), gridBagConstraints1);
                   jPanel.add(getJButton(), gridBagConstraints2);
              return jPanel;
          * This method initializes jTextField     
          * @return javax.swing.JTextField     
         private JTextField getJTextField() {
              if (jTextField == null) {
                   jTextField = new JTextField();
                   jTextField.setColumns(10);
              return jTextField;
          * This method initializes jButton     
          * @return javax.swing.JButton     
         private JButton getJButton() {
              if (jButton == null) {
                   jButton = new JButton();
                   jButton.setText("Set Disabled");
                   jButton.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) {
                             jTextField.setBackground(origBackColor);
                             jTextField.setEditable(false);
              return jButton;
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        BackgroundTester thisClass = new BackgroundTester();
                        thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                        thisClass.setVisible(true);
          * This is the default constructor
         public BackgroundTester() {
              super();
              initialize();
              origBackColor = jTextField.getBackground();
              jTextField.setBackground(Color.RED);
          * This method initializes this
          * @return void
         private void initialize() {
              this.setSize(300, 200);
              this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              this.setContentPane(getJContentPane());
              this.setTitle("JFrame");
          * This method initializes jContentPane
          * @return javax.swing.JPanel
         private JPanel getJContentPane() {
              if (jContentPane == null) {
                   jContentPane = new JPanel();
                   jContentPane.setLayout(new BorderLayout());
                   jContentPane.add(getJPanel(), BorderLayout.CENTER);
              return jContentPane;
    }

  • JTextField's - setting editable false, but without greying out the area?

    Is this at all possible? Is there any other way to go about it? Or is the only way to make a textfeild un-edditable using the setEditable(false); command.. and sticking it with the grey area?
    Sorry for the weird/dumb/annoying question..
    Thanks anyway heh..

    all i wanted was an answer and this dude just flames
    me.I think your need to adjust your sensitivity downward by an order of magnitude. I didn't see anything in Joachim's response that remotely resembled a flame. He simply pointed out that your requested goal violates standard usability principles (rather politely, I might add). You referred to your own question in a more derogatory manner than any respondent.
    Personally, I think his advice was very helpful. You shouldn't violate standard usability principles unless you're just deliberately trying to confuse your users, which is not something many of us would care to give advice on how to do...

  • SetEditable is not working with combobox

    Hi,
    I am working with table and using combo box in cell of table, in certain condition I have to make combo as editable and non editable.
    I have written class which extends DefaultCellEditor
    @Override
    public Component getTableCellEditorComponent(JTable table, Object value, boolean flag, int row, int column)
    comboBox.getModel()).setSelectedItem(value.toString());
    comboBox.setEditable(true);
    if i set comboBox.setEditable(true). cell become editable but i am not able to select item from combo..
    when i do set comboBox.setEditable(false) cell become non editable and i can select value from combo but not able to enter any value.
    i want both the operations. Editable cell in which user can enter any value and also can select value from combo.
    Any Idea???? please share with me, this is blocking issue for me. Thanks in advance.
    Prashant Gour
    Message was edited by:
    Prashant_SDN

    thanks
    that is working idea of key listener. now i am able to select item form combo and can enter value too. but now problem is that by default combo looks non editable and become editable after pressing key .
    so that is looked user friendly.
    have you any suggestions.

  • Cannot start Visual Studio 2013 Community edition

    Windows 7 on a 64-bit PC...
    Downloaded the installer vs_community.exe for Visual Studio 2013 with Update4 yesterday and ran it.
    It took about 1 hour and 20 minutes. At the end the installer reported the web deployment function
    could not be found/installed and that I could locate and install it myself later. It then told me to
    restart the PC, which I did, but the Community edition had not been added to the start menu.
    There are other Visual Studio versions on this PC:
    Visual C# 2010 Express, Visual Express 2012, Visual Express 2013 and Visual Studio 2013 Ultimate
    trial version. They can all be started from the menu and do not interfere with each other and they
    installed without problems. There are 4 weeks evaluation time left for VS 2013 Ultimate and I want to
    make use of that. VS Express can be shown the door if any of these might be blocking the
    Community version.
    I am puzzled by one more VS directory named Microsoft Visual Studio 2012 in Program Files(x86). This
    contains many items added yesterday by the Community install including a directory named Community
    with with two files licencse.htm and ThirdPartyNotices.txt. It also contains files and directories
    added in November last year (ImportProjects, Preemptive Solutions...(don't remember what or if I was installing)) and some added in February this year when I installed VS Ultimate 2013 trial. So the VS 2012 directory contains a mix of items placed there by
    VS 2013 installers.
    Questions:
    1. Could this mixed use be the cause of the Community version not being on the Start menu?
    2. what can I do to fix this without losing the VS Ultimate trial?
    3. Can Community version coexist with other VS versions?
     

    I was installing by running vs_community.exe.
    When I let the mouse hover over this file name information about the file pops up:
    File Description: Microsoft Visual Studio 2013 Community with Update4
    File version: 12.0.31101.0
    Size: 1.18MB
    I don't know, but I would guess this file installs the Community version.
    I did not notice that the Community version will not run on the same computer as other VS 2013 versions. Is this in the documentation? And will the Community version be blocked by VS Express
    versions too?
    Now, as far as I understand to make the Community version work I will need to uninstall the VS Ultimate 2013 trial first. Will that remove the Ultimate files in the MS VS12.0 directory in Program Files (X86)? and will uninstalling Community remove its contribution?
    I mentioned there are other files too in MS VS12.0, like SDK, Silverlight, WDExpress and Web. I don't remember installing any other program that might have put them there. Do I have to empty or remove MS VS12.0 before installing the community version? Then,
    if there are some left-overs can I just delete MS VS12.0 manually?

  • Only send those records in report where expression is True

    Hi,
    I have created a formula with two formula variables on Dates. The expression in formula is Solved Date < Due Date.
    This results in report showing 1 and 0 (1 where expression is true and 0 where expression is false)
    But in BEx query designer is there any way to send only those records in report where expression is 1 (true)
    Thanks
    Ahmad

    Hi Ahmad,
    You can suppress zeros changing the query properties in rows/columns tab. If you select effect on rows, it doesn't show 0 values in the report. This will work if you have only that KF in your query, if there are any other KFs and you still don't want to show other rows then you can use conditions as seshu has mentioned.
    Regards
    Yasemin...

  • JTextFeild.setEditable funny behaviour

    Hey Guys I hope someone can help me as I'm completely stuck to whether this is a bug or whether I'm just missing something. Given the following code:
    private void setComponentState( int state )
    switch(state)
    case 1:
    btnSearch.setEnabled( true ); //JButton
    btnReplace.setEnabled( false ); //JButton
    txtBarcodeReplc.setEditable( false ); //JTextFeild
    break;
    case 2:
    btnSearch.setEnabled( false ); //JButton
    btnReplace.setEnabled( true ); //JButton
    txtBarcodeReplc.setEditable( true ); //JTextFeild
    break;
    The problem I'm having is that everything works fine until the 3rd or sometimes the 4th time I call this method with a state=2 param. At this point the txtBarcodeReplc control refuses to enable itself. It changes color as it should and when the properties of the control are queried, the control thinks it's enabled, it's just that you cannot type anything or select inside the control. Interestingly enough, if I remove the calls to the other 2 jbutton controls so that the only thing this method does is reset my JTextFeild control, then it works perfectly fine. I'm curerntly using 1.3.1_09.
    Hope someone has some idea's to how to solve this as I'm completely stumped

    Apologies - the problem I was getting at is that it is unsafe to make calls on Swing components from any thread other than the Swing thread. This is unlikely when you are new to Java.
    As for your problem - you can search the bug database. Does http://developer.java.sun.com/developer/bugParade/bugs/4680302.html look like your problem? If so then the latest version looks to be your only option, or try putting the text field in front (in tab order) of the buttons.

  • SetEditable

    I have a class project that the user is to only input 10 numbers. I thought it would be cool to after the 10 numbers where entered to change the Editable field to false. When I did that I get an errors after the 10th number entered. How can I stop the errors or am I should I do something different instead of the setEditable(false)?
    This is my code
    // Purpose - Use an array to hold numbers entered and display only ones that are not duplicates.
    // Java Graphics package
    import java.awt.*;
    import java.awt.event.*;
    // Java extension packages
    import javax.swing.*;
    public class Assignment7_13 extends JApplet implements ActionListener {
    int numarray [] = new int[19];      // holds arrary from input
    String display = "";
    boolean firsttime = true ;
    int cntarray = 0;
    // Labels for user interface
    JLabel numlabel;
    JTextField numfield;
    JTextArea output;
    // init method
    public void init()
    Container c = getContentPane();
    c.setLayout(new FlowLayout());
    numlabel = new JLabel("Enter integer from 10 - 100");
    c.add(numlabel);
    numfield = new JTextField(5);
    c.add(numfield);
    numfield.addActionListener(this);
    // Setup textarea for output
    output = new JTextArea(2,20);
    c.add(output);
    } // end int method
    // process input
    public void actionPerformed(ActionEvent e)
         int numinput = 0;
         int found = 0;
         if (cntarray <=10){
              numinput = Integer.parseInt(numfield.getText());
              if (numinput > 9 && numinput <101){
                   found = linearSearch(numinput);
                   if (found == -1 ){
                        numarray[cntarray] = numinput;
                        cntarray++;
                        display += Integer.toString(numinput) + " " ;
                        output.setText(display);
                   } // end of if
              }// end if
         } // end if
         numfield.setText("");
         if (cntarray >= 10)
         numfield.setEditable(false);
    } // end actionPerformed method
    // Search array for specified key value
    public int linearSearch( int key )
    // loop through array elements
    for ( int counter = 0; counter < numarray.length; counter++ )
    // if array element equals key value, return location
    if ( numarray[ counter ] == key )
    return counter;
    return -1; // key not found
    } // end class Assignment7_13

    Hi,
    You have an error in checking the boundary.
    The line:
    if (cntarray<=10) {should be
    if (cntarray<10) {Regards,
    S&oslash;ren

Maybe you are looking for

  • Abap hr PNPCE

    Hi, I am LDB PNPCE, when I use rp-provide macro it says not recognised. Can we use macros in PNPCE or no. Then what is the other way to get latest record instead of using loop. Thanks, Oscar.

  • Numbers 3.5 (Incorrectly?) Activates Sheet When Processing Script

    My earlier post was incorrectly marked as answered, so I have re-posted the original question along with a link to the first thread. Updated Table Name Changes Applescript Operation in Numbers 3.5 I've been using Applescript in Numbers for some time

  • Internal table's Memory space problem

    Internal table is running out of memory due to the no of records. I am trying to merge the records of two internal tables into third one. and this third internal table runs out of memory.

  • Two modifiable invoice output types to be generated

    Hi experts, One of my customer has requested us that he need modifiable output types. the first invoice will be like a normal one which he want to keep it for company internal purpose and posting to FI will be done on that basis. the second invoice i

  • Motion WILL NOT OPEN! AHHHHHH!

    Ok well this is the thing, I had the new OS on my G5 but FCP was giving me all kinds of probs. nothing would really work couldn't burn dvds, so on and so fort blah blah blah. Anyway Motion hasn't been working since I upgrade, so we decided sine we ha