?
Solved

List 1.1.8

Posted on 2005-04-28
22
Medium Priority
?
238 Views
Last Modified: 2008-02-26
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
0
Comment
Question by:thor918
  • 11
  • 10
22 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 13885162
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
 
LVL 30

Expert Comment

by:Mayank S
ID: 13885181
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
 
LVL 35

Expert Comment

by:TimYates
ID: 13885228
>> 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:TimYates
ID: 13885253
http://java.sun.com/products/archive/index.html

would be the place to look for an old version of Swing...
0
 
LVL 2

Author Comment

by:thor918
ID: 13885396
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
 
LVL 2

Author Comment

by:thor918
ID: 13885462
checked it out now. now swing awailable
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13885563
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
 
LVL 35

Expert Comment

by:TimYates
ID: 13885580
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
 
LVL 35

Expert Comment

by:TimYates
ID: 13885589
what device is it (out of interest)?
0
 
LVL 2

Author Comment

by:thor918
ID: 13885683
doh! hehe typo
checked it out now. no swing available

the device is sonyericsson pxxx
0
 
LVL 2

Author Comment

by:thor918
ID: 13885693
I don't need tree structure. only a flat list with images aside the text.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13885733
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
 
LVL 2

Author Comment

by:thor918
ID: 13885830
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
 
LVL 35

Expert Comment

by:TimYates
ID: 13885926
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
 
LVL 35

Expert Comment

by:TimYates
ID: 13885932
>>  Yep a view like that would be something I would like.

Does FExplorer work on your phone?  (I doubt it, but it might) :-/
0
 
LVL 2

Author Comment

by:thor918
ID: 13886000
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
 
LVL 35

Expert Comment

by:TimYates
ID: 13886070
>> is it even written in personal java?

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

0
 
LVL 2

Author Comment

by:thor918
ID: 13887620
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
 
LVL 2

Author Comment

by:thor918
ID: 13891053
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
 
LVL 2

Author Comment

by:thor918
ID: 13891106
is someone is curious on how it looks :
http://home.no.net/thor918/pjava/pxxxjavalist.png
0
 
LVL 35

Accepted Solution

by:
TimYates earned 1000 total points
ID: 13892740
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
 
LVL 2

Author Comment

by:thor918
ID: 13899200
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses
Course of the Month15 days, 21 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question