maggie woo

Ranch Hand
+ Follow
since Dec 18, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by maggie woo

Originally posted by Lasse Koskela:
PeterPrinciple


wow, that's interesting... this is probably a better reference by far. mine is more or less my interpretation of it as it was passed along to me...
[which i deleted, but i realize i removed the pertinent comment, which is that it was irrelevant to this thread and should have been in a signature]
apologies for detracting..
- maggie
[ April 27, 2004: Message edited by: maggie woo ]
20 years ago
exactly! it is very costly to refactor code generated by the IDE, even if you use the IDE to do the refactoring.
and then, there's the peter principle
20 years ago
My guess is you probably *CAN* by screwing around with it, but this is an interesting question since the JScrollPane accepts a row header (setRowHeader(JViewPort rowheader)), but JTable doesn't support one!
If no one has done it out there already, maybe the following track as a possiblity:
1) modify the column header for your "row header" column so that it is blank and unclickable--maybe a shade darker and "flat" instead of "beveled" which i think is the usual rendering.
2) add a cell renderer for the first column, something like a JButton or JToggleButton with a beveled border, make them uneditable.
3) if you want the user's click on the row header to do something (like "select the row"), then have a mouse listener or something--a JToggleButton might be a nice feature if you wanted to select the row (have it be "pressed" when the row is selected by a mouse click and "armed" when the row is selected in some other manner).
This is pretty advanced stuff I think. Try a google groups search to see if anyone's done it already out there...
And then, maybe post YOUR code up here! hurrah for that!
cheers,
- maggie
20 years ago
well, for the JLabel anyhow, maybe extend it to create a JLabel that has the attributes you want and make all your JLabels one of those objects. (e.g., MyBlueTahomaLabel, MyBlueTahomaCheckBox, etc).
or make a "label adder" helper method that (if called) will add the label in the desired font and color (e.g., addBlueTahomaLabel(String text, ...)). this works best if your layout is fairly straightforward and each label can be added given the passed in parameters. like you might pass in x/y coordinates or gridbagconstraints. along those lines, create "adder" methods for other types of components.
just to screw around. there's probably a more elegant way of getting what you want done...
if you needed to put html tags around all the labels for some reason, you could override whatever method it is that renders the text and always nest the text value inside the html tags so that the same code does the same work in the same place for all the same type of component.
or you could write a little engine that iterates over all the visible components in your container(s) and sets the font and color (if setters are available).
just some ideas to pick from. probably plenty of others too..
20 years ago
hmm... seems like there's both a constructor to accept it as well as a setter. but you've probably already tried those too...
yes, you seem to have a sticky problem. closest i've ever used is the progress bar. seems like you may have to build your own if you want very fine control.
what precision are you looking at? forgive my lack of vocabulary here, but just for instance, can you use the original values x 1000 for the ints, and convert to floats in a dirty fashion for the input?
slider from -1.0 to 1.0 in .001 increments; pass in values -1000 to 1000, but display -1.0 to 1.0.
*shrug* i guess i shouldn't spend much time on this. it has nothing to do with anything i need or really know.
good luck.
maggie
20 years ago
javax.swing.DefaultBoundedRangeModel?
but it uses integers...
20 years ago
*shrug*
i use netbeans and i don't hardcode my paths. it could be the way you've got it set up. it does have this weirdness about the way you mount file systems for your packages to compile and run correctly.
but that's neither here nor there. i'm not qualified to advise you on setting up netbeans to work for you.
cheers!
maggie
20 years ago
I almost replied to you over the weekend, but was getting burned out. Anyhow, my first feeling is that images, even if they are in the same directory as your class file, may not be in the search path for the application.
Try specifying the full path of the image, or at least running a test to see if it is an I/O problem, or try to list off the contents of the subdirectory.
20 years ago
Your TreePanel's constructor adds itself as a TreeSelectionListener. That's why updates occur on the same tree.
You probably need to make the two TreePanels first in your TreeTest class, then add the appropriate TreePanel as a TreeSelectionListener to the other.
20 years ago
Assuming you know how to get the data from the database, and get each individual data item (each row, each column)....
Use a JTable, and a custom TableModel. For starters, extend the AbstractTableModel. See the API--it'll tell you what methods you have to define for the JTable to function. If your queries generally return short sets of data, just iterate over the entire set to build the underlying data model, then put that model on the JTable, then put that JTable in a JScrollPane, etc. and see what happens.
You'll eventually probably want to override a few other things, but for now, you probably want to see your data in a table before you care about the little things...
20 years ago
yes, the first correction was in NameInput. here is where you called the .show() method on the wrong thing. instead of calling it on the Stored object you already instantiated (passing in the 'yourname' variable), you called it on a new Stored object that didn't have the 'yourname' variable when it was called.

the second was in the constructor in Stored which orignally accepted an 'arg1' variable, but inside the constructor, you specified a 'yourname' variable that the compiler was complaining about. i was just telling you to make them the same. whatever you pass in, that's what you set to the JTextField:

these are not corrections to what you've done already--don't know what you've done at this point. if you go back to the original code you posted and make these fixes, maybe some of it will work. if there's still stuff not working, sorry for wasting your time..
- maggie
[ April 23, 2004: Message edited by: maggie woo ]
20 years ago
well, I should have pointed out the problem instead of giving you the answer.
The problem is, you instantiated a Stored object (storedFrame), but you did not call that object's show() method, you called it on a new Stored object (one that never got a peek at the value in the "yourname" variable).
That was the problem. I am not a good teacher, or I would have pointed that out to you and let you figure out the solution yourself. As it was, my giving you the code didn't help at all. Eventually, it's possible that it will get you over one tiny little hurdle, but it hardly advances your knowledge of Java.
If you are a student, why are you using Sun One instead of Notepad or JEdit? Nevermind. I'm an oldie..
20 years ago
*sigh*
"public Stored(String yourname) ..."
[please don't remove the curly braces just because i didn't include it here]
If you have compiler errors, you must already have some strategy for figuring out the problem. If nothing else, return to the version that WAS compiling, and add changes one at a time.
[ April 24, 2004: Message edited by: maggie woo ]
20 years ago

Originally posted by mo robertson:
few errors when i tryed that code. unsure why it doing it.
NameInput.java [63:1] name has private access in java.awt.Component
Stored storedFrame = new Stored(name);
^
Stored.java [57:1] cannot resolve symbol
symbol : variable yourname
location: class Stored
jTextField1.setText(yourname);
^
2 errors
Errors compiling class NameInput.


Ok, I didn't examine your code that closely. There are some typos.
First:
Stored storedFrame = new Stored(yourname);
Second:
either:
jTextField1.setText(arg1);
or:
public Stored(yourname){
jTextField1.setText(yourname);
}
20 years ago