I'm doing a calculator in java, to make easyly, and don't put a document filter to the jtextfield. I opted for making the jtextfield not editable and adding a key listener, but when you press de delete button it makes an error sound.
I've go to change system's sounds in configuration, I have changed the system's sounds, and I discover that the sound it's made by "predetermined bip", and makes the sound "Windows Background". I can change my option and don't listen the sound, but I want this game to do it downloadable in the internet.
Here is a simple example: If you press the delete key in the Text Field it' going to make sound:
public Example() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBounds(0, 0,250,200);
setLayout(null);
javax.swing.JTextField jTextField1 = new javax.swing.JTextField();
jTextField1.setEditable(false);
jTextField1.setBounds(30,50,180,60);
add(jTextField1);
}
public static void main(String args[]) {
Example a = new Example();
a.setVisible(true);
}
}
In that code the textfield was not editable, in the next code the Text Field it is not going to make sound:
public Example() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBounds(0, 0,250,200);
setLayout(null);
javax.swing.JTextField jTextField1 = new javax.swing.JTextField();
jTextField1.setEditable(true);
jTextField1.setBounds(30,50,180,60);
add(jTextField1);
}
public static void main(String args[]) {
Example a = new Example();
a.setVisible(true);
}
}
It's because the text field is editable.
I'will appreciate if you can help me, telling me how to fix it or how to change systems sound in code, or whatever you think can help me.