Wats wrong in this code with ...actionlistener... n ...addwidgets..

i m declaring a method with syntax .....
public void addWidgets() {
but the error comes .. illegal start of expression ..... ???
also i m using actionlistener interface in class definition ...
but the error comes .. no actionperformmed method defined ... although i have defined it ..???
''''' i wanna show 2 text fields and when user enters the no. n press swap button the swaped values r shoen in labels '''''''''''
----------------------------- here is the code -----------------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Swap1 implements ActionListener {
private static String lbl = " becomes : " ;
JFrame frame;
JPanel panel;
JLabel aLabel, blabel;
JTextField aText, bText;
JButton button ;
// Constructor
public Swap1() {
// Create the frame and container
frame = new JFrame ("Swapping two values");
panel = new JPanel();
panel.setLayout(new GridLayout(3,2));
addWidgets();
frame.getContentPane().add(panel,BorderLayout.CENTER);
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
// show frame
frame.pack();
frame.setVisible(true);
// Create and add the widgets to the panel
private void addWidgets() {
aLabel = new JLabel(lbl, SwingConstants.CENTER);
bLabel = new JLabel(lbl, SwingConstants.CENTER);
aText = new JTextField(2);
bText = new JTextField(2);
button = new JButton("Swap...");
button.addActionListener(this);
//Adding the widgets to the panel
panel.add(aText);
panel.add(aLabel);
panel.add(bText);
panel.add(bLabel);
panel.add(button);
aLabel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
bLabel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
// Implementing the actionlistener
public void actionPerformed(ActionEvent event) {
int a = (int)(Double.parseDouble(aText.getText()));
int b = (int)(Double.parseDouble(bText.getText()));
int c = a;
a = b;
b = c;
aLabel.setText(lbl + a);
bLabel.setText(lbl + b);
// main method
public void main(String[] args) {
try {
UIManager.setLookAndFeel(
UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception e) {}
Swap1 sp = new Swap1();

DUPLICATE

Similar Messages

  • What is wrong in this code..please

    first of all,i kindly request team please not kill me by giving suggestion using xml parser.......can u please tell how this handle in reading follwing lines....
    orderREF="1036578"><edm:OrderItem><edm:Order orderID="1036579"/> ineed to retoeve value 1036578 i use following code
    final String START6_TAG="orderREF=";
    final String END6_TAG=">";
    final String END7_TAG="/>";
    as per my observation,the follwing code need not work
    if(line.indexOf(START6_TAG)> -1 ) {
    //this code handle "orderREF=" in stands for order id
    if(line.indexOf(END7_TAG,line.indexOf(START6_TAG))>-1){ //because if we use line.indexOf(END7_TAG)it take only first indexof that..
    efound9=false;
    asper above line this code cannot excecute.but igo to loop and set flag efound9=false, what is wrong in this code for handling
    orderREF="1036578"/><edm:OrderItem><edm:Order orderID="1036579"/> this type of line that also comes in same program,here also we need output as 1036578.please tell me what i will do to hanndle these

    first of all,i kindly request team please not kill
    me by giving suggestion using xml parser.......can u
    please tell how this handle in reading follwing
    lines.... I don't understand why you are so opposed to an xml parser. You could have spent 3 hours learning how to use it and been done with this problem in the time you've spent trying to hack your way around it.
    jdom tutorials: http://www.jdom.org/downloads/docs.html
    dom4j tutorials: http://www.dom4j.org/cookbook.html

  • "sql_select"- command - What's wrong at this code ?

    Hello everyone,
    on the zip-attachment is a simple sample vbs-code and
    the sample-db.
    Whats wrong by this sql_select command ?
    The error-box ist is shown as the jpg
    Thanks every one for answers!
    System: DIAdem 8.1, Win2K,A97 all german
    Attachments:
    sql_sample.zip ‏52 KB

    Hi peter28,
    Actually, your code runs through fine on my machine if all I change is the Bindestrich "-" to an underscore "_" (Type-Code" --> "Type_Code") in both the VBS query and of course the data table column name. I have never had any trouble with underscores in database column names, but they're one of the few characters that won't give you trouble aside from A to z and 0 to 9. Spaces are nothing but trouble, for instance.
    Glad you're up and running,
    Brad Turpin
    DIAdem Product Support Engineer
    National Instuments

  • What's wrong in this code?

    Hi,
    I'm using the following code when the user reaches the last
    row in the jtable.In this code i'm calling database and setting
    glasspane to block user input.Here i need to set message like
    "[PAGE] next ...." using JLabel which is not showing.
    What is the reason the message is not showing up?
    ArrayList getData(final int id,final int dir,final String where){
    final String msg =(dir == REVERSE_LT)?"[PAGE] PREVIOUS .... ":"[PAGE] NEXT .... ";
    //cat.info(" msg @ getData "+msg);
    //cat.info(" isEventDipatchThread "+ SwingUtilities.isEventDispatchThread () );
    display.msgLbl.setText(msg);
    cat.info(" msg @ getText() "+display.msgLbl.getText());
    display.glassPane.setVisible(true);
    SwingWorker worker = new SwingWorker() {
         ArrayList al = new ArrayList();
         public Object construct() {
         try{
         return getDataT(id,dir,where);
         catch(Exception ex){
         cat.error(ex.toString());
         SwingUtilities.invokeLater(new Runnable() {
         public void run() {
                   display.setMessage (msg+" failed");
         finally{
         SwingUtilities.invokeLater(new Runnable() {
              public void run() {
              cat.info(" setting glass pane false ");
              display.glassPane.setVisible(false);
         return al;
    public void finished() {
         SwingUtilities.invokeLater(new Runnable() {
         public void run() {
              cat.info(" setting message empty ");
              display.setMessage (" ");
    worker.start();
    //display.setMessage(msg);
    return (ArrayList)worker.get();
    Any help will be appreciated.
    best regards,
    mohan

    it doesn't need an instance of MyOuter to initiate the MyInner objectAnd - as you've found - to supply an instance of MyOuter is just wrong.
    [This thread|http://forums.sun.com/thread.jspa?threadID=765356&tstart=18239] discusses the terminology that's used in Java: classes being static/top-level/inner/nested and class instance creation expressions being qualified/unqualified. There are references to the JLS.
    Briefly put, MyInner is not an inner class: it's a nested one. And the error occurs because you are attempting to create an instance of a non-inner class with a qualified class instance creation expression.

  • Whats wrong in this code using ODBC interface of T10 in C ?

    Hi!
    I am trying to connect TimesTen using ODBC in a C application, I am trying to use the dynamic binding of parameters the query. The problem is elaborated in the code. In the comments.
    #include <windows.h>
    #include <sql.h>
    #include <sqlext.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    int main()
    SQLRETURN rc = SQL_SUCCESS;
    /* General return code for the API */
    SQLHENV hEnv = SQL_NULL_HENV;
    /* Environment handle */
    SQLHDBC hDbc = SQL_NULL_HDBC;
    /* Connection handle */
    SQLHSTMT hStmt = SQL_NULL_HSTMT;
    /* Statement handle */
    SQLCHAR ConnOut[255];
    /* Buffer for completed connection string */
    SQLSMALLINT connOutLen;
    /* number of bytes returned in ConnOut */
    SQLCHAR ConnString = (SQLCHAR ) "DSN=testTT;PWD=spideradm;";
    /* Connection attributes */
    rc = SQLAllocEnv(&hEnv);
    if (rc != SQL_SUCCESS) {
    fprintf(stderr,"Unable to allocate an environment handle\n");
    exit(1);
    SQLINTEGER param1 = 0;
    SQLINTEGER paramstatus = 0;
    rc = SQLAllocConnect(hEnv, &hDbc);
    rc = SQLDriverConnect(hDbc, NULL,ConnString, SQL_NTS,ConnOut, 255,&connOutLen,SQL_DRIVER_NOPROMPT);
    hStmt = SQL_NULL_HSTMT;
    rc = SQLAllocStmt(hDbc, &hStmt);
    rc = SQLPrepare(hStmt,(SQLCHAR*) "select * from test where recno = ? ",SQL_NTS);
    rc = SQLBindParameter(hStmt,1,SQL_PARAM_INPUT,SQL_C_SHORT,SQL_INTEGER,0,0,¶m1,0,¶mstatus);
    param1= 1;
    rc = SQLExecute(hStmt); // here it goes very perfect
    param1 = 2;
    rc = SQLExecute(hStmt); // here is the problem it returns -1
    }

    There are (at least) 3 problems with this code:
    1. The error checking after each ODBC call is far too simplistic. Whenever an ODBC call returns something other than SQL_SUCCESS then you need to call the SQLError() function (multiple times in a loop until it returns SQL_NO_DATA) to retrieve the error or warning information which you should then report. If you do that then the error information would give you a clue to the problem.
    2. The parameter variable 'param1' is declared as a SQLINTEGER (32-bit integer) but you bind it in the SQLBindParameter() call as a SQL_C_SHORT. This is incorrect and will likely cause problems. It should be bound as a SQL_C_SLONG.
    3. When you execute a statement that retrieves data (such as the SELECT statement in your example) a cursor is created. The cursor remains open until (a) you explicitly close it with SQLFreeStmt(hStmt, SQL_CLOSE), or (b) you do a commit or rollback (which closes all open cursors on the connection).
    Your problem here is that the first SQLExecute opens a cursor for hStmt but you then do not fetch any data or close the cursor. When you try the second execute you get an error as there is already an open cursor for that statement. If you had used SQLError(0 to retrieve and report the error codes and messages you would see that you had incurred either an 'INVALID CURSOR STATE' or 'FUNCTION SEQUENCE ERROR' error.
    The fix is to insert the call:
    SQLFreeStmt(hStmt,SQL_CLOSE);
    after the each SQLExecute(0 call. Of course, in a real application there would also be a SQLFetch() loop first to retrieve and process the results of the query.
    Chris

  • Hi can anyone see anything glaringly wrong in this code its only a few line

    class test
    public static void main(String []args)
    public void display()
         int limit=5;
         int total=0;
         for (int i = 0; i<limit; i++)
              System.out.println(i*i+i);
              total+=i;
         System.out.println(total);

    see after running this code
    public class test
         public static void display()
         int limit=5;
         int total=0;
         for (int i = 0; i<limit; i++)
              System.out.println(i*i+i);
              total+=i;
                   System.out.println(total);
                        public static void main(String []args)
                                  display();
    I get this output
    0
    2
    6
    12
    20
    10
    but when i work it out in my mind i get this
    2
    12
    and then i stop because i wonder why i didnt get the 0 and why i missed the 6
    can anyone work out what im doing wrong
    thanks

  • Can you optimize this code with bit shifting?

    Hi there,
    I was wondering if anyone could make this code run faster, by implementing bitshifting techniques. I'd really appreciate it, and thanks!
        public void scaleImage(Image source, Image dest) { 
            int sourceWidth = source.getWidth();
            int sourceHeight = source.getHeight();
            int thumbWidth = dest.getWidth();
            int thumbHeight = dest.getHeight();
            Graphics g = dest.getGraphics();
            int dx, dy = 0;
            for (int y = 0; y < thumbHeight; y++) {
                for (int x = 0; x < thumbWidth; x++) {
                    g.setClip(x, y, 1, 1);
                    dx = x * sourceWidth / thumbWidth;
                    dy = y * sourceHeight / thumbHeight;
                    g.drawImage(source, x - dx, y - dy, Graphics.LEFT | Graphics.TOP);
        }Message was edited by:
    conlanrios

    your method reminds me this stuff:
    http://www.java-tips.org/java-me-tips/midp/displaying-images-as-thumbnails-on-j2me-devices.html
    you can have a look to this article:
    http://developers.sun.com/techtopics/mobility/reference/techart/design_guidelines/image_resizing.html

  • Internet Expenses problem: What's wrong in this code?

    Hi friends,
    [Apps R12]
    I'm trying to incorporate the person_id of the employees picklist on the first screen that appears to create an expense report (+/oracle/apps/ap/oie/entry/header/webui/GeneralInformationPG+) to the query that retrieves the Expense Template.
    I've extended the VO that contains Templates (oracle.apps.ap.oie.server.ExpenseTemplatesVO) and I'm tryiong to overwrite the setWhereParams method, because there is where appears the logic for the where in Templeates query.
    I wrote:
    public void setWhereParams()
    OAApplicationModuleImpl oaapplicationmoduleimpl = (OAApplicationModuleImpl)getRootApplicationModule();
    OADBTransactionImpl oadbtransactionimpl = (OADBTransactionImpl)oaapplicationmoduleimpl.getOADBTransaction();
    String s = (String)oadbtransactionimpl.getValue("ApWebGracePeriod");
    Number n = new Number(Integer.parseInt(oadbtransactionimpl.getAppsContext().getProfileStore().getProfile("OIE_EMPLOYEE_ID")));
    setWhereClause(null);
    setWhereClauseParam(0, s);
    setWhereClauseParam(1, s);
    setWhereClauseParam(2, s);
    setWhereClauseParam(3, n);
    but.. although it doesn't appear any error... what I think it's doing is to retrieve always the template for the actual user (the user who is logged into application)... And that's not correct at all.. because.. a user could create a Expense report for another person (chosen from the Employees picklist) ...
    I see in the AM certain logic to set the employee_id in a profile (OIE_EMPLOYEE_ID).. So.. I created that profile and add to the code what you see above but.. no way...
    Any ideas? I suppose it must be not very complicated.. It's only to add a new parameter to a query.. (with the peculiarity that the "where" clause is built through this method...) I don't know if bind variables would useful here.. (I don't know how to manage bind variables)
    Thanks !!

    Hi again,
    Ok, I was a bit lost in my last post, but... regarding the others, I have to say that the line
    setWhereClause(null);
    is standard.
    I put here the entire code of ExpenseTemplatesVOImpl. This is what I want to extend... The problem I see with youre code is that you're passing as parameter 0 a number (1?) and there already exists params 0,1 and 2. I don't understand very well too the sentence : setWhereClause("emp_id = :1"); ... Here what is +:1+ my main problem is how to get the employee_id from the picklist existing in this screen.. I've tried to get it from oatransaction and pass the to the query as parameter... but it seems to "reset" the expenses picklist query once we have made an employee change on employee's picklist.
    Suggestions?
    [btw: how do you enclose (which kind of format) code lines in these posts?
    +package oracle.apps.ap.oie.server;+
    +import oracle.apps.fnd.common.VersionInfo;+
    +import oracle.apps.fnd.framework.server.*;+
    +import oracle.jbo.Row;+
    +import oracle.jbo.RowSetIterator;+
    +import oracle.jbo.domain.Number;+
    +public class ExpenseTemplatesVOImpl extends OAViewObjectImpl+
    +{+
    +    public ExpenseTemplatesVOImpl()+
    +    {+
    +    }+
    + public void executeQuery()+
    + {+
    + setWhereParams();+
    + super.executeQuery();+
    setWhereClause("emp_id = :1");
    setWhereClauseParams(null);
    setWhereClauseParam(0,new Number(1));
    super.executeQuery();
    + }+
    + public void executeQueryForCollection(Object obj, Object aobj[], int i)+
    + {+
    + setWhereParams();+
    + super.executeQueryForCollection(obj, aobj, i);+
    + }+
    + public void setWhereParams()+
    + {+
    + OAApplicationModuleImpl oaapplicationmoduleimpl = (OAApplicationModuleImpl)getRootApplicationModule();+
    + OADBTransactionImpl oadbtransactionimpl = (OADBTransactionImpl)oaapplicationmoduleimpl.getOADBTransaction();+
    + String s = (String)oadbtransactionimpl.getValue("ApWebGracePeriod");+
    + setWhereClause(null);+
    + setWhereClauseParam(0, s);+
    + setWhereClauseParam(1, s);+
    + setWhereClauseParam(2, s);+
    + }+
    + public Number getFirstExpenseTemplate()+
    + {+
    + OAApplicationModuleImpl oaapplicationmoduleimpl = (OAApplicationModuleImpl)getRootApplicationModule();+
    + OADBTransactionImpl oadbtransactionimpl = (OADBTransactionImpl)oaapplicationmoduleimpl.getOADBTransaction();+
    + if(oadbtransactionimpl.isLoggingEnabled(2))+
    + oadbtransactionimpl.writeDiagnostics(this, "start getFirstExpenseTemplate ", 2);+
    + Row row = first();+
    + if(row != null)+
    + return (Number)row.getAttribute("ExpenseReportId");+
    + else+
    + return null;+
    + }+
    + public String getTemplateName(String s)+
    + {+
    + OAApplicationModuleImpl oaapplicationmoduleimpl = (OAApplicationModuleImpl)getRootApplicationModule();+
    + OADBTransactionImpl oadbtransactionimpl = (OADBTransactionImpl)oaapplicationmoduleimpl.getOADBTransaction();+
    + if(oadbtransactionimpl.isLoggingEnabled(2))+
    + oadbtransactionimpl.writeDiagnostics(this, (new StringBuilder()).append("start getTemplateName ").append(s).toString(), 2);+
    + RowSetIterator rowsetiterator = findRowSetIterator("noValidationIterator");+
    + if(rowsetiterator == null)+
    + rowsetiterator = createRowSetIterator("noValidationIterator");+
    + rowsetiterator.setRangeSize(-1);+
    + rowsetiterator.setRowValidation(false);+
    + rowsetiterator.reset();+
    + while(rowsetiterator.hasNext())+
    + {+
    + Row row = rowsetiterator.next();+
    + if(row.getAttribute("ExpenseReportId").toString().equals(s))+
    + return (String)row.getAttribute("ReportType");+
    + }+
    + return "";+
    + }+
    + public boolean isTemplateWebEnabled(String s)+
    + {+
    + OAApplicationModuleImpl oaapplicationmoduleimpl = (OAApplicationModuleImpl)getRootApplicationModule();+
    + OADBTransactionImpl oadbtransactionimpl = (OADBTransactionImpl)oaapplicationmoduleimpl.getOADBTransaction();+
    + if(oadbtransactionimpl.isLoggingEnabled(2))+
    + oadbtransactionimpl.writeDiagnostics(this, (new StringBuilder()).append("start isTemplateWebEnabled ").append(s).toString(), 2);+
    + RowSetIterator rowsetiterator = findRowSetIterator("noValidationIterator");+
    + if(rowsetiterator == null)+
    + rowsetiterator = createRowSetIterator("noValidationIterator");+
    + rowsetiterator.setRangeSize(-1);+
    + rowsetiterator.setRowValidation(false);+
    + rowsetiterator.reset();+
    + while(rowsetiterator.hasNext())+
    + {+
    + Row row = rowsetiterator.next();+
    + if(row.getAttribute("ExpenseReportId").toString().equals(s))+
    + return true;+
    + }+
    + if(oadbtransactionimpl.isLoggingEnabled(2))+
    + oadbtransactionimpl.writeDiagnostics(this, "couldn't find matched template id in all rows ", 2);+
    + return false;+
    + }+
    + public String[] getCacheEventNames()+
    + {+
    + String as[] = {+
    + "oracle.apps.ap.oie.expenseReport.ExpenseTemplateChangeEvent"+
    + };+
    + return as;+
    + }+
    + public String getCacheKey()+
    + {+
    + OAApplicationModuleImpl oaapplicationmoduleimpl = (OAApplicationModuleImpl)getRootApplicationModule();+
    + OADBTransactionImpl oadbtransactionimpl = (OADBTransactionImpl)oaapplicationmoduleimpl.getOADBTransaction();+
    + String s = Integer.toString(oadbtransactionimpl.getOrgId());+
    + return s;+
    + }+
    + public static final String RCS_ID = "$Header: ExpenseTemplatesVOImpl.java 120.2.12000000.2 2007/10/08 08:27:27 sodash ship $";+
    + public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion("$Header: ExpenseTemplatesVOImpl.java 120.2.12000000.2 2007/10/08 08:27:27 sodash ship $", "oracle.apps.ap.oie.server");+

  • What's wrong w/ this code?

    I am getting closer but I still have not his the nail on the head.
    This application is ot display the twelve days of christmas using 2 switch structures in 1 for loop.
    Can not use arrays or myMetod concept.
    I have got the days to display but I can not get the verses to display correctly. "A partridge in a pear tree" dispalys for all the days with nothing else.
    here is what I got
    //Exercise526.java
    import javax.swing.*;
    public class Exercise526
         public static void main(String args[] )
         JTextArea outputTextArea = new JTextArea( 18,30 );
         JScrollPane scroller = new JScrollPane(outputTextArea);
         outputTextArea.append("\tThe Tweleve Days of Christmas\n");
         String outputDay = "",
         outputVerse = "";
         for (int day=0; day <= 12; day++ )
         switch ( day )
         case 0:
         outputDay = ("1st");
         break;
         case 1:
         outputDay = ("2nd");
         break;
         case 2:
         outputDay = ("3rd");
         break;
         case 3:
         outputDay = ("4th");
         break;
         case 4:
         outputDay = ("5th");
         break;
         case 5:
         outputDay = ("6th");
         break;
         case 6:
         outputDay = ("7th");
         break;
         case 7:
         outputDay = ("8th");
         break;
         case 8:
         outputDay = ("9th");
         break;
         case 9:
         outputDay = ("10th");
         break;
         case 10:
         outputDay = ("11th");
         break;
         case 11:
         outputDay = ("12th");
         break;
         switch ( day )
         case 11:
         outputVerse = ("Tweleve lords a-leaping\n");
         case 10:
         outputVerse = ("Eleven ladies dancing\n");
         case 9:
         outputVerse = ("Ten pipers piping\n");
         case 8:
         outputVerse = ("Nine drummers drumming\n");
         case 7:
         outputVerse = ("Eight maids a-milking\n");
         case 6:
         outputVerse = ("Seven swans swimming\n");
         case 5:
         outputVerse = ("Six geese a-laying\n");
         case 4:
         outputVerse = ("Five golden rings\n");
         case 3:
         outputVerse = ("Four colly birds\n");
         case 2:
         outputVerse = ("Three french hens\n");
         case 1:
         outputVerse = ("Two turtle doves and\n");
         case 0:
         outputVerse = ("A partridge in a pear tree\n");
    outputTextArea.append("\n On the "+outputDay+" day of Christmas \n My"+
         " true love gave to me\n "+ outputVerse);
    outputTextArea.append("\n\tProgramed by: Carly Murphey");
         JOptionPane.showMessageDialog( null, outputTextArea,
                        "The Tweleve Days of Christmas",
                        JOptionPane.PLAIN_MESSAGE );
         System.exit(0);
    This due Friday Midnight Please advise I am down to the wire.
    Carly

    Try this:
    import javax.swing.*;
    public class Exercise526 {
        public static void main(String args[] ) {
            JTextArea outputTextArea = new JTextArea( 18,30 );
            JScrollPane scroller = new JScrollPane(outputTextArea);
            outputTextArea.append("\tThe Tweleve Days of Christmas\n");
            String outputDay = "",
            outputVerse = "";
            for (int day=0; day <= 12; day++ ) {
                switch ( day ) {
                    case 0:
                        outputDay = ("1st");
                        outputVerse += ("A partridge in a pear tree\n");
                        break;
                    case 1:
                        outputDay = ("2nd");
                        outputVerse = ("Two turtle doves and\n") + outputVerse;
                        break;
                    case 2:
                        outputDay = ("3rd");
                        outputVerse = ("Three french hens\n") + outputVerse;
                        break;
                    case 3:
                        outputDay = ("4th");
                        outputVerse = ("Four colly birds\n") + outputVerse;
                        break;
                    case 4:
                        outputDay = ("5th");
                        outputVerse = ("Five golden rings\n") + outputVerse;
                        break;
                    case 5:
                        outputDay = ("6th");
                        outputVerse = ("Six geese a-laying\n") + outputVerse;
                        break;
                    case 6:
                        outputDay = ("7th");
                        outputVerse = ("Seven swans swimming\n") + outputVerse;
                        break;
                    case 7:
                        outputDay = ("8th");
                        outputVerse = ("Eight maids a-milking\n") + outputVerse;
                        break;
                    case 8:
                        outputDay = ("9th");
                        outputVerse = ("Nine drummers drumming\n") + outputVerse;
                        break;
                    case 9:
                        outputDay = ("10th");
                        outputVerse = ("Ten pipers piping\n") + outputVerse;
                        break;
                    case 10:
                        outputDay = ("11th");
                        outputVerse = ("Eleven ladies dancing\n") + outputVerse;
                        break;
                    case 11:
                        outputDay = ("12th");
                        outputVerse = ("Tweleve lords a-leaping\n") + outputVerse;
                        break;
                outputTextArea.append("\n On the "+outputDay+" day of Christmas \n My"+
                " true love gave to me\n "+ outputVerse);
            outputTextArea.append("\n\tProgramed by: Carly Murphey");
            JOptionPane.showMessageDialog( null, outputTextArea,
            "The Tweleve Days of Christmas",
            JOptionPane.PLAIN_MESSAGE );
            System.exit(0);
    }

  • What is wrong in this code .... !

    Hi
    I used the code below to raed a histogram image stored in an two dim. array to detmine the peaks of the histogram or in other words (the tallest rows in the array) but I faced a wrong results. Why ? I couldnt figure out why . Help me plz .
    Thanks in advance
    List tallestList = new ArrayList();
      int numColoredRows = 0;
      int tempTallestIndex = -1;
      int tempTallestNum = 0;
      List listA = new ArrayList();
      List listB = new ArrayList();
      listA.add(new Integer (0));
      for(int rowIndex = 0 ; rowIndex < twoDim.length; rowIndex++) {
        // The current row to examine.
        int[] row = twoDim[rowIndex];
        // Count the number of (concatenated) colored pixels
        // from the current row.
        int numColoredPixels = numColoredPixelsInRow(row);
        if(numColoredPixels > 0) numColoredRows++;
        if(numColoredPixels > tempTallestNum)
          tempTallestNum = numColoredPixels;
          tempTallestIndex = rowIndex;
        if(numColoredRows > 1 && (rowIndex == twoDim.length-1 ||
                                  numColoredPixels == 0))
            tallestList.add(new Integer(tempTallestIndex));
          //  listA.add(new Integer(tempTallestIndex));
        if(numColoredPixels == 0)
          numColoredRows = 0;
          tempTallestIndex = -1;
          tempTallestNum = 0;
      System.out.println("List tallestList   : " + tallestList);

    * @param   the column as an array of int's.
    * @return  the number of non-zero pixels
    public  static int numColoredPixelsInColumn(int[] column) {
      int count = 0;  int startPoint = 5; //(column.length)/4;
      for(int i = startPoint; i < column.length; i++) {
          System.out.print("Column 0   : " + column);
    if(column[i] != -1) count++;
    return count;

  • Please, someone tell me what's wrong in this code...

    My MIDlet can't even start. So I think the problem is on GameCanvas class, 'couse is the only class I've changed before the game don't work. So I'll submit the code and you can see if find the error. Any sugestions will be apreciate.
    import javax.microedition.lcdui.*;
    import javax.microedition.lcdui.game.*;
    public class GameCanvasClass extends GameCanvas implements Runnable {
       private boolean playing;  
       // TiledLayer.
       private TiledLayer tiledCenary;
       // Layer.
       private LayerManager layer1 = new LayerManager();
       // Sprites.
       private CharacterClass player;
       private CharacterClass[] enemy;
       // Game settings;
       public static int gameLevel = 0;
       public static int numLives = 3;
       public static int numEnemies = 0;
       public static final int NUMBER_LEVELS = 10;
       public static boolean[] doneBuildLevel;
       /** Creates a new instance of GameCanvasClass */
       public GameCanvasClass() throws Exception {
          super(true);
          for(int i = 0; i < 10; i++)
             doneBuildLevel[i] = false;   
          Image image = Image.createImage("/bear.PNG");
          player = new CharacterClass(image, 16, 16, 16, 16);
          System.out.println("Public constructor started.");
       public void start() throws Exception {
          playing = true;
          Thread t = new Thread(this);
          t.start();
          System.out.println("start() method of Thread is on.");
       public void run() {
            try {
               setupGameLevel(gameLevel);
            catch(Exception e) {
               e.printStackTrace();
          Graphics g = getGraphics();
          while(playing == true) {
             drawGameScreen(g);
             checkCollision(numEnemies);
             checkInput();
             moveEnemies(numEnemies);
             try {
                Thread.sleep(15);
             catch(InterruptedException ie) {
       public void stop() {
          playing = false;      
       private void setupGameLevel(int level) throws Exception {
          if( (level == 0) && (doneBuildLevel[level] == false) ) {
             // Building cenary for the first level.
             tiledCenary = TiledLayerClass.buildTiledCenary(gameLevel);
             // Append to the layer.
             layer1.append(tiledCenary);
             layer1.append(player);
             doneBuildLevel[level] = true;
             numEnemies = 4;   // Setup 4 enemies for the first level.
             for(int i = 0; i < numEnemies; i++) {
                Image imagem = Image.createImage("/enemy1.PNG");  
                enemy[i] = new CharacterClass(imagem, 16, 16, 160, 32);
                layer1.append(enemy);
    /* TODO
    Change manually positions of all enemies,
    since they start at the same position.
    private void checkInput() {
    int keyState = getKeyStates();
    if(((keyState & UP_PRESSED) != 0) && (player.getPosY() > 16)) {
    player.setLastPosY(player.getPosY());
    player.setPosY(player.getPosY() - 1);
    if(((keyState & DOWN_PRESSED) != 0) && (player.getPosY() < 208)) {
    player.setLastPosY(player.getPosY());
    player.setPosY(player.getPosY() + 1);
    if(((keyState & RIGHT_PRESSED) != 0) && (player.getPosX() < 208)) {
    player.setLastPosX(player.getPosX());
    player.setPosX(player.getPosX() + 1);
    if(((keyState & LEFT_PRESSED) != 0) && (player.getPosX() > 16)) {
    player.setLastPosX(player.getPosX());
    player.setPosX(player.getPosX() - 1);
    /* Check collision of player against cenary, enemies, itens. Also check collision of all enemies against cenary.
    Method must receive the number of enemies on the current level. */
    private void checkCollision(int numberEnemies) {
    if(player.collidesWith(tiledCenary, true)) {
    player.setPosX(player.getLastPosX());
    player.setPosY(player.getLastPosY());
    for(int i = 0; i < numberEnemies; i++)
    if(enemy[i].collidesWith(tiledCenary, true)) {
    enemy[i].setPosX(enemy[i].getLastPosX());
    enemy[i].setPosY(enemy[i].getLastPosY());
    private void moveEnemies(int numberEnemies) {
    for(int i = 0; i < numberEnemies; i++) {
    if(enemy[i].getPosX() < 208) {
    enemy[i].setLastPosX(enemy[i].getPosX());
    enemy[i].setPosX(enemy[i].getPosX() + 1);
    if(enemy[i].getPosX() > 16) {
    enemy[i].setLastPosX(enemy[i].getPosX());
    enemy[i].setPosX(enemy[i].getPosX() - 1);
    private void drawGameScreen(Graphics g) {
    g.fillRect(0, 0, 256, 256);
    player.setPosition(player.getPosX(), player.getPosY());
    for(int i = 0; i < numEnemies; i++)
    enemy[i].setPosition(enemy[i].getPosX(), enemy[i].getPosY());
    layer1.setViewWindow(player.getPosX() - 32, player.getPosY() - 32, 128, 110);
    layer1.paint(g, 0, 0);
    g.setColor(0, 0, 0);
    flushGraphics();

    Hi,
    One thing that stroke me when I read your code is that you never allocate arrays
    replace
    private CharacterClass[] enemy;by
    private CharacterClass[] enemy = new CharacterClass[MAX_ENEMIES];and
    public static boolean[] doneBuildLevel;by
    public static boolean[] doneBuildLevel = new boolean[NUMBER_LEVELS];Hope that help,
    Jack

  • What is the wrong in this code

    *& Report  ZTESTTEST
    REPORT  ztesttest LINE-SIZE 256.
    TYPE-POOLS: slis.
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE ,
                   <dyn_wa>,
                   <dyn_field>.
    FIELD-SYMBOLS: <dyn_table1> TYPE STANDARD TABLE ,
                   <dyn_wa1>,
                   <dyn_field1>.
    DATA: alv_fldcat TYPE slis_t_fieldcat_alv,
          it_fldcat TYPE lvc_t_fcat.
    TYPE-POOLS : abap.
    DATA : it_details TYPE abap_compdescr_tab,
           wa_details TYPE abap_compdescr.
    DATA :itab TYPE abap_component_tab.
    *       CLASS cl_my_structure  DEFENITION
    CLASS cl_my_structure DEFINITION.
      PUBLIC  SECTION.
        METHODS: x.
      PROTECTED SECTION.
      PRIVATE SECTION.
    ENDCLASS.                    "cl_my_structure  DEFENITION
    *       CLASS cl_my_structure IMPLEMENTATION
    CLASS cl_my_structure IMPLEMENTATION.
      METHOD x.
        WRITE 'HI'.
      ENDMETHOD.                    "x
    ENDCLASS.                    "cl_my_structure IMPLEMENTATION
    DATA : ref_descr TYPE REF TO cl_abap_structdescr.
    DATA: new_table TYPE REF TO data,
          new_line  TYPE REF TO data,
          wa_it_fldcat TYPE lvc_s_fcat.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text .
    PARAMETERS: p_table(30) TYPE c DEFAULT 'T001'.
    SELECTION-SCREEN END OF BLOCK b1.
    * Get the structure of the table.
    ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).

    That depends on what you want it to do.  Do you want it to write "Hi"?  If so...
    report  ztesttest line-size 256.
    *type-pools: slis.
    *field-symbols: <dyn_table> type standard table ,
    *               <dyn_wa>,
    *               <dyn_field>.
    *field-symbols: <dyn_table1> type standard table ,
    *               <dyn_wa1>,
    *               <dyn_field1>.
    *data: alv_fldcat type slis_t_fieldcat_alv,
    *      it_fldcat type lvc_t_fcat.
    *type-pools : abap.
    *data : it_details type abap_compdescr_tab,
    *       wa_details type abap_compdescr.
    *data :itab type abap_component_tab.
    *       CLASS cl_my_structure  DEFENITION
    class cl_my_structure definition.
      public  section.
        methods: x.
      protected section.
      private section.
    endclass.                    "cl_my_structure  DEFENITION
    *       CLASS cl_my_structure IMPLEMENTATION
    class cl_my_structure implementation.
      method x.
        write 'HI'.
      endmethod.                    "x
    endclass.                    "cl_my_structure IMPLEMENTATION
    *data : ref_descr type ref to cl_abap_structdescr.
    *data: new_table type ref to data,
    *      new_line  type ref to data,
    *      wa_it_fldcat type lvc_s_fcat.
    data: o_ref type ref to cl_my_structure.
    selection-screen begin of block b1 with frame title text .
    parameters: p_table(30) type c default 'T001'.
    selection-screen end of block b1.
    start-of-selection.    "<--  YES, YOU NEED THIS.
    create object o_ref .
    call method o_ref->x.
    * Get the structure of the table.
    *ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
    Regards,
    RIch Heilman

  • Whatz wrong in this code?

    public void doEdit(IPortalComponentRequest req.....
    IPageContext myContext=PageContextFactory.createPageContext(req,res);
    Document mydoc=myContext.createDocument("absexample");
    Form myForm = myContext.createFormDocument("example");
    mydoc.addComponent(myForm);
    IResource rs=req.getResource(IResource.IMAGE,"images/SAPPortals_opt2.gif");
    logo=new Image(rs.getResourceInformation().getURL(req),"Logo");
    myinput=new InputField("input");
    myinput.setDesign(InputFieldDesign.STANDARD);
    mybutton=new Button("mybutton");
    mybutton.setText("Personalize");
    mybutton.setOnClick("Personalize");
    mytray=new Tray();
    mytray.addComponent(logo);
    myForm.addComponent(mytray);
    mydoc.render(myContext);
    Is this how we create abstractportalcomponent?Iam trying to use this for iview custom personalization..Iam able to open this from the personalize link ..but wud see a blank page instead...
    if i do some response.write("") statements, then i wud see those...
    Y can't i render buttons and other htmlb stuff ??
    Help me out, iam stuck here!
    Thanks

    Hi Peter,
    we have a EP6 SP2 PatchLevel 35. I took your code and what should I say ... it works.
    portalapp.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <application>
         <application-config>
              <property name="ServicesReference" value="htmlb,com.sap.portal.ivs.connectorservice,epcftoolbox"/>
         </application-config>
         <components>
              <component name="HtmlbTest">
                   <component-config>
                        <property name="ClassName" value="com.zf.test.HtmlbTest"/>
                        <property name="SecurityZone" value="com.zf/low_safety/test"/>
                   </component-config>
                   <component-profile>
                        <property name="test1" value="1">
                             <property name="personalization" value="none"/>
                        </property>
                   </component-profile>
              </component>
              <component name="EventReceiver">
                   <component-config>
                        <property name="ClassName" value="com.zf.test.EventReceiver"/>
                        <property name="SecurityZone" value="com.zf/low_safety/test"/>
                   </component-config>
                   <component-profile>
                        <property name="test" value="1">
                             <property name="personalization" value="none"/>
                        </property>
                   </component-profile>
              </component>
              <component name="PersonalizationTest">
                   <component-config>
                   <property name="ClassName" value="com.zf.test.PersonalizationTest"/>
                   <property name="SecurityZone" value="com.zf/low_safety/test"/>
                   <property name="PersonalizationClass" value="com.zf.test.PersonalizationTest"/>
                   </component-config>
              <component-profile/>
              </component>
    </components>
         <services/>
    </application>
    The last component entry is the relevant one. Have a look at the servicesReference, maybe there is your problem?
    And here is my AbstractPortalComponent:
    package com.zf.test;
    import com.sapportals.htmlb.Button;
    import com.sapportals.htmlb.Form;
    import com.sapportals.htmlb.InputField;
    import com.sapportals.htmlb.enum.InputFieldDesign;
    import com.sapportals.htmlb.rendering.IPageContext;
    import com.sapportals.htmlb.rendering.PageContextFactory;
    import com.sapportals.portal.prt.component.AbstractPortalComponent;
    import com.sapportals.portal.prt.component.IPortalComponentRequest;
    import com.sapportals.portal.prt.component.IPortalComponentResponse;
    public class PersonalizationTest extends AbstractPortalComponent
        public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
         public void doEdit(IPortalComponentRequest request, IPortalComponentResponse response) {
              IPageContext myContext=PageContextFactory.createPageContext(request,response);
              Form myForm = myContext.createFormDocument("example");
              InputField myinput=new InputField("input");
              myinput.setDesign(InputFieldDesign.STANDARD);
              Button mybutton=new Button("mybutton");
              mybutton.setText("Personalize");
              mybutton.setOnClick("Personalize");
              myForm.addComponent(myinput);
              myForm.addComponent(mybutton);
              myContext.render();
    Further steps:
    deployment, in Portal Content Area creating an iView from par, put iView to page, page to role ...
    Then using the personalization link of the iView displays the InputField and Button in a new window.
    So, I hope there is some new info for you in here.
    Regards,
    Marcus

  • Please can someone tell me what's wrong in this code

    1var a=0;
    2function main(){
    3var inFolder = Folder.selectDialog("Please select folder to process");
    4//Save the Current Preferences
    5var startRulerUnits = preferences.rulerUnits;
    6preferences.rulerUnits = Units.PIXELS;
    7//Get all the files in the folder
    8var filelist=inFolder.getFiles()
    9n=filelist.length;
    10//Open each file
    11for(a=0; a<n; a++){
    12// The fileList is folders and files so open only files
    13if (fileList[a] instanceof File) {
    14open(fileList[i])
    15var docName = app.activeDocument.name;
    16app.activeDocument.flatten();
    17activedocument.save();
    18}
    19}
    20}
    21main();
    Says the error is "filelist is not recognized".    on line 14.   I thought I had fully defined 'filelist' on line8
    I thought filelist was a one-D array variable.
    Peterkal

    Also, in lines 8 and 9 you use a variable called "filelist" but in lines 13 and 14 you call it "fileList" (notice the capital-L).
    JavaScript is case-sensitive, so you must be consistent with your variable names throughout.

  • Wats wrong wit this sql statement?

    I know the format is right but i'm getting this error message:
    select acnum,givename,famname,instname from
    academic ac,department dep where
    ac.deptnum=dep.deptnum AND acnum in (
    select acnum
    from interest
    group by acnum
    having count(*) >=1
    order by count(*) desc
    ERROR at line 9:
    ORA-00907: missing right parenthesis

    I seem to recall that an ORDER BY in a subquery like this wasn't allowed at one point.It still is not allowed.
    You can inline the order by query though, but as you said, it actually doesn't really make sense:
    SQL>  select * from v$version where rownum=1
    BANNER                                                                         
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production         
    1 row selected.
    SQL>  select * from dual where dummy in (select * from dual order by 1)
    Error at line 1
    ORA-00907: missing right parenthesis
    SQL>  select * from dual where dummy in (select * from (select * from dual order by 1))
    D
    X
    1 row selected.

Maybe you are looking for

  • Acrobat Pro X crashes when trying to Distribute, Windows 7

    It started about 2 months ago, when I was scrolling a PDF rather fast. It crashed.  Then I tried to :"Distribute" a combine file and replace all the headers with new ones. After I typed in the "first" letter for the left upper header, it crashed. Doe

  • Message mapping hint 1:N in group of 2?

    Hi All, I am looking for message mapping hint to do following: Source XML. <itab>   <itab_body>     <a>1</a>     <b>1</b>   </itab_body>   <itab_body>     <a>2</a>     <b>2</b>   </itab_body>   <itab_body>     <a>n</a>     <b>n</b>   </itab_body> </i

  • Getting star(*) as the value of the column

    Dear All, i have created a report on the cube which will display the country wise Expected sales Volume and Weighted sales volume. for all country i am getting the correct value but for the country which are NOT ASSIGNED i am getting Star(*) as the v

  • MIRO and alternative reconciliation accounts?

    Hi all, The situation is following. Purchase order is made and when in MIRO we are processing this PO into a subsequent credit then it is not possible to change an reconciliation account for that vendor even if I did set it up in SPRO as an alternati

  • Max Volume?

    I get on the bus alot to and from school and also play drums to music on my ipod. I've noticed that the volume level on the iPod is higher than that on the nano, even the old iPod mini's volume level is higher than the new nano's. On the bus, at full