Need help in POI plugin in java

Hi,
I am doing a monthly status report using POI plug-in.
Now i am having problem: for example to SUM the cells to one cell:
Example : A1=SUM(A2+A3) ( its working fine)
but if i do SUM for more cells using " : " this caracter its not working :(
=SUM(A1:A10)
How to slove the problem ?
Hope to hear from you soon :)
Cheers,
Sundar Rajagopal

Several solutions:
1) Use A1+A2+A3+...+A10 instead.
2) Rise a bug/feature report at their website/issuetracker and hope that they get it fixed in next release.
3) Try another Excel API's, such as JExcelAPI at Sourceforge.net.

Similar Messages

  • I need help for printing service in Java

    Hello :
    I need to print some file from java program .
    I did every thing , but when i run the program : it didn't return any printer as print service from the system, although I install 2 printers in my system.
    by the way : i use Windows XP

    I was in a rush this morning and forgot my crystal ball. Please post your code and remember to use the code tags.

  • Hello everyone, Need help using POI to access xslx data

    Hi,
    i am trying to make a simple program in OATS which will fetch data and display the output from a xlsx file.
    The file name is DriverAdapter and its java script is as below. I have written a java class called ActionDriver whch performs the actions for me using the POI api. But when i instantiate ActionDriver,
    it is throwing the exception referrring to POI api classes cannot be found. ClassNotFoundException : org.apache.poi.openxml4j.exceptions.InvalidOperationException;
    Can someone help me out to find how can i run this through DriverAdapter. When i tried to run ActionDriver from the same project as a java application by replacing my method with main, it is running fine.
    import oracle.oats.scripting.modules.basic.api.*;
    import oracle.oats.scripting.modules.browser.api.*;
    import oracle.oats.scripting.modules.functionalTest.api.*;
    import oracle.oats.scripting.modules.utilities.api.*;
    import oracle.oats.scripting.modules.utilities.api.sql.*;
    import oracle.oats.scripting.modules.utilities.api.xml.*;
    import oracle.oats.scripting.modules.utilities.api.file.*;
    import oracle.oats.scripting.modules.webdom.api.*;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.Iterator;
    import ats.test.ActionDriver;
    public class script extends IteratingVUserScript {
         @ScriptService oracle.oats.scripting.modules.utilities.api.UtilitiesService utilities;
         @ScriptService oracle.oats.scripting.modules.browser.api.BrowserService browser;
         @ScriptService oracle.oats.scripting.modules.functionalTest.api.FunctionalTestService ft;
         @ScriptService oracle.oats.scripting.modules.webdom.api.WebDomService web;
         @ScriptService oracle.oats.scripting.modules.formsFT.api.FormsService forms;
         private static String myData="C:/data.xlsx";
         public void initialize() throws Exception {
              //initializing ActionDriver
              dAction = new ActionDriver();
         * Add code to be executed each iteration for this virtual user.
         public void run() throws Exception{
              dAction.startAction(myData);
         public void finish() throws Exception {
    Below is the code for my ActionDriver
    package ats.test;
    //package sni.test.ats;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.Iterator;
    import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
    import org.apache.poi.poifs.filesystem.POIFSFileSystem;
    import org.apache.poi.xssf.usermodel.XSSFCell;
    import org.apache.poi.xssf.usermodel.XSSFRow;
    import org.apache.poi.xssf.usermodel.XSSFSheet;
    import org.apache.poi.xssf.usermodel.XSSFWorkbook;
    public class ActionDriver
         public static void main (String ar[])
         //public void startAction(String myData)
              boolean b = true;
              try
                   XSSFWorkbook wb = new XSSFWorkbook("c:/data.xlsx");
                   //XSSFWorkbook wb = new XSSFWorkbook(myData);
                   XSSFSheet sheet = wb.getSheet(DataConstants.businessFlow);
                   ArrayList businessRule = new ArrayList();
    Iterator rows = sheet.rowIterator();
    String myScripts[];
    while (rows.hasNext())
    XSSFRow row = (XSSFRow) rows.next();
    row = (XSSFRow) rows.next();
    Iterator cells = row.cellIterator();
    while (cells.hasNext())
         XSSFCell cell = (XSSFCell) cells.next();
         if (cell.getCellType()==XSSFCell.CELL_TYPE_NUMERIC )
              businessRule.add(cell.getNumericCellValue());
         else
              businessRule.add(cell.getStringCellValue());
    performAction(businessRule);
              catch(Exception fife)
                   System.out.println("Exception Occured"+fife);
                   b=false;
              /*catch(IOException ie)
                   System.out.println("Error Handling Input File"+ie);
         public static void performAction(ArrayList businessRules)
              Object[] businessRuleArray = businessRules.toArray();
              boolean b=true;
              for (int i=1; i<businessRuleArray.length;i++)
                   if(b)
                        String rule = businessRuleArray.toString();
                        System.out.println(rule);
                   else
                   break;

    [this |http://blogs.oracle.com/aamat/2009/06/load_testing_your_oracle_datab_1.html] Hi
    Is that class located in the same folder as the script.java class?
    If note you will need to add it on the manifest, you can look at this blogs for instructions on how to edit the manifest file.
    Regards
    Alex

  • Need help with gallery plugin

    Hola
    I need your help (again) to figure it out
    why the lightbox plugin is not working in this site.
    http://mydsigner.com/claudia/gallery_manteca.html
    So you people know, this is the site that I asked before in this link;
    What's up with the new Adobe wants to use your confidential information thing
    Here is the original site;
    http://www.lascasuelasmexicanrestaurant.com/gallery/details.php?gallery=Manteca_4
    As you see here, ALL PAGES ARE PHP (?)
    Well, I managed to get the html pages, change some things,
    all working well, but the gallery doesn't work, and I don't have any idea why.
    You see, the page has a link to a lightbox css that for a strange reason,
    I cannot find on the server
    ;href="/css/bootstrap-lightbox.min.css
    When I looked for that file, it's just not there, so
    I got a file from bootstrap and put it in there, but the lightbox still don't want to work.
    Need your wizard help here.
    Thanks a lot
    Saludos from California

    Hola Osgood
    Thats what's wrong - it should NOT be <script src="css/prettyPhoto.css"></script>
    It should be linking to the js file NOT the css file:
    <script src="http://mydsigner.com/claudia//js/jquery.prettyPhoto.js"></script>"
    How many 'likes" can I give you?
    This is the right answer !!!
    I knew something was wrong there, but cannot figure it out.
    Definitely I need to keep studying my everything about this stuff.
    Again, thanks a Lot !!!
    Saludos from California :-)

  • Need help with rounding numbers in Java

    I finally have this program to where it needs to be except for one thing. The variable "freetime" isn't showing any kind of output in the applet. The variable sum and freetime are both called at the start of the program, and have equations to figure out the output for them, but only sum shows an output. I tried using brackets as opposed to multiple parentheses. What can I do to fix this so that there is an output? I was thinking of using something to round up the result, but I can't figure it out. Can anyone help?
    import java.awt.*;
    import javax.swing.*;
    public class FinalLab extends JApplet{
    String firstNum, secondNum, thirdNum, fourthNum, fifthNum;
    int personal, family, school, work, sleep, sum, freetime;
    public void init()
    String firstNum, secondNum, thirdNum, fourthNum, fifthNum;
    firstNum = JOptionPane.showInputDialog( "Enter total personal hours." );
    secondNum = JOptionPane.showInputDialog( "Enter total family hours." );
    thirdNum = JOptionPane.showInputDialog( "Enter total school hours." );
    fourthNum = JOptionPane.showInputDialog( "Enter total work hours." );
    fifthNum = JOptionPane.showInputDialog( "Enter total sleep hours." );
    personal = Integer.parseInt( firstNum );
    family = Integer.parseInt( secondNum );
    school = Integer.parseInt( thirdNum );
    work = Integer.parseInt( fourthNum );
    sleep = Integer.parseInt( fifthNum );
    sum = (personal + family + school + work + sleep);
    freetime = ((168-sum)/168)*100;
    public void paint(Graphics g) {
    super.paint( g );
    g.drawRect( 15, 10, 270, 20 );
    g.drawRect( 15, 35, 270, 20 );
    g.drawRect( 15, 60, 270, 20 );
    g.drawRect( 15, 85, 270, 20 );
    g.drawRect( 15, 110, 270, 20 );
    g.drawRect( 15, 135, 270, 20 );
    g.drawRect( 15, 160, 270, 20 );
    g.drawString( "Personal hours: " + personal, 25, 25);
    g.drawString( "Family hours: " + family, 25, 50);
    g.drawString( "School hours: " + school, 25, 75);
    g.drawString( "Work hours: " + work, 25, 100);
    g.drawString( "Sleep hours: " + sleep, 25, 125);
    g.drawString( "Total hours: " + sum, 25, 150);
    g.drawString( "Free time: " + freetime, 25, 175);
    }

    I am guessing that you really meant that you are seeing "Free time: 0" instead of what you said, which was that it wasn't showing any kind of output. (Your whole terminology is weird, you don't "call a variable" just for example.) If that's the case, it's because you are using integer division. You'll find that 27/168, for example, gives zero. I don't know why you are multiplying by 100 in your calculation and doing the division, perhaps you meant to return the free time as a percentage (in which case your output should say that), but since you are doing that you could do it this way:((168-sum)*100/168)Then you are doing 2700/168, which produces a reasonable number.

  • I need help with a plugin. I can't get the quciktime import plugin. Has anyone noticed this.

    I have noticed that the whole abilities to import quicktime plugin. After effects says its gone. I can't find any downloads. I am still on free trial. But why would I buy something in a store that isn't full. Tech support says they won't help. Who knows what to do.

    Nobody can tell you anything without proper system info or other technical details. Start by reinstalling the program and Quicktime. Otherwise the relevant stuff could simply be blocked by a firewall/ virus scanner or whatever and you need to make it behave...
    Mylenium

  • Need help from people who know Java. Some beginner questions.

    Hello all.
    I just recently became interested in programming and I chose Java to learn (not really sure why), I am not really interested in the whole Java Applets thing because i can already do the same things in Flash. What I really want to do is to be able to make a program that can actually complete a task; for instance Is it hard/possible to fabricate a program that could say... do a simple task like open my browser, copy a file, move something ect. What type of file would it be? Would it be a standalone program or .class for MS-DOS? Also (I'v been doing examples and lessons) why are these done in my command prompt and not just executed as the program (.java?) they are (written in notepad). What is my java program export file called that can be used by others with java enviornment. I will finish an excersize and it will say congrats you've just made you first program, but if its a program then why am i running it in command prompt unlike a program i have like Adobe Photoshop where i click the icon and it opens. Is there a better language for me?
    These questions may sound stupid but i'v scrutinized the internet and found very little on these topics.
    Any help to any question would be greatly appreciated!
    Thanks alot,
    Tim

    Hello all.
    I just recently became interested in programming and
    I chose Java to learn (not really sure why), I am notYou should have sound reasons to pick a language...
    really interested in the whole Java Applets thing
    because i can already do the same things in Flash.
    What I really want to do is to be able to make a
    program that can actually complete a task; for
    instance Is it hard/possible to fabricate a program
    that could say... do a simple task like open my
    browser, copy a file, move something ect. What type
    of file would it be? Would it be a standalone program
    or .class for MS-DOS? All java files are compiled to bytecode, which are your .class files. Anyone wanting to use your bytecode will have to have the JRE installed...
    Also (I'v been doing examples
    and lessons) why are these done in my command prompt
    and not just executed as the program (.java?) they
    are (written in notepad). What is my java program
    export file called that can be used by others with
    java enviornment. See the previous answer...
    I will finish an excersize and it
    will say congrats you've just made you first program,
    but if its a program then why am i running it in
    command prompt unlike a program i have like Adobe
    Photoshop where i click the icon and it opens. Is
    there a better language for me?Thats because it starts you out with the language basics. Almost all languages start with the historic command shell programming.
    If you want to write a GUI, then you will have to use AWT, Swing, and or SWT....
    There are several advanced concepts you will have to master before you can write effective GUI's..
    If your looking for an easy way out, learn VB. You will need M$'s IDE to compile though.. Or VBA from within your favorite Windows APP... Many support VBA like the Office Suite, Autocad, and Open Office, and many more..
    These questions may sound stupid but i'v scrutinized
    the internet and found very little on these topics.
    Any help to any question would be greatly
    appreciated!
    Thanks alot,
    TimHave fun Tim...

  • Need help on datasource.plugin.DataSourceException issue

    Can any one help me on this issue.I can try to deploy the application succefully on weblogic.but when developers try to test this application they are receiving thsi error,is this a data source issue or anything else,
    com.xyz.tcc.apollo.webflow.process.flow.StateException: ; nested exception is com.xyz.tcc.apollo.common.datasource.plugin.DataSourceException: com.xyz.tcc.apollo.startup.service.ServiceCommunicationException: com.xyz.POSClient.POSException: org/apache/xpath/XPathAPI
                    at com.xyz.tcc.apollo.workflow.process.ProcessContext.handleException(ProcessContext.java:162)
                    at com.xyz.tcc.apollo.workflow.actions.common.LongOperationAction$3.run(LongOperationAction.java:79)
                    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
                    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
                    at java.awt.EventQueue.access$000(Unknown Source)
                    at java.awt.EventQueue$1.run(Unknown Source)
                    at java.awt.EventQueue$1.run(Unknown Source)
                    at java.security.AccessController.doPrivileged(Native Method)
                    at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
                    at java.awt.EventQueue.dispatchEvent(Unknown Source)
                    at com.xyz.tcc.apollo.core.error.ErrorHandlingEventProcessor.dispatchEvent(ErrorHandlingEventProcessor.java:55)
                    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
                    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
                    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
                    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
                    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
                    at java.awt.EventDispatchThread.run(Unknown Source)
    Caused by: com.xyz.tcc.apollo.common.datasource.plugin.DataSourceException: com.xyz.tcc.apollo.startup.service.ServiceCommunicationException: com.xyz.POSClient.POSException: org/apache/xpath/XPathAPI
                    at com.xyz.tcc.apollo.common.datasource.plugin.extensionpoint.xml.pos.POSDataSourceDelegate.getResponse(POSDataSourceDelegate.java:51)
                    at com.xyz.tcc.apollo.common.datasource.plugin.extensionpoint.xml.serialization.impl.SerializedXMLDataSourceDelegateImpl.perform(SerializedXMLDataSourceDelegateImpl.java:51)
                    at com.xyz.tcc.apollo.common.datasource.plugin.extensionpoint.xml.serialization.impl.SerializedXMLDataSourceDelegateImpl.perform(SerializedXMLDataSourceDelegateImpl.java:47)
                    at com.xyz.tcc.apollo.common.datasource.plugin.extensionpoint.xml.serialization.impl.SerializedXMLDataSourceDelegateImpl.perform(SerializedXMLDataSourceDelegateImpl.java:38)
                    at com.xyz.tcc.apollo.common.datasource.plugin.extensionpoint.xml.serialization.impl.DefaultSerializedXMLDataSource.perform(DefaultSerializedXMLDataSource.java:22)
                    at com.xyz.tcc.apollo.workflow.actions.datasource.AbstractDataSourceOperationAction.submitDataSourceAction(AbstractDataSourceOperationAction.java:102)
                    at com.xyz.tcc.apollo.workflow.actions.datasource.AbstractDataSourceOperationAction.submitDataSourceAction(AbstractDataSourceOperationAction.java:96)
                    at com.xyz.tcc.apolloekgviewerplugin.actions.LoadMyProjectsIfExistsAction.addPOSResponse(LoadMyProjectsIfExistsAction.java:47)
                    at com.xyz.tcc.apolloekgviewerplugin.actions.LoadMyProjectsIfExistsAction.callOperation(LoadMyProjectsIfExistsAction.java:32)
                    at com.xyz.tcc.apollo.workflow.actions.common.LongOperationAction.executeOperationCall(LongOperationAction.java:55)
                    at com.xyz.tcc.apollo.workflow.actions.common.LongOperationAction.access$000(LongOperationAction.java:12)
                    at com.xyz.tcc.apollo.workflow.actions.common.LongOperationAction$1$1.run(LongOperationAction.java:41)
                    at java.lang.Thread.run(Unknown Source)
    Caused by: com.xyz.tcc.apollo.startup.service.ServiceCommunicationException: com.xyz.POSClient.POSException: org/apache/xpath/XPathAPI
                    at com.xyz.tcc.apollo.startup.service.POSClientServiceConsumer.getResponseAsStream(POSClientServiceConsumer.java:69)
                    at com.xyz.tcc.apollo.common.datasource.plugin.extensionpoint.xml.pos.POSDataSourceDelegate.getResponseImpl(POSDataSourceDelegate.java:60)
                    at com.xyz.tcc.apollo.common.datasource.plugin.extensionpoint.xml.pos.POSDataSourceDelegate.getResponse(POSDataSourceDelegate.java:49)
                    ... 12 more
    Caused by: com.xyz.POSClient.POSException: org/apache/xpath/XPathAPI
                    at com.xyz.POSClient.POSErrorContentHandler.getException(POSErrorContentHandler.java:77)
                    at com.xyz.POSClient.POSInputStream.checkForException(POSInputStream.java:69)
                    at com.xyz.POSClient.POSInputStream.checkIfStreamAnError(POSInputStream.java:114)
                    at com.xyz.POSClient.POSInputStream.<init>(POSInputStream.java:37)
                    at com.xyz.POSClient.InputStreamPOSResult.<init>(InputStreamPOSResult.java:21)
                    at com.xyz.POSClient.DefaultInputStreamPOSResultFactory.createResult(DefaultInputStreamPOSResultFactory.java:16)
                    at com.xyz.POSClient.XMLPOSConnection.callService(XMLPOSConnection.java:89)
                    at com.xyz.tcc.apollo.startup.service.POSClientServiceConsumer.getResponseAsStream(POSClientServiceConsumer.java:64)
                    ... 14 more

    Hi,
    This is not issue with Weblogic.
    It seems that your app is using direct provider directly.
    for this you u can include this driver under classpath and restart the server once and try to access your app whether they can able to access your DB or not.
    Regards,
    Kal

  • Need help in writing a small java code

    Hi,
    I have a small requirement where I need write a small java code. I am thinking of using array. Please suggest if you know the solution:
    1. Need to compare user logon id is preset in the lookup table or not.
    2. If user id present in the lookup then send type "A" mail
    3. If user id in not present in the lookup then send type "B" email.
    Please suggest.
    Thanks,
    Kalpana.

    use this code . you have to pass userlogin and lookup name
    Public String GetEmail(String UserLogin,String lookupcode)
    String email;
    try{
    tcLookupOperationIntf lookupIntf = Platform.getService(tcLookupOperationIntf.class);
    HashMap<String, String> lookupValues = getLookupHashMap(lookupIntf, lookupCode);
    String found = lookupValues.get(UserLogin);
    if (found!=null) email= "EMAIL A";
    else
    email= "EMAIL B";
    }catch(Exception e){}
    return email;
    private HashMap<String, String> getLookupHashMap(tcLookupOperationsIntf lookupOperationsIntf, String lookupCode)throws tcAPIException,tcInvalidLookupException,tcColumnNotFoundException {
    HashMap<String, String> lookupMap = new HashMap<String, String>();
              tcResultSet resultLookupHashMap = lookupOperationsIntf
                        .getLookupValues(lookupCode);
              int countResultLookupHashMap = resultLookupHashMap.getRowCount();
    if (countResultLookupHashMap > 0) {
                   for (int i = 0; i < countResultLookupHashMap; i++) {
                        resultLookupHashMap.goToRow(i);
                        lookupMap.put(resultLookupHashMap..getStringValue("Lookup Definition.Lookup Code Information.Code Key"),
    resultLookupHashMap.getStringValue("Lookup Definition.Lookup Code Information.Decode"));
    return lookupMap;
    }

  • I need help with copying files in java?

    hi, i use the following code sample to copy a directory structure and its files.
    It copy's the directory-structure, but all the files in it have 0kb as size. except one file.
    Here's the code:
    public static void copyDir(String source, String target)
    String [] listing = new String [0];
    FileReader in = null;
    FileWriter out = null;
    String sourcePath = source;
    String targetPath = target;
    // Maakt directory onder target directory
    File f = new File(targetPath);
    f.mkdir();
    // Maakt filelist van bestanden in source-directory
    f = new File(sourcePath);
    listing = f.list();
    for(int i = 0; i < listing.length; i++)
    f = new File(sourcePath + listing);
    if(f.isDirectory())
    copyDir(source + listing[i] + File.separatorChar,
    target + listing[i] + File.separatorChar);
    else
    try
    in = new FileReader(sourcePath + listing[i]);
    out = new FileWriter(targetPath + listing[i]);
    int t;
    while (-1 != (t = in.read()))
    out.write(t);
    try { Thread.sleep(200); } catch (InterruptedException e) { }
    System.out.println("Copied: " + sourcePath + listing[i]);
    catch (Exception e)
    System.out.println(e);

    Here is a quick copy program that works. You'll need to deal with the exception instead of just throwing it though.
    import java.io.*;
    public class Copy
      private static void copy(String source, String target) throws IOException
        // Create directory
        File file=new File(target);
        file.mkdirs();
        // Get contents
        file=new File(source);
        File[] files=file.listFiles();
        // Copy files
        int length;
        byte[] buffer=new byte[1024];
        for(int i=0; i<files.length; i++)
          String destination=target+File.separator+files[ i ].getName();
          if(files[ i ].isDirectory())
            copy(files[ i ].getPath(), destination);
          else
            FileInputStream in=new FileInputStream(files[ i ]);
            FileOutputStream out=new FileOutputStream(destination);
            while((length=in.read(buffer))!=-1)
              out.write(buffer, 0, length);
            in.close();
            out.close();
      public static void main(String[] args) throws IOException
        copy(args[0], args[1]);
    }[\code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Need help making pace invaders in java

    So here is my code:
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.*;
    import javax.swing.JFrame;
    import java.awt.*;
    import javax.swing.JPanel;
    import java.awt.Canvas;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.image.BufferedImage;
    import java.net.URL;
    import javax.imageio.ImageIO;
    public class invaders extends Canvas {
    public static final int Width = 800;
    public static final int Height = 600;
    public invaders() {
    JFrame openspace = new JFrame("Space Invaders");
    JPanel window = (JPanel)openspace.getContentPane();
    setBounds(0,0,Width,Height);
    window.setPreferredSize(new Dimension(Width,Height));
    window.setLayout(null);
    window.add(this);
    openspace.setBounds(0,0,Width,Height);
    openspace.setVisible(true);
    openspace.addWindowListener( new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    public void paint(Graphics graph) {
    // graph.setColor(Color.red);
    // graph.fillOval( Width/2-10, Height/2-10,20,20);
    // spacealien = loadImage("spaceAlien.jpg");
    // graph.drawImage(spaceAlien, 50, 50, this);
    public static void main(String[] args) {
    invaders spaceinvaders = new invaders();
    I am trying to add pictures into the JFrame but I don't know how. I am following this tutorial http://www.planetalia.com/cursos/Java-Invaders/JAVA-INVADERS-04.tutorial but I get confused when they talk about how to add in an image.
    This is their Code:
    1 package version04;
    2 /**
    3 * Curso B?sico de desarrollo de Juegos en Java - Invaders
    4 *
    5 * (c) 2004 Planetalia S.L. - Todos los derechos reservados. Prohibida su reproducci?n
    6 *
    7 * http://www.planetalia.com
    8 *
    9 */
    10
    11
    12 import java.awt.Canvas;
    13 import java.awt.Dimension;
    14 import java.awt.Graphics;
    15 import java.awt.event.WindowAdapter;
    16 import java.awt.event.WindowEvent;
    17 import java.awt.image.BufferedImage;
    18 import java.net.URL;
    19
    20 import javax.imageio.ImageIO;
    21 import javax.swing.JFrame;
    22 import javax.swing.JPanel;
    23
    24 public class Invaders extends Canvas {
    25 public static final int WIDTH = 800;
    26 public static final int HEIGHT = 600;
    27
    28
    29 public Invaders() {
    30 JFrame ventana = new JFrame("Invaders");
    31 JPanel panel = (JPanel)ventana.getContentPane();
    32 setBounds(0,0,WIDTH,HEIGHT);
    33 panel.setPreferredSize(new Dimension(WIDTH,HEIGHT));
    34 panel.setLayout(null);
    35 panel.add(this);
    36 ventana.setBounds(0,0,WIDTH,HEIGHT);
    37 ventana.setVisible(true);
    38 ventana.addWindowListener( new WindowAdapter() {
    39 public void windowClosing(WindowEvent e) {
    40 System.exit(0);
    41 }
    42 });
    43 }
    44
    45 public BufferedImage loadImage(String nombre) {
    46 URL url=null;
    47 try {
    48 url = getClass().getClassLoader().getResource(nombre);
    49 return ImageIO.read(url);
    50 } catch (Exception e) {
    51 System.out.println("No se pudo cargar la imagen " + nombre +" de "+url);
    52 System.out.println("El error fue : "+e.getClass().getName()+" "+e.getMessage());
    53 System.exit(0);
    54 return null;
    55 }
    56 }
    57
    58
    59 public void paint(Graphics g) {
    60 BufferedImage bicho = loadImage("res/bicho.gif");
    61 g.drawImage(bicho, 40, 40,this);
    62 }
    63
    64 public static void main(String[] args) {
    65 Invaders inv = new Invaders();
    66 }
    67 }
    68
    I know there must be an easier way. Please help, thanks!!!!

    One way to add an image to a user interface is to use a JLabel with an ImageIcon: [http://java.sun.com/docs/books/tutorial/uiswing/components/label.html]

  • Need help with SharedContent plugin

    I have CS5 and am trying to access a file created by a client. The message I get when I try to open the file says, "Missing plug-ins" and the plug-in I need is called SharedContent.InDesignPlugin however I can't seem to find that plug-in to install it.
    Can somebody help me figure this out? Thanks!

    Ask your client, who is using CS5.5 or CS6, to send you a .idml file, but don't expect a perfect conversion when you open it.
    That error message means the file was saved in a leter version than the one you are using to try to open it.

  • Intro To Java Programming student needing help on how to download java SDK on 10.6.8

    Hey Ladies and Gents,
    For the past hour I have been trying to download Java SDK for my 10.6.8 Mac. Can someone point me in the right direction. I am taking a course in intro to Java programming and the book I am using isnt as helpful as I hoped.

    SE 6 development kits support SE 5 constructs.  Just watch that you use only SE 5 constructs.  Texts on 5 will not list the 6 constructs, and texts on 6 are available that tell what came when.
    There is another forum (https://discussions.apple.com/community/developer_forums) where "developers" troll for questions to answer, and your developer questions will stay at the top of the list longer than in MacbookPro forum.

  • Need help, I am terrible with Java, can someone help.

    Please can someone help me with this program. I am in a JAVA programming class and I am having a heck of a time. I am still having a problem with the basic concepts of JAVA but the teacher continues to give us difficult assignments with out any help. Here is the assignment:
    Write a class named 'Player' that has two attributes, 'name' (which has to be a 'Sting') and 'rating' (which has to be a 'int'). Then write an application class named "PlayerRating" that first creates an array consisting of 5 player objects, then display the list three times; first unsorted, then sorted by Name and finally sorted by rating.
    Must use the Bubble Sort Program and do NOT use Array.sort.
    Example output:
    Unsorted
    Name: Rating:
    Mickey Mantle 5
    Ty Cobb 3
    Babe Ruth 4
    Pete Rose 3
    Sammy Sosa 1
    Sorted by Name
    Name: Rating:
    Babe Ruth 4
    Mickey Mantle 5
    Pete Rose 3
    Sammy Sosa 1
    Ty Cobb 3
    Sorted by Rating
    Name: Rating:
    Sammy Sosa 1
    Pete Rose 3
    Ty Cobb 3
    Babe Ruth 4
    Mickey Mantle 5
    Here is what I have and it is not much, cause I am so lost:
    1 import java.io.*;
    2 import javax.swing.*;
    3 import java.text.*;
    4 import java.lang.*;//String[][];
    5 import java.util.*; //ArrayList;
    6
    7
    8 public class Player
    9 {
    10 public static void main (String [][]args)
    11 {
    12
    13 int maxSize = 100; //array size
    14 // String[][] s = new String[100][100]; //Default values: null
    15 boolean [] b = new boolean[4]; //default values: false
    16 int[][] i = new int[10][10]; //default values: 0
    17
    18
    19 PlayerRating arr; //reference to array
    20 //arr = new PlayerRating(maxSize);
    21 Sting player[]={"Mickey Mantle 5","Ty Cobb 3"
    22 ,"Babe Ruth 4","Pete Rose 3","Sammy Sosa 1"};
    23
    24
    25 }
    26 }
    Here is all I have on the second program:
    public class PlayerRating
    public void PlayerRating (int Max)
    int[][] i = new int[10][10];
    Please help I am totally lost.

    You repeat code, you should do a generic bubble sort with comparators, or declare class as Comparable. You can see how String class is Comparable, furthermore it has a final static Comparator for CASE_INTENSENSITIVE_ORDER.
    class User implements Comparable<User>{
      public static final java.util.Comparator<Cliente> RATING_COMPARATION=new java.util.Comparator<Cliente>(){
        public int compare(User u1,User u2){
               int comp=u1.rating-u2.rating;
               return comp==0?u1.name.compareTo(u2.name):comp;
         private String name;
         private int rating;
         public User(String name, int rating){
              setName(name);
              setRating(rating);
         public String getName(){
              return name;
         public void setName(String name){
              this.name = name;
         public int getRating(){
              return rating;
         public void setRating(int rating){
              this.rating = rating;
            // Compare users first by name and last by rating;
            public int compareTo(User anotherUser){
               int comp=name.compareTo(anotherUser.name);
               return comp==0?rating-anotherUser.rating:comp;
             public void equals(Object o){
              if(this==o)
                return true;
              if(o instanceof User){}
                 User anotherUser=(User)o;
                 return name.equals(anotherUser.name)&&rating==anotherUser.rating;
              return false;
               public int hashCode(){
                  return name.hashCode()+rating<<16;
    public class Sorting{
         public <E extends Comparable<E>>static void bubleSort(E[] arr){
              for(int i = 0; i < arr.length - 1; i++){
                   for(int j = arr.length - 1; j > i; j--){
                        if(arr[j].compareTo(arr[j - 1])<0)
                                     swap(arr,j,j-1);
         public static<E> void bubleSort(E[] arr,Comparator<E> cmp){
              for(int i = 0; i < arr.length - 1; i++){
                   for(int j = arr.length - 1; j > i; j--){
                        if(cmp.compare(arr[j],arr[j-1]) < 0)
                                      swap(arr,j,j-1);
            private static void swap(Object[] arr,int x,int y){
               Object tmp=arr[x];
               arr[x]=arr[y];
               arr[y]=tmp;
         public static void main(String[] args){
              User[] arr = new User[5];
              arr[0] = new User("Mickey Mantle", 5);
              arr[1] = new User("Ty Cobb", 3);
              arr[2] = new User("Babe Ruth", 4);
              arr[3] = new User("Pete Rose", 3);
              arr[4] = new User("Sammy Sosa", 1);
              System.out.println("Sorting by Name : ");
              bubleSort(arr)
              System.out.println(Arrays.toString(arr));
              System.out.println("Sorting by Rating : ");
              bubleSort(arr,User.RATING_COMPARATION);
              System.out.println(Arrays.toString(arr));
    }

  • Need help on passing options to java

    Hi
    I want to call the main method of one java class from another java program. However the callee program expects an option -o (not jvm option but program option) to be specified. Please help how to pass this option?
    thanks
    kannan

    The caller just invokes the callee's main() with the right arguments. Eg:class Callee {
        public static void main(String[] args) {
            if(args[0].equals("-o")) {
                /*etc*/
    class Caller {
        public static void main(String[] args) {
            Callee.main(new String[] {"-o"});
    }

Maybe you are looking for

  • Error message when using Photoshop over the network

    I am currently working with Apple Aperture. My library is on my computer and references files that are saved over a network on a hard drive connected to another computer. I open an image that is within Aperture having set my primary editor as Photosh

  • Error in Logical Port Creation

    Hi, When I try to create a logical port in my consumer system I am getting error "Error: HTTP: Error in interface for management of HTTP destinations; " Any ideas on how to fix this?

  • Is it possible to remove yellow text background in the entire document?

    I have the same problem as the one that is mentioned here:http://forums.adobe.com/message/1155089 In my case the yellow background is already in the pdf-file which was created with a virtual pdf printer and then manipulated with another pdf-editor. 

  • Cells Appearing Black in Report Designer

    Hi Guys, I have an issue here! When I open a report in Report Designer, all cells are coming with black background. When I click on each cell, then I am able to see the cell content with original formatting. I have checked with all cell format settin

  • Minimum & maximum price paid for material

    hi gurus Can u tell me how to see max.& minimum purchase price paid for material with respect to vendor. Reg ROC