Picture in JList!

hi,
i want to add a picture in the JList in such a way that it comes befor any string in a jlist
please help me in this regard
thanks,

Try this: don't forget to change this 2 lines
ImageIcon i1 = new ImageIcon("im1.gif");
ImageIcon i2 = new ImageIcon("im2.gif");
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
public class JlistR extends JFrame 
     Vector      v  = new Vector();
     JList       jc = new JList(v);
     JScrollPane js = new JScrollPane(jc);
public JlistR()
     addWindowListener(new WindowAdapter()
    {     public void windowClosing(WindowEvent ev)
          {     dispose();
               System.exit(0);}});
     for (int j=0; j < 70; j++)     v.add(""+j+"a  d"+j*120);
       setBounds(1,1,500,300);
     getContentPane().add(js);
     js.setPreferredSize(new Dimension(200,199));
     jc.setSelectedIndex(1);
     jc.setCellRenderer(new MyCellRenderer());
     getContentPane().setLayout(new FlowLayout());
     setVisible(true);
public class MyCellRenderer extends JLabel implements ListCellRenderer
     ImageIcon i1 = new ImageIcon("im1.gif");
     ImageIcon i2 = new ImageIcon("im2.gif");
public Component getListCellRendererComponent(JList list,
                         Object  value,           // value to display
                         int     index,           // cell index
                         boolean isSelected,      // is the cell selected
                         boolean cellHasFocus)    // the list and the cell have the focus
     setOpaque(true);
     if (index%2 == 1) setBackground(Color.white);
          else          setBackground(Color.lightGray);
     if (isSelected)
          setBackground(Color.gray);
          setIcon(i1);
     else
          setIcon(i2);
       setForeground(Color.black);
     setText(value.toString());
     return(this);
public static void main (String[] args) 
     new JlistR();
Noah
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
public class JlistR extends JFrame
     Vector v = new Vector();
     JList jc = new JList(v);
     JScrollPane js = new JScrollPane(jc);
public JlistR()
     addWindowListener(new WindowAdapter()
{     public void windowClosing(WindowEvent ev)
          {     dispose();
               System.exit(0);}});
     for (int j=0; j < 70; j++)     v.add(""+j+"a d"+j*120);
     setBounds(1,1,500,300);
     getContentPane().add(js);
     js.setPreferredSize(new Dimension(200,199));
     jc.setSelectedIndex(1);
     jc.setCellRenderer(new MyCellRenderer());
     getContentPane().setLayout(new FlowLayout());
     setVisible(true);
public class MyCellRenderer extends JLabel implements ListCellRenderer
     ImageIcon i1 = new ImageIcon("im1.gif");
     ImageIcon i2 = new ImageIcon("im2.gif");
public Component getListCellRendererComponent(JList list,
                         Object value, // value to display
                         int index, // cell index
                         boolean isSelected, // is the cell selected
                         boolean cellHasFocus) // the list and the cell have the focus
     setOpaque(true);
     if (index%2 == 1) setBackground(Color.white);
          else setBackground(Color.lightGray);
     if (isSelected)
          setBackground(Color.gray);
          setIcon(i1);
     else
          setIcon(i2);
     setForeground(Color.black);
     setText(value.toString());
     return(this);
public static void main (String[] args)
     new JlistR();

