Tim-Ting Chang

Greenhorn
+ Follow
since Jan 13, 2009
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 Tim-Ting Chang

the problem gone away after I restarted eclipse. must have been a gliche something.

sorry
14 years ago
When I use "Run As..." command on an ANT build.xml file in eclipse, the output says: [build file]:1 Premature end of file

The source of the build.xml is:



where <project ...> is line #1. Can somebody tell me what I did wrong?
14 years ago

aruna sameera wrote:why can't we put fixed set of Constant to Collection?
if we already know what are the Constant that we need what is the problem?
We can make generic type collection and put them?



Yes but you have to hard-code the relationship in multiple inheritant classes. Use enum to declare a set of constraint values are quicker. I think that's the idea.

we can compute c++ with c += 1 or even c = c + 1, but c++ stays because it's less typing. (no pun intended)
14 years ago

David Newton wrote:Hibernate could be used as the persistence layer to store historical stock data.

Spring could be used together with Hibernate to both eliminate boiler plate code and manage transactions. Spring could also be used to implement AOP logging, handle the web layer via Spring MVC, handle application security, and countless other ways.



Thanks. I'll pursue the idea.

Do you know of any free stock market data feed that I can use to read live stock market price from?
14 years ago

David Newton wrote:Hibernate could be used to track stock history. Spring can be used in *many* ways across a project, and is easy to integrate in a small piece at a time.



Can you elaborate on the use of Hibernate/Spring? How can they be employed in this particular stock tracker program?
14 years ago
BTW, Does anyone know Live, Free stock market price feed? I need something easier to start with. Just to check current stock price.
14 years ago
I need some suggestion to start a personal project.

I am a fresh grad with no work experience, and it's hard for me to convince to companies that I can code; this is why I am doing this. I have only done some light Swing projects at school. However, I think I have a strong grasp of Java core lib (IO, Collections, Objects, Multithread) and Servlet/JSP on Tomcat. I know some SQL and can write simple join queries. I like to build a project that utilize all these things that I am strong at.

I want to start a scalable project that may be later modified by Spring and Hibernate. I like doing web services stuff so I hope data input can be a web data feed eventually. I was thinking of implementing a stock market price checker web app. Is this a good start?

Any idea in how I can incoporate Spring and Hibernate into such simple web app?

I am basically learning as I go, so I can't do fancy things yet. Just need something that covers OOP and Java SE API for beginner, but scalable and can be extended with complex functions easily.
14 years ago
I cleared the SCJP exam today but I have seen two to three questions that address that concept. I realized I don't know whether the program exits or continue execution after the finally block. I guessed that the program will exit gracefully.

The other confusing topic was about the index used in the String.substring(), replace(), delete() methods. I thought it was absolutely ridiculous for JavaSE team to define the method with a zero-based starting indicee and a 1-based ending indicee (if this is true, please do correct me if wrong). During the exam, I was doing this index counting question and I realize I don't know how to count index of a simple "123456789" string anymore!

I feel like an idiot doing this index counting. Why cann't Sun make everything 0-based? Anyway, this is simply dumb. I am sorry if I offend anyone but I have to say this again, because it is really, really dumb to make people work two different index-base in a single method and expect them to not be confused.

Clear the exam but still mad because I thought I would have done better.





What happens when we assign a new subclass instance to a superclass variable identifier?

Specifically, what happens if I call subclass-only fields and methods from a superclass variable identifier?

e.g.

What's the output of Test?

I want to know the rationale behind the output, that's why I asked here rather than compiling it.
14 years ago


Try-catch not necessary here. Read about Assertion and Try-catch. I think you are confused about their purposes.
14 years ago
I have modified my code to make it extends DefaultCellEditor. and I have extended the isCellEditable() both here, and in my TableModel.
The example code uses extends only, no implements. So I extends my InputEditor to see if it will work, given that implements doesn't work.

The code that you gave me extends DefaultCellEditor. I have seen it working. and I did everything that I can to make my code look like the example code. but my InputEditor class doesn't work, because getCellEditorComponent() doesn't get called.

I've declared a isCellEditable() and make it return true always. so what's there left to do?

There is gotta more to it.

14 years ago
I believe I've isolated the sympton, but I do not have the solution.

If I insert a println statement to my getCellRendererComponent(), I can see that the function gets called 9 times, which corresponds to the number of JButtonand JSpinner I added. But when the println statement is inserted to getCellEditorComponent(), there is no output; that implies, for some reason, the getCellRendererComponent() doesn't get called.

I studied the code you pointed at and I tried everything to make my code look like the examples', the example code does exactly what I want, but when i modify my own to follow the example code, nothing happens.

is this anything to do with isCellEditable() function?

if it is, then shouldn't it be handled by DefaultCellEditor class which I am extending from?

I don't know what to do, I've been stuck on this for days now.

Thanks for your help, I'll keep trying but if you have any insight, please let me know.
14 years ago

Sorry, I missed those JButton returns.



So where do you think the problem is? If I return a new JButton() and new JSpinner() instance, why aren't they clickable? In general, what do I need to ensure that a JButton or a JSpinner component is clickable on a JTable?

The getCellEditorValue method is the one that does the actual triggering. The problem with adding an ActionListener to the JButton is that the first click calls getCellEditorComponent, and does not fire an action performed event. I once solved that by using a mouse listener on the JTable, but my new class is more elegant - all button functionality in one single class.



so what you are saying is that even if I add an ActionListener to the JButton or the JSpinner, the actionPerformed method will not get executed? or that the actionPerformed is invoked by a 2nd click, preceeded by invokation of getCellEditorComponent()?

If you known of any good tutorial on JTable, please let me know.
14 years ago

As for your problem, you editor is returning a label. That doesn't feel right, does it?



I thought I return a new JButton() when the BUY SELL or QUANTITY column is selected. I use the if statement to ensure that.



I think I understand the rest of the code, but I don't understand why we need:



Since the only way to handle a event I've learned so far is through an ActionListener object, which gets added to the button of interest. When are these two functions called? I be appriciated if you can explain, because I have been buffled by the meanings of these functions for days.

Thanks for any help
14 years ago
I am having problem with adding an interactive JButton to a JTable. I am able to render the look of JButton using CellRenderer, but it is not interactive. I try to use CellEditor but currently JButton is still not clickable.

I'll paste the main function, my implementation of the CellEditor class, and my tableModel source codes. Rendered output is attached as .jpg. If the code seems too long, take a look at .jpg and it may be a bit more clear.





14 years ago