Problem with overloading

Hello everyone,
I am trying to create a simple panel with buttons and lines (quite modest, right?).
I have extended JPanel and JButton, and added the new buttons to the new panel, using GridBagConstraints.
For now i've added just one button and drew one line. Both look fine, but i cannot press the button! (nothing happens). The "funny" thing is that there is a place on the panel that when i press it - another button is being drawn there, and the event handler is called.
I should mention that when i add a regular JButton instead of mine (all other code remains the same) - it is being drawn in the same place as the second button appears - the middle of the upper side of the panel - whle i am trying to put it in 100,100 coordinate).
Code:
public class MyButton extends JButton{
     private String name;
     private int x, y; //left upper corner
     public MyButton(String name, int x, int y) {
          super(name);
          this.name = name;
          this.x = x;
          this.y = y;
          setPreferredSize(new Dimension(Consts.NODE_SIZE, Consts.NODE_SIZE));
     public String getName() {
          return name;
     public int getX() {
          return x;
     public int getY() {
          return y;
public class MyDisplay extends JPanel implements ActionListener{
     private Vector nodes = new Vector();
     private GridBagConstraints gbc = new GridBagConstraints();
     public MyDisplay() {                    
setBorder(BasicBorders.getButtonBorder());
setPreferredSize(new Dimension(300, 300));
for (int i=0; i<1; i++) {
     int x = 100;
     int y = 100;
     MyButton b = new MyButton(""+i, x, y);
     //JButton b = new JButton(""+i);
     if (b == null)
          throw new Error("failed creating button");      
     nodes.add(b);
     b.addActionListener(this);
     gbc.gridx = x;
     gbc.gridy = y;
     add(b, gbc);
     public void paintComponent(Graphics graphics){
          super.paintComponent(graphics);
          if (graphics == null) {
               System.out.println("NULL GRAPHICS");
               return;
          graphics.setColor(Color.BLUE);
          graphics.drawLine(50, 50, 100, 100);                    
     public void actionPerformed(ActionEvent ae) {
          for (int i=0; i<nodes.size(); i++)               
               try {
                    MyButton b = (MyButton)nodes.get(i);
                    if (ae.getSource() == b) {          
                         System.out.println("button " + i + " pressed");
                         return;
               } catch (Throwable e) {
                    throw new Error("Received event from non-MyButton");
thank you in advance,
Pavel.

Your overridding doesn't work -
getY() and getX() tells paintComponent where to print your MyButton component
Since your added button is the only one in the GridBagLayout it will be placed on the center of your panel.
Solution: do not use a GridBagLayout - use a null layout
your new constructor could look like this
public MyDisplay() {
super(null);
//super(new GridBagLayout()); -- u should have done this supercall in your old code!
//u could also use do this: setLayout(null);
setBorder(BasicBorders.getButtonBorder());
setPreferredSize(new Dimension(300, 300));
for (int i=0; i<1; i++) {
     int x = 100;
     int y = 100;
     MyButton b = new MyButton(""+i, x, y);
     //JButton b = new JButton(""+i);
     if (b == null)
     throw new Error("failed creating button");
     nodes.add(b);
     b.addActionListener(this);
     add(b);
     b.setSize(b.getPreferredSize());
     b.setLocation(x,y);
}Of course you should delete your overrided methods: getY() and getX().
good luck with your fancy application ;)
imqwerty.

Similar Messages

  • Problem with overloading Bean Classes

    For a default Save- & Rollback-Behavior I have defined a Save & Rollback Button in the template.jspx. The backing bean (GlobalOperationMBean|com.example.GlobalOperationHandler|sessionScope) for the 2 buttons is defined in the taskflow-template. If I want a different or extended behavior I declare the same Bean with a different class (GlobalOperationMBean|com.example.DifferentOperationHandler|sessionScope) in a bounded task flow (Taskflow1). Then I have a second task flow (Taskflow2) where I specified another class (GlobalOperationMBean|com.example.AnotherOperationHandler|sessionScope). DifferentBehaviorHandler and AnotherOperationHandler extend GlobalOperationHandler and override the methods for save and rollback. The overloading of the bean works perfecty in Taskflow 1.
    In Taskflow1 I make a task flow call of Taskflow2. Anticipated behavoir for pressing the Rollback-Button would be the execution of the rollback-method in AnotherOperationHandler (Definition in Taskflow2), but the rollback-method in DifferentOperationHandler (Definition in Taskflow1) is called.
    Do I have to make a special declaration in the taskflow to get it work or do I have to make it completely different?
    Any help is appreciated!
    Thanks,
    Thomas

    Hi Frank,
    this is actually what I'm trying to achieve.
    I'm just trying to understand why in my approach the bean in the second taskflow is not used? Do you have a hint?
    Thanks,
    Thomas

  • Design flaw in overloading? Problem with visitor pattern

    I have been trying some implementations of the Visitor pattern in Java and have encountered a problem with overloaded methods in Java. It seems that the caller (client) of a overloaded method decides what implementation of that method is chosen. I find that strange from an OO / encapsulation point of view and it gets me into problems when using Visitor. This code shows my problem:
    // a class with overloaded methods
    public class OverLoadingTest {
         public void print(String s) {
              System.out.println("This looks like a String to me:");
              System.out.println("\"" + s + "\"");
         public void print(Object o) {
              System.out.println("This looks like an Object to me:");
              System.out.println("\"" + o + "\"");
    //a client for that class
    public class OverLoadingTestClient {
         public void test() {
              OverLoadingTest test = new OverLoadingTest();
              Object o1 = "String in an Object reference";
              String s1 = "String in a String reference";
              test.print(o1);
              test.print(s1);
         public static void main(String[] args) {
              new OverLoadingTestClient().test();
    //And the output is:
    This looks like an Object to me:
    "String in an Object reference"
    This looks like a String to me:
    "String in a String reference"
    //The output I would have expeced (wanted):
    This looks like a String to me: //it is a String!
    "String in an Object reference"
    This looks like a String to me:
    "String in a String reference"
    Why is this? Is there a work around?

    The specific method is decided on in compile time and by the client of that method, not the provider. I'd expect the client to just invoke the method and let the privider figure out what implementation to choose. Whatever the client thinks that he is providing as argument types.
    I am implementing a slightly different version compared to http://ootips.org/visitor-pattern.html. I find implementing "v.visit(this);" for every subclass of the Visisted superclass strange. Why an abstract method "accept(Visitor v);" when all subclasses will iplement it in the same way ("v.visit(this);")?
    Daan

  • Problem with Mac Mail-iMap server on Hosting (Overloading Server)

    Hello, I just created an account with HostGator for my business and we have 6 emails. We have imap email and our account allows us to check email once per minute per email. We have it set up to check every 5 minutes so this should not be a problem.
    They then told us that there was a problem with it checking more frequently and also overloading the server by issueing 'multiple imap commands per email, 3 to 4'. I can view our server processes and sure enough each email is showing 4 imap commands. I unchecked 'use IDLE command" since I know IDLE command has something to do with it checking frequently for email.
    Unfortunately we have 3 processes running on our website so once we had 24 for the 6 emails that goes over our limit of 25 and our website goes down. For now we have had to turn off most of our emails except 2 that we receive most email at which is causing major problems.
    When we talked to HostGator that question was "Do you use Mac mail? Mac Mail is knowing for doing that". Since I only use Mac's I don't want to have to switch to Windows for email or use another email program like Entourage or Thunderbird. This is a frustrating issue and when I did research on Google I saw a lot of other people having this issue but didn't see any answers. Any ideas what is causing this and how I can fix it?

    Hi,
    IMAP IDLE is not the problem - it is even good! http://en.wikipedia.org/wiki/IMAP_IDLE
    I have also an unanswered similar Post some hours ago: http://discussions.apple.com/thread.jspa?threadID=1957241&tstart=15
    paranoja

  • HT4812 i have an issue with overloads. what do i do about that problem?

    I am having problems with Logic Pro. I am getting overloads & I do not understand why but, it keeps appearing & I do not know what to do. Does anyone have these problems also? If so, then contact me back asap.. thank you!

    Sorry, I still have no clue how to advise something sensible.
    Do you mean cpu overloads or audio overloads like clipping, by the way?
    Try to read about the overload / clipping phenomenon in the manual.
    Good luck!

  • Logic Pro system overloaded and MIDI clock problems with Intel

    Hi
    I'm not a super-powerful-rich music producer. I have owned an iMac G5 1GB of RAM for tree years with a lot of problems with the memory, but i could achieve a quite good knowledge of Logic Pro 7.1.1. The thing is that with my new iMac that has a larger memory i'm not able to playback old songs, and it sounds strabge to me because the Intel iMac would have to work better than the older....I think....(the file i'm talking about has got 5 tracks, 4 freezed and one not: it sounds really strange even if I haven't 5 GB of memory!!!)
    Moreover I've had other new problems with MIDI sync but i've never used other MIDI clocks sources even if I use a M-Audio pro 88 keyboard and an audio interface ESI Quatafire 610. I know that i haven't got a great instrumentation in my hands, but this doesn't mean that it doesn't have to work.
    Do I need Logic 7.2? Do I need to change my audio interface?
    Do I need to set up logic in a way that with iMac G5 hadn't be necessary?
    I'm waiting for an answer from someone who's more capable.
    Thank you.
    Luigi
    iMac 2 GHz Intel core duo 20" 1,5 GB RAM Mac OS X (10.4.8) Audio Inteface ESI Quatafire 610

    Do I need Logic 7.2?
    absolutely definitely, you need a minimum of logic 7.2. it is the first version that is intel-native. your problems are 100% because the code you are trying to run has to be emulated first in order to be interpreted by the intel chip in your imac. this means that logic will run like a sick dog, until you give it a version that is actually compatible with your machine.

  • Problems with spaces in directory or file names and Word.exe

    Hi
    I'm trying to open a file with Word from my java aplication, and I have a problem with some file/directory names.
    I have this
    String cmd = "c:\\Program Files\\Microsoft Office\\Office10\\WINWORD.EXE" + " " + path;
    try {
    Runtime.getRuntime().exec(cmd);
    } catch (Exception errorea){ }
    Here is what happens:
    if path is something like this: "c:\people\info.doc" , there's no problem, Word opens the document, but if path contains blank spaces somewhere, it doesn't work. For example:
    path = "c:\Documents and Settings\info.doc"
    path = "c:\Hi everybody\info.doc"
    path = "c:\tests\test results.doc"
    with the above examples it doesn't work :( Word tries to open "c:\Documents", "c:\Hi" or "c:\tests\test".
    Can anyone help? thanx a lot ! : )

    No, the exec method runs the Word.weird, it shouldn't, and it wouldn't on my system going by the test I just made, but I'm running linux & not windows, maybe the command line parsing is different for some reason.
    The problem is that
    Word starts and then Word says that it can't open the
    file because the name or the path to the file is not
    valid.You still should use the overload that takes a String array.

  • Problems with iPod Nano 6th Gen Playback & Updating

    Hi. I have had a look and can't find another post on this - apologies if I have missed it!
    My problems start before I purchased my new Nano 16GB last week.
    When the last update of iTunes came available, I was unable to install it. The task bar would get to about 50% (although it varied) and would then time out. When I had this problem I tried everything from every forum imaginable, from deleting all Temp files, disabling the firewall and all start up applications and clearing the registry – everything. Nothing worked. Eventually I decided that I should uninstall, then install the new version.
    After a week of the same problems trying to install iTunes, I gave up and downloaded on another computer, and saved the .exe file to a USB stick. This worked until two days after I downloaded it, yet another update came out and I had to start all over again (I didn’t – I am running on 10.1.2.17 still).
    I was concerned when I purchased my new Nano that I would have problems connecting it to iTunes as I was not running the new version – but it was okay. Unfortunately, the iPod requires update 1.1 and I am also having the same problem with this – I get time out error 3259 after sometime trying to download it. And yes, I have tried all the same tricks, but nothing seems to work.
    I am running Vista on a Dell PC, and connect to the internet on a pre-pay internet USB dongle. I can download updates for other programmes, and other files successfully – it is only iTunes that I am having an issue with. ITunes is added to my list of accepted programmes on my firewall, but I disable that when I am downloading.
    Meanwhile! My new iPod is fantastic. Unfortunately I am experiencing an odd problem with it, and cannot seem to find other people with the same issue. The memory is not overloaded (it has 1.10GB of free space on it). I have 1857 tracks on it, and 14 podcasts. I play the music files through the ‘Songs’ menu, on Shuffle mode. For some reason, after playing one or two tracks, it doesn’t seem to want to play the next one. The track will be displayed on the screen, but it does not play. When you look at the song progress bar, it shows that it is part way through the song, but it is not moving. I have tried pressing ‘Pause’ followed by ‘Play’ and nothing happens.
    The only way to get it to start playing again is to skip to the next track, but even this has its issues. Sometimes, when you skip forward a track, it plays a completely different track to the one that is displayed. When you look at the progress bar for the song it is showing, it isn’t moving, but music is still coming out!
    Does anyone have any idea what the issue is, and how I can get the machine to play continuously without having to handle it several times? Please?!

    Hi dianak22!
    I have an article here that can help you troubleshoot to resolve this issue:
    iPod nano (6th generation): Hardware troubleshooting
    http://support.apple.com/kb/TS3474
    You can also walk through the steps of troubleshooting using the troubleshooting assistant, which can be found here:
    Apple - Support - iPod nano (6th generation) - iTunes Troubleshooting Assistant
    http://www.apple.com/support/ipodnano/6th_generation/assistant/itunes/
    Thanks for using the Apple Support Communities!
    Cheers,
    Braden

  • Problem with Cisco 861W router and outgoing VPN

    We have a Cisco 861W router that is blocking an outgoing PPTP on the internal access point only. The outgoing VPN works when the traffic is through a wired connection or the connection is on another access point. We fail to make a connection only when connection to the 861W's internal Access Point.
    Here is the Access Point Configuration:
    Current configuration : 2100 bytes
    version 12.4
    no service pad
    service timestamps debug datetime msec
    service timestamps log datetime msec
    no service password-encryption
    hostname obap
    enable secret 5 $1$.1RF$go1D7WITXUn3s8TUaw3tC.
    no aaa new-model
    dot11 syslog
    dot11 ssid OLIVER
       authentication open
       authentication key-management wpa
       guest-mode
       wpa-psk ascii 0 XXXXXXXXXXX
    username XXXXXX privilege 15 secret 5 $1$Wc0K$OzcQDDQfjHP6La31eXMoG/
    bridge irb
    interface Dot11Radio0
    no ip address
    no ip route-cache
    encryption mode ciphers aes-ccm tkip
    ssid OLIVER
    antenna gain 0
    station-role root
    bridge-group 1
    bridge-group 1 subscriber-loop-control
    bridge-group 1 block-unknown-source
    no bridge-group 1 source-learning
    no bridge-group 1 unicast-flooding
    bridge-group 1 spanning-disabled
    interface GigabitEthernet0
    description the embedded AP GigabitEthernet 0 is an internal interface connecti
    ng AP with the host router
    no ip address
    no ip route-cache
    bridge-group 1
    no bridge-group 1 source-learning
    bridge-group 1 spanning-disabled
    interface BVI1
    ip address 192.168.0.2 255.255.255.0
    no ip route-cache
    ip http server
    no ip http secure-server
    ip http help-path http://www.cisco.com/warp/public/779/smbiz/prodconfig/help/eag
    bridge 1 route ip
    banner login ^CC
    % Password change notice.
    Default username/password setup on AP is cisco/cisco with priv¾ilege level 15.
    It is strongly suggested that you create a new username with privilege level
    15 using the following command for console security.
    username <myuser> privilege 15 secret 0 <mypassword>
    no username cisco
    Replace <myuser> and <mypassword> with the username and password you want to
    use. After you change your username/password you can turn off this message
    by configuring  "no banner login" and "no banner exec" in privileged mode.
    ^C
    line con 0
    privilege level 15
    login local
    no activation-character
    line vty 0 4
    login local
    cns dhcp
    end
    obap#
    Here is the Router's Configuration:
    Current configuration : 5908 bytes
    ! No configuration change since last restart
    version 15.0
    no service pad
    service tcp-keepalives-in
    service tcp-keepalives-out
    service timestamps debug datetime msec localtime show-timezone
    service timestamps log datetime msec localtime show-timezone
    service password-encryption
    service sequence-numbers
    hostname obrouter
    boot-start-marker
    boot-end-marker
    logging buffered 51200
    logging console critical
    enable secret 5 $1$i9XE$DjxFVAEC9nC4/r6EQKCd6/
    no aaa new-model
    memory-size iomem 10
    clock timezone PCTime -5
    clock summer-time PCTime date Apr 6 2003 2:00 Oct 26 2003 2:00
    crypto pki trustpoint TP-self-signed-1856757619
    enrollment selfsigned
    subject-name cn=IOS-Self-Signed-Certificate-1856757619
    revocation-check none
    rsakeypair TP-self-signed-1856757619
    crypto pki certificate chain TP-self-signed-1856757619
    certificate self-signed 01
      3082024D 308201B6 A0030201 02020101 300D0609 2A864886 F70D0101 04050030
      31312F30 2D060355 04031326 494F532D 53656C66 2D536967 6E65642D 43657274
      69666963 6174652D 31383536 37353736 3139301E 170D3036 30313032 31323030
      34345A17 0D323030 31303130 30303030 305A3031 312F302D 06035504 03132649
      4F532D53 656C662D 5369676E 65642D43 65727469 66696361 74652D31 38353637
      35373631 3930819F 300D0609 2A864886 F70D0101 01050003 818D0030 81890281
      8100B1A4 FB786547 3D582260 03DB768D 116BDE9A 309FBA04 B53F77B0 BFE32344
      7C3439B3 97192B36 760A9411 1D5C7549 8D86F532 ABA44F53 0D08B7F4 A9A747D5
      071330C3 65BF25A8 927F3596 29BB5A80 90C8D169 22268476 3B8DDE1E FDB7170D
      B4820D03 5580A849 A92C7E76 9AC10867 505A2FEE 64360741 7F9DBDBF 3D79982C
      F81D0203 010001A3 75307330 0F060355 1D130101 FF040530 030101FF 30200603
      551D1104 19301782 156F6272 6F757465 722E6272 75736868 6F672E63 6F6D301F
      0603551D 23041830 168014D8 5BC2FFB2 967A4C7B 11B44122 5C8D31F7 749B9230
      1D060355 1D0E0416 0414D85B C2FFB296 7A4C7B11 B441225C 8D31F774 9B92300D
      06092A86 4886F70D 01010405 00038181 005901F1 C239074B B8213567 CF7B65BF
      DAFE4557 69B2A3B1 5F2593C7 A54B9598 23FD5E7A 563AA6E0 AFB25801 FA0061E8
      F9545372 DB600B3A BE68AE65 1EDA593E 6A0C96B8 5A4136AF 393F9AAC 651E1C36
      B8B7C6C0 47936C24 D2ECE9A5 9446EE32 FC7461FA AD8CF1CE A7FBF341 07E9C3C6
      505AB88D 0E7FCAFC 5792298A E5E4D1FE CC
            quit
    no ip source-route
    ip dhcp excluded-address 192.168.0.1 192.168.0.99
    ip dhcp pool ccp-pool1
       import all
       network 192.168.0.0 255.255.255.0
       dns-server 216.49.160.10 216.49.160.66
       default-router 192.168.0.1
    ip cef
    no ip bootp server
    ip domain name brushhog.com
    ip name-server 216.49.160.10
    ip name-server 216.49.160.66
    license udi pid CISCO861W-GN-A-K9 sn FTX155281FY
    username tech38 privilege 15 secret 5 $1$d/4Z$n/23EsXbzfHF5XfJ8Nv.y0
    ip tcp synwait-time 10
    ip ssh time-out 60
    ip ssh authentication-retries 2
    interface FastEthernet0
    interface FastEthernet1
    interface FastEthernet2
    interface FastEthernet3
    interface FastEthernet4
    description $ES_WAN$$FW_OUTSIDE$
    no ip address
    no ip redirects
    no ip unreachables
    no ip proxy-arp
    ip flow ingress
    duplex auto
    speed auto
    pppoe-client dial-pool-number 1
    interface wlan-ap0
    description Service module interface to manage the embedded AP
    ip unnumbered Vlan1
    no ip redirects
    no ip unreachables
    no ip proxy-arp
    ip flow ingress
    arp timeout 0
    interface Wlan-GigabitEthernet0
    description Internal switch interface connecting to the embedded AP
    interface Vlan1
    description $ETH-SW-LAUNCH$$INTF-INFO-HWIC 4ESW$$ES_LAN$$FW_INSIDE$
    ip address 192.168.0.1 255.255.255.0
    no ip redirects
    no ip unreachables
    no ip proxy-arp
    ip flow ingress
    ip nat inside
    ip virtual-reassembly
    ip tcp adjust-mss 1412
    interface Dialer0
    ip address negotiated
    no ip redirects
    no ip unreachables
    no ip proxy-arp
    ip mtu 1452
    ip flow ingress
    ip nat outside
    ip virtual-reassembly
    encapsulation ppp
    dialer pool 1
    dialer-group 1
    ppp authentication chap pap callin
    ppp chap hostname XXXXXXXXXXXXX
    ppp chap password 7 XXXXXXXXXXXXXXXX
    ppp pap sent-username XXXXXXXXXXXXXX password 7 XXXXXXXXXXX
    no cdp enable
    ip forward-protocol nd
    ip http server
    ip http authentication local
    ip http secure-server
    ip http timeout-policy idle 60 life 86400 requests 10000
    ip nat inside source static tcp 192.168.0.25 80 interface Dialer0 80
    ip nat inside source list 1 interface Dialer0 overload
    ip route 0.0.0.0 0.0.0.0 Dialer0
    logging trap debugging
    access-list 1 remark INSIDE_IF=Vlan1
    access-list 1 remark CCP_ACL Category=2
    access-list 1 permit 192.168.0.0 0.0.0.255
    dialer-list 1 protocol ip permit
    no cdp run
    control-plane
    banner exec ^C
    % Password expiration warning.
    Cisco Configuration Professional (Cisco CP) is installed on this device
    and it provides the default username "cisco" for  one-time use. If you have
    already used the username "cisco" to login to the router and your IOS image
    supports the "one-time" user option, then this username has already expired.
    You will not be able to login to the router with this username after you exit
    this session.
    It is strongly suggested that you create a new username with a privilege level
    of 15 using the following command.
    username <myuser> privilege 15 secret 0 <mypassword>
    Replace <myuser> and <mypassword> with the username and password you
    want to use.
    ^C
    banner login ^CAuthorized access only!
    Disconnect IMMEDIATELY if you are not an authorized user!^C
    line con 0
    login local
    no modem enable
    transport output telnet
    line aux 0
    login local
    transport output telnet
    line 2
    no activation-character
    no exec
    transport preferred none
    transport input all
    line vty 0 4
    privilege level 15
    login local
    transport input telnet ssh
    scheduler max-task-time 5000
    scheduler allocate 4000 1000
    scheduler interval 500
    end
    Any help would be appreciated

    Hello,
    i have the same problem with router CISCO861W-GN-E-K9. Version 12.4(22r)YB5, RELEASE SOFTWARE (fc1)
    Can someone help?
    Thank you.
    Here is my config for internal AP and router.

  • Problem with calling onApplicationStart() method

    Hi all,
         I have a problem with calling application.cfc's methods from coldfusion template. The problem is like when i am calling "onapplicationstart" method inside a cfml template i getting the error shown below
    The onApplicationStart method was not found.
    Either there are no methods with the specified method name and argument types or the onApplicationStart method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity.
    My code is like below.
    Application.cfc
    <cfcomponent hint="control application" output="false">
    <cfscript>
    this.name="startest";
    this.applicationtimeout = createtimespan(0,2,0,0);
    this.sessionmanagement = True;
    this.sessionTimeout = createtimespan(0,0,5,0);
    </cfscript>
    <cffunction name="onApplicationStart" returnType="boolean">
        <cfset application.myvar = "saurav">
    <cfset application.newvar ="saurav2">
        <cfreturn true>
    </cffunction>
    </cfcomponent>
    testpage.cfm
    <cfset variables.onApplicationStart()>
    I have tried to call the above method in different way also like
    1--- <cfset onApplicationStart()>
    i got error like this
    Variable ONAPPLICATIONSTART is undefined.
    2---<cfset Application.onApplicationStart()>
    The onApplicationStart method was not found.
    Either there are no methods with the specified method name and argument types or the onApplicationStart method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity
    Please help me out.
    Thanks
    Saurav

    You can't just call methods in a CFC without a reference to that CFC. This includes methods in Application.cfc.
    What are you trying to do, exactly, anyway? You'd probably be better served by placing a call to onApplicationStart within onRequestStart in Application.cfc, if your goal is to refresh the application based on some condition:
    <cffunction name="onRequestStart">
         <cfif someCondition>
              <cfset onApplicationStart()>
         </cfif>
    </cffunction>
    Dave Watts, CTO, Fig Leaf Software
    http://www.figleaf.com/
    http://training.figleaf.com/

  • Problems with WLST embedded in java app.

    Hi,
    I have a problem with the WLST embedded in a java app.
    I want to programatically create or reconfigure a domain from a java application. Following is a simple example of what I want to do.
    import weblogic.management.scripting.utils.WLSTInterpreter;
    public class DomainTester {
      static WLSTInterpreter interpreter = new WLSTInterpreter();
      private void processDomain() {
        if(domainExists()) {
          System.out.println("Should now UPDATE the domain");
        } else {
          System.out.println("Should now CREATE the domain");
      private boolean domainExists() {
        try {
          interpreter.exec("readDomain('d:/myDomains/newDomain')");
          return true;
        }catch(Exception e) {
          return false;
    }The output of this should be one of two possibles.
    1. If the domain exists already it should output
    "Should now UPDATE the domain"
    2. If the domain does not exist it should output
    "Should now CREATE the domain"
    However, if the domain does not exist the output is always :
    Error: readDomain() failed. Do dumpStack() to see details.
    Should now UPDATE the domain
    It never returns false from the domainExists() method therefor always states that the exec() worked.
    It seams that the exec() method does not throw ANY exceptions from the WLST commands. The catch clause is never executed and the return value from domainExists() is always true.
    None of the VERY limited number of examples using embedded WLST in java has exception or error handling in so I need to know what is the policy to detect failures in a WLST command executed in java??? i.e. How does my java application know when a command succeeds or not??
    Regards
    Steve

    Hi,
    I did some creative wrapping for the WLSTInterpreter and I now have very good programatic access to the WLST python commands.
    I will put this on dev2dev somewhere and release it into the open source community.
    Don't know the best place to put it yet, so if anybody sees this and has any good ideas please feel free to pass them on.
    Here is the wrapper class. It can be used as a direct replacement for the weblogic WLSTInterpreter. As I can't overload the actual exec() calls because I want to return a String from this call I created an exec1(String command) that will return a String and throw my WLSTException which is a RuntimeException which you can handle if you like.
    It sets up stderr and stdout streams to interpret the results both from the Python interpreter level and at the JVM level where dumpStack() just seem to do a printStackTrace(). It also calls the dumpStack() command should the result contain this in its text. If either an exception is thrown from the lower level interpreter or dumpStack() is in the response I throw my WLSTException containing this information.
    package eu.medsea.WLST;
    import java.io.ByteArrayOutputStream;
    import java.io.PrintStream;
    import weblogic.management.scripting.utils.WLSTInterpreter;
    public class WLSTInterpreterWrapper extends WLSTInterpreter {
         // For interpreter stdErr and stdOut
         private ByteArrayOutputStream baosErr = new ByteArrayOutputStream();
         private ByteArrayOutputStream baosOut = new ByteArrayOutputStream();
         private PrintStream stdErr = new PrintStream(baosErr);
         private PrintStream stdOut = new PrintStream(baosOut);
         // For redirecting JVM stderr/stdout when calling dumpStack()
         static PrintStream errSaveStream = System.err;
         static PrintStream outSaveStream = System.out;
         public WLSTInterpreterWrapper() {
              setErr(stdErr);
              setOut(stdOut);
         // Wrapper function for the WLSTInterpreter.exec()
         // This will throw an Exception if a failure or exception occures in
         // The WLST command or if the response containes the dumpStack() command
         public String exec1(String command) {
              String output = null;
              try {
                   output = exec2(command);
              }catch(Exception e) {
                   try {
                        synchronized(this) {
                             stdErr.flush();
                             baosErr.reset();
                             e.printStackTrace(stdErr);
                             output = baosErr.toString();
                             baosErr.reset();
                   }catch(Exception ex) {
                        output = null;
                   if(output == null) {
                        throw new WLSTException(e);
                   if(!output.contains(" dumpStack() ")) {
                        // A real exception any way
                        throw new WLSTException(output);
              if (output.length() != 0) {
                   if(output.contains(" dumpStack() ")) {
                        // redirect the JVM stderr for the durration of this next call
                        synchronized(this) {
                             System.setErr(stdErr);
                             System.setOut(stdOut);
                             String _return = exec2("dumpStack()");
                             System.setErr(errSaveStream);
                             System.setOut(outSaveStream);
                             throw new WLSTException(_return);
              return stripCRLF(output);
         private String exec2(String command) {
              // Call down to the interpreter exec method
              exec(command);
              String err = baosErr.toString();
              String out = baosOut.toString();
              if(err.length() == 0 && out.length() == 0) {
                   return "";
              baosErr.reset();
              baosOut.reset();
              StringBuffer buf = new StringBuffer("");
              if (err.length() != 0) {
                   buf.append(err);
              if (out.length() != 0) {
                   buf.append(out);
              return buf.toString();
         // Utility to remove the end of line sequences from the result if any.
         // Many of the response are terminated with either \r or \n or both and
         // some responses can contain more than one of them i.e. \n\r\n
         private String stripCRLF(String line) {
              if(line == null || line.length() == 0) {
                   return line;
              int offset = line.length();          
              while(true && offset > 0) {
                   char c = line.charAt(offset-1);
                   // Check other EOL terminators here
                   if(c == '\r' || c == '\n') {
                        offset--;
                   } else {
                        break;
              return line.substring(0, offset);
    }Next here is the WLSTException class
    package eu.medsea.WLST;
    public class WLSTException extends RuntimeException {
         private static final long serialVersionUID = 1102103857178387601L;
         public WLSTException() {
              super();
         public WLSTException(String message) {
              super(message);
         public WLSTException(Throwable t) {
              super(t);
         public WLSTException(String s, Throwable t) {
              super(s, t);
    }And here is the start of a wrapper class for so that you can use the WLST commands directly. I will flesh this out later with proper var arg capabilities as well as create a whole Exception hierarchy that better suites the calls.
    package eu.medsea.WLST;
    // Provides methods for the WLSTInterpreter
    // just to make life a little easier.
    // Also provides access to the more generic exec(...) call
    public class WLSTCommands {
         public void cd(String path) {
              exec("cd('" + path + "')");
         public void edit() {
              exec("edit()");
         public void startEdit() {
              exec("startEdit()");
         public void save() {
              exec("save()");
         public void activate() {
              exec("activate(block='true')");
         public void updateDomain() {
              exec("updateDomain()");
         public String state(String serverName) {
              return exec("state('" + serverName + "')");
         public String ls(String dir) {
              return exec("ls('" + dir + "')");
         // The generic wrapper for the interpreter exec() call
         public String exec(String command) {
              return interpreter.exec1(command);
         private WLSTInterpreterWrapper interpreter = new WLSTInterpreterWrapper();
    }Lastly here is some example code using these classes:
    its using both the exec(...) and cd(...) wrapper commands from the WLSTCommand.class shown above.
        String machineName = ...; // get name from somewhere
        try {
         exec("machine=create('" + machineName + "','Machine')");
         cd("/Machines/" + machineName + "/NodeManager/" + machineName);
         exec("set('ListenAddress','10.42.60.232')");
         exec("set('ListenPort', 5557)");
        }catch(WLSTException e) {
            // Possibly the machine object already exists so
            // lets just try to look it up.
         exec("machine=lookup('" + machineName + "','Machine')");
    ...After this call a machine object is setup that can be allocated later like so:
         exec("set('Machine',machine)");Regards
    Steve

  • E71 problem with BT stereo headphones

    Hello!
    I have got a E71 and I have a problem with the BT stereo headphones (Model Clip IIs of I-TECH I have some time with other phones and I have never given any problem) I use to listen to MP3s on my SD, and the fact that at some point the sound begins to 'stutter', that is no longer playing but continues to sobs, the sound comes and goes ... it does not always but sometimes, and sometimes no But often jumps out the problem and I have to close the player, wait a while 'and then restart it. Given that the first thing I did was upgrade to the latest version noBrand FW 110.07.127 RM-436 09/10/2008, but has not resolved ...

    I think this is due to the phone's CPU getting overloaded by having to recompress the audio stream for A2DP (the BT profile used for stereo). Avoid running any other apps when you're listening to music and see what happens.
    Sanjay Mehta
    Motorola "Brickphone" circa 1996, Alcatel One Touch, Ericsson R380, Sony Ericsson T220, Sony Ericsson T630, Nokia E50, Nokia E61i, Nokia 9300i, Nokia E71,Nokia X6, Google Nexus S, iPhone 4S

  • Problem with createTempFile

    I am following code in Joseph Weber's Using Java2 Special Edition. I am getting an error when compiling the following code (taken from the cd accompanying the book):
    File tempFile = File.createTempFile("temp#que");
    The following error ensues:
    cannot resolve symbol: method createTempFile (java.lang.String)
    location: class java.io.File
    File tempFile = File.createTempFile("temp#que");
    I am using SDK 1.3.1 so I presume it is not a problem with the version of Java I have on my system.
    The book is not very clear on the correct usage of this method, can anyone help?
    ps deleteOnExit is not working alos, the file is still in the directory when the program exits.

    Hello npirs,
    Everything is fine with your code. The only problem is that the method is not overloaded to take one String. It is overloaded to take 2 Strings public static File createTempFile(String name, String suffix) or public static File createTempFile(String name, String suffix, File directory).
    Check the documentation - it sometimes solves a lot of problem.
    [email protected]

  • Problem with traverse method

    Hi, I am having this problem:
    I made a CustomItem, a TextField, now I overloaded the traverse method, so if the keycode is Canvas.UP or Canvas.DOWN then return false else return true.
    The problem is that when I press the left or rigth button it also returns false and not true.
    and there is another problem with traverse, before returning false or true I set a boolean and call to repaint to draw it on some way if its selected or not, the paint method is being called but it just dont draw as desired.
    protected void paint(Graphics g, int ancho, int alto) {
              System.out.println ("Dentro del paint, seleccionado="+seleccionado);
              try {
                   g.drawString(label, 0, 0, Graphics.TOP|Graphics.LEFT);
                   if (!seleccionado) {
                        g.setColor(120, 120, 120);
                   g.drawRect(0, 4, tama�oTexto+8, 25);
                   if (seleccionado) {
                        g.setColor(255, 255, 255);
                        g.fillRect(1, 5, (tama�oTexto+8-1), 23);
                   g.setColor(0, 0, 0);
                   if (!seleccionado) {
                        g.setColor(80, 80, 80);
                   g.drawString(texto, 4, 7, Graphics.TOP|Graphics.LEFT);
                   if (seleccionado) {
                        int cursorX=Font.getDefaultFont().charsWidth((texto.substring(0, idLetraActual)).toCharArray(), 0, texto.substring(0, idLetraActual).length())+4;
                        g.drawChar('|', cursorX, 7, Graphics.TOP|Graphics.LEFT);
              } catch (Exception E){
                   E.printStackTrace();
         }the traverse method set the seleccionado variable and calls to repaint but instead of being false the paint method is drawing it as true (most of times).

    I have a problem with findByxxx() method.. in
    Container managed bean.
    i have
    Collection collection =
    home.findByOwnerName("fieldValue");
    specified in my Client Program, where ownerName is the
    cmp fieldname..
    and
    public Collection findByOwnerName(String ownerName)
    throws RemoteException, FinderException
    defined in my home interface.
    i have not mentioned the findBy() method anywhere else
    (Bean class). You have to describe the query in the deployment descriptor.
    >
    Even if i have a same "fieldValue" in the database
    (Oracle), which i specified in findBy() method, iam a
    result of owner Not found, which is not the case as i
    have that owner name.
    for the same application if i use findByPrimaryKey(),
    it is working..
    Can any one please post me the solution.

  • Performance problems with UI grid of rectangles

    Am looking for some help on how to program a specific user interface (UI). I need to create a large matrix (n x m) of rectangles, and give the user the ability to click and drag the mouse over them to select them. When a user clicks/drags over a rectangle, it should repaint itself a different color and store the fact that it was selected. Since the matrix is rather large, I want to put it in a JScrollPane so that the user can scroll over the entire matrix.
    So far I have come up with two ways to do this, and one of them was horrendously slow. (It is unusable.) I would like some advice on how to do this to get the best UI performance so that I have a really slick and fast UI. The two methods I have tried are:
    1. Create a new class called MyRectangle that extends java.awt.Rectangle. This is a pretty simple class that just adds a couple of instance vars to keep track of if it has been selected or not, and what color it should paint itself and its border. Next, I create a class called MyJPanel that extends JPanel. MyJPanel contains an (n x m) array of MyRectangles and overloads the paintComponent() method to paint them all on the panel. MyJPanel also implements the mouseListener(s) so it can tell when someone has pressed/clicked/ or dragged over it. When it receives a MouseEvent, it finds the correct MyRectangle (by comparing the point returned on MyJPanel), sets that MyRectangle's instance vars appropriately, and then calls UpdateUI().
    Here is the problem with this design. That array of MyRectangles looks at least like this:
    MyRectangle myRectangleArray[][] = new MyRectangle[50][200];
    So, in the paintComponent() method of the MyJPanel, it has to iterate through the 50 * 200 rectangles in order to know how to paint each one on the screen. Not to mention the fact that at each one it has to do a comparision to determine how to set Graphics2D.setPaint( Color.XX ); for that specific rectangle. As mentioned, I have implemented this and it is EXCRUTIATINGLY SLOW. So, I moved on to....
    2. Create a new class called MyJButton that extends javax.swing.JButton. MyJButton contains instance vars to note if it is selected or not, what its background color should be. MyJButton also implements the mouseListener(s) and handles all the MouseEvents themselves. Now, instead of having MyJPanel overload paintComponent() and handle all that myself, I just have it contain an (n x m) array of MyJButtons and just add them to the panel using a GridLayout. The problem here is that the mouseDragged event doesn't work quite the way I'd like. In order to implement mouseDragged, I have to create an interface and have each MyJButton callback to its container MyJPanel to tell it when / where the dragging started and stopped so that MyJPanel can update all the other MyJButtons. However, the performance seems to be much better and the user can click all over without causing the screen to lock up doing repaints.
    Ok, here's my question. DOES ANYONE HAVE A BETTER WAY OF DOING THIS???
    What I want is to present the user with an (n x m) matrix of rectangles (inside a scrollable pane). This matrix will be LARGE, like at least 50 x 200 and would prefer to go up to 70 x 500 or more. The size of each rectangle will need to be definable as the number of columns gets larger, I will need to make the size of the individual rectangles smaller. The user should be able to click and drag over these rectangles, and the program should store which row / column was selected, and should then paint those selected rectangles on the screen in a different (configurable) color.
    Can anyone offer any help?
    Don Osburn
    [email protected]
    [email protected]

    using JTable is worth looking into, I did a quick test for speed purposes and this looks good if you do decide to go with a custom solution. Mouse processing shouldn't be too hard (the code for converting from user space to model space is in the paint method), but I can't figure out how to intercept mouse events properly (think this is done in the UI delegate or smt)
    asjfimport javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MatrixComponent extends JComponent {
       int rows, columns;
       int swidth, sheight;
       Dimension mySize;
       boolean [][] isSelected;
       Font myFont;
       public MatrixComponent(int rows, int columns, int w, int h) {
          this.rows = rows;
          this.columns = columns;
          this.swidth = w;
          this.sheight = h;
          this.mySize = new Dimension(columns*swidth,rows*sheight);
          this.isSelected = new boolean [columns][rows];
          this.myFont = new Font("Monotype",Font.PLAIN,8);
       public void paintComponent(Graphics g) {
          Rectangle clip = g.getClipBounds();
          int sx = clip.x/swidth;
          int ex = Math.min(1 + sx + clip.width/swidth, columns);
          int sy = clip.y/sheight;
          int ey = Math.min(1 + sy + clip.height/sheight, rows);
          g.setFont(myFont);
          for(int x=sx; x<ex; x++)
             for(int y=sy; y<ey; y++) {
                g.setColor(new Color(x*255/columns, y*255/rows, 100));
                g.drawRect(x*swidth,y*sheight,(swidth-1),(sheight-1));
                g.drawString(""+(x+y*columns),swidth/2+x*swidth,sheight/2+y*sheight);
       public Dimension getPreferredSize() {return mySize;}
       public Dimension getMaximumSize() {return mySize;}
       public Dimension getMinimumSize() {return mySize;}
       public static void main(String [] arg) throws Exception {
          JFrame frame = new JFrame("MatrixComponent");
          frame.getContentPane().add(new JScrollPane(new MatrixComponent(1000,1000,50,50)));
          frame.pack();
          frame.show();
    }

Maybe you are looking for

  • Open Production Order with Mark for deletion

    Hi Friends again stuck in open production order i want to calculate  production order quantity for open production order, only those production order which dont have mark for deletion. I find a field in afpo XLOEK ..but it wont get reflects when done

  • My Apple TV does not show all of the movies in my library.

    All are in the movies category, no home videos here.  It almost seems to be movies that I have removed from a device.  At least some of the ones not showing up were recently removed from my iPad.  Came back from a trip and removed some of the movies

  • Mac Mini, no video after 10.5.7 upgrade

    I installed the 10.5.7 upgrade after reboot, had no video. I reset the smc and pmu then I got no power light and the fans raced. Reset pmu again and mini booted to grey screen with spinning indicator, then after a min or two the mac would just shut d

  • I cant verify my account. Cant find the mail on my yahoo

    i need help please

  • Medical Collection Question...

    Hello allI have a question to do with medical collection: I ask the billing office of where all the medical bills stem from for charity care. I was asked to send them a letter and explain my situation to them I did and they forgave my debt. The quest