chihwah li

Greenhorn
+ Follow
since Apr 23, 2010
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
7
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by chihwah li

Aah thanks!

Let me make a guess why XML. By using a XML file, the program does not need to be re-compiled, changes are only made in the XML file.
The file is easier to change Right?

What would be a good place to read the Java API changes? Oracle has API pages, but it's not that you would look very time you need certain code. I prsonally only look if I forgot about
the syntax etc....


Hello all,

I have a question about 2 ways to connect to a database. The following link says that using a dataSource is the preferred way. What is the other way then?
The can't extract that from the text. The text is confusing.

http://docs.oracle.com/javase/tutorial/jdbc/overview/index.html

the part of text which says 2 ways:


JDBC Driver Manager — The JDBC DriverManager class defines objects which can connect Java applications to a JDBC driver. DriverManager has traditionally been the
backbone of the JDBC architecture. It is quite small and simple.

The Standard Extension packages javax.naming and javax.sql let you use a DataSource object registered with a Java Naming and Directory Interface™ (JNDI) naming
service to establish a connection with a data source. You can use either connecting mechanism, but using a DataSource object is recommended whenever possible.
for an assignment I need to install and use STS with Netbeans.
But it seems it's only for Eclipse, the STS website only has a download for Eclipse.

??? Can Anyone give me an reference please ??? Kinda odd that STS website has nothing to do with STS....and netbeans

Hello,

Is it possibe for an instance to de-reference (destroy) itself?

Cw
11 years ago

Hello,

I was wondering if the following is correct and if it could be improved, if so how?
My instance person has several states: child,teacher, artist. At this moment I draw the sequence diagram,
the succes scenario , that the child becomes a teacher. I draw an message call to itself to change the state.

and is the following correct or wrong:
Draw the states of the instance as instances with lifelines? (My first guess is that this is wrong, but I am not sure)

Cw

Thank you Jesper,

I was locked in my thinking, didn't know how to create the relationships between the objects so that it would work.
Forgot about the part that I could send an instance referance towards the constructor of another object. Doing so the new instance is able to use
the reference and so access it public methods.

(applying some more anti-rust.... joints are loosing up....)

Cw
11 years ago

Paul Clapham wrote:This is extremely simple:




But I don't understand this yet... could someone explain this with a short code example? thanks
11 years ago
In which situation (how) can I access the class B in the class C then? I know that class A can access B with the getValue() method, because it has an reference to the instance B.
But with Class C which has no reference I don't know. Creating a new instance of class B in class C is not good because I like to access the only one class B I created.

Perhaps the following code will explain it why I like to do this.

Goal:
- want to create a class ClockPanelDigital, want to seprate analog and digital clock panel

problem:
- my current class ClockPanelAnalog creates the ClockPanel, thus ClockPanelAnalog can call ClockPanel's method addPanel(object ClockPanelAnalog)
This adds the clockPanel to the clock frame. But how do I add another clockpanelDigital to the same ClockFrame?

Extra info:
- I have to let ClockPanelAnalog create the instance of ClockPanel, so that the TimeGenerator instance can add ClockPanelAnalog as an Observer.







11 years ago
I tried this, but it does not work yet. What am I doing wrong?







11 years ago

Situation:
3 classes A, B and C

A creates an instance of B. Code in A:


How can I use the created instance of B inside class C? I don't want to create a new B instance.
Is there a way to send the reference of the instance B to C? Is my way good or bad in terms of OO programming?

Thanks

Cwli
11 years ago

I have the following situation clock that has a analog and digital view in the same JFrame:

Classes:
- ClockFrame extends JFrame
- ClockPanel extends JPanel implements Observer,
- TimeGenerator class extends Observable implements Runnable

What happends:
- I run timeGenrator's main, creates TimeGenerator and ClockPanel.
- timeGenerator calls method addObserver(ClockPanel)
- The ClockPanel creates ClockPanel, then calls method ClockFrame.addPanel(this). To add this JPanel to the JFrame.

I must follow the situation above because:
- TimeGenerator can only add an instance if it created it. I don't know how to call method addObserver() if it did not create that ClockPanel instance.
- Because the panel is created, I let ClockPanel create an instance of ClockFrame and call method ClockPanel.addPanel(this).

Problem:
- I am trying to create 1 class for each clock view: Clockanalog and a class ClockDigital. but How can I do that? The problem is that only one ClockPanel (analog or digital) can create the ClockFrame.
Without creating the instance in a specific ClockPanel, I don't know how to add it to the ClockPanel.

Hope it's clear... I can provide my code if needed. What Java principle do I lack to successfully refactor this code? If you have suggestions, please do tell. =)
11 years ago

Thank you Daniel. Something to read about then: References. Have not done much Java lately. time to catch up. =)
11 years ago