List 1.1.8

Hi there. Looking for an example for java application using jdk 1.1.8.
Would like to see some examples involving a list with icons.
if I would make a filebrowser I wan't for example
* folder icon on foldernames
* audio icon on mp3 filenames
* video icon on video filenames
LVL 2
thor918Asked:
Who is Participating?
 
TimYatesCommented:
I'm on holiday today, but I can have a look at this next week if someone doesn't help you out in the mean time :-/

Good luck!  That looks REALLY nice :)

Tim
0
 
TimYatesCommented:
I don't think this is a small task with 1.1.8 :-(

Why not use a later version of java, where it would be much simpler?
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Not sure if you could do that. Try fiddling with the look and feel (though I doubt it if will do it). You might want to use native-code.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
TimYatesCommented:
>> Try fiddling with the look and feel

That would require using Swing...  

I guess you could download the swing.jar library for 1.1.8, and have a go using that...  But I have no idea how good the old swing.jar lib is...

File.isDirectory() ;
File.getName().endsWith( ".mp3" ) ;

and

File.getName().endsWith( ".mov" ) ;

will be needed somewhere though ;-)
0
 
TimYatesCommented:
http://java.sun.com/products/archive/index.html

would be the place to look for an old version of Swing...
0
 
thor918Author Commented:
why not use a newer.
Simple because the device I'm programming on has 1.1.8 and it's not upgradable.
I'm not sure if there is any swing there. don't thinks so.
0
 
thor918Author Commented:
checked it out now. now swing awailable
0
 
TimYatesCommented:
Cool...

You'll need something like this as a base:

http://java.sun.com/products/jfc/tsc/articles/treetable1/

Then implement your own TableCellRenderer to do the icons dependant on file extension :-)
0
 
TimYatesCommented:
Of course, you're going to have to be careful not to use methods which are marked as "Since 1.2+", as they won't exist on your target device...

It's basically going to be a case of

  compile
  test
  deploy
  see which functions aren't there
  workaround
  test
  deploy...

:-/
0
 
TimYatesCommented:
what device is it (out of interest)?
0
 
thor918Author Commented:
doh! hehe typo
checked it out now. no swing available

the device is sonyericsson pxxx
0
 
thor918Author Commented:
I don't need tree structure. only a flat list with images aside the text.
0
 
TimYatesCommented:
And it runs java 1.1.8?

I thought the sony ericsson p-series phones just supported MIDP 2?

If it's a Symbian 60 phone, FExplorer should work...

http://users.skynet.be/domi/fexplorer.htm

is this the sort of thing you want?
0
 
thor918Author Commented:
Yep a view like that would be something I would like.
sony ericsson p-series phones support Midp2 and personal Java 1.1.8.
And it runs quite well personal java.the application gets the look and feel like a native app and that's the most important reason I don't want to make a midlet.

0
 
TimYatesCommented:
a midlet wouldn't work either :-(  (you won't be able to get at the files)

looks like you're stuck with AWT then...  and I have forgotten most (all?) of my AWT stuff...hopefully someone else can help...

Tim
0
 
TimYatesCommented:
>>  Yep a view like that would be something I would like.

Does FExplorer work on your phone?  (I doubt it, but it might) :-/
0
 
thor918Author Commented:
I doubt if it works. sonyericsons are UIQ not S60.
And there is no source there either.is it even written in personal java?
0
 
TimYatesCommented:
>> is it even written in personal java?

No...  It's a Symbian App :-(

0
 
thor918Author Commented:
I tried to put swing classes in device now.And it seems that the example file seems to work partialy. maby if anyone has a relly simple example with icons in list that is made in swing1.1.1 it may infact work.
0
 
thor918Author Commented:
I have found this swing code and it works okey on my device :)
It must be tru what I read about swing. it is written in pure java and therefor can be used even if the swing isn't in the device javalib.
thanks TimYates for putting me up to the ide of adding the swing lib to my project jar.

Anyway what seems to be missing in this code is :
* width should be fixed and not change dynamicaly of the size text
* the elements will center, i want all elements to be left aligned
* a scrollbar to view the itemes at the bottom

 import javax.swing.*;
 import java.awt.*;
 import java.util.*;

 public class JListWithImages extends JList {

  public JListWithImages() {
    setCellRenderer(new CustomCellRenderer());
    }

  public static void main(String[] args) {
    JFrame frame = new JFrame();
    JPanel panel = new JPanel();

    Vector vector = new Vector();
    panel.setForeground(Color.black);
    panel.setBackground(Color.white);

    // 1 line
    JPanel jp1 = new JPanel();
    jp1.add(new JLabel(new ImageIcon("up.gif")));
    jp1.add(new JLabel(".."));

    // 2 line
    JPanel jp2 = new JPanel();
    jp2.add(new JLabel(new ImageIcon("mp3.gif")));
    jp2.add(new JLabel("Music1.mp3"));

    vector.addElement(jp1);
    vector.addElement(jp2);
    vector.addElement(jp2);
    vector.addElement(jp2);
    vector.addElement(jp2);
    vector.addElement(jp2);
    vector.addElement(jp2);
    vector.addElement(jp2);
    vector.addElement(jp2);
    vector.addElement(jp2);
    vector.addElement(jp2);
    vector.addElement(jp2);
    vector.addElement(jp2);

    JListWithImages jlwi = new JListWithImages();
    jlwi.setListData(vector);

    panel.add(jlwi);
    frame.getContentPane().add(panel);
    frame.setSize(208,276);
    frame.setVisible(true);
    }

  class CustomCellRenderer implements ListCellRenderer {
    public Component getListCellRendererComponent
     (JList list, Object value, int index,
      boolean isSelected,boolean cellHasFocus) {
      Component component = (Component)value;
      component.setBackground
       (isSelected ? Color.black : Color.white);
      component.setForeground
       (isSelected ? Color.white : Color.black);
      return component;
      }
    }
 }
0
 
thor918Author Commented:
is someone is curious on how it looks :
http://home.no.net/thor918/pjava/pxxxjavalist.png
0
 
thor918Author Commented:
Okey.
I have Manageed to get scrolling and leftalignment.
http://home.no.net/thor918/pjava/pxxxjavalist2.png

But is it possible to disable the selection frame(a black rectangel) I get if I click outside the list?
http://home.no.net/thor918/pjava/pxxxjavalist3.png
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.