Results 1 to 3 of 3
  1. #1
    bigj is offline Member
    Join Date
    Dec 2009
    Posts
    68
    Rep Power
    0

    Default java.lang.IncompatibleClassChangeError

    Java Code:
    public class PasswordField extends JFrame {
    
        private JPanel passwordPanel;
    
        private JPasswordField passwordField;
    
        private JLabel passwordLabel;
    
        private JButton userConfirmationBtn;
        private JButton submenu;
        
        private Image icon;
        
        private ImageIcon frameBackground;
        private ImageIcon buttonBackground;
    
        private String passwordAuthentication;
        
        public PasswordField() {
    
            initComponents();
        }
    
        private void initComponents() {
    
            icon = new ImageIcon("c:/pics/mercuryLogo.jpg").getImage().getScaledInstance(300, 300, 0);
            frameBackground = new ImageIcon("c:/pics/passwordbck2.jpg");
            buttonBackground = new ImageIcon("c:/pics/buttonbck");
            passwordField = new JPasswordField();
            passwordLabel = new JLabel("Password: ");
            userConfirmationBtn = new JButton("Enter");
            submenu = new JButton("Submenu");
            
            // set the properties of this label
            passwordLabel.setBounds(12, 13, 80, 20);
            passwordLabel.setFont(new Font("Monospaced", Font.BOLD, 12));
            passwordLabel.setForeground(Color.BLACK);
    
            
            // set the properties and actions of this text field
            passwordField.setBounds(88, 13, 185, 20);
    
            // set the properties and actions of this button
            Action pass = new AbstractAction() {
    
                public void actionPerformed(ActionEvent e) {
    
                    Password p = new Password();
    
                    p.addNewPassword("asd");
                    // retrive the password data from the password field
                    char[] passwordChars = passwordField.getPassword();
    
                    String passwordStr = "";
    
                    // convert the returned password characters as string
                    for (int x = 0; x <= passwordChars.length - 1; x++) {
    
                        passwordStr = passwordStr + passwordChars[x];
                    }
                    // check if the password entered is valid
                    
                    if (p.isPasswordAuthentic(passwordStr)) {
    
                        new InventoryDatabase();
                        disableWindow();
                    }
                    else if (passwordStr.equals("")) {
    
                        PopUpDialog.popTheErrorMessage(" Unauthorized Entry", "Please Fill The Specified Field.");
                    }
                    else {
    
                        PopUpDialog.popTheErrorMessage(" Unauthorized Entry !", "Access Denied.");
                    }
                }
            };
            userConfirmationBtn.addActionListener(pass);
            userConfirmationBtn.setMnemonic(KeyEvent.VK_E);
            userConfirmationBtn.setBounds(88, 55, 90, 20);
            userConfirmationBtn.setFont(new Font("Monospaced", Font.BOLD, 11));
            userConfirmationBtn.setBackground(Color.LIGHT_GRAY);
            userConfirmationBtn.registerKeyboardAction(userConfirmationBtn.getActionForKeyStroke(
                                                       KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, false)),
                                                       KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false),
                                                       JComponent.WHEN_IN_FOCUSED_WINDOW);
            userConfirmationBtn.registerKeyboardAction(userConfirmationBtn.getActionForKeyStroke(
                                                       KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true)),
                                                       KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true),
                                                       JComponent.WHEN_IN_FOCUSED_WINDOW);
    
            // set the properties and actions of this button
            Action openSubmenu = new AbstractAction() {
    
                public void actionPerformed(ActionEvent e) {
    
                    Submenu.openSubmenu();
                }
            };
            submenu.addActionListener(openSubmenu);
            submenu.setMnemonic(KeyEvent.VK_S);
            submenu.setBounds(184, 55, 90, 20);
            submenu.setFont(new Font("Monospaced", Font.BOLD, 11));
            submenu.setBackground(Color.LIGHT_GRAY);
            
            
            passwordPanel = new JPanel() {
    
                @Override
                protected void paintComponent(Graphics g) {
    
                    // Scale image to size of component
                    Dimension d = getSize();
    
                    g.drawImage(frameBackground.getImage(), 0, 0, d.width, d.height, null);
    
                    super.paintComponent(g);
                }
            };
            passwordPanel.setOpaque(false);
    
            // set this panel's layout to null for absolute positioning of
            // components
            passwordPanel.setLayout(null);
            
            // add the components to this panel
            passwordPanel.add(passwordLabel);
            passwordPanel.add(passwordField);
            passwordPanel.add(userConfirmationBtn);
            passwordPanel.add(submenu);
    
            // add the panel to the container
            getContentPane().add(passwordPanel);
            
            setTitle(" User Confirmation");
            setIconImage(icon);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setSize(288, 120);
            setResizable(false);
            setLocationRelativeTo(null);
            setVisible(true);
        }
    
        /**
         * Invoke this method if this window doesnt have any more use for the current
         * event.
         */
        private void disableWindow() {
    
            setVisible(false);
        }
        
        public static void main(String[] args) {
    
            SwingUtilities.invokeLater(new Runnable() {
                
                public void run() {
    
                    new PasswordField();
                }
            });
        }
    }
    Password class
    Java Code:
    public class Password {
    
        private static String[] passwords;
    
        public Password() {
    
            passwords = new String[] {"123", "ABC"};
        }
    
        public boolean isPasswordAuthentic(String password) {
    
            boolean isAuthentic = false;
            
            for (int x = 0; x <= passwords.length - 1; x++) {
    
                if (password.equals(passwords[x])) {
    
                    isAuthentic = true;
                    break;
                }
            }
    
            return isAuthentic;
        }
    
        public void addNewPassword(String newPassword) {
    
            // UNSUPPORTED
            throw new UnsupportedOperationException();
        }
    
        public void deletePassword(String password) {
    
            // UNSUPPORTED
            throw new UnsupportedOperationException();
        }
    }

    why does it throw me this?
    Java Code:
    Exception in thread "AWT-EventQueue-0" java.lang.IncompatibleClassChangeError: Expected static method xxTestxx.Password.addNewPassword(Ljava/lang/String;)V
            at xxTestxx.PasswordField$1.actionPerformed(PasswordField.java:83)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
            at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
            at javax.swing.plaf.basic.BasicButtonListener$Actions.actionPerformed(BasicButtonListener.java:287)
            at javax.swing.JComponent$ActionStandin.actionPerformed(JComponent.java:3368)
            at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1636)
            at javax.swing.JComponent.processKeyBinding(JComponent.java:2851)
            at javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:267)
            at javax.swing.KeyboardManager.fireKeyboardAction(KeyboardManager.java:216)
            at javax.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:2928)
            at javax.swing.JComponent.processKeyBindings(JComponent.java:2920)
            at javax.swing.JComponent.processKeyEvent(JComponent.java:2814)
            at java.awt.Component.processEvent(Component.java:6040)
            at java.awt.Container.processEvent(Container.java:2041)
            at java.awt.Component.dispatchEventImpl(Component.java:4630)
            at java.awt.Container.dispatchEventImpl(Container.java:2099)
            at java.awt.Component.dispatchEvent(Component.java:4460)
            at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1848)
            at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:704)
            at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:969)
            at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:841)
            at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:668)
            at java.awt.Component.dispatchEventImpl(Component.java:4502)
            at java.awt.Container.dispatchEventImpl(Container.java:2099)
            at java.awt.Window.dispatchEventImpl(Window.java:2475)
            at java.awt.Component.dispatchEvent(Component.java:4460)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    when i change these two method's static declaration with every compile
    Java Code:
        public void addNewPassword(String newPassword) {
    
            // UNSUPPORTED
            throw new UnsupportedOperationException();
        }
    
        public void deletePassword(String password) {
    
            // UNSUPPORTED
            throw new UnsupportedOperationException();
        }
    i got those errors, but when i wait a few seconds and compile it again it produces my expected output
    Java Code:
    UnsupportedOperationException();

    i cant figure how does this affect the changes that i made in my program..
    Java Code:
        public static void main(String[] args) {
    
            SwingUtilities.invokeLater(new Runnable() {
                
                public void run() {
    
                    new PasswordField();
                }
            });
        }
    should i always include this inner class when im updating or using any GUIs?
    or should i always include this in all of my GUI classes?, because i have many classes that extends JFrame and JDialog with lots of components..
    Last edited by bigj; 01-29-2010 at 04:04 AM.

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    Java Code:
        public void addNewPassword(String newPassword) {
            boolean unsupported = false;
            // You might be doing so checking in here
            // to determine whether or not this operation
            // is supported. If it isn't then you would
            // be interested in throwing an exception.
            // This next comment is suggesting this.
            // UNSUPPORTED
            if(unsupported)
                throw new UnsupportedOperationException();
        }
    Otherwise, as soon as this method is called it throws an exception.

  3. #3
    sathishsengg is offline Member
    Join Date
    Jan 2010
    Posts
    10
    Rep Power
    0

    Default

    I executed the code and i got ur expected Error. But i didnt get "java.lang.IncompatibleClassChangeError" . when this Error occured , whether fired "Enter Button" or "SubMenu" Button

Similar Threads

  1. Replies: 5
    Last Post: 03-17-2011, 02:26 PM
  2. Replies: 4
    Last Post: 11-03-2009, 04:01 PM
  3. Replies: 3
    Last Post: 09-07-2009, 01:28 PM
  4. Replies: 4
    Last Post: 06-24-2009, 06:34 AM
  5. Replies: 2
    Last Post: 09-18-2008, 07:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •