Link to home
Start Free TrialLog in
Avatar of thor918
thor918Flag for Norway

asked on

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
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

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?
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.
>> 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 ;-)
http://java.sun.com/products/archive/index.html

would be the place to look for an old version of Swing...
Avatar of thor918

ASKER

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.
Avatar of thor918

ASKER

checked it out now. now swing awailable
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 :-)
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...

:-/
what device is it (out of interest)?
Avatar of thor918

ASKER

doh! hehe typo
checked it out now. no swing available

the device is sonyericsson pxxx
Avatar of thor918

ASKER

I don't need tree structure. only a flat list with images aside the text.
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?
Avatar of thor918

ASKER

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.

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
>>  Yep a view like that would be something I would like.

Does FExplorer work on your phone?  (I doubt it, but it might) :-/
Avatar of thor918

ASKER

I doubt if it works. sonyericsons are UIQ not S60.
And there is no source there either.is it even written in personal java?
>> is it even written in personal java?

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

Avatar of thor918

ASKER

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.
Avatar of thor918

ASKER

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;
      }
    }
 }
Avatar of thor918

ASKER

is someone is curious on how it looks :
http://home.no.net/thor918/pjava/pxxxjavalist.png
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thor918

ASKER

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