Extending button class
Hello all,
I am trying to extend the button class to include the ability
to click the button when a user presses the enter key on the
keyboard. I do not know how I would go about doing this. There are
two private functions that control the press and release of the
button; buttonPressed() and buttonReleased(), along with a private
property ButtonPhase that seem to control this functionality. At
first I thought I would override the keyDownHandler and the
keyUpHandler, as they allow the user to click the button with the
space bar, but it won't work with the private functions and
property. Any ideas on how I could achieve this goal without having
to copy and alter the original button class would be greatly
appreciated. Does anybody know why the developers chose to have the
button click when the space is hit instead of the enter key? It
seems to me that the enter key is a much more intuitive keyboard
shortcut than the space bar.
Thanks for your help
I recently had the same problem extend the Button class and
override the two methods as follows
override protected function
keyDownHandler(event:KeyboardEvent):void
super.keyDownHandler(event);
if (event.keyCode == Keyboard.ENTER)
this.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
override protected function
keyUpHandler(event:KeyboardEvent):void
super.keyUpHandler(event);
if (event.keyCode == Keyboard.ENTER)
this.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_UP));
}
Similar Messages
-
Extend standar class with new button(method)
Hi,
I want to create new button in standard class /SAPSRM/IF_PDO_AO_BP_BASE.
Does anyone know how to extend the class with a new button?
Very thanks.I NEED TO CREATE NEW BUTTON IN THIS CLASS.
THE BUTTON MUST SHOW A POP-UP WHEN PARTNET HAVE DOCUMENT´S IN SYSTEM.
CAN YOU HELP ME? -
Is there another way to extends two classes?
hi
I was wondering if anyone knows how to have one class to inherit two other classes methods?
I know that extending the main class with the two other classes are an invalid, just wondering is there another alternative to solve this problem?
Thank
JI don't know the MHP class, but you could do the following:
if MHP.Button inherits feom awt.Button you may not have anything to do except change the constructor. You will be able to assign an MHP Button to an awt reference.
If MHP button is a truly seperate class, create an Interface with all the button methods you use. Then create a subclass of the MHP button which implements the interface and an awt subclass. Both these subclasses will be assignable to your interface reference.
I have done this with a button and JButton below. Of course this was not strictly necessary in this case because JButton extends from the awt Button class.
package package4;
import javax.swing.*;
import java.awt.*;
interface MyButton {
// add ALL the rest of the methods you use!
void setText(String txt);
void show();
class myJButton extends JButton implements MyButton {
class myAWTButton extends Button implements MyButton {
// AWTButton and JButton not quite compatible - call different function
public void setText(String str) {
setLabel(str);
public class Class2 extends Object {
JFrame myframe ;
MyButton button;
JPanel jp;
public Class2() {
myframe = new JFrame() ;
jp = new JPanel();
myframe.setSize(500,500);
myframe.setVisible(true);
myframe.getContentPane().add(jp);
void addJButton() {
button = new myJButton();
button.setText("DEFAULT");
jp.add( (Component) button);
void addAWTButton() {
button = new myAWTButton();
button.setText("DEFAULT");
jp.add( (Component) button);
void setButtonText(String str)
button.setText(str);
public static void main(String[] args) {
Class2 awt = new Class2();
awt.addAWTButton();
awt.myframe.show();
Class2 swing = new Class2();
swing.addJButton();
swing.myframe.setLocation(500,0);
swing.myframe.show();
// now we can use the same method on both
swing.setButtonText("SWING!!!");
awt.setButtonText("AWT!!!");
}In practice you would probably have a factory mettod to produce each type of button. -
Is it possible to create a javafx class without extending Application class ? If yes, how ?
There is no such thing as a javafx class. It is a regular java class. The Aapplication class is the entry
point for JavaFX application. You have to extend the Application class to create Javafx application . -
LoadClass (error loading a class which extends other class at run-time)
Hey!
I'm using the Reflection API
I load a class called 'SubClass' which exists in a directory called 'subdir' at run-time from my program
CustomClassLoader loader = new CustomClassLoader();
Class classRef = loader.loadClass("SubClass");
class CustomClassLoader extends ClassLoader. I have defined 'findClass(String className)' method in CustomClassLoader.
This is what 'findClass(String className)' returns:
defineClass (className,byteArray,0,byteArray.length);
'byteArray' is of type byte[] and has the contents of subdir/SubClass.
the problem:
The program runs fine if SubClass does not extend any class.
If however, SubClass extends another class, the program throws a NoClassDefFoundError. How is it conceptually different?
Help appreciated in Advance..
Thanks!Because i'm a newbie to the Reflection thing, i'm notI don't see reflection anywhere. All I see is class loading.
sure what role does the superclass play when i'm
trying to load the derived class and how to get away
with the errorWell... hint: all the superclass's stuff is not copied into the subclass.
I am quite sure it fails to load the superclass because of classpath issues. -
Error while extending controller: class name is wrong or not included
Hi All,
I am getting this error while I port my extended controller class to the custom top and assign this controller to the page. I have made sure its the class file that is copied. The directory is correct, the permissions were given using chmod 775. There exists a soft link betwen the custom top and the oracle top as well. What else am I missing here?
Error: oracle.apps.fnd.framework.OAException: Could not create Java class: (oracle.apps.ap.oie.entry.webui.XXEntryFlowPageCO) associated with region: (GeneralInformationPG). This is probably because the class name is wrong or not included in project.:( Started out with that Gyan. If i do give the path with xx. appended to it, it lets me save and when i log back in and there are no changes to the page. I go to the personalise option to find the modification has been overwritten. I was told that this is so because Oracle doesnt recognise the xx.path and since there exists a soft link already the standard path with the new controller name should work.
i have really tried both of these options and am not sure what could be wrong. thanks for all your attempts to help. anything else i can try? -
Loading external swfs extending from classes in the same shared codebase
Hey there!
I'm currently developing a game in flash and want to be able to divide up my .fla assets in a way that means artists can work on a game menu .fla in isolation from the game.fla and rest of the game code.
If I could briefly explain how I've approached this so far, I would be extremely if people could shout in my general direction and tell me I am stupid, or even better still, give me helpful advice as to where I am going wrong and how I can correct it!
My project is setup like this:
HighScoreMenu.fla -> document class HighScoreMenu extending GameMenu class.
game.fla ->document class game.as
game.as class loads the published HighScoreMenu.swf and manipulates the menu i.e. animates on and off screen via inherited functions in the GameMenu class.
Now this seemed to work to begin with, until my code evolved and upon going to publish my HighScoreMenu.fla flash started complaining about symbols being used in Game.as that were in Game.fla... If I'm only publishing the HighScoreMenu which extends from GameMenu then why is it even looking to compile Game.as?
Can you spot the problem in the way I am doing this, or is there a better approach I should try?
Any advice greatly appreciated!
Stevie.No it doesn't seem to, however though they both have a reference to the HighScoreManager so there is some overlap there between menu and game code, but the menu classes don't reference any symbols on the game.fla...
Just to clarify, I have an fla HighScoreMenu.fla, which has a child symbol HighScoreMenu which uses the following class.
public dynamic class HighScoreMenu extends GameMenu
//convenient storage for competition Manager object
private var _highScoreManager:HighScoreManager;
The game then loads this class as follows:
I load the swf "HighScoreMenu.swf" and once its loaded I obtain the menu class like so:
var cls:Class = Class( applicationDomain.getDefinition("Menus.HighScoreMenu") );
var object:* = new cls();
...and create a new instance of the menu.
Is there anything fundamentally wrong with approaching it in this way? -
Not able to pass values to variables in extended Tree class
Hi,
I have a as class that extends from Tree, additionally this
custom class defines
new class level variables as follows:
public class MyTree extends Tree {
public var arrayColl:ArrayCollection;
and i call this tree from mxml as follows:
<customTree:MyTree
arrayColl={list}
xmlns:customTree="../../.*"/>
Though my 'list' collections is not null, when i place an
alert in the constructor of extended tree class
it shows as null.
Please advice.
Thanks,
Luckybelow is the canvas:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="
http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.IViewCursor;
import mx.collections.ArrayCollection;
import com.citi.ascript.TreeData;
import mx.controls.Alert;
import com.citi.ascript.CitiTree;
public var availableTreeDataColl:ArrayCollection;
public var selectedTreeDataColl:ArrayCollection;
public var treeData:TreeData;
public var srcTree:CitiTree;
public var availableTreeDataArray:Array = [{a:1},
{b:2},
{c:3}
public function formTreeData():void {
var tempColl:ArrayCollection = new
ArrayCollection(availableTreeDataArray);
availableTreeDataColl = new ArrayCollection();
for (var i:int=0; i<tempColl.length; i++) {
var tempTreeData:Object = tempColl
treeData = new TreeData();
treeData.a = tempTreeData.a;
treeData.b = tempTreeData.b;
treeData.c = tempTreeData.c;
availableTreeDataColl.addItem(treeData);
]]>
</mx:Script>
<mx:VBox>
<mx:Label text="Drag & Drop the analysis sections
that you would like to include in the report" width="450"
height="20"/>
<mx:HBox id="treeContainer"
creationComplete="formTreeData();">
<customTree:MyTree treeList={availableTreeDataColl} //
here collection becomes null.
</customTree:MyTree>
</mx:HBox>
</mx:VBox>
</mx:Canvas>
The collection of TreeData is iterated in the customTree to
form xml which will act as dataprovider for tree.
and this canvas is added as a child for a panel in my main
application.
Hope this gives an idea.
Thanks,
Lucky -
How to map a custom enum list to a custom form property in an extended incident class
Hi,
I'm struggeling to understand how to map a custom enum list to a custom form property in an extended incident class.
Here's what i want to have happen:
I am going to publish a request offering on my SMPortal for allowing users to submit basic IT incidents. I want the form to include "Whom does this problem affect" (answers(This is the custom enum list): Me, Multiple Users, Whole department or Whole
company), "What is the problem about", "Description" and "Attachments".
Here's what i've done:
In the authoring tool i created a MP for the custom enum list and put only the list in it. I sealed the MP and imported it.
I created another unsealed MP called TST.Incident.Library for storing incident library customizations and extended the incident class to add an extension class i called ClassExtension_Affected scope with a custom property i called AffectedScope. Then i am trying
to set the datatype of this property to "list". In the "select a list" dialog i cannot chose my previously sealed MP with the custom enum list in it. Why?
- Do i need to scratch the sealed MP and put the custom enum list in the latter TST.Incident.Library MP instead?
- If so, can i do that and keep this MP unsealed, or will i get an error on import saying "Unsealed management packs should not contain type definitions"
- Should i create one sealed MP for both the custom enum list and the extension class + custom property?Hi,
Authoring Tool simply isn't informed about your list. Open the sealed management pack where you define the root of the list in the Authoring Tool and in the same time open TST.Incident.Library. You will have two opened MPs in the Authoring
Tool and be able to add a custom list for your custom field.
Cheers,
Marat
Site: www.scutils.com Twitter:
LinkedIn:
Facebook: -
Abstract class extends other class?
What happens when a abstract class extends other class?
How can we use the abstract class late in other class?
Why do we need an abstract class that extends other class?
for example:-
public abstract class ABC extends EFG {
public class EFG{
private String name="";
private int rollno="";
private void setName(int name)
this.name=name;
private String getName()
return this.name;
}shafiur wrote:
What happens when a abstract class extends other class?Nothing special. You have defined an abstract class.
How can we use the abstract class late in other class?Define "Late". What "other class"?
Why do we need an abstract class that extends other class?Because it can be useful to define one. -
How to extend a class in same package
I have a class called LoginBean.java which extends the class ConnectDB.java
this both files have a statement both the classes are under the directory pmtools.
and both are included in package pmtools.
(they both have statement "package pmtools; " at top)
when i am trying to compile LoginBean.java, it is giving me following error,
LoginBean.java:7: cannot resolve symbol
symbol : class ConnectDB
location: class pmtools.LoginBean
public class LoginBean extends ConnectDB
^
LoginBean.java:59: cannot resolve symbol
symbol : variable dbConn
location: class pmtools.LoginBean
stmt = dbConn.createStatement();
^
2 errorsdid you compile the other class already? donnow if ithahahaha!!!!!
ok include the import statement
import pmtools.ConnectDB;
in the second class and than compile.. -
Extend base class to customize some properties
Hi
Using Jdev 11g
I need to extend UIGraph class to change the defualt color of pie graph . anyone have a solution to it ? i already extend the class but i donot know what is next steps and what is the method i must to override ??Hi frank
how can i use skinning to change default color of pie chart . for example i have 5 status and count them for every emp but i need specified color for every status ( green for done , red for not done ans so on) if one status missing ( the emp have not (,done status) for example) then the pie color rearranged for other status ???:)). i try to change color in EL but color attr of pie series donot support EL -
How to Extend Java class in UI Module
Hi All,
I am trying to make z for one of the java file GenericSearchDynamicContent.java in the standard package com.sap.wec.app.common.module.catalog.ui.utils. Can anyone please let me know what are steps do i need to follow to extend the same java file in our customer namespace and make use of it.
Thanks in Advance.
Regards,
Rahul.Hi Rahul,
It's upto you whether you want to keep seprate packages for custom changes (then create your own package and keep all the Z class under this) or create a Z_GenericSearchDynamicContent.java and extend this class by GenericSearchDynamicContent.java.
After doing this you can make your custom changes accordingly and you have to also make the changes in *config.xml (replace this entry GenericSearchDynamicContent by Z_GenericSearchDynamicContent.java.) files as mapping is done there.
Could you please let me know if you need any further information.
Thanks,
Hamendra -
Creating a dynamic button class
Hi all. I'm trying to create a button class that has some
properties such as scale that can be coded at runtime. The tutorial
I found hard codes the scale amount into the class, but I would
like to be able to create a new instance of the button class in
Flash, and say on the main timeline, define my variables for
scale...and pass these to the class file. I'm running into an
"1120" error message. I have attached the original working code.
Thanks.Thanks. I'm having trouble finding a clear tutorial that I
can understand on this topic. I've tried creating a set function
but not sure where to write the get function. I have attached my
class file and my call to it in the main timeline. I've been
struggling with learning custom classes and appreciate any help!
Also, I am now creating a new instance on the main timeline
instead of linking to it in the library. What is the best way of
doing this. -
Using two Button classes for single Button control MFC
Hi,
Here is my problem:
I have a VC++ MFC dialog based application. There I am adding a Button to my dialog by just drag and drop from the tool box.
I am also having a MyCustomButton.dll to give new looks to the button.
Inside MyCustomButton.dll, MyCustomButton.cpp is the button class which is derived from CButton.
Now I want the behavior of my application in such a way at execution of my application, like if the MyCustomButton.dll is present in system then the button of my dialog should look like as per implementation of MyCustomButton.dll, where as if the dll
is not present normal MFC button should get displayed.
Please guide me in achieving this. How can I make my application (*.exe) decide at run time.
Thanks in Advance,
Thanks & Regards, Mayank AgarwalThanks Rupesh,
But my requirement is like that only I have to decide at run time.
Please look the scenario below:
// MyDialogDlg.h //
#include "MyCustomButton.h"
class MyDialogDlg
MyCustomButton m_CalcButton;
In the above piece of code
m_CalcButton is object of MyCustomButton class.
and my requirement is such that if MyCustomButton
.dll is not present then, m_CalcButton should executed as the object of CButton class of MFC.
There are cases where I cant ship the dll.
In such case how should I write the code? Please guide.
Thanks in Advance.
Thanks & Regards, Mayank Agarwal
Maybe you are looking for
-
Can't convert Word 2003 documents to PDF
I purchased Adobe Acrobat XI Pro and it will not convert any of my Word documents (.doc Word 2003). I get an error message saying "Attempt failed. Please correct the error and try again." there is no description as to what the error is, or how I migh
-
Same jena code loading ontology won't work in 11.2.0.2 in linux
Hi, The sample code of loading univ-bench.owl ontology into database won't work in oracle 11..2.0.2 in my linux guest system. However, it is working perfectly in oracle 11.2.0.1 in windows environment. The error I got is: WARN [main] (SimpleLog.java:
-
I cannot get the lockpref to work. RH6.3, Firefox 18. I created mozilla.cfg at: /usr/lib64/firefox It contains two lines: lockpref ("security.enable_ssl3", true); I created local-settings at: /usr/lib64/firefox/default/preferences It contains two lin
-
Which one is better to use?
-
I need help on my ipod touch 2g it has been frozen the last two days it froze on the connect to itunes logo