« first day (533 days earlier)      last day (4391 days later) » 

12:00 AM
@JideobiBenedineOfomah for to add ti jlist i have just to use jList1.add("files");
right?
ist not working
 
File fileFolder = new File("folder-path");
File[] listOfFiles = selectedFolder.listFiles();
for (int i = 0; i < listOfFiles.length; i++){
if (listOfFiles[i].isFile()) {

String files = listOfFiles[i].getName();

}
what error did u get
File fileFolder = new File("folder-path");
File[] listOfFiles = selectedFolder.listFiles();
for (int i = 0; i < listOfFiles.length; i++){
if (listOfFiles[i].isFile()) {

String files = listOfFiles[i].getName();

}
File fileFolder = new File("folder-path");
File[] listOfFiles = selectedFolder.listFiles();
for (int i = 0; i < listOfFiles.length; i++){
if (listOfFiles[i].isFile()) {

String files = listOfFiles[i].getName();
jlist.add(files);
}
 
no suitible method
found to add(java.lang.tring)
 
see
to use JList you have to create a List Model
 
yes i have
 
look for Item.Add maybe
Java is weird like that
 
12:08 AM
i have created a jlist by interface and not code
its ok!
o i didtn creat a line to define jlist
u understd what i mean?
 
Can we see the code? I'm confused now
 
ok
java.io.File directorio;
directorio = new java.io.File("C:\\MyGalery\\ ");
File[] dirAlbums = directorio.listFiles();
for (int i = 0; i < dirAlbums.length; i++){
if (dirAlbums[i].isFile()) {

String files = dirAlbums[i].getName();

jList1.add(files);
}
look
i'm working with interface java
 
sorry am back
 
ok
 
DefaultListModel listModel = new DefaultListModel(); //creates a list model
listModel.clear(); //clears the list midel
listModel.addElement(files);// this should be in the loop where you have jlist1.add(files)
 
12:16 AM
ok
 
DefaultListModel listModel = new DefaultListModel(); //creates a list model
listModel.clear(); //clears the list midel
these two lines should be outside the loop
only listModel.addElement(files); should be in the loop
then to now display the file names in the jlist1 do the following jlist1.setModel(listModel);
 
ok
yes yes
its ok
 
is it working now?
 
 java.io.File directorio;

  directorio = new java.io.File("C:\\MyGalery\\ ");


  File[] dirAlbums = directorio.listFiles();
  String[] listaArchivos=directorio.list();


  for(int i=0; i<listfiles.length; i++){


       System.out.println(dirAlbums[i]);

     String namealbum = dirAlbums[i].getName();
     String path = dirAlbums[i].getPath();


  DefaultListModel list = new DefaultListModel();

     for(int x = 0; x<listfiles.length; x++){
      list.addElement(dirAlbums[x].getName());


     jList1.setModel(lista);
yes
ok
ok we return the the first probm
now if in my list if i want to get the name of the selected files
how can i do it?
@JideobiBenedineOfomah yes its working
 
pk
ok
now to get selected values do the following
 
12:23 AM
ok
 
String[] selectedFileNames = jList1.getSelectedValues();
to see if it working use loop to print selectedFileNames array
for(int i = 0; i<selectedFileNames.length; i++){
 
but i want to select just one file
ok
 
ok
String selectedFileName = jList1.getSelectedValue();
then System.out.println(selectedFileName);
 
ok
one minut plz
 
12:33 AM
it not working like you send me
it have to be like this String selectedFileName = (String) jList1.getSelectedValue();
System.out.println(selectedFileName);
so with
String selectedFileName = (String) jList1.getSelectedValue();
System.out.println(selectedFileName);
 
yeah sorry i forgot that getSelectedValue() returns object so u have to cast it to a string
 
yes
 
what else you now have the selectedFileName
 
u think that i can now use this string
for the other class? that need a String?
 
yeah all you have to do is create a method that returns this string then call that method in the other class
 
12:38 AM
ok :)
 
did you send me a mail?
 
yes
but with out code
:)
 
if i find some probl i will end u ok :D
send
 
anyother thing? wanna go and sleep
 
12:57 AM
no thanks
it ok
good night
 
you too see you
 
 
4 hours later…
5:26 AM
hi everyone
can someone tell me why java doesn't add features because of backward compatibility?
if i add new features how can they break existing code?
 
 
9 hours later…
2:02 PM
hi, is there someone familiar with java annotation?
i have questions about how to take advantage of it
 
 
2 hours later…
4:07 PM
Hello, is it possible to pass an object as a parameter and have a true reference to it inside this function?
 
Explain that again?
A true reference.. how do you define that?
 
I mean, for eg.
class a{
b object_b;

a(b bobj){
object_b = bobj;
}

}
i passed bobj as a parameter and stored it in a
when i refer to it in a, will it be the same object or a copy of it?
 
A reference
Everything is pass by value
 
a reference to the actual object?
 
Yeah.
 
4:10 PM
then what would be syntax to ceate just a copy?
 
new a(new b()) yes?
@shishirgarg You can't.. unless you are doing C++
 
im not doing new a(new b())..
b exists beforehand
 
It doesn't matter.
It is stored on the heap
So what is passed is a reference to an instance of b..
 
That's different.
It is still pass by value.
We have value types and reference types
For value types the actual value is copied.
class a is a reference type.. so the address of a is copied
 
4:14 PM
im trying to create a reference to b inside a
 
You did so already in your constructor.. does it not work?
 
i havent tried it.. thinking it'ss just assign a copy
it'll*
i will now
thanks a lot!
 
No problem.
 
but doesn't it seem a bit counter intuitive that object_b = bobj would not create a copy but assign a reference?
how would one create a copy if he wanted to
 
It takes a copy of the reference
 
4:18 PM
ok
hmm
i'll remember that
 
What you pass in the constructor is an object reference..
Yeah it is a bit confusing as well.. that is where C++ is easy lol
 
 
1 hour later…
5:47 PM
hey @LewsTherin
u there?
now I'm trying to create a copy of an object, but I don't want it to be changed when the original object gets changed. How can I dp it?
do*
anybody?
 
Hi
@shishirgarg You want the class object to be separate different?
 
6:08 PM
@shishirgarg Do you still need help?
 
6:32 PM
yes
yes i want to create a copy of the object
 
Hello
@shishirgarg Make a copy constructor
 
i just want to do it with a local object
 
@LewsTherin Hello! :)
@shishirgarg Can you post your class?
 
@Andreas Hey dude what's up
@shishirgarg You should learn to use the bell to notify someone.. I didn't know you replied.
 
Working on a Java EE application
 
6:38 PM
@Andreas Sounds cool, what is it supposed to do?
 
@LewsTherin What have happened to the Java room? It is getting crowdy here!
 
@Andreas But no one speaks however :(
 
it's basically like this:
class someClass{
A a1, A a2;

void somefunction(){
a1 = geta1fromsomewhere();
a2 = a1;
}


}
i just want to keep the initial copy of a1
in a2
bcoz a1 gets changed later
 
@shishirgarg um you can't overload the assignment operator like in C++. What about the clone method? I haven't tried it yet
@Andreas That won't work... you are still doing the same thing. Copying a reference.
It is close however.. you need a deep copy.
public class A {
    int x;
    int y;
    public A(A aCopy) {
        x = aCopy.x;
        y = aCopy.y ;
    }
}
 
Yeah, true!
 
6:42 PM
Even that is not a true copy :(
@Andreas Have you tried the clone method?
 
Nope
I was always told to use copy constructor
But I haven't runned into many cases where I needed to use one either.
 
The copy constructor is the standard way. But much easier to use in C++. I have't done Java in a long time.
So rusty :(
 
Made something cool in C++ yet?
 
Haven't written anything in C++ yet.. but I have been writing C# a lot lately.
I love that language.
 
Web apps?
 
6:52 PM
Console, forms as well.
You should try it someday. You will love it
 
Forms? Like GUI you mean?
 
Yup
 
Cool
 
Yea.. I don't use forms as much.. boring kinda drag and drop. Console & Web mostly
Talk later in a few hrs maybe. Take care
 
 
1 hour later…
8:36 PM
Hello?
 
8:54 PM
Hello
Anybody who does Jax-RS
 

« first day (533 days earlier)      last day (4391 days later) »