Help with display glith using JList

Hi, first post so bit of background - I'm teaching Java at the moment, am fine with command line but am dabbling more with Swing, despite certain glitches I always get ( e.g. the 7-segment display last year) but anyway....
I've been trying to develop a little app that picks random boxers for a computer game. My current problem is that i am trying to add custom boxers and then update the JList and repaint the frame. When I add a boxer i can see it adding to the list, however it is unreadable and displayed too small.
Forgive any bad coding etiquettes - its very much a work in progress from a relatively poor programmer ;)
theBoxers is a JPanel containing the JLists, aWindow is the JFrame, customButton is a button to add a custom fighter - this gets a name from a field, and a weight from a combo box, adds it to an array and then attempts to add it to an array, then re-generate the lists
customButton.addActionListener(new ActionListener()
            public void actionPerformed(ActionEvent e)
                    addCustom(customCombo.getSelectedIndex(),addCustomName.getText());
                         System.out.println(customCombo.getSelectedIndex() + addCustomName.getText());
                         theBoxers.repaint();
                         aWindow.repaint();
public void addCustom(int theWeight, String theName)
          switch(theWeight)
               case 0:          featherCustoms[featherCustomsSize]=theName;
                              featherFighters = new JList(featherCustoms);
                              featherCustomsSize++;
                              break;
               case 1:          lightCustoms[lightCustomsSize]=theName;
                              lightFighters = new JList(lightCustoms);
                              lightCustomsSize++;
                              break;
               case 2:          welterCustoms[welterCustomsSize]=theName;
                              welterFighters = new JList(welterCustoms);
                              welterCustomsSize++;
                              break;
               case 3:          middleCustoms[middleCustomsSize]=theName;
                              middleFighters = new JList(middleCustoms);
                              middleCustomsSize++;
                              break;
               case 4:          lightHeavyCustoms[lightHeavyCustomsSize]=theName;
                              lightHeavyFighters = new JList(lightHeavyCustoms);
                              lightHeavyCustomsSize++;
                              break;
               case 5:          heavyCustoms[featherCustomsSize]=theName;
                              heavyFighters = new JList(heavyCustoms);
                              heavyCustomsSize++;
                              break;
               default:     System.out.println("Not Added");
                              break;
     }

Awww, its nice that DB has someone to comeback and carry on a discussion.....long after its over.
The problem here seems to be your lack of understanding between what a teacher or what an 'instructor' is.
From the way you speak, an instructor appears to be someone who is technically skilled in both coding and teaching Java as a programming language, designed for people who wish to code in Java.
A Teacher is someone who must deliver a wide range of subject knowledge to a wide range of abilities, including those who were unable to pass High-School exams. They are responsible for pitching the subject at the correct level for the student, whilst also teaching towards passing the exam, and ultimately gaining a qualification.
The computing course i am currently teaching does not require OOP, but as Java is the language i was taught at University, and is still often used in our University's, I chose it. I don't pretend to be the best programmer in the world. But I do know that I am teaching the pupils the correct basics, at a higher level than is probably required, to give them the right approach at university. also, this is whilst teaching a large amount of theory.
Whether you agree, or disagree, matters not to me as I think you would be unfamilier with the specification I am currently teaching to, or what area's of study need to be taught. The exam board appears happy, as do past students who are now well into their university course, as did my marker when i achieved my degree.
The code posted in the OP (as stated earlier) had nothing to do with displaying my coding abilities, nor did it display the technique's I use when teaching students. It was a small sample of a program which included a JList which was not displaying properly. I tried to include the whole code but it was too big, therefore it was cut down.
It was a work in progress which i now have working. So now i can look at it again in terms of programming structure. It appears I have made a mistake asking for assistance on here, as instead I got a lecture, with very little insight on your part as to my situation or the nature of the problem/solution.
At the end of the day, each to his/her own opinion. What I will say is that when someone requests help, positive feedback/criticism is well recieved along with instructions/guidance on how the problem can be solved. I feel that I received none of this on here, but this is what I will always provide to the students I teach.
Not everyone is a full-time Java programmer or has the time to hit the highest expectations.

