|
bugger.....Reading your answer, i might be half right!
I'm sure i've seen the exact same diagram in my uni course texts, but i can't find it. It will be buried somewhere.
Dave
Find Me On: Web| Facebook| Twitter| LinkedIn
CPRepWatcher now available as Packaged Chrome Extension, visit my articles for link.
|
|
|
|
|
This diagram isn't really UML so it is hard to know what it is intended to show.
In UML, the solid arrow means that Thread implements Runnable (Thread is a Runnable).
The other arrow is an open arrow and in UML this would normally represent a "has a" relationship rather than "is a". So, this would mean that MyRunnable has a Runnable, and the concrete implementation of that Runnable is a Thread.
However, the names of the classes in this example lead me to think this is not what is intended.
It might be that MyRunnable implements Runnable, and this runs as the target of a Thread, in which case the meaning of the symbols would be completely reversed. MyRunnable is a Runnable, and Thread has a Runnable target.
In other words, this diagram could have two completely opposite meanings. It is not a good diagram.
|
|
|
|
|
Hello,
I define a class as bellow
public class Items
{
public int id;
public String model;
public String type;
public String name;
public String description;
public String creator;
public Date created;
public void setId(int _id)
{
this.id = _id;
}
public int getId()
{
return id;
}
public void setModel(String _model)
{
this.model = _model;
}
public String getModel()
{
return model;
}
public void setType(String _type)
{
this.type = _type;
}
public String getType()
{
return type;
}
public void setName(String _name)
{
this.name = _name;
}
public String getName()
{
return name;
}
public void setDescription(String _description)
{
this.description = _description;
}
public String getDescription()
{
return description;
}
public void setCreataor(String _creator)
{
this.creator = _creator;
}
public String getCreator()
{
return creator;
}
public void setCreated(Date _created)
{
this.created = _created;
}
public Date getCreated()
{
return created;
}
public Items(int Id, String Model, String Type, String Name, String Description, String Creator, Date Created)
{
this.id = Id;
this.model = Model;
this.type = Type;
this.name= Name;
this.description = Description;
this.creator = Creator;
this.created = Created;
}
}
next, I have another class and in this class I define a method with argument
public class dataInteraction
{
public static insert(int id, String model, String type, String name,
String description, String craetor, Date created )
{
ArrayList arrayList = new ArrayList();
arrayList.add(??????????????)
}
}
my question is do I have to add argument or class?
arrayList.add(Items)
or
arrayList.add(id);
.
.
.
arrayList.add(created);
|
|
|
|
|
1) You probably don't want to create your list in the insert method: if you do so, you will create a new list each time the insert method is called (and I guess it's not what you want). So, preferably make it a member of your DataInteraction class (and create it in the constructor of the class).
2) It's a bit strange that you call the class Items and not Item . Is this class supposed to represent multiple items or only one ? From your code, I guess it should be called Item .
3) I guess you want to store several items in your array list. If so, simply create an instance of the Item class when you call the insert method and add the object to the list:
public class dataInteraction{
public static insert(int id, String model, String type, String name, String description, String craetor, Date created ) {
Item newItem = new Item(id, model, type, name, description, creator, created);
arrayList.add(newItem);
}
}
|
|
|
|
|
thanks for your reply,
this class shows multiple items.so, do I need to call item or items?
as I am beginner, regarding to your advice(1), do you reckon if my array be a member of DataInteraction class is better or do I have to put inside the insert method. the reason I put inside the method is, I wanna call this method in another class to assign data.
I would be happy if you tell me any suggestion.
thx
|
|
|
|
|
I think you are missing some fundamental concepts on object oriented programming. It would help if you read your class book or some tutorial about classes first.
future3839 wrote: this class shows multiple items.so, do I need to call item or items?
Which class will contain multiple items ? The dataInteraction class or the Item class ? Furthermore, dataInteraction is I guess not a really useful name. What do you want to do with the list of objects ? You probably don't need the dataInteraction class anyway but use the list directly.
future3839 wrote: the reason I put inside the method is, I wanna call this method in another class to assign data.
If you create the list inside the method, each time the method is called, a new list is created. Furthermore, the method has to return the list (you forgot the return type of the method) otherwise it will be "lost" (you don't have any reference to it anymore so you can't manipulate it).
|
|
|
|
|
You may be better using one of the built in collections classes; see the tutorials[^] pages for some good examples.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
ArrayList is one of the built in collections classes
|
|
|
|
|
It was the very first one, unless you consider Array a collection as well (it doesn't grow well).
|
|
|
|
|
It may be the first alphabetically but it was not the first in the language. It wasn't added to Java until release 1.2. Prior to that we just had Victor the Vector.
|
|
|
|
|
I stand corrected. While I have been using Java quite a lot, almost from its start, I don't remember not having ArrayList...
|
|
|
|
|
The java.util collections classes were Joshua Blosch's work, before he left Sun and made lots of money writing books.
Sadly, I have been using Java since the 1.1 days (longer than I care to remember), and I remember the new collection classes being added, and Vector being retro-fitted with the "new" List interface. That's why we have Hashtable and HashMap as well. Hashtable has been there since 1.0, HashMap is one of the 1.2 generation of collection classes.
|
|
|
|
|
I really must learn to read properly.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Oh don't do that Richard! Have another GnT, take a deep breath and carry on as before.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
Nagy Vilmos wrote: Have another GnT
Don't mind if I do; Cheers!
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hi,I want to implement Table control with GEF.Does anybody have examples like that?
Any suggestion will be appreciate.
modified on Monday, September 27, 2010 8:02 AM
|
|
|
|
|
hello i have almost completed my project in java and i want to know is there any way possible to refresh table component or other values residing on mainFrame form of application on closing a separate frame/window/dialog (not child)
--------------------------------------
The same i want with jpanels showing within tabs but thats an issue of less priority
Alok sharma
|
|
|
|
|
|
Hello,
when I create new project in Java desktop application. a for Automatically create. now, I add another jframeform. my question is how to make the new form as default. i wanna after running project my form show up.
|
|
|
|
|
How are you creating this application? Java does not automatically show anything as a default when a Swing application starts up, so my guess is you must be using some toolkit or framework to do this?
|
|
|
|
|
hi, I read a few article regarding java fx and all said it use to have better GUI.is that true?
in this case, if i use java fx, the syntax and all ohter things is the same? what is the main advantages of using java fx?
if i wana develope desktop application do I have to use java fx?
|
|
|
|
|
This is quite a controversial topic, and is the subject of much debate in the Java community. If you search on Google for something like "javafx versus swing" you will find lots and lots of opinions.
To answer your specific questions:
JavaFX uses a different syntax from Swing, and has its own language, JavaFX Script, which is not Java. However, you can use JavaFX with Java.
There are three main advantages to using JavaFX, as I understand it. First, JavaFX has better support for animations and media such as video and audio. Second, JavaFX has a similar idea to WPF in as much as it separates the visual design from the code, the idea being that the application can be built by a specialist programmer, and the look and feel can be put together by a specialist graphic designer. (The technical implementation is different from WPF, though.) Third, JavaFX offers better support for mobile platforms than Swing does.
Disadvantages: mainly that JavaFX isn't fully ready yet. It is still lacking some basic components you might need for writing desktop applications, such as a table component. It is still evolving and just this week Oracle announced that JavaFX Script will not be supported in the next version of JavaFX.
If you want to develop a desktop application, you don't have to use JavaFX but you can if you want to, if it suits your requirements. Personally, I wouldn't use it because Swing gives me everything I need for the kind of applications I build, but if I had a requirement that Swing couldn't meet, I might consider JavaFX. For example, if someone wanted me to write something with JavaME I would look at maybe using JavaFX, or at least weigh it up against LWUIT (another toolkit for Java GUIs on mobile phones).
More here:
http://javafx.com/faq/[^]
|
|
|
|
|
I need a help to develop an application in JavaFx 2.2. I'm trying to learn it through official site. But it is not enough for me and I need help.
Could you please help me?
|
|
|
|
|
Hi,
I have a store which has different sort of stuff like table,chair, rug etc. I define a class for public characteristics like name, color, size etc. id addition public features, if each item has particular characteristic do I have to implement inheritance? for example each item come up with different price in different month?
thanks for your help,in advance.
|
|
|
|
|
yes, you could (and should) take advantage of inheritance in such a situation: put the data members and code methods that are common to all kinds into a common base class, then "specialize" the things you need by creating new classes that inherit from said base class.
Most text books have an Animal,Cat&Dog example (or something similar) illustrating the concept.
|
|
|
|
|