What is the following syntax for?

I saw this on the Sun tutorial for swing components and was a little baffled. I'm a "professional core java programmer" yet I did not recognized the syntax. Here it is...
JLabel myLabel = new JLabel("A Label"){
public void Amethod(){
// method body
public void AnotherMethod(){
// method body 2
What is the purpose of the curly bracketed code after a object declaration?
I even tried this in eclipse and it worked....
Object _obj = new Object(){}; // compiles
I know you can put {} anywhere but what does it do when you have method implementation in them?

It creates an anonymous inner class which extends something else;
in your example the JLabel class is extended. At the same time an
object of that extended class is created. The syntax is funny indeed
but very handy for all sorts of Listeners used in the Swing framework.
Note that there are other situations where such an anonymous inner
class can come in handy. Try this for example (see below) and change
the text in the label:JLabel label= new JLabel("initial text") {
   public void setText(String text) { // override the setText method
      super.setText(text);
      System.out.println("Changed label text: "+text);
label.setText("new text");kind regards,
Jos

Similar Messages

  • What is the exact syntax for calling remote function module.

    Hi to all
    1.....what is the exact syntax for calling remote function module.?
    Thanks and regards,
    k.swaminath reddy

    hi
    good
    Lets do simple example where you will first create a RFC in one server (say A) and create normal program in othere server (say B). Finally you will call the RFC in A from B.
    Do the following steps for creating RFC in server A.
    1. log on to server A
    2. go to se37
    3. Edit -> function groups-> create function group and give the function group name (say ZGRP).
    4. create a FM ( say Z_TEST_RFC) in se37 providing the function group which is created just now.
    5. go to attribute tab -> choose remote-enabled module from processing type.
    so that your FM will become RFC.
    6. provide the import parameter in import tab.
    we will provide only two import parameters.
    - parameter name : P_NUM1, typing: TYPE, associated type : I & check the pass value (all the parameters of RFC must pass by value).
    - parameter name : P_NUM2, typing: TYPE, associated type : I & check the pass value
    7. provide the export parameter in export tab.
    parameter name : P_SUM, typing: TYPE, associated type : I & check the pass value
    8. write the given simple code in source code tab.
    FUNCTION Z_TEST_RFC.
    P_TOT = P_NUM1 + P_NUM2.
    ENDFUNCTION.
    Do the following steps for creating ABAP program which will call the RFC in server B.
    1. se38 - > creat a program.
    2. write the given simple code.
    data tot type i.
    call function 'Z_TEST_RFC' destination 'XXXXXX'
    exporting
    p_num1 = 10
    p_num2 = 15
    importing
    p_tot = tot.
    write tot.
    please note that XXXXXX is RFC connection which is avialable in sm59 transaction in server A.
    -go to sm59 - > abap connection (list of RFC connection configurations are avialable). choose server B connection and replace it of XXXXXX in the code.
    finally you can execute the normal abap program that will call the RFC and display the result.
    reward point if helpful.
    thanks
    mrutyun^

  • What is the setVariable syntax for AS3

    Hi,
    I am having issues with setting a variable in AS3 SWF playing inside a Dir12
    spriteObjRef.setVariable(variableName, newValue)
    In the context of ActionScript 3, this method is only supported on a Flash object, not on a
    spriteObjectRef.
    What would the Flash Object syntax be??
    Thanks,
    Jim

    Jusclark-Oracle wrote:
    What is the correct syntax for referencing a page item (P23_ID, for example) in a PL/SQL page process, after submit?
    See "About Referencing Session State" in the documentation.
    Within an anonymous block in an APEX page process, use the standard bind variable syntax:
    :P23_ID
    In general, use bind variable syntax when referencing session state values in SQL or DML:
    select
        ename
    into
        :p23_name
    from
        emp
    where
        empno = to_number(:p23_id);
    and obviously when assigning values to the item:
    :P23_ID := foo.nextval;
    PL/SQL function references v('p23_id') and nv('p23_id') [for number values] must be used to access values in stored program units called from APEX, although it's usually better to pass the values as parameters: foo(:p23_id).

  • What is the correct syntax for using a variable in an ad hoc query?

    Hi all
    I am an occasional DB user and at the moment need to update about 1000+ records so that a certain column gets a unique value.
    So I thought that I would use a variable for this.
    I then built this kind of SQL statement for just a small subset of the records:
    variable recNumber number;
    exec :recNumber := 1;
    UPDATE TABLE_TO_BE_UPD
    SET COL_TO_BE_UPD = COL_TO_BE_UPD + recNumber
    WHERE COL_TO_BE_UPD IN ('VAL_A','VAL_B');
    I get the invalid SQL statement error when attempting to execute above (besides the prompt that asks for a value which I would like to omit).
    Anyway I also tried this one:
    CREATE SEQUENCE seqCounter;
    UPDATE TABLE_TO_BE_UPD
    SET COL_TO_BE_UPD = COL_TO_BE_UPD + seqCounter.NEXTVAL
    WHERE COL_TO_BE_UPD IN ('VAL_A','VAL_B');
    From this one I got the error ORA-01722: invalid number...I am guessing this comes because seqCounter is of type number and the COL_TO_BE_UPD is of type character...(?)
    So what I would like to ask is what is the correct way to define and use a counter type of variable to append a number at the end of a character string?
    Also another question that I would like to ask is that are variables that are used in ad hoc queries also called 'bind variables'?
    Thanks muchly

    If you want to append a unique number to a column then this would do it:
    UPDATE TABLE_TO_BE_UPD
    SET COL_TO_BE_UPD = COL_TO_BE_UPD ||to_char(rownum)
    WHERE COL_TO_BE_UPD IN ('VAL_A','VAL_B');

  • What is the Opendocument syntax for java SDK -BOXI3.1

    Hi,
    We are using java sdk for BOXI3.1 to open the reports from J2EE Screens.
    Earlier we have used below syntax for opendocument in BOXIR2, it worked fine. Now our client is migrated to BOXI3.1 same URL syntax is not working.
    BOXIR2 we have used below syntax to open the webi reports from J2EE screen:
    URL: "http://" + CMS + ":8080/businessobjects/enterprise115/desktoplaunch/opendoc/openDocument.jsp?" + "iDocID=" + webiID + "&sType=wid&sWindow=Same&token=" + token;
    Please help in this regard.

    The URL path and such has changed.
    Here is a pdf for [XI 3.1 URL Reporting|http://help.sap.com/businessobject/product_guides/boexir31/en/xi3-1_url_reporting_opendocument_en.pdf]
    Jason

  • What's the REST syntax for TODAY()?

    I'm new to javascript/REST and I'm trying to run a REST api against a SharePoint list of Events.  What's the syntax to show only the dates greater than or equal today (see below) 
    ..._api/web/lists/getbytitle('Events')/items?$select=Id,EventDate,Location&$filter=EventDate ge
    TODAY()

    TODAY option doesn't seem to be available in SharePoint REST. An alternative is to create a JavaScript Variable to hold date represented by today, convert it to ISO date format and use that in REST query:
    var today = new Date();
    api/web/lists/getbytitle('Events')/items?$select=Id,EventDate,Location&$filter=EventDate ge '" + today.toISOString() + "'
    Source: http://sharepoint.stackexchange.com/questions/105576/rest-api-filter-by-start-and-end-dates-using-today
    Blog | SharePoint Learnings CodePlex Tools |
    Export Version History To Excel |
    Autocomplete Lookup Field

  • What's the correct syntax for animate scale

    I have tried to animate the scale transformation of an object from code.
    I had a little success with the code from here:
    http://stackoverflow.com/questions/5029035/how-do-we-add-css-animation-in-jquery
    But animating the scale looks jerky on the iPad with this hack.
    There must be an option of doing it from within Edge since a timeline animation which does the same (just transform scale of an object over time) runs smooth.
    I know there are jQuery extensions for things like that but I don't want to interfere with anything Edge does itself.
    Can someone give me a hint what syntax I need for animating the scale of an object within Edge?

    Hi Bittamer,
    There is no built-in code to animate objects. If you don't want to use the CSS scale code, you can use jQuery animate to animate the width and height props of your object, like so:
    sym.yourHeight = 500;
    sym.yourWidth = 500;
    sym.$("your_symbol").animate({height:sym.yourHeight, width:sym.yourWidth}, 500, 'swing');

  • What is the correct syntax for Sumif when condition is for a text string?

    B2 and b3 both contain the text "Grc".
    C2 contains 1 and C3 contains 2.
    F2 contains a Sumif that reads as: =SUMIF(B2:B10, "=Grc", C2:C10)
    The result is "0" when it should yield 3
    I can't figure out what happened.

    Hi ishii,
    Your screen shots make no sense to me. I am using Numbers'09 on a MacBook Pro running OS X. Please tell us what device, operating system and app you are using. You still have not told us.
    This forum is for Numbers on a Mac running OS X. Is your screen shot from an iOS device?
    I don't know anything about Numbers for iOS.
    Or are you using Excel?
    I can not help you. If you are using an iPad, you will get a better answer in this forum:
    https://discussions.apple.com/community/app_store/iwork_for_ios?view=discussions
    Regards,
    Ian.

  • What's the correct syntax for this?

    Hey guys
    If...
    trace(rowsHolder.getChildByName("mc"+newStr).y);  
    ...correctly outputs the y coordinate of (in this case) mc001, how do I output the y coordinate of a movieClip called item_base_mc that's within the timeline of mc001?
    trace(rowsHolder.getChildByName("mc"+newStr).item_base_mc.y);
    ...gives me a display object error.
    I've tried permutations of the above with [] brackets in various places, but haven't cracked the code.
    What would be the correct way to write it?
    Thanks for taking a look.
    Shaun

    I don't know how to really explain this, but from documentation you will notice  -   getChildByName()  -  is actually a function from  -  DisplayObject  - not MovieClip.
    Link here provides a better explanation!
    http://curtismorley.com/2007/06/13/flash-cs3-flex-2-as3-error-1119
    GOOD LUCK

  • Can't figure out the correct syntax for this select statement

    Hello,
    The following statement works great and gives the desired results:
    prompt
    prompt Using WITH t
    prompt
    with t as
       select a.proj_id,
              a.proj_start,
              a.proj_end,
              case when (
                         select min(a.proj_start)
                           from v b
                          where (a.proj_start  = b.proj_end)
                            and (a.proj_id    != b.proj_id)
                        is not null then 0 else 1
              end as flag
         from v a
        order by a.proj_start
    select proj_id,
           proj_start,
           proj_end,
           flag,
           -- the following select statement is what I am having a hard time
           -- "duplicating" without using the WITH clause
            select sum(t2.flag)
              from t t2
             where t2.proj_end <= t.proj_end
           ) s
      from t;As an academic exercise I wanted to rewrite the above statement without using the WITH clause, I tried this (among dozens of other tries - I've hit a mental block and can't figure it out):
    prompt
    prompt without with
    prompt
    select c.proj_id,
           c.proj_start,
           c.proj_end,
           c.flag,
           -- This is what I've tried as the equivalent statement but, it is
           -- syntactically incorrect.  What's the correct syntax for what this
           -- statement is intended ?
            select sum(t2.flag)
              from c t2
             where t2.proj_end <= c.proj_end
           ) as proj_grp
      from (
            select a.proj_id,
                   a.proj_start,
                   a.proj_end,
                   case when (
                              select min(a.proj_start)
                                from v b
                               where (a.proj_start  = b.proj_end)
                                 and (a.proj_id    != b.proj_id)
                             is not null then 0 else 1
                   end as flag
              from v a
             order by a.proj_start
           ) c;Thank you for helping, much appreciated.
    John.
    PS: The DDL for the table v used by the above statements is:
    drop table v;
    create table v (
    proj_id         number,
    proj_start      date,
    proj_end        date
    insert into v values
           ( 1, to_date('01-JAN-2005', 'dd-mon-yyyy'),
                to_date('02-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 2, to_date('02-JAN-2005', 'dd-mon-yyyy'),
                to_date('03-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 3, to_date('03-JAN-2005', 'dd-mon-yyyy'),
                to_date('04-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 4, to_date('04-JAN-2005', 'dd-mon-yyyy'),
                to_date('05-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 5, to_date('06-JAN-2005', 'dd-mon-yyyy'),
                to_date('07-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 6, to_date('16-JAN-2005', 'dd-mon-yyyy'),
                to_date('17-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 7, to_date('17-JAN-2005', 'dd-mon-yyyy'),
                to_date('18-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 8, to_date('18-JAN-2005', 'dd-mon-yyyy'),
                to_date('19-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 9, to_date('19-JAN-2005', 'dd-mon-yyyy'),
                to_date('20-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           (10, to_date('21-JAN-2005', 'dd-mon-yyyy'),
                to_date('22-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           (11, to_date('26-JAN-2005', 'dd-mon-yyyy'),
                to_date('27-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           (12, to_date('27-JAN-2005', 'dd-mon-yyyy'),
                to_date('28-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           (13, to_date('28-JAN-2005', 'dd-mon-yyyy'),
                to_date('29-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           (14, to_date('29-JAN-2005', 'dd-mon-yyyy'),
                to_date('30-JAN-2005', 'dd-mon-yyyy'));

    Hi, John,
    Not that you asked, but as you proabably know, analytic functions are much better at doing this kind of thing.
    You may be amazed (as I continually am) by how simple and efficient these queries can be.
    For example:
    WITH     got_grp          AS
         SELECT     proj_id, proj_start, proj_end
         ,     proj_end - SUM (proj_end - proj_start) OVER (ORDER BY  proj_start)     AS grp
         FROM     v
    SELECT       ROW_NUMBER () OVER (ORDER BY grp)     AS proj_grp
    ,       MIN (proj_start)                         AS proj_start
    ,       MAX (proj_end)               AS proj_end
    FROM       got_grp
    GROUP BY  grp
    ORDER BY  proj_start
    ;Produces the results you want:
      PROJ_GRP PROJ_START  PROJ_END
             1 01-Jan-2005 05-Jan-2005
             2 06-Jan-2005 07-Jan-2005
             3 16-Jan-2005 20-Jan-2005
             4 21-Jan-2005 22-Jan-2005
             5 26-Jan-2005 30-Jan-2005This is problem is an example of Neighbor-Defined Groups . You want to GROUP BY something that has 5 distinct values, to get the 5 rows above, but there's nothing in the table itself that tells you to which group each row belongs. The groups are not defined by any column in hte table, but by relationships between rows. In this case, a row is in the same group as its neighbor (the row immediatly before or after it when sorted by proj_start or proj_end) if proj_end of the earlier row is the same as proj_start of the later row. That is, there is nothing about 03-Jan-2005 that says the row with proj_id=2 is in the first group, or even that it is in the same group with its neighbor, the row with proj_id=3. Only the relation between those rows, the fact that the earlier row has end_date=03-Jan-2005 and the later row has start_date=03-Jan-2003, that says these neighbors belong to the same group.
    You're figuring out when a new group starts, and then counting how many groups have already started to see to which group each row belongs. That's a prefectly natural procedural way of approaching the problem. But SQL is not a procedural language, and sometimes another approach is much more efficient. In this case, as in many others, a Constant Difference defines the groups. The difference between proj_end (or proj_start, it doesn't matter in this case) and the total duratiojn of the rows up to that date determines a group. The actual value of that difference means nothing to you or anybody else, so I used ROW_NUMBER in the query above to map those distinct values into consecutive integers 1, 2, 3, ... which are a much simpler way to identify the groups.
    Note that the query above only requires one pass through the table, and only requires one sub-query. It does not need a WITH clause; you could easily make got_grp an in-line view.
    If you used analytic functions (LEAD or LAG) to compute flag, and then to compute proj_grp (COUNT or SUM), you would need two sub-queries, one for each analytic function, but you would still only need one pass through the table. Also, those sub-queries could be in-line views; yiou would not need to use a WITH clause.

  • What are the ports required for the Audio, Video and A/V conferencing when the following end points are enabled for QoS in Lync 2013 server?

    Hi All,
    What are the ports required for the Audio, Video and A/V conferencing when the following clients are enabled for QoS in Lync 2013 server?
    Client Type
    Port range  and Protocol required for Audio
    Port range and Protocol required for
    Video
    Port range and Protocol required for
    A/Vconferencing
    Windows Desktop   Client
    Windows mobile App
    Iphone
    Ipad
    Andriod phone
    Andriod Tablet
    MAC desktop client
    Please advise. Many Thanks.

    Out of the box, 1024-65535 for all of the client ports.  :) 
    https://technet.microsoft.com/en-us/library/gg398833.aspx
    You'll want to tune your client ports a bit
    https://technet.microsoft.com/en-us/library/jj204760.aspx as seen here, and then the client ports would use those ranges which is easier to set QoS markings.  I'm not sure the mobile clients respect that setting.
    Elan's got the best writeup for Windows clients here:
    http://www.shudnow.net/2013/02/16/enabling-qos-for-lync-server-2013-and-various-clients-part-1/
    However, the marking of the packets is the tricky part.  Windows can do it via Group Policy, but for the other clients you'll need to have the network specifically prioritize ports regardless of DSCP markings.  You have to do it based on ports
    as the traffic could be peer to peer.
    Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question please click "Mark As Answer".
    SWC Unified Communications
    This forum post is based upon my personal experience and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • HT201303 I received this update from Apple, but I have no record of altering anything, can you tell me what has been updated, who updated anything, and how was it done?  Hello,  The following information for your Apple ID was updated on 03/22/2014:  Phone

    I received this  update from Apple, but I have no record of altering anything, in particular telephone numbers, can anyone tell me what has been updated, who updated it, and how was entry made to my account?
    Hello,
    The following information for your Apple ID was updated on 03/22/2014:
    Phone number(s)
    If these changes were made in error, please CLICK HERE,  to Cancel this changes withing 24hours..
    This is an automated message. Please do not reply to this email. If you need additional help, visit Apple Support.
    Thanks,
    Apple Customer Support

    This is a user to user forum, so no one here can provide an answer.  You should contact iTunes Support directly.
    Here's how you can do that:  http://www.apple.com/support/itunes/contact/

  • What are the following:1)Cisco 1600 Series IOS WIRELESS LAN RECOVERY. 2)Service Provider Option 60 for Vendor Class Idenfier

    What are the following:1)Cisco 1600 Series IOS WIRELESS LAN RECOVERY. 2)Service Provider Option 60 for Vendor Class Idenfier
    These items are listed with 1600 series AP but I'm unable to understand what are these things & the use of them

    DHCP Option 60:  Go HERE.

  • I have problems in the initiation of the Encore process when opening presents the following error message : "Encore CS6 Cannot Run in Non-Royalty Serialized".... What is the best solution for this problem ?

    Help Me.
    What is the best solution for this problem ?

    Encore is activated when you activate Premiere Pro... so, as Stan asked, how did you install P-Pro?
    Ask for serial number http://forums.adobe.com/thread/1234635 has a FAQ link
    -and a fix for Encore http://forums.adobe.com/thread/1421765?tstart=0 in reply #7
    -plus more Encore http://helpx.adobe.com/encore/kb/cant-write-image-fie-larger1.html

  • What are the following script doing?

    What are the following script doing? What does symbol *<* stand for?
    protected Map<Member, List<String>> divideWork(Set members, List<String>
    fileNames)
    Thank you

    su_penguin wrote:
    Side note: http://en.wikipedia.org/wiki/Operator_overloading
    Extra credit: What trick does Java's syntax use to allow Generics to compile with or without whitespace between the angle brackets? Ex: Map< Member, List< String > >
    Why doesn't it work in C++?Does this have something to do with the comment "Note that it is not an LL(1) grammar"? [http://java.sun.com/docs/books/jls/third_edition/html/syntax.html]

Maybe you are looking for