Michael Dunn

Ranch Hand
+ Follow
since Jun 09, 2003
Cows and Likes
Cows
Total received
-1
In last 30 days
0
Total given
0
Likes
Total received
281
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Michael Dunn

> Michael Dunn,
> your approach works only in the FIRST time.Once you pressed jbutton, after i change the cell value(putting others to 40), the color change to blue without pressing JButton.

rubbish.

it's a JToggleButton, not a JButton and it's your code:
private class ColorButton extends JToggleButton

if you don't know the difference, read the docs to find out why a JToggleButton remains 'pressed'
4 years ago
apologies for butting in here, but this might be one way of doing what you want (from your description)

run it, change (0,1) to 40 [enter], click the toggleButton for selection --> row should change to blue foreground,
then click again to unselect it --> row reverts to normal color.

(I've stripped everything unrelated to the specific problem)
4 years ago
a) in your class declarations you have this
JTextField tf1 = new JTextField(2);

b) in public void GUI_1() you have this
JTextField tf1=new JTextField();
...
pane.add(tf1);

the tf1 in (b) is the one you see on the screen
the tf1 in (a) is the one accessed by the listener (it is not on the screen, so nothing is entered into it)

either remove JTextField tf1=new JTextField() from (b), or change it to
tf1=new JTextField();

see how you go with that change
4 years ago
this is the end of what prints out when attempting to compile your mess:

98 errors
Press any key to continue...


so, how could you possibly get a NPE from the posted code?
4 years ago
I don't use Netbeans or JTattoo, but just a thought - have you tried setting the row height to (say) 35?
if it's still ignored, perhaps contacting JTattoo via their website might be worth a try.
4 years ago
go back to my demo code and run it again, replacing *all* occurrences of "Test.gif" with
"images\\c.jpg"
not
"images/c.jpg"

remember it's *all* occurrences
4 years ago
> Why not my code is smart or where i done mistake?

I've explained (in some detail) on numerous occasions that all you need to do
is to create a 'safe' rectangle (very similar to your friend's code) and then check
the position in mouseReleased *not* in mouseDragged i.e. when the dragging has
stopped.

Do you actually know how often mouseDragged fires during a drag?
Put in a System.out.println(..) and you'll find it's a significant number,
so mouseDragged will be continually going through those if/else's - all
for nothing.

To put it bluntly, you've butchered the dragger class.
4 years ago
another way is to use a Jpanel to paint the image as its background, then add components as normal

here's a very simple demo
(the BackgroundPanel class is from this forum's FAQ (main page))

4 years ago
> Check my profile for my e-mail to send the program together with the codes.

time to take your feet off the desk
4 years ago
the textfield/label stuff has been discussed-to-death in most of your topics

http://www.coderanch.com/t/605700/java/java/user-input-JTextField-class-label

despite the advice (20 or 30 times?) to cretae a simplified version that fails,
all you seem you want to do is to get someone to fix your code.

there's a web-site for that: rent-a-coder, where you pay someone to do it.
4 years ago
> Java told me that line 636, 123, and 120 were having NPE, so what should I do?

the code at the link only has about 30 lines, the last line having about 10,000 characters.

this smells trollish to me - just someone trying to have a bit of fun.

recommendation to mods - lock this, and any of his other topics if they start with go to my blog.
4 years ago
Swing is 'event' driven - all events are fired.

your program registers listeners for specific events it wants to be notified when happened (mouse/key/action/whatever).

here's a simple program to play around with.
click anywhere on the panel (there's no mouseListener 'added' to the panel).
4 years ago
you need to set the frame visible
you'll also need a window listener to close the frame/program
and you also need to do a lot more add(..)ing

4 years ago