Similar Messages

  • Resizing a JList with variable row heights, not updating the "picture"

    Firstly I would like to apologize for posting this Swing question here, but I was unable to find the Swing category, if someone could direct me to that I would be most grateful.
    Ok, so in abstract what I am trying to do is have a JList with resizable rows to act as a row header for a JTable (exactly like the row headers in OO Calc or MS Excel).
    What I have is a RowHeaderRenderer:
    public class RowHeaderRenderer extends JLabel implements ListCellRendererand it has a private member:
    private Vector<Integer>        _rowHeights            = new Vector<Integer>();which contains a list of all the variable row heights.
    Then there is my getListCellRendererComponent method:
        public Component getListCellRendererComponent(    JList         list,
                                                          Object        value,
                                                          int           index,
                                                          boolean       isSelected,
                                                          boolean       cellHasFocus)
            // Make sure the value is not null
            if(value == null)
                this.setText("");
            else
                this.setText(value.toString());
            // This is where height of the row is actually changed
            // This method is fed values from the _rowHeights vector
            this.setPreferredSize(new Dimension(this.getPreferredSize().width, _rowHeights.elementAt(index)));
            return this;
        }And then I have a row header:
    public class RowHeader extends JList implements TableModelListener, MouseListener, MouseMotionListenerand you may be interested in its constructor:
        public RowHeader(JTable table)
            _table = table;
            _rowHeaderRenderer = new RowHeaderRenderer(_table);
            this.setFixedCellWidth                        (50);
            this.setCellRenderer                        (_rowHeaderRenderer);
            // TODO: grab this value from the parent view table
            JScrollPane panel = new JScrollPane();
            this.setBackground(panel.getBackground());
            this.addMouseMotionListener                    (this);
            this.addMouseListener                        (this);
            this.setModel                                (new DefaultListModel());
            table.getModel().addTableModelListener        (this);
            this.tableChanged                            (new TableModelEvent(_table.getModel()));
        }and as you can see from my mouse dragged event:
        public void mouseDragged(MouseEvent e)
            if(_resizing == true)
                int resizingRowHeight = _rowHeaderRenderer.getRowHeight(_resizingRow);
                _rowHeaderRenderer.setRowHeight(_resizingRow, resizingRowHeight + (e.getPoint().y - _cursorPreviousY));
                _cursorPreviousY = e.getPoint().y;  
        }all I am doing is passing the rowHeaderRenderer the values the currently resizing row should be, which works fine. The values are being changed and are accurate.
    The issue I am having is that while this dragging is going on the row does not appear to be resizing. In other words the "picture" of the row remains unchanged even though I change the values in the renderer. I tried calling:
    this.validate();and
    this.repaint();at the end of that mousedDragged method, but to no avail, neither of them worked.
    Again, I verified that I am passing the correct data in the RowHeaderRenderer.
    So, anyone have any ideas how I should get the image of the RowHeader (JList) to update after calling my MouseDragged event?
    Thank you for your time,
    Brandon

    I was able to fix this some time ago. Here is the solution:
         public void mouseDragged(MouseEvent e)
              if(_resizing == true)
                   int newHeight = _previousHeight + (e.getPoint().y - _cursorPreviousY);
                   if(newHeight < _minRowHeight)
                        newHeight = _minRowHeight;
                   _rowHeaderRenderer.setRowHeight(_resizingRow, newHeight);
                   _table.setRowHeight(_resizingRow, newHeight);
              this.updateUI();
         }

  • JList with aligned pictures

    What would be the best way to make a JList with a picture for each item?
    I have all the pictures loaded as ImageIcons btw.

    Write a custom list renderer, see http://java.sun.com/j2se/1.4.1/docs/api/javax/swing/ListCellRenderer.html
    Then, to get the text aligned, you'll need to use the setIconTextGap method of JLabel. If the maximum icon width is 16 and your current icon is 13 pixels wide, then just set the icon-text-gab to 3.
    Something like this:
    import java.awt.*;
    import javax.swing.*;
    public class Dummy
         public static void main(String [] args)
              JList list = new JList(new Object[]{
                   new JLabel("small", new ImageIcon("d:/java/resources/java logo 16x16.png"), JLabel.LEFT),
                   new JLabel("large", new ImageIcon("d:/java/resources/java logo 32x32.png"), JLabel.LEFT)
              list.setCellRenderer(new MyCellRenderer());
              JFrame f = new JFrame();
              f.getContentPane().add(list);
              f.setSize(400,400);
              f.setVisible(true);
         static class MyCellRenderer extends JLabel implements ListCellRenderer
              public MyCellRenderer()
                   setOpaque(true);
              public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
                   JLabel label = (JLabel)value;
                   setText(label.getText());
                   setIconTextGap(4 + 32 - label.getIcon().getIconWidth());
                   setIcon(label.getIcon());
                   setBackground(isSelected ? Color.red : Color.white);
                   setForeground(isSelected ? Color.white : Color.black);
                   return this;

  • How to center JList  items

    Hi,
    I want to center my Jlist item instead of leave them in the left like usual. My List contains pictures and for the beauty of the design it's better to have the image in the center of each cells. How to do it?
    thanks.

    Do you know how to make a JLabel which contains a centred icon? Now make a ListCellRenderer that uses one of those to render your images in the JList.

  • How do I put a picture in my gui?

    Can anyone tell me how to put a picture in my gui?
    Thank you

    Someone used my code before I added this new stuff. They took it word for word.
    I apologize if you are getting frustrated with me. Please know I am working very hard on this. Learning Java in just a few weeks to me is impossible so I wil take all the help i can get. I know it must seem very easy to you because you know it very well but I am just learning, maybe you can remember back to when you were learning?
    Anyways i tried this code but it did not work. I didn't get any errors when compiling but nothing showed.:
    JLabel label = new JLabel ( new ImageIcon("test.gif"));
        f.getContentPane().add(label, BorderLayout.NORTH);Here is my code but please keep in mind that alot of it has comments because I have not actually worked on the code for it yet. Just getting the buttons set up is where I am at.
    I really wish that i could look at the examples and just have it be easy to code from it. I tried and I tried and sometimes I can get it but sometimes I just can't.
    Thank you,
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.JFrame.*;
    import java.io.*;
    class Testing
      java.util.List<DVD> dvds = new java.util.ArrayList<DVD>();
      JTextField tfTitle = new JTextField(15);
      JTextField tfGenre = new JTextField(15);
      JTextField tfProductNumber = new JTextField();
      JTextField tfPrice = new JTextField();
      JTextField tfQuantity = new JTextField();
      JTextField tfInventoryValue = new JTextField();
      DefaultListModel dlm = new DefaultListModel();
      JList list = new JList(dlm);
      public void buildGUI()
        JButton btnLoadfile = new JButton("Load File");
        JButton btnAdd = new JButton("Add");
        JButton btnModify = new JButton("Modify");
        JButton btnDelete = new JButton("Delete");
        JButton btnSearch = new JButton("Search");
        JButton btnSave = new JButton("Save");
        JButton btnFirst = new JButton ("First");
        JButton btnPrevious = new JButton ("Previous");
        JButton btnNext = new JButton ("Next");
        JButton btnLast = new JButton ("Last");
        JPanel p1 = new JPanel(new BorderLayout());
        JPanel p = new JPanel(new GridLayout(6,2));
        p.add(new JLabel("DVD Title: "));
        p.add(tfTitle);
        p.add(new JLabel("Genre: "));
        p.add(tfGenre);
        p.add(new JLabel("Product Number: "));
        p.add(tfProductNumber);
        p.add(new JLabel("Price per Unit: "));
        p.add(tfPrice);
        p.add(new JLabel("Quantity on Hand: "));
        p.add(tfQuantity);
        p.add(new JLabel("Inventory Value: "));
        p.add(tfInventoryValue);
        p1.add(p,BorderLayout.NORTH);
        JPanel p2 = new JPanel();
        p2.add(btnLoadfile);
        p2.add(btnAdd);
        p2.add(btnModify);
        p2.add(btnDelete);
        p2.add(btnSearch);
        p2.add(btnSearch);
        p2.add(btnSave);
        p2.add(btnFirst);
        p2.add(btnPrevious);
        p2.add(btnNext);
        p2.add(btnLast);
        p1.add(p2,BorderLayout.CENTER);
        JFrame f = new JFrame();
        //f.setIconImage(new ImageIcon("test.gif").getImage());
        JLabel label = new JLabel ( new ImageIcon("test.gif"));
        f.getContentPane().add(label, BorderLayout.NORTH);
        f.getContentPane().add(p1,BorderLayout.NORTH);
        JScrollPane sp = new JScrollPane(list);
        f.getContentPane().add(sp,BorderLayout.CENTER);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.pack();
        f.setLocationRelativeTo(null);
        dvds.add(new DVD("StarWars","Action","1245",10.00,5,55.00));
        dvds.add(new DVD("OfficeSpace","Comedy","9821",20.00,5,105.00));
        dvds.add(new DVD("Lost","Drama","9382",25.00,2,52.50));
        dvds.add(new DVD("Friends","Comedy","9824",18.00,5,94.50));
        dvds.add(new DVD("Superman","Action","3652",20.00,10,210.00));
        dvds.add(new DVD("Batman","Action","9583",17.00,7,124.95));
        dvds.add(new DVD("Cinderella","Family","2734",19.00,8,159.60));
        setList();
        f.setVisible(true);
        f.setIconImage(new ImageIcon("Images/test.gif").getImage());
        btnAdd.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent ae){
            dvds.add(new DVD(tfTitle.getText(),tfGenre.getText(),tfProductNumber.getText(),
                                    Double.parseDouble(tfPrice.getText()),
                                   Integer.parseInt(tfQuantity.getText()),
                                   Double.parseDouble(tfInventoryValue.getText())));
            setList();
            clearTextFields();
        btnDelete.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent ae){
            int index = list.getSelectedIndex();
            dvds.remove(index);
            setList();
            clearTextFields();
            btnModify.addActionListener(new ActionListener(){
               public void actionPerformed(ActionEvent ae){
             int index = list.getSelectedIndex();
            dvds.remove(index);
                 dvds.add(new DVD(tfTitle.getText(),tfGenre.getText(),tfProductNumber.getText(),
                                         Double.parseDouble(tfPrice.getText()),
                                        Integer.parseInt(tfQuantity.getText()),
                                        Double.parseDouble(tfInventoryValue.getText())));
                 setList();
                 clearTextFields();
    // btnSave.addActionListener(new ActionListener(){
    //          public void actionPerformed(ActionEvent ae){
    //                try
    //                  File file = new File("TestSave.txt");
    //                  PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file)));
    //                  out.println("a line");
    //                  out.println("another line");
    //                  out.close();//<---------very important
    //                catch(IOException ioe){ioe.printStackTrace();}
                  //dvds.add(new DVD(tfTitle.getText(),tfGenre.getText(),tfProductNumber.getText(),
                  //                            Double.parseDouble(tfPrice.getText()),
                  //                           Integer.parseInt(tfQuantity.getText()),
                  //                           Double.parseDouble(tfInventoryValue.getText())));
    //                  setList();
    //                  clearTextFields();
    //    btnSearch.addActionListener(new ActionListener(){
    //          public void actionPerformed(ActionEvent ae){
    //               String Search =
    //               JOptionPane.showInputDialog("Enter name of Movie");
    //               int x =0;
    //               for(x = 0; x < dvds.size(); x++)
    //            DVD dvd = (DVD)dvds.get(x);
    //  if(dvd.title.equals(searchTitle))// or
    //            if(dvd.title.equalsIgnoreCase(searchTitle))
    //        list.setSelectedIndex(x);
    //        break;
    //          if(x == dvds.size()) System.out "not found";
        btnPrevious.addActionListener(new ActionListener(){
               public void actionPerformed(ActionEvent ae){
                 DVD dvd = (DVD)dvds.get(list.getSelectedIndex());
                                int index = list.getSelectedIndex()-1;
                                 if (index <0) index = dvds.size()-1;
                                list.setSelectedIndex(index);
         btnNext.addActionListener(new ActionListener(){
                    public void actionPerformed(ActionEvent ae){
                                  DVD dvd = (DVD)dvds.get(list.getSelectedIndex());
                                   //int index = list.getSelectedIndex()+1;
                                   int index = (list.getSelectedIndex()+1) % dvds.size();
                                list.setSelectedIndex(index);
        list.addListSelectionListener(new ListSelectionListener(){
          public void valueChanged(ListSelectionEvent lse){
            if(lse.getValueIsAdjusting() == false)
              int index = list.getSelectedIndex();//<---
              if(index > -1)//<---
                DVD dvd = (DVD)dvds.get(index);//<---
                tfTitle.setText(dvd.title);
                tfGenre.setText(dvd.genre);
                tfProductNumber.setText(dvd.productNumber);
                tfPrice.setText(""+dvd.price);
                tfQuantity.setText(""+dvd.quantity);
                tfInventoryValue.setText(""+dvd.inventoryValue);
      public void setList()
        dlm.clear();
        for(int x = 0, y = dvds.size(); x < y; x++)
          dlm.addElement((DVD)dvds.get(x));
      public void clearTextFields()
        tfTitle.setText("");
        tfGenre.setText("");
        tfProductNumber.setText("");
        tfPrice.setText("");
        tfQuantity.setText("");
        tfInventoryValue.setText("");
        tfTitle.requestFocusInWindow();
      public static void main(String[] args)
        EventQueue.invokeLater(new Runnable(){
          public void run(){
            new Testing().buildGUI();
    class DVD
      String title;
      String genre;
      String productNumber;
      double price;
      int quantity;
      double inventoryValue;
      public DVD(String t,String g, String pn, double p, int q, double i)
        title = t; genre = g; productNumber = pn; price = p; quantity = q; inventoryValue = i;
      public String toString(){return title;}
    }

  • Click an item twice or more in JList

    Hy,
    I have create a JList with some animal's name in it. When I click on one of the animal's
    name for the FIRST time, it appears in a JTextArea.
    What I want is that when I click on that same name consecutively, it appears again in that
    JTextArea. Can anyone please send me the code for doing that. Its very urgent.
    Here are my code:
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class PropertyWindow extends JFrame implements ListSelectionListener, ActionListener {
         private JList list;
         private JScrollPane scrollTextArea;
         private JTextArea textArea;
         private String text;
         private Vector imageNames;
         private JLabel picture;
         private DefaultListModel listModel;
         public PropertyWindow () {
              super("Property Window");
              //create a text area
              textArea = new JTextArea();
              textArea.setFont(new Font("Arial", Font.PLAIN, 16));
              textArea.setLineWrap(true);
              textArea.setWrapStyleWord(true);
              //create a scrollpane and add it to the text area
              scrollTextArea = new JScrollPane(textArea);
              scrollTextArea.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
              scrollTextArea.setPreferredSize(new Dimension(200,35));
              //create a list of button and add it to the JPanel
              JButton addButton = new JButton("+");
              JButton subtractButton = new JButton("-");
              JButton multiplyButton = new JButton("x");
              JButton divideButton = new JButton("/");
              JButton assignButton = new JButton("=");
              JButton equalButton = new JButton("= =");
              JButton greaterButton = new JButton(">");
              JButton G_EqualButton = new JButton("> =");
              JButton lessButton = new JButton("<");
              JButton L_EqualButton = new JButton("< =");
              JButton notEqualButton = new JButton("! =");
              JButton oneButton = new JButton("1");
              JButton twoButton = new JButton("2");
              JButton threeButton = new JButton("3");
              JButton fourButton = new JButton("4");
              JButton fiveButton = new JButton("5");
              JButton sixButton = new JButton("6");
              JButton sevenButton = new JButton("7");
              JButton eightButton = new JButton("8");
              JButton nineButton = new JButton("9");
              JButton zeroButton = new JButton("0");
              addButton.setActionCommand ("+");
              subtractButton.setActionCommand("-");
              multiplyButton.setActionCommand("x");
              divideButton.setActionCommand ("/");
              assignButton.setActionCommand ("=");
              equalButton.setActionCommand ("= =");
              greaterButton.setActionCommand (">");
              G_EqualButton.setActionCommand ("> =");
              lessButton.setActionCommand ("<");
              L_EqualButton.setActionCommand ("< =");
              notEqualButton.setActionCommand("! =");
              oneButton.setActionCommand ("1");
              twoButton.setActionCommand ("2");
              threeButton.setActionCommand ("3");
              fourButton.setActionCommand ("4");
              fiveButton.setActionCommand ("5");
              sixButton.setActionCommand ("6");
              sevenButton.setActionCommand ("7");
              eightButton.setActionCommand ("8");
              nineButton.setActionCommand ("9");
              zeroButton.setActionCommand ("0");
              JPanel buttonPane = new JPanel();
              buttonPane.setBorder(
                                            BorderFactory.createCompoundBorder(
                                       BorderFactory.createCompoundBorder(
                                  BorderFactory.createTitledBorder("Arithmetic/Logical Operations"),
                                  BorderFactory.createEmptyBorder(5,5,5,5)),
                                       buttonPane.getBorder()));
              buttonPane.setLayout(new GridLayout (3,7));
              buttonPane.add(addButton);
              buttonPane.add(subtractButton);
              buttonPane.add(multiplyButton);
              buttonPane.add(divideButton);
              buttonPane.add(assignButton);
              buttonPane.add(equalButton);
              buttonPane.add(greaterButton);
              buttonPane.add(G_EqualButton);
              buttonPane.add(lessButton);
              buttonPane.add(L_EqualButton);
              buttonPane.add(notEqualButton);
              buttonPane.add(oneButton);
              buttonPane.add(twoButton);
              buttonPane.add(threeButton);
              buttonPane.add(fourButton);
              buttonPane.add(fiveButton);
              buttonPane.add(sixButton);
              buttonPane.add(sevenButton);
              buttonPane.add(eightButton);
              buttonPane.add(nineButton);
              buttonPane.add(zeroButton);
              addButton.addActionListener(this);
              subtractButton.addActionListener(this);
              multiplyButton.addActionListener(this);
              divideButton.addActionListener(this);
              assignButton.addActionListener(this);
              equalButton.addActionListener(this);
              greaterButton.addActionListener(this);
              G_EqualButton.addActionListener(this);
              lessButton.addActionListener(this);
              L_EqualButton.addActionListener(this);
              notEqualButton.addActionListener(this);
              oneButton.addActionListener(this);
              twoButton.addActionListener(this);
              threeButton.addActionListener(this);
              fourButton.addActionListener(this);
              fiveButton.addActionListener(this);
              sixButton.addActionListener(this);
              sevenButton.addActionListener(this);
              eightButton.addActionListener(this);
              nineButton.addActionListener(this);
              zeroButton.addActionListener(this);
              //create the 'ok' and 'cancel' button
              JButton okButton = new JButton("Ok");
              JButton cancelButton = new JButton("Cancel");
              okButton.setActionCommand("Ok");
              okButton.addActionListener(this);
              cancelButton.setActionCommand("Cancel");
              cancelButton.addActionListener(this);
              JPanel controlPane = new JPanel();
              controlPane.setLayout(new FlowLayout());
              controlPane.add(okButton);
              controlPane.add(cancelButton);
              //create a Jlist where to insert variables
              listModel = new DefaultListModel();
    listModel.addElement("dog");
    listModel.addElement("cat");
    listModel.addElement("rat");
    listModel.addElement("rabbit");
    listModel.addElement("cow");
              list = new JList(listModel);
              list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
              //list.setSelectedIndex(0);
              list.addListSelectionListener(this);
              JScrollPane scrollList = new JScrollPane(list);
              scrollList.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
              scrollList.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollList.setPreferredSize(new Dimension(200,300));
              scrollList.setBorder(
                                            BorderFactory.createCompoundBorder(
                                       BorderFactory.createCompoundBorder(
                        BorderFactory.createTitledBorder("Variables"),
                        BorderFactory.createEmptyBorder(5,5,5,5)),
                                       scrollList.getBorder()));
              //create a pane and put the scroll list and ok/cancel button in it
              JPanel rightPane = new JPanel();
              BoxLayout rightBox = new BoxLayout(rightPane, BoxLayout.Y_AXIS);
              rightPane.setLayout(rightBox);
              rightPane.add(scrollList);
              rightPane.add(controlPane);
              //create a pane and put the scroll text area and arithmetic button in it
              JPanel leftPane = new JPanel();
              BoxLayout leftBox = new BoxLayout(leftPane, BoxLayout.Y_AXIS);
              leftPane.setLayout(leftBox);
              leftPane.add(scrollTextArea);
              leftPane.add(buttonPane);
              //add both pane to the container
              JPanel contentPane = new JPanel();
              BoxLayout box = new BoxLayout(contentPane, BoxLayout.X_AXIS);
              contentPane.setLayout(box);
              contentPane.add(leftPane);
              contentPane.add(rightPane);
    setContentPane(contentPane);
         public void valueChanged(ListSelectionEvent e) {
         if (e.getValueIsAdjusting() == false) {
         if (list.getSelectedIndex() == -1) {
              //No selection, disable fire button.
         else {
              //Selection, update text field.
         String name = list.getSelectedValue().toString();
         textArea.append(" " + name + " ");
         public void actionPerformed(ActionEvent e) {
              String cmd = e.getActionCommand();
              if (cmd.equals("Ok")) {
                   // save current textarea
                   text = textArea.getText();
                   System.out.println(text);
                   dispose();
                   setVisible(false);
              if (cmd.equals("Cancel")) {
                   dispose();
                   setVisible(false);
              if (cmd.equals("+")) {
                   textArea.append(" + ");
              if (cmd.equals("-")) {
                   textArea.append(" - ");
              if (cmd.equals("x")) {
                   textArea.append(" x ");
              if (cmd.equals("/")) {
                   textArea.append(" / ");
              if (cmd.equals("=")) {
                   textArea.append(" = ");
              if (cmd.equals("= =")) {
                   textArea.append(" == ");
              if (cmd.equals(">")) {
                   textArea.append(" > ");
              if (cmd.equals("> =")) {
                   textArea.append(" >= ");
              if (cmd.equals("<")) {
                   textArea.append(" < ");
              if (cmd.equals("< =")) {
                   textArea.append(" <= ");
              if (cmd.equals("! =")) {
                   textArea.append(" != ");
              if (cmd.equals("1")) {
                   textArea.append("1");
              if (cmd.equals("2")) {
                   textArea.append("2");
              if (cmd.equals("3")) {
                   textArea.append("3");
              if (cmd.equals("4")) {
                   textArea.append("4");
              if (cmd.equals("5")) {
                   textArea.append("5");
              if (cmd.equals("6")) {
                   textArea.append("6");
              if (cmd.equals("7")) {
                   textArea.append("7");
              if (cmd.equals("8")) {
                   textArea.append("8");
              if (cmd.equals("9")) {
                   textArea.append("9");
              if (cmd.equals("0")) {
                   textArea.append("0");
         public static void main(String args []) {
         JFrame frame = new PropertyWindow();
         frame.addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
         System.exit(0);
         frame.pack();
         frame.setVisible(true);
         frame.setResizable(false);
    }

    Morten,
    I have since found that the problem is related to the .DS_store files. If you delete it from the parent folder, the ghost disapears. I found a little application that does this and is easy to use, it's called "DS_Store cleaner" and it's free. It doesn't solve the problem for the future though, but it might illimenate any corrupted .DS_Store files on the server.
    Another thing I read, but didn't implement because of the side effects is to set the clients to NOT write the DS_Store on the server. This of corse means that they won't have their settings kept when reopening the folder, that's why I didn't implement it yet, still need to see if it's worth it.
    Here is the URL from Apple tech note
    http://docs.info.apple.com/article.html?artnum=301711
    Keep me posted
    Jeff

  • Selecting an item twice in JList

    Hy,
    I have create a JList with some animal's name in it. When I click on one of the animal's
    name for the FIRST time, it appears in a JTextArea.
    What I want is that when I click on that same name consecutively, it appears again in that
    JTextArea. Can anyone please send me the code for doing that. Its very urgent.
    Here are my code:
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class PropertyWindow extends JFrame implements ListSelectionListener, ActionListener {
         private JList list;
         private JScrollPane scrollTextArea;
         private JTextArea textArea;
         private String text;
         private Vector imageNames;
         private JLabel picture;
         private DefaultListModel listModel;
         public PropertyWindow () {
              super("Property Window");
              //create a text area
              textArea = new JTextArea();
              textArea.setFont(new Font("Arial", Font.PLAIN, 16));
              textArea.setLineWrap(true);
              textArea.setWrapStyleWord(true);
              //create a scrollpane and add it to the text area
              scrollTextArea = new JScrollPane(textArea);
              scrollTextArea.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
              scrollTextArea.setPreferredSize(new Dimension(200,35));
              //create a list of button and add it to the JPanel
              JButton addButton = new JButton("+");
              JButton subtractButton = new JButton("-");
              JButton multiplyButton = new JButton("x");
              JButton divideButton = new JButton("/");
              JButton assignButton = new JButton("=");
              JButton equalButton = new JButton("= =");
              JButton greaterButton = new JButton(">");
              JButton G_EqualButton = new JButton("> =");
              JButton lessButton = new JButton("<");
              JButton L_EqualButton = new JButton("< =");
              JButton notEqualButton = new JButton("! =");
              JButton oneButton = new JButton("1");
              JButton twoButton = new JButton("2");
              JButton threeButton = new JButton("3");
              JButton fourButton = new JButton("4");
              JButton fiveButton = new JButton("5");
              JButton sixButton = new JButton("6");
              JButton sevenButton = new JButton("7");
              JButton eightButton = new JButton("8");
              JButton nineButton = new JButton("9");
              JButton zeroButton = new JButton("0");
              addButton.setActionCommand ("+");
              subtractButton.setActionCommand("-");
              multiplyButton.setActionCommand("x");
              divideButton.setActionCommand ("/");
              assignButton.setActionCommand ("=");
              equalButton.setActionCommand ("= =");
              greaterButton.setActionCommand (">");
              G_EqualButton.setActionCommand ("> =");
              lessButton.setActionCommand ("<");
              L_EqualButton.setActionCommand ("< =");
              notEqualButton.setActionCommand("! =");
              oneButton.setActionCommand ("1");
              twoButton.setActionCommand ("2");
              threeButton.setActionCommand ("3");
              fourButton.setActionCommand ("4");
              fiveButton.setActionCommand ("5");
              sixButton.setActionCommand ("6");
              sevenButton.setActionCommand ("7");
              eightButton.setActionCommand ("8");
              nineButton.setActionCommand ("9");
              zeroButton.setActionCommand ("0");
              JPanel buttonPane = new JPanel();
              buttonPane.setBorder(
                                            BorderFactory.createCompoundBorder(
                                       BorderFactory.createCompoundBorder(
                                  BorderFactory.createTitledBorder("Arithmetic/Logical Operations"),
                                  BorderFactory.createEmptyBorder(5,5,5,5)),
                                       buttonPane.getBorder()));
              buttonPane.setLayout(new GridLayout (3,7));
              buttonPane.add(addButton);
              buttonPane.add(subtractButton);
              buttonPane.add(multiplyButton);
              buttonPane.add(divideButton);
              buttonPane.add(assignButton);
              buttonPane.add(equalButton);
              buttonPane.add(greaterButton);
              buttonPane.add(G_EqualButton);
              buttonPane.add(lessButton);
              buttonPane.add(L_EqualButton);
              buttonPane.add(notEqualButton);
              buttonPane.add(oneButton);
              buttonPane.add(twoButton);
              buttonPane.add(threeButton);
              buttonPane.add(fourButton);
              buttonPane.add(fiveButton);
              buttonPane.add(sixButton);
              buttonPane.add(sevenButton);
              buttonPane.add(eightButton);
              buttonPane.add(nineButton);
              buttonPane.add(zeroButton);
              addButton.addActionListener(this);
              subtractButton.addActionListener(this);
              multiplyButton.addActionListener(this);
              divideButton.addActionListener(this);
              assignButton.addActionListener(this);
              equalButton.addActionListener(this);
              greaterButton.addActionListener(this);
              G_EqualButton.addActionListener(this);
              lessButton.addActionListener(this);
              L_EqualButton.addActionListener(this);
              notEqualButton.addActionListener(this);
              oneButton.addActionListener(this);
              twoButton.addActionListener(this);
              threeButton.addActionListener(this);
              fourButton.addActionListener(this);
              fiveButton.addActionListener(this);
              sixButton.addActionListener(this);
              sevenButton.addActionListener(this);
              eightButton.addActionListener(this);
              nineButton.addActionListener(this);
              zeroButton.addActionListener(this);
              //create the 'ok' and 'cancel' button
              JButton okButton = new JButton("Ok");
              JButton cancelButton = new JButton("Cancel");
              okButton.setActionCommand("Ok");
              okButton.addActionListener(this);
              cancelButton.setActionCommand("Cancel");
              cancelButton.addActionListener(this);
              JPanel controlPane = new JPanel();
              controlPane.setLayout(new FlowLayout());
              controlPane.add(okButton);
              controlPane.add(cancelButton);
              //create a Jlist where to insert variables
              listModel = new DefaultListModel();
    listModel.addElement("dog");
    listModel.addElement("cat");
    listModel.addElement("rat");
    listModel.addElement("rabbit");
    listModel.addElement("cow");
              list = new JList(listModel);
              list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
              //list.setSelectedIndex(0);
              list.addListSelectionListener(this);
              JScrollPane scrollList = new JScrollPane(list);
              scrollList.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
              scrollList.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollList.setPreferredSize(new Dimension(200,300));
              scrollList.setBorder(
                                            BorderFactory.createCompoundBorder(
                                       BorderFactory.createCompoundBorder(
                        BorderFactory.createTitledBorder("Variables"),
                        BorderFactory.createEmptyBorder(5,5,5,5)),
                                       scrollList.getBorder()));
              //create a pane and put the scroll list and ok/cancel button in it
              JPanel rightPane = new JPanel();
              BoxLayout rightBox = new BoxLayout(rightPane, BoxLayout.Y_AXIS);
              rightPane.setLayout(rightBox);
              rightPane.add(scrollList);
              rightPane.add(controlPane);
              //create a pane and put the scroll text area and arithmetic button in it
              JPanel leftPane = new JPanel();
              BoxLayout leftBox = new BoxLayout(leftPane, BoxLayout.Y_AXIS);
              leftPane.setLayout(leftBox);
              leftPane.add(scrollTextArea);
              leftPane.add(buttonPane);
              //add both pane to the container
              JPanel contentPane = new JPanel();
              BoxLayout box = new BoxLayout(contentPane, BoxLayout.X_AXIS);
              contentPane.setLayout(box);
              contentPane.add(leftPane);
              contentPane.add(rightPane);
    setContentPane(contentPane);
         public void valueChanged(ListSelectionEvent e) {
         if (e.getValueIsAdjusting() == false) {
         if (list.getSelectedIndex() == -1) {
              //No selection, disable fire button.
         else {
              //Selection, update text field.
         String name = list.getSelectedValue().toString();
         textArea.append(" " + name + " ");
         public void actionPerformed(ActionEvent e) {
              String cmd = e.getActionCommand();
              if (cmd.equals("Ok")) {
                   // save current textarea
                   text = textArea.getText();
                   System.out.println(text);
                   dispose();
                   setVisible(false);
              if (cmd.equals("Cancel")) {
                   dispose();
                   setVisible(false);
              if (cmd.equals("+")) {
                   textArea.append(" + ");
              if (cmd.equals("-")) {
                   textArea.append(" - ");
              if (cmd.equals("x")) {
                   textArea.append(" x ");
              if (cmd.equals("/")) {
                   textArea.append(" / ");
              if (cmd.equals("=")) {
                   textArea.append(" = ");
              if (cmd.equals("= =")) {
                   textArea.append(" == ");
              if (cmd.equals(">")) {
                   textArea.append(" > ");
              if (cmd.equals("> =")) {
                   textArea.append(" >= ");
              if (cmd.equals("<")) {
                   textArea.append(" < ");
              if (cmd.equals("< =")) {
                   textArea.append(" <= ");
              if (cmd.equals("! =")) {
                   textArea.append(" != ");
              if (cmd.equals("1")) {
                   textArea.append("1");
              if (cmd.equals("2")) {
                   textArea.append("2");
              if (cmd.equals("3")) {
                   textArea.append("3");
              if (cmd.equals("4")) {
                   textArea.append("4");
              if (cmd.equals("5")) {
                   textArea.append("5");
              if (cmd.equals("6")) {
                   textArea.append("6");
              if (cmd.equals("7")) {
                   textArea.append("7");
              if (cmd.equals("8")) {
                   textArea.append("8");
              if (cmd.equals("9")) {
                   textArea.append("9");
              if (cmd.equals("0")) {
                   textArea.append("0");
         public static void main(String args []) {
         JFrame frame = new PropertyWindow();
         frame.addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
         System.exit(0);
         frame.pack();
         frame.setVisible(true);
         frame.setResizable(false);
    }

    If the whole point of the JList is to display the information in the JTextArea and you don't mind losing the selection in the JList I have a solution for you (just had something similar come up).
    Add the following lines in the public void valueChanged(ListSelectionEvent e) method:
    listModel = list.getModel();
    list.setModel(listModel);
    This causes the particular animal in the JList to be un-selected and with each subsequent clicks on that JList selection a new ListSelectionEvent will fire and the text will keep appending.
    This gives the effect of a JList just being a bunch of buttons that can be clicked on all you want.

  • JList to JList Selection Exchange

    I'm trying to build a GUI for a project where
    Selectable Values can be transfered from one list to
    another. I cant explaine what I mean to well so an ASCII picture may come in handy:
    From: --> To:
    JList <-- JList
    Note: --> and <-- are Buttons to do the swaping.
    I cant seem to Lay this out I've tried GridBag Grid, Box,
    Border as type of ways of laying it out Can someone please help.

    Ok new Quandry!
    How do I transfere JList Data to annother JList and remember avery & gt; is supposed to be > and any <x> are really [x];
    Here is my code I've tried but it doesn't work.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    class LtoL extends JFrame implements ActionListener
         public LtoL()
              String listtest[] = {"one","two","three","four","five","Six"};
              JList rightList = new JList();
              JLabel rightLabel = new JLabel("Selected Processes");
              JList leftList = new JList(listtest);
              JLabel leftLabel =  new JLabel("Available Processes");
              JPanel buttonPanel = new JPanel();
              JPanel buttonPanelNorth =  new JPanel();
              JPanel buttonPanelSouth =  new JPanel();
              JPanel rightSide = new JPanel();
              JPanel leftSide = new JPanel();
              JButton toRight = new JButton("Add Process");
              JButton froRight =  new JButton("Remove Process");
              JButton nextPage =  new JButton("Continue");
              toRight.addActionListener(this);
              froRight.addActionListener(this);
              rightSide.setLayout(new BorderLayout());
              leftSide.setLayout(new BorderLayout());
              rightSide.add(rightLabel,BorderLayout.NORTH);
              rightSide.add(rightList,BorderLayout.CENTER);
              leftSide.add(leftLabel,BorderLayout.NORTH);
              leftSide.add(leftList,BorderLayout.CENTER);
              buttonPanelNorth.setLayout(new BorderLayout());
              buttonPanelSouth.setLayout(new BorderLayout());
              buttonPanel.setLayout(new GridLayout(2,0));
              buttonPanelSouth.add(toRight,BorderLayout.NORTH);
              buttonPanelSouth.add(nextPage,BorderLayout.SOUTH);
              buttonPanelNorth.add(froRight,BorderLayout.SOUTH);
              buttonPanel.add(buttonPanelNorth);
              buttonPanel.add(buttonPanelSouth);
              JPanel mainPanel =  new JPanel();
              mainPanel.setBorder(new EmptyBorder(new Insets(5,5,5,5)));
              mainPanel.setLayout(new GridLayout(0,3));
              mainPanel.add(leftSide);
              mainPanel.add(buttonPanel);
              mainPanel.add(rightSide);
              this.getContentPane().add(mainPanel);
              //Placement 
              Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
              setLocation(dim.width/4-this.getWidth()/2, dim.height/4-this.getHeight()/2);
              //Actions
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              //Show it
              setSize(640,480);
              setResizable(true);
              setVisible(true);
         public void actionPerformed(ActionEvent e)
              if( e.getActionCommand().equals("Add Process"))
                   //on button Add :
              rightList.setSelectedIndices(leftList.getSelectedIndices());
              else
                   //on button remove
              leftList.setSelectedIndices(rightList.getSelectedIndices());
         public static void main(String args[])
              LtoL l = new LtoL();
    }I here are the errors i get as well when i try to compile it.
    cannot resolve symbol leftList or rightList why?

  • Displaying JList holding JLabel with icons of different height screwed up

    I started to create a unix 'make' wrapper, which filters for the binaries being created and display their names and potentially some icon for those in a JList.
    But sometimes the display of the icons is screwed up. It's cut to the size of a pure text (JLabel) line in the JList.
    Below you can find test program.
    You need to put two different sized picture files binary1.jpg and binary2.jpg in the run directory of the java build (i use eclipse)
    and create some test input file like this:
    > cat input
    binary1
    binary2
    binary3
    binary4
    binary5
    binary6
    binary7
    binary8
    binary9
    Set TEST_DIR environment variable to the build run directory.
    Finally start the java class like this:
    > bash -c 'while read line; do echo $line; sleep 1; done' < input| (cd $TEST_DIR; java -classpath $TEST_DIR myTest.MyTest)
    Then you should see the issue.
    ( Don't mind about the JAVA code in general - i know, that there are quite some other issues to fix :-) )
    - many thanks!
    best regards,
    Frank
    ================================================
    package myTest;
    import java.io.*;
    import java.util.HashMap;
    import java.util.Map;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.Dimension;
    import javax.imageio.ImageIO;
    import javax.swing.DefaultListModel;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JList;
    import javax.swing.JScrollPane;
    import javax.swing.ListCellRenderer;
    public class MyTest {
        static class MyCellRenderer extends JLabel implements
                ListCellRenderer<Object> {
            private static final long serialVersionUID = 577071018465376381L;
            public MyCellRenderer() {
                setOpaque(true);
            public Component getListCellRendererComponent(JList<?> list,
                    Object value, int index, boolean isSelected,
                    boolean cellHasFocus) {
                if (value.getClass().equals(JLabel.class)) {
                    JLabel label = JLabel.class.cast(value);
                    setText(label.getText());
                    setIcon(label.getIcon());
                    setBackground(label.getBackground());
                    setForeground(label.getForeground());
                } else {
                    setText(value.toString());
                    setBackground(Color.WHITE);
                    setForeground(Color.BLACK);
                return this;
        static final Map<String, String> fileToPicture = new HashMap<String, String>() {
            private static final long serialVersionUID = 1L;
                put("binary1", "binary1.jpg");
                put("binary2", "binary2.jpg");
        static boolean endProcess;
        static boolean guiStarted;
        static DefaultListModel<Object> listModel;
        static JList<Object> list;
        static public void startGui() {
            JFrame frame = new JFrame("Building...");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setLayout(new BorderLayout());
            listModel = new DefaultListModel<Object>();
            list = new JList<Object>(listModel);
            list.setCellRenderer(new MyCellRenderer());
            list.setLayoutOrientation(JList.VERTICAL);
            list.setFixedCellHeight(-1);
            JScrollPane scrollPane = new JScrollPane(list);
            scrollPane.setPreferredSize(new Dimension(300, 500));
            frame.getContentPane().add(scrollPane, BorderLayout.NORTH);
            JButton ok = new JButton("CLOSE");
            ok.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    endProcess = true;
            frame.getContentPane().add(ok, BorderLayout.SOUTH);
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
            guiStarted = true;
        static private void addElem(String string, Color color) {
            String fileName = fileToPicture.get(string);
            ImageIcon icon = null;
            if (null != fileName) {
                File file = new File(new File(".").getAbsolutePath() + "/"
                        + fileName);
                try {
                    icon = new ImageIcon(ImageIO.read(file));
                } catch (IOException e) {
                    System.err
                            .println("Exception: IOException for trying to read file '"
                                    + file + "'");
                    e.printStackTrace();
            JLabel label = new JLabel(string);
            Color darker = color.darker();
            label.setForeground(darker);
            label.setBackground(Color.WHITE);
            label.setIcon(icon);
            listModel.addElement(label);
            list.ensureIndexIsVisible(list.getModel().getSize() - 1);
        public static void main(String[] args) {
            endProcess = false;
            guiStarted = false;
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    startGui();
            while (!guiStarted) {
                try {
                    Thread.sleep(200);
                } catch (InterruptedException e) {
                    e.printStackTrace();
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line = null;
            try {
                while (!endProcess) {
                    line = br.readLine();
                    if (line == null) {
                        break;
                    addElem(line, Color.BLACK);
                    System.out.println(line);
            } catch (IOException e) {
                e.printStackTrace();
            if (!endProcess) {
                addElem("...DONE", Color.RED);
                while (!endProcess) {
                    try {
                        Thread.sleep(200);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
            System.exit(0);

    I found out, that the issue is caused by trying to use auto-scrolling via line #100:
    list.ensureIndexIsVisible(list.getModel().getSize() - 1);
    this helped to solve it:
    java - ensureIndexIsVisible(int) is not working - Stack Overflow
    The result is:
    if (autoScroll.isSelected()) {
      SwingUtilities.invokeLater(new Runnable() {
         public void run() {
             list.ensureIndexIsVisible(list.getModel().getSize() - 1);
    rgds,
    Frank

  • JList repaint()

    I can't post all my code because it is a very large jumble of crap...but here is the situation:
    -I have a "fillList()" method that returns a String [] of information retrieved from a SQL query. (the size can be different with a max size of 10 every time I call fillList())..this method works fine.
    -I have a frame that creates a window with some buttons a picture and a JList in the constructor by simple getContentPane().add(<component>); (I'll worry about layout later).
    -One of these buttons (next10) updates the JList. Here is the code in the event handler:
    resultList = new JList(fillList(data.query));
    resultScrollPane = new JScrollPane(resultList);
    resultsPanel = new JPanel();
    resultsPanel.add(resultScrollPane, "North");
    resultsPanel.add(prev10, "South");
    if(numResultsLeft > 0) 
      resultsPanel.add(next10, "South");
    getContentPane().add(resultsPanel, "North");
    repaint();oh, and the variables are the following types:
    -resultList is a JList
    -resultScrolPane is a JScrollPane
    -resultsPanel is a JPanel
    -(Am I being too obvious yet?)
    -next10 is a JButton
    -prev10 is a JButton
    Now I've tried this a bunch of different ways, and I can't seem to get the JList info to change. I know the data is passed correctly because when I click the JList...well, the right stuff happens at the right indexes...but the old information is still displayed.

    You the man! Sweet! Yeah, I'm using set functions for everything else that updates, but I didn't know JLists have one too. Super Sweet! Much Thanks!

  • JList - Adding Data & Refreshing

    Hi
    I have two JLists in JDialog. First JList is get populated with some items. I selected some items in the first list and click on ">>" button the selected items has to add to the second list and remove from first list.
    First time getting selected items using the method (getSelectedValues()) and assigning to second list. working fine. Again selected some more items from the first list and trying to assing to second list the items first assigned were vanished and the new items comes into picture. I want to preserve the existing list and add new items to the list.
    Code
    Vector listData = list1.getSelectedValues();
    list2.setListData(listData);
    Thanks
    Hari Babu Popuri

    I am trying to attain similar events as listed in the original post (move selected multiple items from one jList to another). I have searched through hundreds of posts and a few list tutorials. I tried the code listed here, but am getting an error on it.
    on the line:
    Vector listData = list1.getSelectedValues();
    My compiler doesn't like that I'm trying to put Object[] into a Vector. I've tried casting it to a vector and a couple other things, but I'm just lost right now.

  • Java Turduckin: JScrollPane in a JList in a JScrollPane

    Probably a quick answer for someone: I have a JScrollPane containing a JList. The JList has a custom renderer that returns a subclass of JScrollPane: the idea is a scrollable list of individual panels of scrollable text.
    Is this possible? When I run it, it looks ok (the inner scroll bar hilights correctly, etc), but, even after a fair amount of investigation, I can't get the inner scrollbar to respond to the mouse. Can I get JList to forward clicks?
    Many thanks,
    -bmeike

    Renderers return a picture, not something you can interact with.
    Try setting your inner JScrollPane as the editor.

  • I am unable to capture pictures on my Iphone 4s

    Any one assist me how to fix this problem, I am unable to capture the pictures using back camera but I am seeing through it and when I click, it automatically come to home screen.

    If there is No 'X' on any apps you have Downloaded... then check in Restrictions... Settings > General > Restrictions > Deleting Apps  =  Off / On
    Understanding Restrictions  >  http://support.apple.com/kb/HT4213

  • Mini-DVI to Video to SD TV, no NTC display setting, fuzzy B&W picture

    I've seen several posts on this topic but I haven't seen a specific one that addresses my problem. I apologize for rehashing an old topic but I'm fairly desperate at this point.
    I have a Mini-DVI to Video adapter (from Best Buy and yes, I heard they had problems but haven't been able to find exactly what those problems are). I live in the United States. I am trying to connect my Macbook to my SD CRT TV and cannot get it to properly work. My first problem is that I do not have a display selection option for NTSC, 720x468 at 60Hz in my "Display" window. The second problem is that for all of the 60Hz display options that I do have the picture is in B&W and scrolls or displays multiple skinny images.
    Please help!

    The problem with the Dynex adapter, as near as I can tell, is that it doesn't have any EDID data inside of it. The Apple Mini DVI to Video Adapter does have a valid EDID inside of it. That's probably why your MB doesn't know it's connected to a TV, because it isn't being told it is by the plug-and-display driver (EDID), which is either missing or not correctly formed.

  • No picture w/ mini dvi adapter

    ok. So, I have an Apple mini dvi to video adapter. I use it all the time on my tv's using both composite and s-video (s video on my HD flat screen, and composite on m cheaper tv.) Everything works great. no problems. Until I go to my girlfriend's house. I use the composite side to connect to her tv. I believe it is a Sylvannia or something like that. I get no video, just scrambled style lines.
    Now I've seen this before, with my iPod video cable where i had to change the PAL/NATC settings. Something to do with American versus overseas products. No worries. But i can't seem to find those same settings on my MacBook.
    Where do I change the settings so i can watch movies on her tv? like i said, I didn't change anything when i connected it to my tvs, i get great picture.
    Please help !!!! I can't watch another movie with her on my little MacBook screen......

    ME TOO !!!
    I have connected the mini DVI to video adapter with the composite to my TV (about a 5 year old model). Also connected Audio cords to TV, and the audio is wonderful...BUT NO VIDEO! Actually I get about 5 seconds of a DVD or whatever, and then the screen turns blank...just nice audio thru TV. HELP!!!!!!!!!!!!
    Thank you!!

Maybe you are looking for

  • How do I make groups in my contacts

    im trying to put all my football team in one group so I don't have to keep entering 20 numbers each time I message them (just I have done with all my previous phones with no problem). I just can't seem to find how to do it. I've even synced my phone

  • How to connect java to oracle 9i

    Hi guys , i'm still beginner in oracle ,I've created a database and i need to connect a java application to it ,i mention that i'm using netbeans as IDE (tomcat server is embedded with it),please any help.

  • Iphone camera

    i can take a photo easy enough but i cant see it when i click on the thumbnail or will it save to the iphone photo album ....when i go into the album all of my 300 odd photos are gone  ie all photos 0  recently deleted 0  and the message "restoring"

  • I have followed all the instructions to export a slideshow but it does not work

    can someone please tell me why i can not export a slideshow when i used to be able to What has changed

  • Premiere Pro CS6 "startup error" because of no "capable video play module."

    Hi, I need to edit some native 3D video and burn a Blu-ray of it, but cannot run a trial version of Premiere Pro CS6 on a brand new HP DV7-6b78us laptop because I get a prompt that says "Adobe Premiere Pro could not find any capable video play module