JList bug help

there's a bug in JAVA about JList that when you select an item the selectvalue sends it twice
i got an answer but it doesn't work
i build a Jlist from a list of items in a DB, first there put in an string[] then in a vector & then in the JList
can anyone please help me

Swing related questions should be posted in the Swing forum.
there's a bug in JAVA about JList that when you select an item the selectvalue sends it twiceThis is not a bug.
i got an answer but it doesn't workIts nice of you to share this answer. Are we supposed to quess what you have attempted to do.
can anyone please help me Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/list.html]How to Use Lists for a working example on how to write your ListSelectionListener.

Similar Messages

  • How to copy the text from textfield to jlist(please help me)..

    hi to all,i am making chat application , in my program user enters ip in the text field to connect to other computer.whenever user wants to send the message ,he has to enter ip in the text field , all i want to do is to copy the ip from text field to jlist , so user does'nt enter same ip every time , he can just select from the jlist . please help me in this ,can u tell me code for that , i would be thankful to u
    Thankyou
    Naresh

    You've asked a lot of questions the last few days. I think its time you do some reading. The Swing tutorial titled "Creating a GUI Using JFC/Swing: has sections on every component and example code of how to use them. You can even download the entire tutorial and all the example from the following link:
    http://java.sun.com/docs/books/tutorial/
    Here's the link specific link to the section on "Using Lists"
    http://java.sun.com/docs/books/tutorial/uiswing/components/list.html

  • JList bug? Or is it just me? Testers needed

    I have been having a minor but definitely irritating problem with an application I wrote. In several places I have 2 JList boxes inside JScrollPanes. Clicking on an item in the first list should instantly update the contents of the second. Most of the time it does just that. But it seems like 20% of the time my mouse click is ignored, or atleast the action is not acted on (the first list's item gets highlighted, but the second list does not update). It seems to either be OS or JDK version related as I created a simple test program and tried running it on a different OS with a different version (Solaris server with JDK 1.2.2), and there it worked fine. My system, which is where the problem occured uses Win2000 and I am using JDK 1.4.0. I tried reporting this bug to Sun but they wrote back and said they could not reproduce the bug.
    Is there some weird glitch with just my PC? Or has anyone else ever seen anything like this? I will paste my test program code below. To use it, just keep selecting different items in the left-hand list and noting whether the contents of the right-hand list change to match. If you can do this about 20 times and they stay in sync, then it works fine for you. Otherwise please let me know! And if anyone can actualy help me prove to sun that this is a bug, or provide a fully-functional workaround I'll hand out some Duke Dollars.
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.event.*;
    import java.awt.*;
    * Used to test an aparent bug in JList or MouseAdapter
    public class JListTest extends JFrame
       private Container    contentPane;
       private JScrollPane  scrollOne, scrollTwo;
       private JList        listOne, listTwo;
       private static final String[] listOneItems =
          {"Letters", "Pets", "Names", "Sports"};
       private static final String[] letterItems =
          {"A", "B", "C", "D", "E", "F", "G", "H"};
       private static final String[] petItems =
          {"Cat", "Dog", "Bird", "Fish", "Lizard", "Feret"};
       private static final String[] nameItems =
          {"Joe", "Bob", "Mike", "Sally", "Julie", "Mary", "Tony"};
       private static final String[] sportItems =
          {"Football", "Basketball", "Hockey", "Baseball", "Track & Field"};
       * Constructor
       public JListTest()
          super("JList Test");
          contentPane = this.getContentPane();
          contentPane.setLayout(new BorderLayout());
          listOne = new JList();
          listTwo = new JList();
          listOne.setFixedCellWidth(200);
          listTwo.setFixedCellWidth(200);
          scrollOne = new JScrollPane(listOne,
                   JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                   JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
          scrollTwo = new JScrollPane(listTwo,
                   JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                   JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
          listOne.setListData(listOneItems);
          contentPane.add(scrollOne, BorderLayout.WEST);
          contentPane.add(scrollTwo, BorderLayout.EAST);
          this.setResizable(true);
          addEventHandlers();
          this.setLocation(100,40);
          this.pack();
          this.setVisible(true);
       private void addEventHandlers()
          listOne.addMouseListener(new MouseAdapter()
             public void mouseClicked(MouseEvent e)
                handleMouseClicks(e);
          // Handles clicking on the window's "x" button to close it
          this.addWindowListener(new WindowAdapter()
             public void windowClosing(WindowEvent e)
                System.exit(1);
       protected void handleMouseClicks(MouseEvent e)
          int listIndex = listOne.getSelectedIndex();
          if (listIndex == 0)
             listTwo.setListData(letterItems);
          else if (listIndex == 1)
             listTwo.setListData(petItems);
          else if (listIndex == 2)
             listTwo.setListData(nameItems);
          else if (listIndex == 3)
             listTwo.setListData(sportItems);
       public static void main(String[] args)
          JListTest jListTest = new JListTest();
    }

    I am not able to reproduce what you have seen, but have you tried using a ListSelectionListener in place of your MouseListener?
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.event.*;
    import java.awt.*;
    /*** Used to test an aparent bug in JList or MouseAdapter*/
    public class JListTest
        extends JFrame
        private              Container   contentPane;
        private              JScrollPane scrollOne, scrollTwo;
        private              JList       listOne, listTwo;
        private static final String[]    listOneItems = {"Letters", "Pets", "Names", "Sports"};
        private static final String[]    letterItems  = {"A", "B", "C", "D", "E", "F", "G", "H"};
        private static final String[]    petItems     = {"Cat", "Dog", "Bird", "Fish", "Lizard", "Feret"};
        private static final String[]    nameItems    = {"Joe", "Bob", "Mike", "Sally", "Julie", "Mary", "Tony"};
        private static final String[]    sportItems   = {"Football", "Basketball", "Hockey", "Baseball", "Track & Field"};
        /**   * Constructor   */
        public JListTest()
            super("JList Test");
            contentPane = this.getContentPane();
            contentPane.setLayout(new BorderLayout());
            listOne = new JList();
            listOne.setFixedCellWidth(200);
            listOne.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // <------------------------------<<<
            listTwo = new JList();
            listTwo.setFixedCellWidth(200);
            scrollOne = new JScrollPane( listOne,
                                         JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                         JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
            scrollTwo = new JScrollPane( listTwo,
                                         JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                         JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
            listOne.setListData(listOneItems);
            contentPane.add(scrollOne, BorderLayout.WEST);
            contentPane.add(scrollTwo, BorderLayout.EAST);
            this.setResizable(true);
            addEventHandlers();
            this.setLocation(100,40);
            this.pack();
            this.setVisible(true);
        private void addEventHandlers()
            listOne.addListSelectionListener( // <------------------------------<<<
                new ListSelectionListener() {
                    public void valueChanged(ListSelectionEvent e)
                        if ( ! e.getValueIsAdjusting()) { // <------------------------------<<<
                            handleListSelection();
            // Handles clicking on the window's "x" button to close it
            this.addWindowListener(
                new WindowAdapter() {
                    public void windowClosing(WindowEvent e)
                        System.exit(1);
        protected void handleListSelection() // <------------------------------<<<
            int listIndex = listOne.getSelectedIndex();
            if (listIndex == 0) {
                listTwo.setListData(letterItems);
            } else if (listIndex == 1) {
                listTwo.setListData(petItems);
            } else if (listIndex == 2) {
                listTwo.setListData(nameItems);
            } else if (listIndex == 3) {
                listTwo.setListData(sportItems);
        public static void main(String[] args)
            JListTest jListTest = new JListTest();
    }

  • Creative Alchemy Bug help

    C ?
    i have recently installed the supposed latest software of Creative Alchemy (along with some other Creative media software via Windows Update) for my X-fi sound blaster which is built-in to my PC. after installing it the sound on my PC suddenly disappeared. i do not know the reason why if this might b a bug or the program is in conflict with my other audio softwares (like VLC player, Windows classic media player, media monkey among others). I NEED URGENT HELP PLEASE

    Well try deleting creative alchemy, and then reinstall your card's latest drivers

  • BUG:  Help (F1) dialog constantly pops up in dialogs

    Every time I go to use Photoshop CS3 Extended (and I've heard this problem also exists in CS4), the Help (F1) dialog inevitably pops up repeatedly over and over again.  I searched Google and came up with "out of memory" as the "cause" - I checked Task Manager and, out of 4GB RAM, only 800MB in use.  Actually, I also have Visual Studio 2008 installed and about half the time, the VS debugger wanted to hook into CS3 - in other words, Photoshop is crashing but instead of completely bailing, it fires up the Help dialog.  Only by rapidly clicking the close button on the help dialog and then immediately pressing ESC do I manage to get out of this infinite loop.  The main dialog that I've encountered this problem within is the styles dialog for a layer.  Seriously annoying BUG because it happens every single time.  And don't try to tell me it isn't.  I know crappy programming when I see it and this is crappy programming.  Especially since I paid $$$ for this product.
    I have all the latest updates installed according to the software.  Running this on Windows XP SP3, fully patched, all drivers updated.  I seem to recall this product supposedly recently started using the GPU for rendering layers and I also know that the latest Adobe Premiere Elements has issues with NVidia + Asus or something like that (I have an ATI Radeon HD 4870 card on a Gigabyte board - custom-built machine, no overclocking).  This is also a relatively new XP install and CS3 Extended has only been used a few dozen times.  I'm pretty sure I ran into the issue on my first use even.  So wiping the preferences isn't going to do a single bit of good (that seems to be the recommended course of action around here).  I also had the same issue on my older computer (same software) but I chalked it up to it just being a six year old installation of Windows XP.

    John Joslin wrote:
    igeterrors wrote:
    I have all the latest updates installed according to the software.
    What version number is reported in Help >About...  ?
    I'm pretty sure I ran into the issue on my first use even.  So wiping the preferences isn't going to do a single bit of good (that seems to be the recommended course of action around here).
    Not true – the preference files can be corrupted at any time; even before the program is used.
    And a re-install will not affect these files, which are generated independently in another location.
    Adobe Photoshop CS3 Extended 10.0.1.  Using the "Help -> Updates..." feature says there are no updates.  Checking the Adobe site:
    http://www.adobe.com/support/downloads/product.jsp?product=39&platform=Windows
    Also confirms I have the latest CS3 build.
    For your second response:  Then that is a bug too.  There is this little thing called a "Checksum" that has been around since, well, forever.  If the product is so shoddily written that it can blow up its own config at install, then, at the very least, automatically detect the broken config and repair or replace it.
    http://en.wikipedia.org/wiki/Checksum

  • My imac is infected with a bug.Help

    my imac is infected with a bug.Help

    If the problem could be adware or malware, a product you may have inadvertently downloaded
    to do something and then found the computer acted up, there are ways to remove those things.
    However it helps to know what computer model build year and OS X the machine is running.
    Then what the problem is, with detail to describe what it is doing wrong, or not doing right...
    If you have odd issues in Safari browser, there are methods and descriptions here that may help:
    •Remove unwanted adware that displays pop-up ads and graphics on your Mac - Apple Support
    •Adware Removal Guide:
    http://www.thesafemac.com/arg/
    •Tech Guides: (malware, adware, & performance guides)
    http://www.thesafemac.com/tech-guides/
    Until communication is established, we can only wait to see what you can tell us about the problem.
    For the most part, Macs just do not get infected.
    In any event, a reply could help...
    Good luck & happy computing!

  • How to do the multiple-line String at JList? help!

    i need some code to multiple-line String at JList.
    i know that it is can be done by html code.
    example:
    <p>line1</p><p>line2</p>
    but if i use that html code...
    i face another problem to my JList..
    it cannot set the font use the ListCellRenderer..
    like:
    public Component getListCellRendererComponent(
    JList list,
    Object value,
    int index,
    boolean isSelected,
    boolean cellHasFocus)
    Color newColor = new Color(230, 230, 230);
    setIcon(((DisplayItem)value).getIcon());
    setText(((DisplayItem)value).getChat());
    setFont(((DisplayItem)value).getFont());
    setBackground(isSelected ? newColor : Color.white);
    setForeground(isSelected ? Color.black : Color.black);
    if (isSelected) {
    setBorder(
    BorderFactory.createLineBorder(
    Color.red, 2));
    } else {
    setBorder(
    BorderFactory.createLineBorder(
    list.getBackground(), 2));
    return this;
    all my JList will be html type...
    i don't want that happen..can be another method to do that multiple-line String in JList??
    i also need to set a icon image between string in the JList. anyone get idea??
    i need ur help!
    thank you.

    I think you should create/override several methods like setText(String), setIcons(Icon[]), paintComponent(Graphics), getMinimumSize(), getPreferredSize(), etc.
    I would like to code like below...:class MultilineLabel extends JLabel {
        private String[] text = null;
        private ImageIcon[] icons = null;
        public void setText( String newText ) {
            // It overrides JLabel.setText( String )
            // Tokenize newText with line-separator
            // and put each text into the 'text' array.
        public void setIcons( Icon[] newIcon ) {
            // It is similar to JLabel.setIcon( Icon ) method,
            // but it receives an array of Icon-s. Set these icons to 'icons' variable.
        public void paintComponent( Graphics g ) {
            // It overrides JComponent.paintComponent( Graphics ) method.
            super.paintComponent( g );
            if ( text != null && icons != null ) {
                int icon_x = 0;
                int text_x = 0;
                int y = 0;
                // draw customized content..
                for ( int i=0; i<text.length; i++ ) {
                    // compute x and y locations
                    // icon_x = ...
                    // text_x = ...
                    // y = ...
                    // and draw it!
                    g.drawString( text[ i ], text_x, y );
                    icon[ i ].paintIcon( this, g, icon_x, y );
        public Dimension getMinimumSize() {
            int width = super.getMinimumSize().width;
            int height = ... // I think you must compute it with 'text' and 'icons'' arrays.
            return new Dimension( width, height );
        public Dimension getPreferredSize() {
            int width = super.getPreferredSize().width;
            int height = ...
            return new Dimension( width, height );
    }I think that code-structure above is the minimum to implement your requirements. (Of course if you want to implement it :)
    Good luck and let me know it works or not. :)

  • Button Event Handler in a JList, Please help.

    Hi everyone,
    I have created a small Java application which has a JList. The JList uses a custom cell renderer I named SmartCellRenderer. The SmartCellRenderer extends JPanel and implements the ListCellRenderer. I have added two buttons on the right side inside the JPanel of the SmartCellRenderer, since I want to buttons for each list item, and I have added mouse/action listeners for both buttons. However, they don't respond. It seems that the JList property overcomes the buttons underneath it. So the buttons never really get clicked because before that happens the JList item is being selected beforehand. I've tried everything. I've put listeners in the Main class, called Editor, which has the JList and also have listeners in the SmartCellRenderer itself and none of them get invoked.
    I also tried a manual solution. Every time the event handler for the JList was invoked (this is the handler for the JList itself and not the buttons), I sent the mouse event object to the SmartCellRenderer to manually check if the point the click happened was on one of the buttons in order to handle it.
    I used:
    // Inside SmartCellRenderer.java
    // e is the mouse event object being passed from the Editor whenever
    // a JList item is selected or clicked on
    Component comp = this.getComponent (e.getX(), e.getY())
    if(!(comp instanceof JButton)) {
              System.out.println("Recoqnized Event, but not a button click...");
              //return;
    } else {
              System.out.println("Recognized Event, IT IS A MOUSE CLICK, PROCESSING...");
              System.out.println("VALUE: "+comp.toString());
    What I realized is that not only this still doesn't work (it never realizes the component as a JButton) it also throws an exception for the last line saying comp is null. Meaning with the passed x,y position the getComponent() returns a null which happens when the coordinates passed to it are outside the range of the Panel. Which is a whole other problem?
    I have yet to find an example on the web, using Google, that demonstrated using buttons inside a JList.
    Can anyone help me with this. Thanks.

    A renderer is not a component, so you can't click on it. A renderer is just used to paint a representation of a component at a certain position in your JList.
    I have yet to find an example on the web, using Google, that demonstrated using buttons inside a JList.Thats probably because this is not a common design. The following two designs are more common:
    a) Create a separate panel for your JButtons. Then when you click on the button it would act on each selected row in the JList
    b) Or maybe like windows explorer. Select the items in the list and then use a JPopupMenu to perform the desired functionality.
    I've never tried to add a clickable button to a panel, but this [url http://forum.java.sun.com/thread.jspa?threadID=573721]posting shows one way to add a clickable JButton as a column in a JTable. You might be able to use some of the concepts to add 2 button to the JPanel or maybe you could use a JTable with 3 columns, one for your data and the last two for your buttons.

  • Compiz bug , help!!!

    I have install compiz fusion,but when I change compiz mode,I can't see anything in gnome-terminal.can you help me ?

    joeda wrote:
    Can you tell more about what you did that caused the bug to appear? Or about what's wrong with the terminal?
    (And please don't put that "help!!!!!" statements in your thread title, that's just annoying.)
    I just install compiz-fusion by using pacman -S compiz-fusion ,and start it.Everything is OK,but the gnome-terminal area is white.

  • Bug-HELP !!!!

    Annoying pop up box keeps appearing and obliterates my video screen. It asks to access or deny to store information. It will not respond to deny. It will not go away. Does anyone know how to get rid of this and is it part of Adobe or not?

    Not a bug.
    Websites might occasionally want to store information, such as your high score from a game that runs in  Flash Player or what products you have purchased, to your computer. In the Global Storage Settings panel, you can control how much disk space websites can use to store information, or you can prohibit websites from storing any information at all. (If you prohibit websites from storing information, the website might or might not function as intended.)
    Use this panel to specify the default storage settings for websites that you haven't yet visited. (To change settings for websites you have already visited, use the Website Storage Settings panel.) The following list explains the storage options:
    If you don't want to let applications from any website save information on your computer, and you don't want to be asked again, select Never Ask Again. This action doesn't delete any information that is already stored. (To delete existing information, use the Delete options in the Website Storage Settings panel.)
    If you want to decide on a case-by-case basis whether applications from a website can save information on your computer, move the slider to the far left (None). Each time an application wants to save information on your computer, you will be asked for more disk space.
    If you want to let applications from any website save as much information on your computer as they need to, move the slider to the far right (Unlimited).
    If you want to let applications from any website save information on your computer, but want to limit the amount of disk space they can use, move the slider to select 10 KB, 100 KB, 1 MB, or 10 MB. If an application needs more space than you have allotted, you will be asked for more disk space while the application is running.
    (Flash Player 8 and later) If you do not want to let third-party content store information on your computer, deselect Allow Third-Party Content To Store Data On Your Computer.
    When you visit a website, the address shown in the browser address bar is usually where most of the website is located. For example, if you visit a fictional website www.[hotel].com, most of the website is located at www.[hotel].com. Sometimes, websites combine content from different sources. For example, www.[hotel].com might display a reservations form in Flash that actually comes from [reservations.hotel].com. The content from the latter website is called third-party content.
    Third-party content might try to store information on your computer. In the hotel reservations example, you might be willing to let [reservations.hotel].com store information on your computer, such as data about which hotels you prefer, so that you can make a hotel reservation. However, you might not be willing to let third-party content store information on your computer in other situations. For example, a car-rental company, www.[my-car-rental].com, might have a banner ad on www.[hotel].com, to track your website usage or to record your preferences.
    To prohibit all third parties from storing information on your computer, deselect Allow Third-Party Content To Store Data On Your Computer. This option is available only with Flash Player 8 and later. Adobe recommends that you upgrade to the most recent version of Flash Player available.
    (Flash Player 9.0.115.0 and later) If you do not want to store Flash components on your computer, deselect Store Common Flash Components To Reduce Download Times.
    Flash Player lets you store common or shared SWF and FLV files and other components from different websites on your computer to significantly reduce download times and allow faster viewing. For example, www.[hotel].com and [reservations.hotel].com might both use the same Adobe components on their sites.
    For an overview of issues related to storage, see What are storage settings? in the discussion of the Settings Manager. http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager03.htm l

  • JList ListCellRenderer Help

    Hello All,
    I have a small query in regards to a ListCellRenderer implementation.
    I have my own ListCellRenderer implementation, and it is working fine in regards to bolding text, colors and so on. But I was wondering about how I would go making a nice "glowing" effect on the mouseover event of the List item.
    I have been a web programmer for a while, and have had many nice experiences with JavaScript and using timing events, to slowly change the color of an HTML element, to give it that glowing effect.
    I was kind of hoping to do the same for a JList, is there anyone out there that has had experiences with this kind of thing?
    Any help is appreciated, I will also post if I find anything on my own.
    Cheers,
    Mark

    I've no idea of what glowing effect you are after, but I was bored and have been playing with timers and colors and came up with this effect. If you develop your glow effect, please post your code so we can play with it.
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import javax.swing.BorderFactory;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    import javax.swing.Timer;
    class GlowSwing2 extends JPanel
        private static final int TIMER_PERIOD = 60;
        private static final int DIMEN = 400;
        private static final int GRID_SIZE = 5;
        private static final int COLOR_STEPS = 16;
        private Color currentColor = Color.black;
        private Color originalColor = Color.black;
        private int colorIndex = 0;
        private JLabel[][] labels = new JLabel[GRID_SIZE][GRID_SIZE];
        private JLabel currentLabel = null;
        private Timer timer = new Timer(TIMER_PERIOD, new MyTimerAction());
        private Color[] colors;
        GlowSwing2()
            setPreferredSize(new Dimension(DIMEN, DIMEN));
            int ebGap = 10;
            setBorder(BorderFactory.createEmptyBorder(ebGap, ebGap, ebGap, ebGap));
            setLayout(new GridLayout(GRID_SIZE, GRID_SIZE));
            for (int i = 0; i < GRID_SIZE; i++)
                for (int j = 0; j < GRID_SIZE; j++)
                    JLabel jl = new JLabel("Hello");
                    jl.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 24));
                    jl.addMouseListener(new LabelMouseListener());
                    add(jl);
                    labels[i][j] = jl;
            initColors();
            timer.start();
         * creates a nice sin wave of blue color
        private void initColors()
            colors = new Color[COLOR_STEPS];
            double periodStep = 2 * Math.PI / COLOR_STEPS;
            for (int i = 0; i < colors.length; i++)
                int c = (int)(256 * (Math.sin(i * periodStep) + 1)/2);
                if (c == 256)
                    c = 255;
                colors[i] = new Color(c, c, 255);
        private class LabelMouseListener extends MouseAdapter
            @Override
            public void mouseEntered(MouseEvent mEvent)
                JLabel source = (JLabel)mEvent.getSource();
                originalColor = source.getForeground();
                currentLabel = source;
                super.mouseEntered(mEvent);
            @Override
            public void mouseExited(MouseEvent mEvent)
                currentLabel = null;
                ((JLabel)mEvent.getSource()).setForeground(originalColor);
                super.mouseExited(mEvent);
        private class MyTimerAction implements ActionListener
            public void actionPerformed(ActionEvent arg0)
                myTimerAction(arg0);
         * changes the colors of the labels
         * @param arg0
        private void myTimerAction(ActionEvent arg0)
            if (currentLabel != null)
                colorIndex++;
                colorIndex %= colors.length;
                currentColor = colors[colorIndex];
                currentLabel.setForeground(currentColor);
                currentLabel.repaint();
        private static void createAndShowGUI()
            JFrame frame = new JFrame("GlowSwing Application");
            frame.getContentPane().add(new GlowSwing2());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        public static void main(String[] args)
            SwingUtilities.invokeLater(new Runnable()
                public void run()
                    createAndShowGUI();
    }

  • Circular  JList . Help required please

    Folks,
    I need a bit of help please.
    I have created a JList,but I want this to be circular.
    Im my JList example,I display 11 numbers,the first 5 are displayed
    when the application starts up,the user should be able to
    press the 'Down Button'and the focus shud then go to 2.
    Once the focus reaches 5,and the user presses the Down Button,
    number 1 should scroll up and the screen shud display numbers
    2 to 6.
    The user presses the Down Button again,and the screen shud display
    3 to 7.
    This way till number 11 is reached,and when the user presses
    the 'Down' button,number 1 will be displayed.
    All shud be circular.
    Attached is my code.
    Can some please suggest what needs to be coded in the
    Down Button action performed inner class??
    Or Am I overlooking something?
    public class MyCircularList extends JPanel{
        private JList list;
        private DefaultListModel listModel;
        private JButton DownButton;
        private static final String DownString = "Down";
         public MyCircularList() {
              super(new BorderLayout());
              listModel = new DefaultListModel();
              listModel.addElement("1");
              listModel.addElement("2");
              listModel.addElement("3");
              listModel.addElement("4");
              listModel.addElement("5");
              listModel.addElement("6");
              listModel.addElement("7");
              listModel.addElement("8");
              listModel.addElement("9");
              listModel.addElement("10");
              listModel.addElement("11");
              //Create the list and put it in a scroll pane.
              list = new JList(listModel);
              list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
              list.setSelectedIndex(0);
              list.setVisibleRowCount(5);
              JScrollPane listScrollPane = new JScrollPane(list);
              DownButton = new JButton(DownString);
              DownButton.setActionCommand(DownString);
               DownButton.addActionListener(new DownListener());
               JPanel buttonPane = new JPanel();
               buttonPane.setLayout(new BoxLayout(buttonPane,                                                                                           BoxLayout.LINE_AXIS));
               buttonPane.add(DownButton);
               buttonPane.add(Box.createHorizontalStrut(5));
               buttonPane.add(new JSeparator(SwingConstants.VERTICAL));
               buttonPane.add(Box.createHorizontalStrut(5));
               buttonPane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
               add(listScrollPane, BorderLayout.CENTER);
               add(buttonPane, BorderLayout.PAGE_END);
            // Inner class to handle Button Listener.
         class DownListener implements ActionListener {
         public void actionPerformed(ActionEvent e) {
            // How to handle the circluar motion of the list???
         }  // End of actionPerformed.
         }  // End of Inner class.
         public static void main(String[] args) {
            JFrame.setDefaultLookAndFeelDecorated(true);
         JFrame frame = new JFrame("Circular List Demo");
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         JComponent newContentPane = new MyCircularList();
         newContentPane.setOpaque(true);
         frame.setContentPane(newContentPane);
         frame.pack();
         frame.setVisible(true);          

    Since you didn't include any code in your listener, I'm not sure what you want. Perhaps:
    int n=(list.getSelectedIndex()+1)%list.size();
    list.setSelectedIndex(n);
    list.ensureIndexIsVisible(n);
    But the JList keyboard support does all this automatically?

  • IMAP email bug - help required to resolve

    Hi...
    I am trying to set up IMAP on my new HP Touchpad.  The problem is, my touchpad won't download any emails.
    After creating an account, the touchpad is able to recognise the folder structure of my email account, and I can send messages. However, my inbox and all other folders appear empty. These folders are definitely populated with thousands of emails, and I have no problem accessing them with IMAP on my Ipod Touch or through my computer.  The touchpad must be successfully linked in to both the IMAP and SMTP servers (since I get my folder structure, and can send messages). However, no matter how many times I try to refresh the inbox, the touchpad won't download a single email.
    I have tried reinstalling the accounts and a complete reset of the ipad but no joy. I get no error messages of any kind - just empty folders.
    I have created a log file after recreating the problem. Let me know if this is useful.
    Help please!
    Harry
    Post relates to: HP TouchPad (WiFi)

    Hi...
    Thanks for the quick response. Unfortunately this hasn't resolved the issue.
    Default folders were already assigned for my account. I tried assigning different ones, or unassigning but this didn't make any difference.
    I'm pretty sure my email provider doesn't require a root folder. There's no mention of it in their help topics, and I've never assigned one in the past when I set up email on my Ipod Touch.  This is what they say about setting up IMAP
    IMAP Settings
    =========
    Incoming Mail Server: imap.mailanyone.net
    Outgoing Mail Server: smtp.mailanyone.net
    Incoming (IMAP) Port: 143
    Outgoing (SMTP) Port: 25
    "SMTP requires authentication" should be ticked.
    Optional Security settings
    ================
    "Use Secure Connections": can be ticked or unticked and will still work.
    "Use Secure Authentication": tick if secure connection is set to "never" and untick if secure connection is set to "SSL" 
    I feel like this must be a bug with the way the email app is trying to communicate with their IMAP server, but I really need to iron it out!
    Thanks again
    Harry

  • Ipod no longer recognized, software is bugged help plz!!!

    I cant stand Itunes or any I-program anymore. Ive had my ipod forever, with alot of songs (2000 of them). Recently my Itunes tells me I need to update software, so I do so. I then had Itunes 6, and Ipod update 2006-01-10. Biggest mistake EVER.
    1. My ipod starts functioning funny with many glitches
    2. Next time I plugged it in, it told me that it must be updated to function properly, then it realized it IS updated, THEN it restores my Ipod by itself, without me pressing anything.
    3. THEN, the next time I try to plug in my Ipod, its not being read by Itunes and the Updater freezes if I open it. My 2000 songs have vanished (worst part).
    Basically, my pc is treating my Ipod as if its not plugged, my songs are gone, and I dont want to uninstall everything and start fresh without doing it right (while not downloading this glitch version).
    -If any Apple workers do care enough to read this, GO AWAY CUZ IM REALLY UPSET AT ALL OF YOU TECHNICIAN IDIOTS AND ID MAKE YOU PAY ME MONEY FOR MY SONGS IF I COULD
    -If any helpful knowledgable apple forumers can help me, please do so, this is killing me.
    Thank you!

    iOS: Device not recognized in iTunes for Mac OS X
    Do not omit the additional information pararaph.

  • Using iWeb to publish my mobileme photo gallery -really weird bugs help plz

    I have a really weird problem and have tried searching the forums already with no luck.
    I'm using iWeb09 to put mobileme photo album on my website. When I initially add the widget onto my page, the widgets will show a "preview" of what pictures are in the gallery if you hover your mouse over it. Later during the day, I'm not sure if I did anything to mess it up but that "preview" is no longer there. It's just a black box. It still works however if you click on it because it takes you to the mobile gallery.
    The only way for me to fix it was to delete the mobile me album and create a new one. Then re-add the widget onto my iWeb.
    This has happened twice to me already and I cannot figure out why it happens. I'm sorry if my description is vague. Please help.

    There is no point in re-installing iWeb, because after you have published it really is not an iWeb problem - if there is something not working on uploading the files, then it is really nothing to do with iWeb after html pages have been created.
    If you are using Fetch to upload, then you have obviously published your site to a local folder? If so, are the photos there when you look at your local site? If they are there when you publish to a local site, then it is an error in uploading and if photos do not show, it means that some things are not being uploaded to your server correctly.
    Have you tried using Cyberduck instead of Fetch? Cyberduck or Transmit are two of the better ftp programmes to try.

Maybe you are looking for