Vector with collection
Hi,
I'd like to create JTable with vector (Collection).
Are there any sample described from collection instance to jTable instance?
Thanks in advance.
// god awful simple class to show lazy student how to do his code........
// complete with compilation errors....... ;)
public User{
private string userName;
private string firstName;
private string middleName;
private string lastName;
public User(userName, firstName, middleName, lastName){
this.userName = userName;
this.firstName = firstName;
this.middleName = middleName;
this.lastName = lastName;
public String getUserName(){
return userName;
public String firstName(){
return userName;
public String middleName(){
return userName;
public String lastName(){
return userName;
// now the method to build the TableModel from a Collection class
// passing a generic List to hide implementation..
// with a few compilation errors of course.... ;)
public void updateTableModel(List data){
// be lazy and use the DefaultTableModel
DefaultTableModel theTableModel = new DefaultTableModel();
// add the columns
theTableModel.addColumn("UserID);
theTableModel.addColumn("Name);
// add the rows
Iterator iterator = data.Iterator();
User u;
while(iterator.hasNext()){
u = iterator.next();
String userName = u.getUserID();
String firstName = u.getFName();
String lastName = u.getLName();
String name = firstName + " " + lastName;
theTableModel.addRow(new Object[]{userName, name});
// now pad the table out.......
if (theTableModel.getRowCount < 45){
theTableModel.setRowCount(45);
// now set the model for the table....
theTable.setModel(theTableModel);
}have fun....
as you're too lazy to look at the API documentation, I've been lazy to make sure it's correct.. irespective of the delibrate compilatons errors I put in........
Similar Messages
-
How to create Vector with reference to Collection
hello experts,
can someone let me know how to create vector with reference to Collection interface.
Collection is an interface. and we cant create an instance of it. i'm not clear of what to pass in that constructor.
Vector v = new Vector (Collection c);
what are the possible objects of 'c'
post some example code please.
thanksEver heard of reading the javadocs?
"Collection is an interface. and we cant create an instance of it." - you don't understand interfaces, then.
// I certainly can create a Collection - here's one
Collection c = new ArrayList();
// Now I'll add some Strings to my Collection.
c.add("foo");
c.add("bar");
c.add("baz");
// Now I'll make a Vector out of it.
Vector v = new Vector(c);% -
Replacing vectors with better collection
Hi,
My Netbeans IDE is giving me a hint that vectors (which I am using to build custom table models from AbstractTableModel) are obsolete.
What should I replace vectors with, or what collection should I use to build custom table models, any example will be appreciated.
Thanksjverd wrote:
Use ArrayList instead of Vector.
However, interaction with legacy GUI APIs is one commons place where you have to use Vector. I'm not sure if AbstractTableModel falls into that category, but you can find out easily enough.Unlike DefaultTableModel, AbstractTableModel makes no assumptions about how the data must be stored. That is why it is useful. It can be used to adapt other data structures to TableModel without the need to copy the data. -
Compiler warning with Collections.sort() method
Hi,
I am sorting a Vector that contains CardTiles objects. CardTiles is a class that extends JButton and implements Comparable. The code works fine but i get the following warning after compilation.
Note: DeckOfCards.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
After compiling with -Xlint, i get the following warning;
DeckOfCards.java:173: warning: [unchecked] unchecked method invocation: <T>sort(java.util.List<T>) in java.util.Collections is applied to (java.util.Vector<CardTiles>)
Collections.sort(handTwo);
^
What could be the problem? Is Collections.sort() only intended for Collections of type List?
Many thanks!Hi Jverd, my handTwo Vector was declared as follows;
Vector<CardTiles> handTwo = new Vector<CardTiles>();
The CardTiles Source code is as follows;
import javax.swing.*;
import java.util.*;
public class CardTiles extends JButton implements Comparable{
static String typeOfSort = "face";
public static final long serialVersionUID = 24362462L;
int i=1;
public ImageIcon myIcon;
public Card myCard;
public CardTiles(ImageIcon i, Card c){
super(i);
myIcon = i;
myCard = c;
public int compareTo(Object o){
CardTiles compare = (CardTiles)o;
if(typeOfSort.equals("face")){
Integer ref1 = new Integer(this.myCard.getFaceValue());
Integer ref2 = new Integer(compare.myCard.getFaceValue());
return ref1.compareTo(ref2);
}else{
if(this.myCard.getFaceValue() > 9 || compare.myCard.getFaceValue() >9){
if(this.myCard.getFaceValue() > 9 && compare.myCard.getFaceValue() >9){
String ref1 = this.myCard.getSuit().substring(0,(this.myCard.getSuit().length()-1));
String ref2 = compare.myCard.getSuit().substring(0,(compare.myCard.getSuit().length()-1));
return ref1.compareTo(ref2);
}else{
if(this.myCard.getFaceValue() > 9 || compare.myCard.getFaceValue() >9){
String ref1 = this.myCard.getSuit().substring(0,(this.myCard.getSuit().length()-1));
String ref2 = compare.myCard.getSuit() + Integer.toString(compare.myCard.getFaceValue());
return ref1.compareTo(ref2);
}else{
String ref1 = this.myCard.getSuit() + Integer.toString(this.myCard.getFaceValue());
String ref2 = compare.myCard.getSuit().substring(0,(compare.myCard.getSuit().length()-1));
return ref1.compareTo(ref2);
}else{
String ref1 = this.myCard.getSuit() + Integer.toString(this.myCard.getFaceValue());
String ref2 = compare.myCard.getSuit() + Integer.toString(compare.myCard.getFaceValue());
return ref1.compareTo(ref2);
public String toString(){
return ( myCard.toString() + " with fileName " + myIcon.toString());
}What could be wrong?
Many thanks! -
How can I copy a Font Book library with "Collections" to my 2nd laptop?
How can I copy a Font Book library with "Collections" to my 2nd laptop?
I have a number of fonts (approx. 500) on my work laptop which are sorted to different Collections. I'd like to have a copy of the Font Book library with Collections on the laptop I use at home to work. I'd think there was a more straight forward way to do it, but I haven't found any posts regarding the matter so any help would be appreciated.
ThanksTo anyone who is reading this based on needing to copy their Font Book to another machine as I do, there is a way to make a copy of the fonts in Font Book by going to file/export fonts. Keep in mind that you will need to have all the fonts selected (command A) in your "All Fonts" list for them to be exported. You will then have a new folder saved to where ever you chose, with all your Font Book fonts in it.
-
EJB 3.0: How to merge detached entity with collection
Hello,
suppose you have 2 database tables: PARENT and CHILD with one-to-many association. In a session bean you load the parent entity together with collection of children and send it all to client. Client might change parent or child data, add/remove children.
Now back in a session bean you want to update database, so you call:
entityManager.merge(detached_parent_entity);Problem is, that removed child objects from entity bean collection are not deleted from database. Bacause I am currently using Hibernate, I could follow the FAQ (http://www.hibernate.org/116.html#A17) and add delete-orphan cascade, but I don't want to be tight to Hibernate nor other frameworks.
Is there any sexy solution?
Thanks for replies!I'm afarid not - a generic feature that will allow to
delete orphan children didn't make it into the final
spec.
regards,
-marinaDo you happen to have any links to public discussions about this feature with regard to the development of the spec? This is a very nice feature in Hibernate and it's absence in EJB 3.0 is rather disappointing.
Thanks. -
Problems Creating Mappings with Collections with tools or workbench
Hi -
I am a new kodo user for my company. And am having a few problems in genereal with mapping objects with collections
in them.
I followed the tutorial on how to use the kodo workbench
using the Passenger example. Build the java code and then
tried to creat a new set of metadata. After going through
this process I expected to see TWO tables. Something like
'PAssenger' and something like 'Luggage' where luggage
would be joined to passenger. However what I am getting
is ONE table passenger with a BLOB field 'Luggage'. This
has been a contant problem with me with any composite
java class containing collection. Obviously I am configuring something wrong. Any help would be great.
Thanks
MattAnswered by one of my fellow and unknown colleagues that suddenly entered the room
-
Can i save a vector with gradient mesh as isolated .PNG?
Hi,
Can i save a vector with gradient mesh as isolated .PNG?
It has some effects, so if i'm taking it out from the blue background it becomes darker.
Any advice? I need it isolated png for using it in an iOS app.
Many thanksI am using Illustrator CS6, on Mac.
I can't copy and paste the "cloud" into a new document to save it, because it looses the effect of those filters (since the background is no longer behind it).
Sorry if im not explaining it right, i'm a beginner in illustrator. Can i group both the "cloud" and the blue background, to get just one shape: the realistic white cloud?
P.S: i can make a link with the .esp file of the clouds, if it helps. -
Problems with collective search help
Hello SDNers,
I was working with collective search help.
Ex : zc_srch1 (Collective)
In the 'Include search help' i have included 2 search elementary search
help
Ex : zsrc1 and zsrc2 (both elementary)
I have also assigned the parameter assignment for each included search help.
I have also mentioned the search help parameter under definition tab
Ex field form zsrch1 and field1 from zsrch2
and also checked the import and export checkboxes.
Now i have used the search help in the abap program
ex: tmp type field1 matchcode object zc_srch1.
Now when i execute the program the collective search help is getting populated. when i try to choose a value it is not getting selected to the parameter box.
Regards,
Ranjith NHi,
Once again check back your seach help creation by following the link below.
http://help.sap.com/saphelp_erp2005/helpdata/en/cf/21ee86446011d189700000e8322d00/content.htm
Cheers!!
VEnk@ -
Working with collections in powershell
Hi,
I'm struggeling with collections in Powershell in general.
I have a variable of type SPWebCollection created and want to add
1) a single SPWeb - Object
2) another collection of SPWeb - Objects
Can someone tell me please why the following doesn't work:
[Microsoft.Sharepoint.SPWebCollection]$allWebs += Get-SPWeb $URL1
or this
[Microsoft.Sharepoint.SPWebCollection]$allWebs += $site.AllWebs | Where-Object {$_.Url -like $URL2}
Finally I want to empty the $allWebs collection i.e. remove all objects. How do I do that?
I appreciate any feedback
Thank youHi,
According to your description, you might want to gather all the SPWeb object into a collection object in order to delete all of them finally.
As we can see, there is no such method in
SPWebCollection object can meet you requirement, as a workaround, we can push all the SPWeb objects into an array, then operate
these SPWeb objects in this array would do the trick.
Here is a link about how to create a generic collection for a list of objects:
http://www.andreasbijl.com/powershell-create-collections-of-custom-objects/
More information about using collection in PowerShell:
https://www.simple-talk.com/sysadmin/powershell/powershell-one-liners--collections,-hashtables,-arrays-and-strings/
Best regards,
Patrick
Patrick Liang
TechNet Community Support -
Element-by-element multiplication of a vector with matrix rows
I want to element-by-element multiply a Vector with the rows of a Matrix ,in the most efficient way. Anybody knows if there is a sub vi for this in LW7.0 ?
(The Inputs are a Matrix; and a Vector with the same size as Matrix's # of columns ; the output is a Matrix with the same dimension as input Matrix. Every row of the output Matrix is the product of element-by-element multiplication of input vector with the correspondind input Matrix's row )
Thanks(Yes, the 2D linear evaluation is basically the same as the 1D evaluation except for the dimension if the array. NI could merge them into one and make the array input polymorphic with respect to size. )
I "think" you want a plain multiply (not a polynomial evaluation). You can do it (A) one row at a time or (B) one column at a time, but A might possibly be slightly more efficient. Do all three (including the one in the next message) and race them with your real data! Message Edited by altenbach on 03-14-2005 07:47 AM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
MatrixTimesVector.gif 5 KB -
How to execute a procedure with collection passed as parameter?
i have created the collection:
CREATE TYPE typ_Project AS OBJECT( project_no NUMBER(2), title VARCHAR2(35), cost NUMBER(7,2))
CREATE TYPE typ_ProjectList AS VARRAY (50) OF typ_Project
and a procedure:
CREATE OR REPLACE PROCEDURE add_project (
p_deptno IN NUMBER,
p_new_project IN typ_Project,
p_position IN NUMBER )
IS
v_my_projects typ_ProjectList;
BEGIN
SELECT projects INTO v_my_projects FROM department
WHERE dept_id = p_deptno FOR UPDATE OF projects;
v_my_projects.EXTEND;
FOR i IN REVERSE p_position..v_my_projects.LAST - 1 LOOP
v_my_projects(i + 1) := v_my_projects(i);
END LOOP;
v_my_projects(p_position) := p_new_project; -- add new
UPDATE department SET projects = v_my_projects
WHERE dept_id = p_deptno;
END add_project;
Now please explain how to call this procedure with collection passed as parameter . . .For example:
BEGIN
add_project(
10, -- department number
typ_Project(
99, -- project number
'New Project', -- project title
99999.99 -- project cost
), -- new project
5 -- project position
END;
/SY. -
Why do images/vectors with effects get rasterised when clipped in Illustrator
Why do images/vectors with effects get rasterised when clipped in Illustrator@
Which version
which system?
What exactly did you do?
What exactly happened?
What exactly is wrong with that?
Can you show a screenshot? -
Hi i have some problem with collect statement.
hi when i am using collect statement and whn ever any field is modified it is getting doubled and showing doubled value. may i knoe what would be problem.
Hai Kumar
Go through the following Collect Syntax
COLLECT
Basic form
COLLECT [wa INTO] itab.
Addition
... SORTED BY f
Effect
COLLECT is used to create unique or compressed datsets. The key fields are the default key fields of the internal table itab .
If you use only COLLECT to fill an internal table, COLLECT makes sure that the internal table does not contain two entries with the same default key fields.
If, besides its default key fields, the internal table contains number fields (see also ABAP/4 number types ), the contents of these number fields are added together if the internal table already contains an entry with the same key fields.
If the default key of an internal table processed with COLLECT is blank, all the values are added up in the first table line.
If you specify wa INTO , the entry to be processed is taken from the explicitly specified work area wa . If not, it comes from the header line of the internal table itab .
After COLLECT , the system field SY-TABIX contains the index of the - existing or new - table entry with default key fields which match those of the entry to be processed.
Notes
COLLECT can create unique or compressed datasets and should be used precisely for this purpose. If uniqueness or compression are unimportant, or two values with identical default key field values could not possibly occur in your particular task, you should use APPEND instead. However, for a unique or compressed dataset which is also efficient, COLLECT is the statement to use.
If you process a table with COLLECT , you should also use COLLECT to fill it. Only by doing this can you guarantee that
the internal table will actually be unique or compressed, as described above and
COLLECT will run very efficiently.
If you use COLLECT with an explicitly specified work area, it must be compatible with the line type of the internal table.
Example
Compressed sales figures for each company
DATA: BEGIN OF COMPANIES OCCURS 10,
NAME(20),
SALES TYPE I,
END OF COMPANIES.
COMPANIES-NAME = 'Duck'. COMPANIES-SALES = 10.
COLLECT COMPANIES.
COMPANIES-NAME = 'Tiger'. COMPANIES-SALES = 20.
COLLECT COMPANIES.
COMPANIES-NAME = 'Duck'. COMPANIES-SALES = 30.
COLLECT COMPANIES.
The table COMPANIES now has the following appearance:
NAME SALES
Duck 40
Tiger 20
Addition
... SORTED BY f
Effect
COLLECT ... SORTED BY f is obsolete and should no longer be used. Use APPEND ... SORTED BY f which has the same meaning.
Note
Performance
The cost of a COLLECT in terms of performance increases with the width of the default key needed in the search for table entries and the number of numeric fields with values which have to be added up, if an entry is found in the internal table to match the default key fields.
If no such entry is found, the cost is reduced to that required to append a new entry to the end of the table.
A COLLECT statement used on a table which is 100 bytes wide and has a key which is 60 bytes wide and seven numeric fields is about approx. 50 msn (standardized microseconds).
Note
Runtime errors
COLLECT_OVERFLOW : Overflow in integer field when calculating totals.
COLLECT_OVERFLOW_TYPE_P : Overflow in type P field when calculating totals.
Thanks & regards
Sreenivasulu P -
Biller Direct Integration with Collections Manangement
Hi Experts
I know the Biller Direct integration with Dispute management but not with collections management.
Can anyone explain me the process / Steps of Integration between Biller Direct and Collections Management?
Thanks in advance
Regards,
Meenakshi.NHi Meenakshi,
There is no direct integration between Collections management and Biller direct.
Cristobal.
Maybe you are looking for
-
How Can I do to make an interactiv​e user interface?
I have to make a virtual laboratory, with a oscilloscope, multimeter, function generator and power supply, i don´t know how can interconnect the different outputs of the devices, How can I draw for example a probe and put it in the function generator
-
Would anyone know if there is a free translator tool that can be inserted in the Mail tool bar? imtranslator from Firefox would be ideal.
-
Enter run time in hours / mins / secs on the front pannel
I am trying to get a pop up VI to run alongside my main program. While the measurment parts of my software run I want a VI to pop up and display the run time in hours / mins / secs. Once the main VI ends its sequence, I want the timer VI to close dow
-
Hi Experts, We have installed a new HP printer (devise type HPLJ5SI) . When we print the work order or anything related, at the end of the printing, there are 2 extra pages are coming. If we use any other printer, it works fine. Can anyboty help, to
-
I am a newbie with MPEG and would like to know what type or kind of file is necessary to make a QuickTime movie for the Internet. The producer of the files gave me a DVD which was not mountable on my computer, so I could not even see what kind of fil