Similar Messages

  • Help with displaying image using OpenGL ES sample code - image size prb

    I am using some sample code that currently displays an image 256x256 pixels. The code states the image size must be a power of 2. I have tried an image 289x289 (17^2) and it displays a square the same size as the 256x256 with a white background. I want an image 320x320 displayed. Should be obvious for people familiar with OpenGL. Here is the code which displays the image and rotates:
    - (void)setupView
    // Sets up an array of values to use as the sprite vertices.
    const GLfloat spriteVertices[] = {
    -0.5f, -0.5f,
    0.5f, -0.5f,
    -0.5f, 0.5f,
    0.5f, 0.5f,
    // Sets up an array of values for the texture coordinates.
    const GLshort spriteTexcoords[] = {
    0, 0,
    1, 0,
    0, 1,
    1, 1,
    CGImageRef spriteImage;
    CGContextRef spriteContext;
    GLubyte *spriteData;
    size_t width, height;
    // Sets up matrices and transforms for OpenGL ES
    glViewport(0, 0, backingWidth, backingHeight);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrthof(-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f);
    glMatrixMode(GL_MODELVIEW);
    // Clears the view with black
    //glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClearColor(255, 255, 255, 1.0f);
    // Sets up pointers and enables states needed for using vertex arrays and textures
    glVertexPointer(2, GL_FLOAT, 0, spriteVertices);
    glEnableClientState(GLVERTEXARRAY);
    glTexCoordPointer(2, GL_SHORT, 0, spriteTexcoords);
    glEnableClientState(GLTEXTURE_COORDARRAY);
    // Creates a Core Graphics image from an image file
    spriteImage = [UIImage imageNamed:@"bottle.png"].CGImage;
    // Get the width and height of the image
    width = CGImageGetWidth(spriteImage);
    height = CGImageGetHeight(spriteImage);
    // Texture dimensions must be a power of 2. If you write an application that allows users to supply an image,
    // you'll want to add code that checks the dimensions and takes appropriate action if they are not a power of 2.
    if(spriteImage) {
    // Allocated memory needed for the bitmap context
    spriteData = (GLubyte *) malloc(width * height * 4);
    // Uses the bitmatp creation function provided by the Core Graphics framework.
    spriteContext = CGBitmapContextCreate(spriteData, width, height, 8, width * 4, CGImageGetColorSpace(spriteImage), kCGImageAlphaPremultipliedLast);
    // After you create the context, you can draw the sprite image to the context.
    CGContextDrawImage(spriteContext, CGRectMake(0.0, 0.0, (CGFloat)width, (CGFloat)height), spriteImage);
    // You don't need the context at this point, so you need to release it to avoid memory leaks.
    CGContextRelease(spriteContext);
    // Use OpenGL ES to generate a name for the texture.
    glGenTextures(1, &spriteTexture);
    // Bind the texture name.
    glBindTexture(GLTEXTURE2D, spriteTexture);
    // Speidfy a 2D texture image, provideing the a pointer to the image data in memory
    glTexImage2D(GLTEXTURE2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GLUNSIGNEDBYTE, spriteData);
    // Release the image data
    free(spriteData);
    // Set the texture parameters to use a minifying filter and a linear filer (weighted average)
    glTexParameteri(GLTEXTURE2D, GLTEXTURE_MINFILTER, GL_LINEAR);
    // Enable use of the texture
    glEnable(GLTEXTURE2D);
    // Set a blending function to use
    glBlendFunc(GL_ONE, GLONE_MINUS_SRCALPHA);
    // Enable blending
    glEnable(GL_BLEND);
    // Updates the OpenGL view when the timer fires
    - (void)drawView
    // Make sure that you are drawing to the current context
    [EAGLContext setCurrentContext:context];
    glBindFramebufferOES(GLFRAMEBUFFEROES, viewFramebuffer);
    glRotatef(direction * 3.0f, 0.0f, 0.0f, 1.0f);
    glClear(GLCOLOR_BUFFERBIT);
    glDrawArrays(GLTRIANGLESTRIP, 0, 4);
    glBindRenderbufferOES(GLRENDERBUFFEROES, viewRenderbuffer);
    [context presentRenderbuffer:GLRENDERBUFFEROES];
    }

    +I am using some sample code that currently displays an image 256x256 pixels. The code states the image size must be a power of 2. I have tried an image 289x289 (17^2)+
    The phrase "a power of 2" refers to 2^x so your choices above 256 are 512, 1024 etc.
    The texture size has nothing to do with the displayed size - OGL will stretch or shrink your texture to fit the size of the polygon you're displaying it on. I recommend you scale your image to 256x256 and work on make the polygon the size you want and work on your image quality from there.
    You can work on the size or orientation of the poly surface to make it larger but OGL doesn't support setting a model to a screen image size or anything like that. That sounds more like a Quartz or CoreGraphics kind of thing if you want to set an exact screen size to the pixel.
    HTH,
    =Tod
    PS You can display your code correctly by using { code } (without the spaces) on either side of your code block.

  • A little help with displaying a % using printf

    I know this is rather basic, but since I don't know, I thought I'd ask. I am trying to display a % while using printf, but printf is interpreting it as a format modifier. I need to use printf because I intend to use the format modifiers, but there must be a way to type a percent, such as -5%.
    The line in question is
    System.out.printf( "Inventory Value (-5% Restock fee): $%.2f\n", videogame[p].getRestockInvValue() );
    When I try this, of course I get a run-time formatting error.

    BigDaddyLoveHandles wrote:
    Thanks. By the way, the correct way to put a "newline" into your format is to use %n -- that will generate the right new line character sequence for your platform.Natch, that assumes that you are targetting the running platform versus matching a specification for example where the end of line is specifically defined (and thus might not match the running platform.)

  • Help with display quality (LCD TV)

    I've hooked up my Mac mini to my Samsung 32" LCD TV via HDMI cable.
    The overall quality is just far from desireable and is taking away all of the fun from using this new mac.
    I set the resolution output to 720p, which is what the TV supports. So that's good.
    I played slightly with the Contrast and Brightness on the TV settings.
    But I must be missing something. Although the image is sharp, it's very difficult to read from 6ft away, pictures look terrible (seeing the same picture on a different computer and monitor is so much more revealing), and the display is bad for everything basically.
    Please help with any settings suggestions or perhaps a detailed guideline for my setup.
    I started to configure a color profile on the display settings but the results weren't that great and I reverted to default. Too many subtle changes. My colorblindness probably doesn't help.
    Thanks.

    Thanks for the response.
    It's the latest Mac Mini with 2.5ghz i5, AMD Radeon HD 6630M, and 8GB RAM.
    I am familiar with the "Just Scan" setting under picture size on the Samsung TV.
    I'll look for the digital noise reduction.
    Are there complete guides with recommended settings for different setups? Or maybe even general, that would help me here?
    Thanks.

  • Help with display settings needed urgently

    Graphics and icons that are supposed to be round appear oval. For instance the Safari and App icons on the dock appear very oval. Logos on websites I've visited before and I know are round appear oval.
    I've tried all display settings and nothing helps. I'm a designer and this is causing a major hinderance. Everything appears condenced / squashed sideways. I'd be very grateful if someone could help with this.
    I've just purchased the laptop. I have been using Mac for a few years and I've always selected the "stretched" option from the Display settings which sorted out the problem completely. A circle looked a proper circle. But in this version the option is not available.
    Badly hoping someone can help with this.
    Thanks.
    Version Details - OS X Lion 10.7.4

    It sounds like you have selected an incorrect resolution.  For starters, are you talking about your Air's display or an external display?  You haven't said which Air you have.  If you have an 11" model, make sure your display resolution is set to 1366x768.  If you have a 13" model, it should be set to 1440x900.  These are the proper resolutions for the built in displays.  Chosing anything other than the referenced "native" display resolutions will result in distortions or clarity problems. 

  • Help with Photo Gallery using XML file

    I am creating a photo gallery using Spry.  I used the Photo Gallery Demo (Photo Gallery Version 2) on the labs.adobe.com website.  I was successful in creating my site, and having the layout I want.  However I would like to display a caption with each photo that is in the large view.
    As this example uses XML, I updated my file to look like this:
    <photos id="images">
                <photo path="aff2010_01.jpg" width="263" height="350" thumbpath="aff2010_01.jpg" thumbwidth="56"
                   thumbheight="75" pcaption="CaptionHere01"></photo>
                <photo path="aff2010_02.jpg" width="350" height="263" thumbpath="aff2010_02.jpg" thumbwidth="75"
                   thumbheight="56" pcaption="CaptionHere02"></photo>
                <photo path="aff2010_03.jpg" width="350" height="263" thumbpath="aff2010_03.jpg" thumbwidth="75"
                   thumbheight="56" pcaption="CaptionHere03"></photo>
    </photos>
    The images when read into the main file (index.asp) show the images in the thumbnail area and display the correct image in the picture pain.  Since I added the pcaption field to the XML file, how do I get it to display?  The code in my index.html file looks like this:

    rest of the code here:
            <div id="previews">
                <div id="controls">
                    <ul id="transport">
                        <li><a href="#" class="previousBtn" title="Previous">Previous</a></li>
                        <li><a href="#" class="playBtn" title="Play/Pause" id="playLabel"><span class="playLabel">Play</span><span class="pauseLabel">Pause</span></a></li>
                        <li><a href="#" class="nextBtn" title="Next">Next</a></li>
                    </ul>
                </div>
                <div id="thumbnails" spry:region="dsPhotos" class="SpryHiddenRegion">
                    <div class="thumbnail" spry:repeat="dsPhotos"><a href="{path}"><img alt="" src="{thumbpath}"/></a><br /></div>
                    <p class="ClearAll"></p>
                </div>
            </div>
            <div id="picture">
                <div id="mainImageOutline"><img id="mainImage" alt="main image" src=""/><br /> Caption:  {pcaption}</div>
            </div>
            <p class="clear"></p>
        </div>
    Any help with getting the caption to display would be greatly appreciated.  The Caption {pcaption} does not work,

  • Help with displaying image received from socket on Canvas

    Dear programmers
    I know that I'm pestering you lot for a lot of help but I just got one tiny problem which I just can't get over.
    I'm developing a remote desktop application which uses an applet as it's client and I need help in displaying the image.
    When a connection is made to the server, it continuously takes screenshots, converts them to jpg and then send them to the client applet via socket communication. I've got the the server doing this in a for(;;) loop and I've tested the communication and all seems to be working fine. However the applet is causing some issues such as displaying "loading applet" until I stop the server and then the 1st screenshot is displayed. Is there a way to modify the following code so that it displays the current image onto a canvas while the next image is being downloaded and then replace the original image with the one which has just been downloaded. All this needs to be done with as little flicker as possible.
    for(;;)
        filename = dis.readUTF();
        fileSize = dis.readInt();
        fileInBuffer = new byte[fileSize];
        dis.readFully(fileInBuffer, 0, fileSize-1);
        //Create an image from the byte array
        img = Toolkit.getDefaultToolkit().createImage(fileInBuffer);
        //Create a MyCanvas object and add the canvas to the applet
        canvas = new IRDPCanvas(img, this);
        canvas.addMouseListener(this);
        canvas.addKeyListener(this);
        add(canvas);
    }

    Anyone?

  • Help with display of numbers

    First of all I have to say the tutorials on this site are extremely helpful. My instructor wants all our java code written as Object Oriented and when I did a search on here for Object Oriented it totally helped out. Now I just need help with the display of numbers, my code works perfectly fine except that the number has wayyyyyyyyyyy to many decimal points after it. I only wanted two.
    public class Mortgage
         double mtgAmount;
         double mtgTerm;
         double mtgRate;
         double monthPymt;
              public void Amount(double newValue)
                     mtgAmount = newValue;
              public double Amount()
                   return mtgAmount;
              public void Term(double newValue)
                     mtgTerm = newValue;
              public double Term()
                   return mtgTerm;
              public void Rate(double newValue)
                     mtgRate = newValue;
              public double Rate()
                   return mtgRate;
              public void calcmonthPymt(double newValue)                            //(LoanAmt * Rate) / (1- Math.pow(1+Rate,-Term));
                     monthPymt = (newValue);
              public void display()
              System.out.println ("The Mortgage Amount is:" +(Amount( ) * Rate( )) / (1- Math.pow(1+Rate( ),-Term( ))));
         public static void main (String[] args)
                     Mortgage Mortgage1=new Mortgage();
                     Mortgage1.Amount(200000);
                     Mortgage1.Term(360);
                     Mortgage1.Rate(.0575);
                     Mortgage1.display();
    }

    I figured it out, the math is wrong I think but I got everything to display correctly
    import java.io.*;
    import java.text.*;
    import java.text.DecimalFormat;
    public class Mortgage
         double mtgAmount;
         double mtgTerm;
         double mtgRate;
         double monthPymt;
         DecimalFormat money = new DecimalFormat("$0.00");
              public void Amount(double newValue)
                     mtgAmount = newValue;
              public double Amount()
                   return mtgAmount;
              public void Term(double newValue)
                     mtgTerm = newValue;
              public double Term()
                   return mtgTerm;
              public void Rate(double newValue)
                     mtgRate = newValue;
              public double Rate()
                   return mtgRate;
              public void calcmonthPymt(double newValue)                            //(LoanAmt * Rate) / (1- Math.pow(1+Rate,-Term));
                     monthPymt = (newValue);
              public void display()
              monthPymt = (Amount( ) * Rate( )) / (1- Math.pow(1+Rate( ),-Term( )));
              System.out.printf("The payment amount is:$%.2f", monthPymt);
              System.out.println();
         public static void main (String[] args)
                     Mortgage Mortgage1=new Mortgage();
                     Mortgage1.Amount(200000);
                     Mortgage1.Term(360);
                     Mortgage1.Rate(.0575);
                     Mortgage1.display();
    }

  • Help with swap images using rollovers

    I have a website created using DW CS5. Recently purchased FW CS5 to help with web graphics and design. I am trying to create a list of numbers that will swap with images. The intial page would simply be a list of numbers and 1 static image. Each number, when hovered will change the image with another. I've attempted this by first using DW and not having much success with FW either.
    If able to complete this using FW, is it possible to export the file for use in DW? Then insert into an AP Div?

    You're over-complicating it.
    Simply hit File>Save once you're done in photoshop.
    ian

  • Need Help With Military DTD Using FrameMaker 8

    Fellow Forum Members,
    I hope someone out there with experience in using Department of Defense DTDs with FrameMaker can contribute to this thread.
    Attached is the MIL STD 400051-2 DTD that needs to play with FrameMaker. Does anyone out there know where I could find FrameMaker templates already setup that comply and play with the MIL STD 400051-2 DTD standard? If the Department of Defense is freely distributing the MIL STD 400051-2 DTD, shouldn't somebody in the Department of Defense also be providing MIL STD 400051-2 FrameMaker Templates for free that are already setup?  I would greatly appreciate if anyone out there could provide an online source where I could download MIL STD 400051-2 FrameMaker templates.
    Lastly, can anyone out there clarify what the purpose of the entities are inside the "Charant" and "Boilerplate" folders?  The Department of Defense does not provide a readme file that define what the "Charant" and "Boilerplate" folders are about.
    Any info will be greatly appreciated. Thanks.

    I'll answer the specifics that I know about your questions, but please look at the post from Srini for additional info:
    1) Do i need to do full export using SYS/SYSTEM user.
    exp80 system/manager file=c:full.dmp log=c:\full.txt full=y consistent=yA full export will move as much information (metadata/data) as possible. In order to do a full export/import, you need to do this from a
    privileged account. A privileged account is one with EXP_FULL_DATABASE for export and IMP_FULL_DATABASE for import.
    2) Will there be any data corruption while export.The data in the objects that you are exporting is being read, nothing is written to user data. I'm not sure what this is available in 8.0.6,
    but if you need a consistent export, look to see if consistent=y is available in 8.0.6. All this means is that the dump file created will have
    consistent data in it.
    3) Is export/import the only method of migration/upgradation.If you are changing hardware, the only supported way from 8.0 to 10.2.0.4, that I know of, is using exp/imp.
    Hope this helps.
    Dean

  • Help with displaying integer values

    I am not sure what is going on in my code.
    I have a field where  use
    <?php
    if ($pets==1) echo "Pets Allowed";
    ?>
    and that works fine.  Integer 1 in my database.
    But when I want to use that for another field, same exact settings, just different field, nothing shows up.  Even tried putting in quotes.  I queried from mysql with success and using the entered value of 1 in the dreamweaver recordset window and it showd.  But yet the PHP wont display.

    That's the thing.  Everything is exactly the same.  The line of code is copied and only replacing pets with cdla.

  • Help with displaying images (gif, jpeg...) within a JFrame (or similar)

    Hi all,
    i'm new to the forum and i'll be granted if you kind gentlemen/women could use some advices for my gui home application.
    My purpose is to display a static image in a container (i'd prefer to use javax.swing objects, but if you think that java.awt is more suitable for my app, please feel free to tell me about...). I used a modified code from one of the Java Tutorial's examples, tht actually is an applet and displays images as it is using the paint() method. I just can't realize how to set the GraphicContext in a JFrame or a JPanel to contain the image to display, without using applets. Following part of the code I use (a JButton will fire JApplet start, JApplet is another class file called Apple.java):
    class DMToolz extends JFrame {
         private static final long serialVersionUID = 1L;
         private JPanel jContentPane = null;
         private JButton jButton = null;
         private JComboBox jComboBox = null;
         private JMenuItem jMenuItem = null;
         private JMenuBar jJMenuBar = null;
         private JMenu jMenu = null;
         private JMenu jMenu1 = null;
         public int w=10, h=10;
         public String filename;
          * @throws HeadlessException
         public DMToolz() throws HeadlessException {
              // TODO Auto-generated constructor stub
              super();
              initialize();
         public DMToolz(String arg0) throws HeadlessException {
              super(arg0);
              // TODO Auto-generated constructor stub
              initialize();
          * This method initializes jButton
          * @return javax.swing.JButton
         private JButton getJButton() {
              if (jButton == null) {
                   jButton = new JButton();
                   jButton.setBounds(new Rectangle(723, 505, 103, 38));
                   jButton.setText("UrcaMado'");
                   jButton.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) {
    /**************SCRIVERE QUI IL NOME DEL FILE CON L'IMMAGINE DA CARICARE*******************/
                             filename = "reference table player2.gif";
                           java.net.URL imgURL = DMToolz.class.getResource("images/"+filename);
                           BufferedImage img = null;
                           try {
                                img =  ImageIO.read(imgURL);
                               w = img.getWidth();
                               h = img.getHeight();
                               System.out.println("*DM* Immagine letta - W:"+w+" H:"+h);
                            } catch (Exception ex) {System.out.println("*DM* Immagine non letta");}
                           JApplet a = new Apple();
                           a.setName(filename);
                           JFrame f = new JFrame ("UrcaBBestia!");
                           f.addWindowListener(new WindowAdapter() {
                               public void windowClosing(WindowEvent e) {System.exit(0);}
                           f.getContentPane().add(a);
                           f.setPreferredSize( new Dimension(w,h+30) );//30 � (circa) l'altezza della barra del titolo del frame
                               f.pack();
                             f.setVisible(true);                      
              return jButton;
    public class Apple extends JApplet {
         private static final long serialVersionUID = 1L;
        final static Color bg = Color.white;
        final static Color fg = Color.black;
        final static Color red = Color.red;
        final static Color white = Color.white;
        public void init() {
            //Initialize drawing colors
            setBackground(bg);
            setForeground(fg);
        public void paint(Graphics g) {
            Graphics2D g2 = (Graphics2D) g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            try {
                 String filename = this.getName(); //uso il nome dell'applet come riferimento al nome del file da caricare
                 java.net.URL imgURL = DMToolz.class.getResource("images/"+filename);
                 BufferedImage img =  ImageIO.read(imgURL);
                 if (img.equals(null)) {System.out.println("IMG null!");System.exit(0);}
                System.out.println("IMG letta");
                int w = img.getWidth();
                int h = img.getHeight();
                resize(w,h);
                g2.drawImage(img,
                            0,0,Color.LIGHT_GRAY,
                            null);// no ImageObserver
             } catch (Exception ex) {ex.printStackTrace();
                                          System.out.println("Immagine non letta.");System.exit(0);}
    }//end classPlease never mind about some italian text, used as reminder....
    Thanks in advance.

    Read the Swing tutorial on "How to Use Labels" or "How to Use Icons" for working examples:
    http://java.sun.com/docs/books/tutorial/uiswing/TOC.html
    By the way you should never override the paint() method. Custom painting (not required in this case) is done by overriding the paintComponent(...) method in Swing. Overriding paint() is an old AWT trick.

  • Help with Switch statements using Enums?

    Hello, i need help with writing switch statements involving enums. Researched a lot but still cant find desired answer so going to ask here. Ok i'll cut story short.
    Im writing a calculator program. The main problem is writing code for controlling the engine of calculator which sequences of sum actions.
    I have enum class on itself. Atm i think thats ok. I have another class - the engine which does the work.
    I planned to have a switch statement which takes in parameter of a string n. This string n is received from the user interface when users press a button say; "1 + 2 = " which each time n should be "1", "+", "2" and "=" respectively.
    My algorithm would be as follows checking if its a operator(+) a case carry out adding etc.. each case producing its own task. ( I know i can do it with many simple if..else but that is bad programming technique hence im not going down that route) So here the problem arises - i cant get the switch to successfully complete its task... How about look at my code to understand it better.
    I have posted below all the relevant code i got so far, not including the swing codes because they are not needed here...
    ValidOperators v;
    public Calculator_Engine(ValidOperators v){
              stack = new Stack(20);
              //The creation of the stack...
              this.v = v;          
    public void main_Engine(String n){
           ValidOperators v = ValidOperators.numbers;
                    *vo = vo.valueOf(n);*
         switch(v){
         case Add: add();  break;
         case Sub: sub(); break;
         case Mul: Mul(); break;
         case Div: Div(); break;
         case Eq:sum = stack.sPop(); System.out.println("Sum= " + sum);
         default: double number = Integer.parseInt(n);
                       numberPressed(number);
                       break;
                      //default meaning its number so pass it to a method to do a job
    public enum ValidOperators {
         Add("+"), Sub("-"), Mul("X"), Div("/"),
         Eq("="), Numbers("?"); }
         Notes*
    It gives out error: "No enum const class ValidOperators.+" when i press button +.
    It has nothing to do with listeners as it highlighted the error is coming from the line:switch(v){
    I think i know where the problem is.. the line "vo = vo.valueOf(n);"
    This line gets the string and store the enum as that value instead of Add, Sub etc... So how would i solve the problem?
    But.. I dont know how to fix it. ANy help would be good
    Need more info please ask!
    Thanks in advance.

    demo:
    import java.util.*;
    public class EnumExample {
        enum E {
            STAR("*"), HASH("#");
            private String symbol;
            private static Map<String, E> map = new HashMap<String, E>();
            static {
                put(STAR);
                put(HASH);
            public String getSymbol() {
                return symbol;
            private E(String symbol) {
                this.symbol = symbol;
            private static void put(E e) {
                map.put(e.getSymbol(), e);
            public static E parse(String symbol) {
                return map.get(symbol);
        public static void main(String[] args) {
            System.out.println(E.valueOf("STAR")); //succeeds
            System.out.println(E.parse("*")); //succeeds
            System.out.println(E.parse("STAR")); //fails: null
            System.out.println(E.valueOf("*")); //fails: IllegalArgumentException
    }

  • Help with displaying errors in jsp using html:errors/

    Here is my problem.
    In my overridden ActionForm.validate() method, i am returning ActionErrors (as required). When there are input errors in my form submission, the control goes back to the JSP page i used to read user input (so far so good). The JSP page is rendered fine for taking input for the second time but no errors are displayed although i am using the tag <html:errors/>
    I tried to find the org.apache.struts.action.ERROR in my request attributes and it is there with the size of 1 (because i am reporting one error, in my sample run). Any idea why <html:errors/> won't display the errors even though they are there??? Here is what i am doing in my ActionForm class:
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
    if (this.email == null || this.email.length() < 1) {
    errors.add("username", new ActionError
    ("error.username.required"));
    return errors;
    Any help is appreciated.

    First of all, thanks for taking time to look at my message. Here is how my message-resources tag look like in struts-config.xml file:
    <message-resources parameter="ApplicationResources"/>
    The "ApplicationResources.properties" file exist in the WEB-INF folder of my application and following are the entries in that file that i think are relevant:
    errors.header=<h3><font color="red">Validation Error</font></h3>You must correct the following error(s) before proceeding:<ul>
    errors.footer=</ul><hr>
    error.username.required=<li>Username is required</li>
    Is there anything else needed to go into resource file? Or should i put my resource file somewhere else?

  • Help with displaying BLOBs in OBIEE 11g

    I am trying to get OBIEE 11g to display photographs in an Analysis report. I know BLOB fields are not supported, and I have been reading posts on this board and following examples on internet sites that try to get round this problem. But, try as I might, I cannot get those pesky photos to display.
    Below are all the steps I have followed. Sorry that there is a lot to read, but I was hoping that somebody has been successful in doing this, and may spot something in one of my steps that I am doing wrong.
    ORACLE TRANSACTIONAL SOURCE_
    Table : EMPL_PHOTO
    Fields:
    USN VARCHAR2(11) ( Unique Key )
    EMPLOYEE_PHOTO BLOB ( I think the photos are stored as 'png' )
    ORACLE WAREHOUSE SOURCE_
    Table : D_PERSON_PHOTO_LKUP
    Fields :
    PERSON_KEY     NUMBER(38,0) ( Primary Key - Surrogate )
    USN     VARCHAR2(11)
    PHOTO     CLOB
    BLOB to CLOB conversion.
    I used this function :
         create or replace function blob_to_clob_base64(p_data in blob)
         return clob
         is
         l_bufsize integer := 16386;
         l_buffer raw(16386);
         l_offset integer default 1;
         l_result clob;
         begin
         dbms_lob.createtemporary(l_result, false, dbms_lob.call);
         loop
         begin
         dbms_lob.read(p_data, l_bufsize, l_offset, l_buffer);
         exception
         when no_data_found then
         exit;
         end;
         l_offset := l_offset + l_bufsize;
         dbms_lob.append(l_result, to_clob(utl_raw.cast_to_varchar2(utl_encode.base64_encode(l_buffer))));
         end loop;
         return l_result;
         end;
         select usn, employee_photo ,
         BLOB_TO_CLOB_BASE64(employee_photo)
         from empl_photo
    IN OBIEE ADMINISTRATION TOOL_
    *1) Physical Layer*
    Added D_PERSON_PHOTO_LKUP from Connection Pool
    Left it as 'Cachable'
    Didn't join it to any tables
    Changed field PHOTO to a 'LONGVARCHAR' length 100000
    Set USN as the Key ( not the surrogate key )
    *2) BMM Layer*
    Dragged D_PERSON_PHOTO_LKUP across.
    Renamed it to 'LkUp - Photo'
    Ticked the 'lookup table' box
    Removed the surrogate key
    Kept USN as the Primary key
    The icon shows it similar to a Fact table, with a yellow key and green arrow.
    On Dimension table D_PERSON_DETAILS (Dim - P01 - Person Details) added a new logical column
    Called it 'Photo'
    Changed the column source to be derived from an expression.
    Set the expression to be :
    Lookup(DENSE
    "People"."LkUp - Photo"."PHOTO",
    "People"."Dim - P01 - Person Details"."USN" )
    Icon now shows an 'fx' against it.
    Note: This table also had it Surrogate key removed, and USN setting as primary key.
    *3) Presentation Layer*
    Dragged the new Photo field across.
    Saved Repository file, uploaded, and restarted server.
    ONLINE OBIEE_
    Created a new Analysis.
    Selected USN from 'Person Details'
    Selected Photo from 'Person Details'
    Selected a measure from the Fact table
    Under column properties of Photo ( data format ) :
    - Ticked 'Override Default Data Format' box
    - Set to Image URL
    - Custom text format changed to : @[html]"<img alt="" src=""@H"">"
    Under column properties of Photo ( edit formula ) :
    - Changed to : 'data:image/png;base64,'||"Person Details"."Photo"
    The Advanced tab shows the sql as :
         SELECT
         0 s_0,
         "People"."Person Details"."USN" s_1,
         'data:image/png;base64,'||"People"."Person Details"."Photo" s_2,
         "People"."MEASURE"."Count" s_3
         FROM "People"
         ORDER BY 1, 2 ASC NULLS LAST, 3 ASC NULLS LAST
         FETCH FIRST 65001 ROWS ONLY
    Going into the 'results' tab, get error message:
    +State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 17001] Oracle Error code: 932, message: ORA-00932: inconsistent datatypes: expected - got CLOB at OCI call OCIStmtExecute. [nQSError: 17010] SQL statement preparation failed. (HY000)+
    It doesn't seem to be using the Lookup table, but can't work out at which step I have gone wrong.
    Any help would be appreciated.
    Thanks

    Thanks, yes I followed http://docs.oracle.com/cd/E28280_01/bi.1111/e10540/busmodlayer.htm#BGBDBDHI, but when I get to the part of setting the LOOKUP function on th Physical source, only ONE physical source is displayed. I need TWO sources ( The Employee Table, and the Photo LookUp.
    I have raised this as an error with Oracle. We are now on OBIEE 11.1.1.7, but Oracle say BLOBS are still not supported in that release. It will be fixed in 11.1.1.8 and it will be backported into 11.1.1.6.11
    In the meantime we have abandoned showing Photo's in any of our reports.

Maybe you are looking for

  • Viewing/extracting SAP structure and Table DDL

    Hope someone can help me ....I I want to create tables with column names as exactly as those in SAP, for an ETL process. I was able to get the DDL for VBAP, though I had to edit quite a few things. But couldn't get those of Structures (tried KUAGV).

  • Not enough USB ports!

    I have 3 USB ports on my G5 and 4 things that need to be powered directly off them (the keyboard; a DigiDesign M-Box; a Mackie Baby HUI; and a 4-port hub). How can I get this to work all at once? I'd rather not have to un-plug the 4-port hub every ti

  • Strange User Account behaviour at Log In - not solved re duplicate thread

    This morning I cold booted my laptop and strangely after signing in it declared that it was "Preparing Windows." I was then taken to a desktop with empty Documents etc. folders. Panicking I went to the User Accounts and found all my folders and data

  • Configure the stamp ,Digital signature and water mark in DMS

    Hi... I want to configure the stamp ,Digital signature and water mark in for my client in DMS. Stamp:detaiils showing doc type, doc status,who has open, doc no,version,date and time Digital Sign:with respect to approval (system should ask user name a

  • Unzipping a gz file that's in a JMS Message

    Could anyone please help me figure out how to unzip a message from a JMS Message. I have tried all sorts of things and I just can't get it to work. Jeremy