Problems with size with JList

Hi...I have made an application that has a JTable with listeners on. When you press a cell the information in the cell appears in the Jlist.
When you first run the program you see the JTable and the empty JList. We have set a preferredSize on the JList, but when we press the different cells in the JTable (even though it has no information under it), the size sometimes changes. The JList gets bigger (even though its empty), and when we press a nother cell again it goes back to normal size.
Anyone has any idea why the size changes? How can you set a static size, or a none altering size??

Set minimumSize and maximumSize for the list and for the viewport of the jscrollpane (if any) as well.

Similar Messages

  • Problems with JList & JTable in Netbeans 5.5

    Hi,
    Netbeans provides good GUI building provider.
    But when i am adding JList inside panel
    and trying to add elements its giving error.
    So how to modify read only code in netBeans 5.5 generated code. ??
    There is problem accessing JList variable to be modify.
    HOW TO ACHIEVE THIS ????
    because When you add JList in your GUI Part.
    Netbeans generates code automatically.
    we can't change it.
    HOW TO DO it... ???

    I have had similar trouble.
    In NetBeans Guieditor, JList and JTable are automatically created in a JScrollPanel. This is good as it saves you lots of formatting.
    PROBLEM: when you click/select the JTable or JList in the GUI Editor the Properties box (right hand side ) only shows properties for the JScrollPane.
    So you will only be able to edit Init code etc for the JScrollPane
    SOLUTION: The "Members View" is a list of members (Panels, Objects, etc) on the left hand side of the screen.
    The JScrollPane is listed there. You simply click on this to expand and select the JTable/JList that it contains.
    When you select the JTable/JList the Properites window (right side of screen) now shows the properties for the component you really want to deal with.
    The code options are very powerful.

  • Problems with JList

    Hi all,
    I'm trying to use a JList for a program that I'm making.
    To initialize the JList, I use the following code:
    public static JList menu;
    public MadLibsManagerGui() {
    menu = new JList(MadLibsGui.getComboInfo());
    the getComboInfo() method returns an array of strings. This should work, no? But, it doesn't seem to be working! When i try printing the number of indices in the jlist, i get -1even though all of my strings (from the array) do get displayed in the JList. Any ideas? Thanks so much! any help is greatly appreciated.
    PS. Does anyone know how to close a JFrame using the push of a button?

    Even when i pass it an integer constant, i get the
    exceptionA couple of things:
    First of all, the remove(int) method defined in JList is inherited from java.awt.Container: it is used for removing a child Component with the given index from a Container. In other words, you cannot use it to remove items from the list.
    In fact, there are no methods defined in the JList API for adding or removing items once the list is created. This is because the ListModel interface that defines the data that backs the JList is immutable.
    It is still possible, of course, to add and remove items from a JList. The trick is to use a custom ListModel implementation, such as DefaultListModel, that allows such modifications. See the JList tutorial for examples of this.
    Secondly, if something is selected in the list, getSelectedIndex() will not return -1. If the JList you see on your screen has something selected, but getSelectedIndex() returns -1 when called on a JList reference in your code, then chances are good that you have two different JList objects. The JList that you add to the UI is not the same JList instance you refer to when calling getSelectedIndex().

  • Serious problems with JLists

    Could someone please look at my code and help me fix it. As you can see there are four JLists. I need to have the choice in list 1 generate the entries for list 2 and so on. I have four temporary methods to 'generateVectors' but I only want to generate the vector AFTER the previous choice has been made.
    Would appreciate any help
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.util.*;
    public class LoginApplet extends JApplet {
         private JList prods,tests,cards,users;
         private Container c;
         private JLabel prodChoice,testChoice,cardChoice,usr;
         private Vector v1,v2,v3,v4;
         private String colorNames[] =
         { "Black", "Blue", "Cyan", "Dark Gray", "Gray", "Green",
         "Light Gray", "Magenta", "Orange", "Pink", "Red",
         "White", "Yellow" };
         private Color colors[] =
         { Color.black, Color.blue, Color.cyan, Color.darkGray,
         Color.gray, Color.green, Color.lightGray,
         Color.magenta, Color.orange, Color.pink, Color.red,
    Color.white, Color.yellow };
         //private Vector p,t,c,u;
         public void init() {
              c = getContentPane();
              c.setLayout( new FlowLayout() );
              prodChoice = new JLabel("Product: ");
              testChoice = new JLabel("Stage: ");
              cardChoice = new JLabel("Card: ");
              usr = new JLabel("User: ");
              prods = new JList(colorNames);
              prods.setVisibleRowCount( 5 );
              prods.setSelectionMode(
                   ListSelectionModel.SINGLE_SELECTION );
              c.add( new JScrollPane( prods ) );
              c.add(prodChoice);
              prods.addListSelectionListener(
                   new ListSelectionListener() {
                        public void valueChanged( ListSelectionEvent e )
    //this is where I want to generate the entries for the second list,
    //based on the selection in the first
              tests = new JList(getTestVector());
              tests.setVisibleRowCount( 5 );
              tests.setSelectionMode(
                   ListSelectionModel.SINGLE_SELECTION );
              c.add( new JScrollPane( tests ) );
              c.add(testChoice);
              tests.addListSelectionListener(
                   new ListSelectionListener() {
                        public void valueChanged( ListSelectionEvent e )
                             //do something
              cards = new JList(getCardVector());
              cards.setVisibleRowCount( 5 );
              cards.setSelectionMode(
                   ListSelectionModel.SINGLE_SELECTION );
              c.add( new JScrollPane( cards ) );
              c.add(cardChoice);
              cards.addListSelectionListener(
                   new ListSelectionListener() {
                        public void valueChanged( ListSelectionEvent e )
                             //do something
              users = new JList(getUserVector());
              users.setVisibleRowCount( 5 );
              users.setSelectionMode(
                   ListSelectionModel.SINGLE_SELECTION );
              c.add( new JScrollPane( users ) );
              c.add(usr);
              users.addListSelectionListener(
                   new ListSelectionListener() {
                        public void valueChanged( ListSelectionEvent e )
                             //do something
              setSize( 500 , 250 );
              setVisible( true );
         public Vector getProdVector() {
              Vector v1 = new Vector();
              v1.add("None");
              v1.add("APX");
              v1.add("Stinger");
              v1.add("TNT");
              v1.add("Max");
              return v1;
         public Vector getTestVector() {
              v2 = new Vector();
              for (int i=0;i<colorNames.length;i++){
              v2.add(colorNames);
              return v2;
         public Vector getCardVector() {
              v3 = new Vector();
              v3.add("None");
              v3.add("Card1");
              v3.add("Card2");
              v3.add("Card3");
              v3.add("Card4");
              return v3;
         public Vector getUserVector() {
              v4 = new Vector();
              v4.add("None");
              v4.add("user1");
              v4.add("user2");
              v4.add("user3");
              v4.add("user4");
              return v4;
    public static void main ( String args[] ){
    LoginApplet lApp = new LoginApplet();
    lApp.init();

    You should not call the constructor with the items for the other 3 lists if you want this lists empty initially
    users = new JList(); instead of
    users = new JList(getUserVector());
    and then call the method getUserVector() and add the items to the JList in the listener for the previous JList.

  • Problems with JList (multiple selection)

    hi!
    i have a simple question.. why does this construct not work? i recieve a Casting Exception!
    recList is a JList!
    if(source == send){
         String[] rec = (String[])recList.getSelectedValues();
         String message = messageArea.getText();
    thx,
    chris

    You can only cass an Object array to a String array if the array was created as a String array.
    Object[] o = new String[] { "string1", "string2" };
    String[] s = (String[])o; // this works fineIf it was created as an Object array, then you will get a ClassCastException:
    Object[] o = new Object[] { "string1", "string2" };
    String[] s = (String[])o; // throws ClassCastExceptionSo either you have to cast each Object element to a String, or copy all the elements to a String array like this:
    Object[] o = new Object[] { "string1", "string2" };
    String[] s = new String[o.length];
    System.arraycopy(o, 0, s, 0, o.length); // or copy them in a for-loop which may be faster for small arraysReturning you an Object array that was created as an Object array is the easiest way for the JList to return you the selected values. So that's why you can't just cast it to a String array even though YOU know they are all String objects.

  • Problem with ScrollPane and JFrame Size

    Hi,
    The code is workin but after change the size of frame it works CORRECTLY.Please help me why this frame is small an scrollpane doesn't show at the beginning.
    Here is the code:
    import java.awt.*;
    public class canvasExp extends Canvas
         private static final long serialVersionUID = 1L;
         ImageLoader map=new ImageLoader();
        Image img = map.GetImg();
        int h, w;               // the height and width of this canvas
         public void update(Graphics g)
            paint(g);
        public void paint(Graphics g)
                if(img != null)
                     h = getSize().height;
                     System.out.println("h:"+h);
                      w = getSize().width;
                      System.out.println("w:"+w);
                      g.drawRect(0,0, w-1, h-1);     // Draw border
                  //  System.out.println("Size= "+this.getSize());
                     g.drawImage(img, 0,0,this.getWidth(),this.getHeight(), this);
                    int width = img.getWidth(this);
                    //System.out.println("W: "+width);
                    int height = img.getHeight(this);
                    //System.out.println("H: "+height);
                    if(width != -1 && width != getWidth())
                        setSize(width, getHeight());
                    if(height != -1 && height != getHeight())
                        setSize(getWidth(), height);
    }I create frame here...
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.JFrame;
    public class frame extends JFrame implements MouseMotionListener,MouseListener
         private static final long serialVersionUID = 1L;
        private ScrollPane scrollPane;
        private int dragStartX;
        private int dragStartY;
        private int lastX;
        private int lastY;
        int cordX;
        int cordY;
        canvasExp canvas;
        public frame()
            super("test");
            canvas = new canvasExp();
            canvas.addMouseListener(this);
            canvas.addMouseMotionListener(this);
            scrollPane = new ScrollPane();
            scrollPane.setEnabled(true);
            scrollPane.add(canvas);
            add(scrollPane);
            setSize(300,300);
            pack();
            setVisible(true);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        public void mousePressed(MouseEvent e)
            dragStartX = e.getX();
            dragStartY = e.getY();
            lastX = getX();
            lastY = getY();
        public void mouseReleased(MouseEvent mouseevent)
        public void mouseClicked(MouseEvent e)
            cordX = e.getX();
            cordY = e.getY();
            System.out.println((new StringBuilder()).append(cordX).append(",").append(cordY).toString());
        public void mouseEntered(MouseEvent mouseevent)
        public void mouseExited(MouseEvent mouseevent)
        public void mouseMoved(MouseEvent mouseevent)
        public void mouseDragged(MouseEvent e)
            if(e.getX() != lastX || e.getY() != lastY)
                Point p = scrollPane.getScrollPosition();
                p.translate(dragStartX - e.getX(), dragStartY - e.getY());
                scrollPane.setScrollPosition(p);
    }...and call here
    public class main {
         public main(){}
         public static void main (String args[])
             frame f = new frame();
    }There is something I couldn't see here.By the way ImageLoader is workin I get the image.
    Thank you for your help,please answer me....

    I'm not going to even attempt to resolve the problem posted. There are other problems with your code that should take priority.
    -- class names by convention start with a capital letter.
    -- don't use the name of a common class from the standard API for your custom class, not even with a difference of case. It'll come back to bite you.
    -- don't mix awt and Swing components in the same GUI. Change your class that extends Canvas to extend JPanel instead, and override paintComponent(...) instead of paint(...).
    -- launch your GUI on the EDT by wrapping it in a SwingUtilities.invokeLater or EventQueue.invokeLater.
    -- calling setSize(...) followed by pack() is meaningless. Use one or the other.
    -- That's not the correct way to display a component in a scroll pane.
    Ah, well, and the problem is that when you call pack(), it retrieves the preferredSize of the components in the JFrame, and you haven't set a preferredSize for the scroll pane.
    Please, for your own good, take a break from whatever it is you're working on and go through The Java&#8482; Tutorials: [Creating a GUI with JFC/Swing|http://java.sun.com/docs/books/tutorial/uiswing/TOC.html]
    db

  • Problem with Cell size in Excel output of XML report

    Dear all,
    I am facing a problem with cell size when i run my XML report in Excel output. I found that it imitates the cell size of whatever i gave in the RTF. I cannot increase the cell size in RTF as my report contains 60 columns and max width of MS Word table is 22 inches.
    Can any one suggest a way of doing this which shows full data in Excel sheet depending on the column data size with out any word wrap.
    Thanks
    RAJ

    Hi ,
    You can try with
    <xsl:attribute xdofo:ctx="block" name="wrap-option">no-wrap</xsl:attribute>
    may be helpful to you
    Thanks,
    Ananth
    http://bintelligencegroup.wordpress.com/

  • Printing Problem with custom size paper in Illustrator

    Hi having problems with my custom sized paper print using my canon printers it's the same on both the ip100 and the pro-100s,  it was printing fine until i've updated my illustrator and mac os Yosemite, it prints the image at a reduced size on the paper to what it should be does anyone have any understanding of this? I've tried everything i know, is this a driver or system problem?

    Hi there wasn't an option to set the default printer to pdf where would I do this?
    I've done a bit of a work around that seems to be working. I've put the page set up as A4 and then clicked on the printer utility custom settings and then unticked detect paper width, so I can put through the paper I want just got to tweak the x and y to get it right, its not the best but sitting here for four hours trying to figure it out, it will have to do for now. Thanks Jacob for your help, no doubt I'll be back in the morning, I'm burnt out now!

  • Firefox does not load long images, pixelates images if they are not in their original size, and has problems with thumbnails (in some sites)

    Firefox has problems with images.
    In sites like deviantART or ImageShack with full-view option, images that are not in full size/thumbnails get slightly pixelated e.g. http://img251.imageshack.us/f/screenshot2tq.jpg/
    Long images get completely messed up if full-viewed e.g. http://img689.imageshack.us/f/screenshot5z.jpg/ (though if the file is only big, it loads just fine)
    Also, thumbnails in some sites get messed up e.g. http://img201.imageshack.us/f/screenshotyr.jpg/
    And in general, Firefox has more 'glitches' like not allowing to add more search engines. It wasn't like that before and I can only assume that it got messed up somewhere with updates, but I'm not really sure.
    I've tried cleaning out cache, re-installing Firefox (multiple times) and even downloaded Firefox 4 beta, but the problem remains.
    I use Ubuntu.
    Does anyone else have similar problems? Or know where the problem lies?

    Do you have the latest driver for your graphics display card?
    Create a new profile as a test to check if your current profile is causing the problems.
    See [[Basic Troubleshooting#Make_a_new_profile|Basic Troubleshooting&#58; Make a new profile]]
    If that new profile works then you can transfer some files from the old profile to that new profile (be careful not to copy corrupted files)
    See http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox

  • Having problem with "artwork size & resolution exceeds the max that can be rasterized"

    Hi all,
    Ok, I created a 162.7" x 90.6" document (artboard) for an exhibition display I'm designing. The document was created using all the defaults - i think this is where i went wrong. Illustrator is now telling me that "the combination of artwork size and resolution exceeds the maximum that can be rasterized" after i open the document and when i try to add a drop shadow to anything.
    Other than some vector graphics i created in illustrator, I only have 3 180ppi and 4 300ppi photos tranfered right off the photograpers camera.
    I selected :
    1. "Print Document" from the initial splash window.
    2. I entered the artboard size, bleed and left the "Raster Effects" setting to "High (300ppi)"
    I think leaving the Raster Effects setting at 300ppi is where the problem is.
    Do i have to create a new document or can i fix the existing one?

    nados you are a little confused that's all I think things are ll right and you are probably set to go with out going to Photoshop.
    1. Your file is probably fine as is
    2. Make certain you images are linked and not embedded
    3. Your Images are probably ok as far as they are for the the specs required do not lower the resolution just make certain they are linked.
    You may have to reimport them and in the place dialog make certain link is checked.
    4. The Raster Image Effects setting is fine leave it as is.
    5. The jpegs are fine lee your images as is if that was what was supplied to you and they look clean.
    6. When saving the file save as .AI format and in the AI save as option dialog uncheck include linked files
    (you will send them the jpegs as well as the AI file.)
    7. Send the images in what ever format they are now since that is jpeg leave it be just make certain the dimensions are the same as is being used in the document at 100%.
    8 Make Certain you select the text and got Type> Create Outlines before saving the file.
    9 Do not export the file to any other format.
    10 Send the printer production house the AI file and the Jpegs you will be fine.
    You should not have a problem with this file.

  • Is there a problem with maximum RAM size for Satellite 320CDT?

    I have a Satellite 320CDT with the latest BIOS (v8.00) and Windows 98 SE installed; there is 32MB base memory and a 32MB module in the single expansion slot. If I change this for a 64MB expansion module I can still only see 64MB total memory reported, not 96MB as expected; the spec for the machine states that the maximum allowable memory is 160MB (32MB base + 128MB expansion). Does anybody know if there is a problem with the maximum memory size for this model and whether there is a solution or workaround? I need to know quickly, in order to decide if I need to return the memory module to the supplier! Many thanks for any help, Peter

    Are you certain you tried the correct type of memory module? It sounds like you're maybe trying to fit an incompatible type.
    There's a few different suppliers below.
    http://www.orcalogic.co.uk/asp/prodtype.asp?prodtype=5634&ft=m&st=3
    http://www.offtek.co.uk/product.php?manuname=Toshiba&maincat=1&subcat=1&mo del=Satellite+320CDT
    http://www.crucial.com/uk/store/listparts.aspx?model=Satellite+320CDT
    http://www.memoryx.net/tosa323bame1.html

  • Problem with custom paper size on dot matrix printer

    Hi All,
    I'm using CR2008 with updated to SP2. I have a problem with custom paper size (W=21; H=14), the CR Viewer show report with custom paper size correctly but when I print it to a dot matrix printer (Epson LQ 300+) the content was rotated to landscape. If print to a laser printer the content was printed correctly. My report was printed correctly by CR10 or previous versions I got this issue when upgraded to CR2008. I aslo tested my computer and printer with orther application like MS Word the printing have no problem with custom paper size.
    Thanks for any advice for me.
    Han

    Looking at the Epson LQ 300+ driver, I see that the latest update is from 2002. In my experience, most matrix printer drivers are not unicode. Crystal Reports is designed to only work with unicode printer drivers. See the [How Printer Driver Options Affect a Report|https://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/a09051e9-721e-2b10-11b6-f9c65c64ef29&overridelayout=true] article, page 6 for details. Also, see [this|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_dev/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do] note.
    Finally, see if you can print from the CR designer to this printer and if you get the correct results here.
    Ludek

  • Problem with font size, not showing up as expected.

    I've been wrestling with this for a few weeks now, but surely must be getting closer to having it resolved. It's just a problem with font size on just this one page.
    http://www.kgngroup.net/logos_and_packaging.html
    I want the body text to be 10px, but after two weeks, have played with every conceivable way, altering body font size in CSS and in the document itself. I've viewing it in Safari but others on Windows machines tell me that it is out of whack also.
    My main problem is that I can change the font size to extremes but it still shows up as the same size in the browser (about 12px.) I know changes can be made because I can modify the wording and that does change online. It's just a problem with the font size. Oh, and in the third column, the one to the right, in Dreamweaver, the font looks like it is miniscule, cannot even be read, but in the browser, since the style11 is applied, all three columns look equal size.
    Not sure where to go from here. I just want to get the body font down to 10 pixels.
    TIA,
    Ken

    John Waller wrote:
    I guess this a follow up to your earlier thread
    http://forums.adobe.com/message/3627681
    What would really help you in diagnosing issues such as this is to install the Firebug add-in for Firefox (as suggested in the earlier thread).
    Firebug shows you visually what CSS rules apply to whatever element you click on the screen.
    In this case, you have a confusion of CSS font sizes cascading on top of each other and that's confused again by mixing units for no real reason. .style11 is unnecessarily applied to lots of individual <p> tags. Remove those classes and delete the rule.
    e.g.
    The tiny font in the RHS column is affected first by
    .style8 {
    font-size: 0.5em;
    affecting the <td> then by
    .style11 {font-size: 75%}
    affecting the <p> tag.
    End result = tiny text (approx 2px).
    In these cases of mass confusion, my approach is to strip out all font sizing from the CSS and start over.
    Avoid %. Use px.
    Apply font sizing rules logically starting from the <body> tag downwards.
    That'll give you a solid baseline without weird effects.
    Ah, I find your answer worth repeating.
    Very cool that you have diagnosed so well and spelled it out here.
    I will get the Firefox add-on you mention, plus, print out this response and follow it like a recipe.
    It makes perfect sense and you have saved me from the 'clutter' of being wound up in too many directions with this because I could not make all of the connections that you have done here. I appreciate your help very much.
    Thank You,
    Ken

  • Problems with the background image size in a photobook

    Hi there, I really need help here. When I make a photobook I want to display my images large, taking the whole page. To do that I put the image as a background and it's OK. My problem is that when I do this, iPhoto always crops it. I have to use the move tool to move the image up and down, left or right to chose a best position. I don't want to do this, I want my image to be shown perfectly from end to end. I have to resize the image in many ways, even used the book's native resolution but it still doesn't work. If I choose "fit photo to frame size" I end up with two stripes at the top and the bottom of the page.
    Please help me, what size should I resize my image to, so that iPhoto displays it as it is?
    Thank you

    Hi
    The fact you are using a Mac is why both myself and JCellini assumed you where using a pre IE7 version.
    But the code you are using to test in IE will cause a problem with any 'virtual machine' such as crossover, because it cannot reference anything outside its own assigned section of the drive, and referencing the png in the way you are would be for it an invalid reference, it also would not work in any browser when you uploaded the site.
    Change - background-image:url(file:///Macintosh  HD/Users/myname/Documents/websites/test/Test/images/test_back.png);
    To - background-image:url(images/test_back.png);
    But if the region is not editable I would suggest you temporarily make it so, externalize your css to a css file, insert a link to the external css file in your head content, then lock the region once again. This way you will always be able to edit your css without worrying about 'locked regions'.
    PZ
    www.pziecina.com

  • Problem with too small page size using Java 2D Printing API.

    Hello,
    I have problem with resolution of printer using Java 2D Printing API. Despite my printer has 600 x 600 DPI, inside java.awt.print.Printable.print(Graphics, PageFormat, int) I receive page format with 600 x 840 page size.
    I have tried to set resolution using javax.print.attribute.PrintRequestAttributeSetand javax.print.attribute.standard.PrinterResolution, but with no result.
    Can anybody solve this problem?
    Regards,
    Karl.

    600 x 840 is a Point value; Point is defined as 1/72nd of an inch. Printers do have much higher DPI than this, but I believe that this DPI has to do with richness of the printed image, not an actual ability to color with that level of resolution. You might want to try calling zoom on your Graphics2D object. Otherwise, I don't know what else you can try.

  • Aperture2.0 and iweb08 - problems with size of photos

    Just got a new Imac and Aperture2 and I have my first problem. Hopefully I can explain this without sounding confusing. I have 10 photos in album "A" in Aperture. The photos are 'web ready' .jpg at 500 pixels by 500 pixels and 72 dpi. When i make an album page in iweb08 and use the media window to bring in my 'aperture album' the photos come into iweb much smaller then there original size, maybe 200 pixels by 200 pixels - I cant resize the images or if I can, there way distorted.
    Here's the tricky part.
    When I created an album in iphoto08 and placed the SAME photos in it and add it (using the media window, same step as above) into iweb - all the photos display correctly.
    So.
    What could be the problem with aperture and iweb?? Thanks for any help.
    and I have all the lastest updates including the new Aperture2.01
    Message was edited by: mezzo17

    I tried that (switching the preview resolution from 1/2 to no limit) and it didn't work.
    but then
    I deleted the entire project folder, with the albums etc. and decided to start from scratch.
    With the settings (as you guys suggested) prior to creating my folders and projects
    and just created the project folder again, created a new album folder and imported the images again.
    and then it worked just fine.
    I guess switching the preview quality while the folders 'existed' wasn't updating somewhere.
    Sounds buggy.
    Anyways. Its working now.
    I haven't gotten the .mac side of my new web working yet but you can check out the old site
    at www.garage17.com
    Thanks for the help.

Maybe you are looking for