Results 1 to 2 of 2
- 01-19-2013, 04:36 PM #1
Member
- Join Date
- Jan 2013
- Posts
- 1
- Rep Power
- 0
Display error message for JSlider
Hi, I have create a Java app using BlueJ, in which you can change the size of a selected shape using a JSlider. One of the shapes to choose from is just a 'point', the size of a pixel, whose size i do not want to be changed.
I am trying to get an error message to display when the 'point' shape is selected and the user tries to change the size using the JSlider. The code I have got is shown below. The problem I have is that the error message is displayed loads of times in the terminal window if you drag the slider a large amount, it is displayed for each time the slider changes by 1, if that makes sense. Is there any way I can get the error message to display just once no matter how far the slider has moved?
"
//When the slider is moved the following method will be called
public void stateChanged(ChangeEvent e) {
//Rewrite the label reflecting the new value of the slider
label.setText("Size: " + adjustsize.getValue() + " pixels");
//Change size of shape when slider is moved
adjustsize = (JSlider)e.getSource();
newSize = adjustsize.getValue();
aShape.reSize(newSize);
//If Point shape is selected display error message
if (aShape == firstPoint) {
System.out.println("You can't resize a point");
//Repaint the window to reflect the updates made
repaint();
}
"
Thanks!
- 01-19-2013, 06:04 PM #2
Re: Display error message for JSlider
Thread moved from New to Java. Also, please go through Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming and edit your post accordingly.
I would hate to be a user of such an application. The common programming idiom is to disable a GUI control that it isn't right to use.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
JTabbedPane to display a message
By lanmonster in forum AWT / SwingReplies: 2Last Post: 12-21-2012, 05:37 PM -
JOptionPane - Message dialog box does not display
By aibao in forum NetBeansReplies: 4Last Post: 05-15-2011, 04:47 AM -
Error message does not display
By kaga01 in forum JavaServer Faces (JSF)Replies: 1Last Post: 12-31-2010, 11:52 AM -
how to display only the error message and exit
By renu in forum New To JavaReplies: 6Last Post: 10-08-2010, 07:50 PM -
Display Message Without Throwing Exception
By kailashchandra in forum JavaServer Faces (JSF)Replies: 0Last Post: 09-27-2008, 09:05 AM


LinkBack URL
About LinkBacks


Bookmarks