Accelerators, JTextField, and focus

I created a JMenuItem for Save. I also created an accelerator for the Save menu item.
JMenuItem saveItem;
JMenu fileMenu = new JMenu ("File");
fileMenu.add (saveItem = new JMenuItem ("Save"));
saveItem.setMnemonic ('S');
KeyStroke cntrlS = KeyStroke.getKeyStroke(KeyEvent.VK_S,
Event.CTRL_MASK);
saveItem.setAccelerator (cntrlS);
saveItem.addActionListener (new ActionListener() {
public void actionPerformed (ActionEvent e) {
doSaveNote();
When the user is finished entering data into the JTextField(s), the user then either presses ctrl-S or clicks on the Save button on the menu. My code (not shown) validates data in JTextFields when the Save accelerator or button is pressed (blank field is considered invalid as well as wrong flight number). If data is invalid, then the first field with invalid data gets focus.
If the JTextField has focus and invalid data is there, then when the user clicks the Save button the JTextField still has focus with a message letting the user know the data is invalid. However, if the user puts invalid data in the JTextField and uses the accelerator ctrl-S without tabbing out of the field first, the invalid JTextField does not get focus and no error message is presented. When using the accelerator the invalid JTextField only gets focus and prints an error message if the user tabs out of the JTextField befor pressing ctrl-S.
I don't want to tab out of the field. Why is the behavior different between the accelerator and clicking the Save button? Any help is appreciated.

You can request focus for another component.
Or you could do: myTextField.setFocusable(false). But in this case you would have to make it fosucable later on if you want to use it.

Similar Messages

  • JTextField and Focus

    Hi everybody!
    please tell me how can I set focus to the JTextField with some event handling, for example, if I want to set the focus on myTextField after some button clicking event
    Thanks in advance

    Set the caret Position to the initial column position of the JTextfield.
    JTextField jtextfield=new JTextField();
    public void actionPerformed(ActionEvent e){
    jtextfield.setCaretPosition(int position);
    }

  • JTextField and JTextArea don't get focus occuasionally

    I am developing a Java Swing Applet. At edit mode, JComboBox, JCheckBox, JRadioBox, and JButton work fine, but JTextField and JTextArea can't get focus occuasionally while I click them.
    Anyone has idea?
    Thanks

    Thank you Himanshu,
    but that's not exactly what my issue is. This link describes the undesired effect of ending up outisde of the player window and in the browser.
    My problem is kind of the opposite. When I launch the page in the html file I cannot use the tab key to get to any of the controls in the captivate window. I'm stuck in the browser unless I click on the captivate window. That is not acceptable if we want it accessible without using a mouse. I found a way to make it work for chrome like I stated above, but not in FF. Do you have any ideas for this?
    Thanks!
    Monique

  • Problem while adding both Key And Focus Listeners to JTextField

    Hi!
    I have something peculiar while adding Key and Focus Listener to JTextField. Suppose i add just Key Listener then everything's fine and i could keep track of keys being pressed. But as soon as i add a Focus Listener to it with the code to select full text in focusGained() method, it starts reponding wrongly to arrow keys pressed and does not perform desired actions. For let arrow key it moves caret by one for the first time after that it does not resond to that unless caret is changed by using mouse. If right arrow key is pressed the it moves the caret to last position from wherever it is. For UP and DOWN it selects the full text(This should be done when it gets focus)
    public void focusGained(FocusEvent fe)
    setCaretPosition(0);
    moveCaretPosition(getDocument().getLength());
    Can someone help me out on this?
    thanks and regards,
    Amit.

    None of those things will cause your JFrame to resize itself. And this is probably a good thing, because your JFrame shouldn't change size once you have created it. Why not create your JPanel so that it has enough space for you to add the component later? Or why not just add the component to start with and then enable it or make it editable when you decide that's necessary?

  • JTextfield:  Changing focus, then doing stuff

    So I have 3 JTextFields that are essentially "connected" (I automate tabbing and such back and forth). I have no problem gaining focus, whether it be transferFocusBackward(), or whatever else. My problem is when getting the focus I cannot do anything with it like taking the letter the user typed and insert it into the next field.
    My code that I used is in KeyTyped and I do a
    JTextField fake = new JTextField();
    fake.transferFocus();
    JTextField newFocus = ((JTextField)KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    newFocus.setText(String.valueOf(event.getKeyChar))
    When I check to see who the focus is on before and after I call transferFocus(), it doesn't change JTextFields (I know because I name them differently and ask their names). Does someone know a better way...that actually changes focus, when it is called, or have any workarounds?

    Nevermind I figured a workaround for it. I set the setFocusCycleRoot to true in the constructor, and then said
    JTextField fake = new JTextField();
    JTextField newFocus = ((JTextField)this.getFocusTraversalPolicy().getComponentBefore(this, fake));
    //I stuck what the user typed at the beginning of the text field...not really sure which is the better way
    newFocus.setText(event.getKeyChar()+newFocus.getText());
    fake.transferFocus();
    The reason it wasn't working is because swing hadn't actually acknowledged that the focus had changed yet...apparently this happens later.
    The reason I had asked was that there was an edge case on the three JTextField, lets say the user types something into the first text field and moves to the next field, then randomly goes back, well, when they press a letter, then they would just jump to the next JTextField, and the letter wouldn't appear...i think that would be more confusing than having the letter appear in the next text field, but meh, we'll see.

  • Reading values from JTextField and using them?

    Hello,
    I am trying to make a login screen to connect to an oracle database. Im pretty new to creaing GUI. I need help with reading the values from the JTextField and to be able to use them for my connection. So do I need to apply a listener? How do I go about doing that in this project. Thanks for any code or advice.
    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.sql.*;
    public class UserDialog
        String databaseURL;
        String driver;
        String database;
        String username;
        String password;
        String hostname;
        String port;
        UserDialog() {
            getInfo();
        static String[] ConnectOptionNames = { "Login", "Cancel" };
        static String   ConnectTitle = "Login screen";
        public void getInfo() {
            JPanel      connectionPanel;
            JLabel     databaseURLLabel = new JLabel("Database URL:   ", JLabel.LEFT);
         JTextField databaseURLField = new JTextField("");
         JLabel     driverLabel = new JLabel("Driver:   ", JLabel.LEFT);
         JTextField driverField = new JTextField("");
            JLabel     databaseLabel = new JLabel("Database:   ", JLabel.LEFT);
         JTextField databaseField = new JTextField("");
            JLabel     usernameLabel = new JLabel("User Name:   ", JLabel.LEFT);
         JTextField usernameField = new JTextField("");
            JLabel     passwordLabel = new JLabel("Password:   ", JLabel.LEFT);
         JTextField passwordField = new JPasswordField("");
            JLabel     hostnameLabel = new JLabel("Host Name:   ", JLabel.LEFT);
         JTextField hostnameField = new JTextField("");
            JLabel     portLabel = new JLabel("Port:   ", JLabel.LEFT);
         JTextField portField = new JTextField("");
         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(databaseURLLabel);
         namePanel.add(driverLabel);
            namePanel.add(databaseLabel);
            namePanel.add(usernameLabel);
            namePanel.add(passwordLabel);
            namePanel.add(hostnameLabel);
            namePanel.add(portLabel);
         JPanel fieldPanel = new JPanel(false);
         fieldPanel.setLayout(new GridLayout(0, 1));
         fieldPanel.add(databaseURLField);
            fieldPanel.add(driverField);
            fieldPanel.add(databaseField);
            fieldPanel.add(usernameField);
         fieldPanel.add(passwordField);
            fieldPanel.add(hostnameField);
            fieldPanel.add(portField);
         connectionPanel.add(namePanel);
         connectionPanel.add(fieldPanel);
            // Connect or quit
            databaseURL = databaseURLField.getText();
            driver = driverField.getText();
            database = databaseField.getText();
            username = usernameField.getText();
            password = passwordField.getText();
            hostname = hostnameField.getText();
            port = portField.getText();
            int n = JOptionPane.showOptionDialog(null, connectionPanel,
                                            ConnectTitle,
                                            JOptionPane.OK_CANCEL_OPTION,
                                            JOptionPane.PLAIN_MESSAGE,
                                            null, ConnectOptionNames,
                                            ConnectOptionNames[0]);
            if (n == 0) {
                System.out.println("Attempting login: " + username);
                String url = databaseURL+hostname+":"+port+":"+database;
             // load the JDBC driver for Oracle
             try{
                   DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                   Connection con =  DriverManager.getConnection (url, username, password);
                System.out.println("Congratulations! You are connected successfully.");
                con.close();
                System.out.println("Connection is closed successfully.");
             catch(SQLException e){
                System.out.println("Error: "+e);
            else if (n == 1)
                    System.exit(0);
        public static void main (String args []) {
             UserDialog ud = new UserDialog();
    }thanks again,
    James

    the reason why you can't get the text is because you are reading the value before some actually inserts anything in any fields.
    Here is what you need to do:
    Create a JDialog/JFrame. Create a JPanel and set that panel as contentPane (dialog.setContentPane(panel)). Insert all the components, ie JLabels and JTextFields. Add two buttons, Login and Cancel to the panel as well. Now get the username and password field values using getText() inside the ActionListener of the Login.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class LoginDialog extends JDialog
    String username, password;
      public LoginDialog( ){
        setTitle( "Login" );
        JPanel content = new JPanel(new GridLayout(0, 2) ); // as many rows, but only 2 columns.
        content.add( new JLabel( "User Name" ) );
        final JTextField nameField = new JTextField( "" );
        content.add( nameField );
        content.add( new JLabel( "Password" ) );
        final JTextField passField = new JTextField( "" );
        content.add( passField );
        JButton login = new JButton( "Login" );
        login.addActionListener( new ActionListener(){
          public void actionPerformed( ActionEvent ae ){
            username = nameField.getText();
            password = passField.getText();
            // call a method or write the code to verify the username and login here...
        content.add( login );
        JButton cancel = new JButton( "Cancel" );
        cancel.addActionListener( new ActionListener( ){
          public void actionPerformed( ActionEvent ae ){
            dispose(); // close the window or write any code that you want here.
        content.add( cancel );
        pack( ); // pack everything in the dialog for display.
        show(); // show the dialog.

  • JTextfield and JButton

    Hi all
    My problem is that i have a JTextfield that is connected to a Oracle database that allow the user to enter data in the database. I want to have a button that will allow the user to test to see whether the data entered in the textfield is valid.
    I'm not sure if i need to use sqlj or not. Any help would be gladly received.
    Thanks
    null

    Hmmm... lots and lots of ways to handle this, depending on your particular need for the particular type of 'validation'. ( More info? )
    "JTextField" is not connected to a database in the same way that the infoswing "TextFieldControl" is.. .therefore one could trap the event ActionPerformed off the JTextField and do the checks ( or use the jbutton like you suggest..but it would seem like you'd always want it checked and corrected before continuing towards the inevitable commit attempt??? ).
    You can use sqlj, or you can not use it... depends upon the way you've architected your application/environment and your needs and desires.
    Note (if you haven't already ) that you can also do a heck of a lot of validation at the entity/view object level.
    In my case ( an application ) I have a jdbc connection up at the front end for all my miscellaneous stuff, and a validate PL/SQL stored function. The nice things about using stored procedures/functions are that the validate routines can be nested for quick and easy use by triggers and stored procedures. If you put it outside the database it gets more fun should you want to get at the common validation routines from all approaches.
    Curious as to how other folk are architecting their validations....

  • JTextField and JButtons not appearing until clicked.

    I'm writing a program to refresh my CS1 java skills. For some reason when I try to add a JTextField and two JButtons to my container they don't appear until Ive clicked them.
    Actually more specifically, this only happens after a 100ms wait after setting the frame visible. Any less and the components wind up visible, but scrunched up in the top middle of my frame.
    Ive found that if I add the components before and after the wait they are visible and in the correct place, but this makes a noticeable flicker.
    I'm running windows vista if that matters.
    If someone could help me I would appreciate it.
    snippet of code:
    public scrollText()
         drawingThread.start();
         mainFrame.setSize(640,160);
         mainFrame.setContentPane(draw);
         mainPane = mainFrame.getContentPane();
         mainPane.setBackground(Color.white);
         mainFrame.setResizable(false);
         mainFrame.setVisible(true);
         try
              Thread.sleep(100);
              addInterface();
         catch(InterruptedException e){}
    public void addInterface()
         textInput.setBounds(1,103,501,31);
         play.setBounds(502,103,65,30);
         play.addActionListener(this);
         stop.setBounds(568,103,65,30);
         stop.addActionListener(this);
         mainPane.add(textInput);
         mainPane.add(play);
         mainPane.add(stop);
    }

    Postings can't be moved between forums. Now you know for the next time.
    The general form for building a GUI is
    frame.getContentPane().add( yourComponentsHere );
    frame.pack();
    frame.setVisible( true );Then all the compnoent will show up according to the rules of the layout managers used.
    However is you add components to the GUI "after" the GUI is visible then the components are not automatically painted. You need to tell the GUI to invoke the layout manager again so your code would be:
    frame.getContentPane().add( componentsToVisibleGUI );
    frame.getContentPane().validate();

  • JtextField and list of data

    Hi everyone (and sorry for my english language....).
    I've this problem:
    I've a Frame with a JtextField and a button. When I click on this button, I want to show a list of data from a database and then I must choose a value that must go to the JtextField.
    Have you an idea how I can implement this? Sorry for this generic question, but I don't know how to do..
    Thank you!

    >
    As to your question.
    I've a Frame with a JtextField and a button. When I click on this button, I want to show a list of data from a database and then I must choose a value that must go to the JtextField.
    Have you an idea how I can implement this? ..Sure, plenty of people. But they will want to know exactly what you are having trouble with. E.G.
    - Getting data from a DB.
    - Putting data into a JList.
    - Adding listeners to that JList so that choices are acted on, rather than simply high-lighted as the selection.
    - Using the event provided to the listener, to update the JTextField.
    - Adding a JTextField and JList to a JFrame using layout managers.
    If your answer is 'all of that', then I suspect they would be tempted to:
    a) Advise you to put this project aside until you have considerably more experience.
    b) Refer you to the [Java Tutorial|http://java.sun.com/docs/books/tutorial/].

  • JTextField and JPasswordField

    Hi!
    How do I limit the character number that can be inserted into a JtextField and JPasswordField.
    For examen is the Password can be mam 6 characters, how do I do from limit the input?
    Thanks

    The most common way to limit what is entered in a JTextField is to create your own document. See the following thread:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=414464
    Graeme

  • JTextField and TextListener

    I am using an JTextField and I want to be notified when the text there have been changed. But there is no TextListener accessible in JTextField. Do I have to modify a CaretListener ?
    many Thanks/ Sam

    I am using an JTextField and I want to be notified
    when the text there have been changed. But there is no
    TextListener accessible in JTextField. Do I have to
    modify a CaretListener ?DocumentListener.

  • JTextField and transparency

    I have a JTextField and I am trying to set it up so it is somewhat transparent.
    mTextField.setBackground(new Color(255,255,255,50));
    But what happens when i do that is this: the textfield as a text value gets the text that i have set up for one of the neighbouring components.
    I am not sure why this happens.
    Has anyone experienced this problem before? Is there a fix to it?
    I tried setting up the text using setText to an empty string but it happens agian. I dont have this problem when the transparency is Not set.
    Cheers
    Dan

    I am not sure why this happens. An opaque component is responsible for painting the entire area of the component, which basically means that the RepaintManager doesnt' have to worry about the garbage that may exist where the component is about to be repainted.
    Since you background is somewhat transparent, you can see the garbage left behind. (Don't ask me what its left behind from, thats in the details of the Swing repaint manager which I know nothing about).
    Michaels suggestion makes the component transparent which means Swing will paint the background of the components parent. However when you do this, the background of your component isn't painted.
    So heres a solution that paints the background of the parent and the child:
    JTextField textField = new JTextField("Some Text")
         protected void paintComponent(Graphics g)
              g.setColor( getBackground() );
              g.fillRect(0, 0, getSize().width, getSize().height);
              super.paintComponent( g );
    textField.setBackground(new Color(0, 255, 255, 50));
    textField.setOpaque( false );

  • JTextField [] and MouseEntered

    Hello
    I know this type of question has been asked in the forums before, but might is kind of different...i think.
    I have an array of JTextFields and i want each of there color to turn to GRAY when the mouse is on top of them.
    So if mouse is on top of TextField1 then only TextField1 turns GRAY.
    my Current mouseEntered() method is this
    public void mouseEntered(MouseEvent me)
                 for (int i=0; i < nasdaqTFs.length; i++){
                nasdaqTFs.setEditable(false);
              nasdaqTFs[i].setBackground(Color.GRAY);
    This, obviously, turns ALL the TextFields to GRAY when the cursor is in the Panel. So cursor can be anywhere and they all turn GRAY.
    So the question is...how do i find out when the Cursor is on the Specific TextField.

    Learning from earlier today This time i did write a Short Example of what i want done.
    Maybe this time i didnt do a bad job at it
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Listener extends JFrame implements MouseListener
         JTextField t;
         JTextField t1;
         public Listener ()
              super ("test");
              Container c = getContentPane();
              c.setLayout(new BorderLayout());
              t = new JTextField(4);
              c.add(t, BorderLayout.NORTH);
              t1 = new JTextField (4);
              c.add(t1, BorderLayout.SOUTH);
              addMouseListener(this);
              setVisible(true);
              setSize(300,300);
              MouseMotionListener don = new MouseMotionAdapter(){
              public void mouseEntered(MouseEvent me) {
                   System.out.println("Enterd)");
                 me.getComponent().setBackground(Color.GRAY);
              t.addMouseMotionListener(don);
              t1.addMouseMotionListener(don);
         public static void main (String args[])
              Listener l = new Listener ();
           public void mouseEntered(MouseEvent me)
             /*JTextField tf = (JTextField) me.getSource();
             tf.setBackground(Color.GREEN);*/
                me.getComponent().setBackground(Color.GREEN);
           public void mouseExited(MouseEvent me)
             /*JTextField tf = (JTextField) me.getSource();
             tf.setBackground(Color.white);*/
                me.getComponent().setBackground(Color.WHITE);
           public void mousePressed(MouseEvent me){}
           public void mouseReleased(MouseEvent me){}
           public void mouseClicked(MouseEvent me){}
    }This GUI wont change colors of TF's either. However when i move around the GUI i see somethin Green flickering!

  • [svn] 3079: Pop up and focus fixes.

    Revision: 3079
    Author: [email protected]
    Date: 2008-09-03 10:53:07 -0700 (Wed, 03 Sep 2008)
    Log Message:
    Pop up and focus fixes.
    QE: YES
    Doc:
    Checkintests: YES
    Reviewer: Alex
    Bugs: SDK-16669, SDK-15688
    mx/events/SWFBridgeEvent.as
    Add marshal() method. Update ASDoc.
    mx/managers/FocusManager.as
    Fix bug SDK-15688. Type coercion error fixed by moving to a common super class of IFocusManagerComponent and SWFLoader.
    mx/managers/PopUpManagerImpl.as
    Renaming.
    airframework/src/mx/managers/WindowedSystemManager.as
    mx/managers/SystemManager.as
    Fix problems introduced from API scrub and fix an old problem activating A.2.2.
    mx/managers/SystemManagerProxy.as
    Override addEventListener() and removeEventListener() to also add listeners on the proxied SystemManager. This
    allows the Proxy to get keyboard focus events that happen in the proxied SystemManager. Dispatch activate/deactivate messages to the sandbox root.
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-16669
    http://bugs.adobe.com/jira/browse/SDK-15688
    http://bugs.adobe.com/jira/browse/SDK-15688
    Modified Paths:
    flex/sdk/branches/3.0.x/frameworks/projects/airframework/src/mx/managers/WindowedSystemMa nager.as
    flex/sdk/branches/3.0.x/frameworks/projects/framework/src/mx/events/SWFBridgeEvent.as
    flex/sdk/branches/3.0.x/frameworks/projects/framework/src/mx/managers/FocusManager.as
    flex/sdk/branches/3.0.x/frameworks/projects/framework/src/mx/managers/PopUpManagerImpl.as
    flex/sdk/branches/3.0.x/frameworks/projects/framework/src/mx/managers/SystemManager.as
    flex/sdk/branches/3.0.x/frameworks/projects/framework/src/mx/managers/SystemManagerProxy. as

    I would suggest not to use JWindow but JPopupMenu! In
    the JPopupMenu you can add any swing-components!
    You can show the Popup in focusGained (ok, that is
    not so user-friendly, in my opinion a shortcut would
    do better!).
    The Popup will hide automatically if you click with
    the mouse somewhere else or hit escape.Thank you for the reply.
    I'm still having problems. I'd prefer not to use a jpopupmenu, because I want to use that for something else. This was just going to be a simple list that would appear near the text field so user could have a list of options to choose from.
    Focus gained on the textfield brings up the list. Selecting something on the list clears it (hides). This idea works well on the mac. But on the pc the jwindow keeps hiding behind the main frame ?
    I have the following code
    The windows is created as follows
         listWindow = new JWindow(SwingUtilities.getWindowAncestor(this));
    listWindow.getContentPane().add(pane);
    listWindow.setVisible(false);
    pane contains the jlist of values
    Then the textfield is as follows
    textField.addFocusListener(new java.awt.event.FocusAdapter() {
    public void focusGained(java.awt.event.FocusEvent evt) {
    if (showListWindow) {
    if (!listWindow.isVisible()) {
    Point los = getLocationOnScreen();
    listWindow.setVisible(true);
    listWindow.setLocation(los.x +580, los.y +75);
    listWindow.pack();
    listWindow.toFront();
              textField().requestFocus();
    I use a boolean showListWindow to decide when to show. Because I noticed that displaying the jlist and requesting focus to the textfield caused the focusGain to fire again.
    Any ideas why the pc keeps the list hidden ? If I move the main frame I can see !

  • AWT and focusing on different windows

    Hey guys.
    I have a problem, I'm trying to set the focus a window but can't.
    I have two windows A and B.
    I also have a Events being picked up set on window A.
    So the set of events are detailed as follows.
    Window A display's and responds to events.
    When a particular event occurs it loads up a new window (WindowB) and focus is given to that window.Wasn't a problem until we realised that there was a delay between Window A being displayed and Window B being displayed, enough to cause a problem.
    So the code was changed like follows.
    WindowB.pack();
    WindowB.setVisible(true);
    WindowA.setVisible(false);When it was changed to the above, we lost the ability to pick up keyboard events, as WindowA was still the window with focus.
    I've had a look at the KeyboardFocusManager where it seems that focus can be change between components.
    However is also states for method setGlobalFocusWindow() that it can only be set if it is in the same context.
    Which it is not.
    Is it possible to set focus to the window before the window has been set visible? Is KeyboardManager the right class to look at?
    Sorry about the lack of code(It's spread in many directions and is sensitive)
    Thanks for any help in advance

    hello,
    the following link may help: http://java.sun.com/j2se/1.4.2/docs/api/java/awt/doc-files/FocusSpec.html
    wrappingduke

Maybe you are looking for

  • My computer will not recognize my IPhone 4 after being updated

    I was updating my iphone and the screen changed to "plug into itunes" in the middle of it, but it was already plugged in. Now my computer will not recognize that my iphone is plugged in and it is stuck on the "plug into itunes" screen. what should I

  • How can I use the F11 short cut to go to next field in Microsoft Word 2011 on Macbook Air

    How can I use the F11 short cut to go to next field in Microsoft Word 2011 on Macbook Air?

  • Problem Management

    Is their an add on that will allow me to manage reported problems with SAP (Help Desk Function)? I would like to capture, track and resolve user reported problems. I am aware their is a service call function in SAP B1, has anyone effectively used tha

  • Action to "Save as JPG" always offers "foo copy copy.jpg" as file name

    When I use Photoshop CS4 "Save As", and then select jpg, it offers me to save my file, foo.psd as foo.jpg. No problem. I have prepared an action to "Save as JPG" but it always offers me to save as "foo copy copy.jpg". This is rather annoying as I'll

  • MR21 price change not possible

    Dear pal, I have a material code X with valuation type RM_IND In material master accounting view1- Price determination  is 3 with price control S.There is some stock of material with some value. I am trying to change the price in MR21. System prevent