Determine event handler for swing components from the API browser
Is there a way to determine what event handlers are assocaited with the different swing classes. For example JTextField is associated to ActionListener, and JCheckbox uses the event handle ItemListener. Is there a way to determine this by looking at the class via the Java API?
Yes, there is. You'll observe that JTextField has an "addActionListener(ActionListener)" method, for a start. And JTextField is a subclass of JTextComponent, which has "addCaretListener(CaretListener)" and "addInputMethodListener(InputMethodListener)" methods. And JTextComponent is a subclass of JComponent, which has an "addAncestorListener(AncestorListener)" method. And so on... there are more. All of this can be found in the API documentation by looking for methods whose names start with "add".
Similar Messages
-
Abort Could not determine a value for variable 0DAT from the authorizations
Hi All,
I encountered an error '/ Abort Could not determine a value for variable 0DAT from the authorizations\' when executing my query on a multiprovider in BW 3.5.
Can anyone help me in finding a solutionn to this issue.
Thanks,
Kartik.Hi Kartik,
I am sorry as that note is for NW2004s. Please check if 0DAT variable installed from a business content? if not then I think thats the cause of the problem.
Hope this helps,
Bye... -
Explicit Event Enabling for Swing Components
Hi all swing-experts,
I want to enable some events for an JInternalFrame explicitely,
but I can't find the corresponding EVENT_MASK anywhere...
Who knows??
AnjaHello again,
(besonderes HALLO an Stephen fuer die Muehe!!!)
there exist two ways of handling an event, at least for awt events:
1) writing an action listener and adding it to the component who will handle the event
2) letting the component handle the event itself by "explicit event enabling"
I am talking about no 2.
This works so:
a) Subclass component
b) in the constructor of the subclass, call
enableEvents(AWTEvent.XXX_EVENT_MASK)
c) provide the subclass with a processXXXEvent() method (that should call the superclass' version of this method)
An other version of my question: is this also possible with Swing?
Where do I find the appropriate XXX_EVENT_MASK and processXXXEvent method?
Seems to be an unusual problem...
Anja
PS: sieht so aus... -
Event for transferring information from the billing document to the fica do
Dear all,
We are having a requirement in which we need to transfer the information from the billing document to the fica document..Can anybody tell me which event can be used for transferring information from the billing document to the fica document
SusmitaSusmitha Harini,
Can you provide exactly what you want to transfer? Do u want to transfer that information at billing moment?
Best Regards,
Pedro Nunes -
How to add event handling for a menu?
hi,
I have created a menu and few mneu items.
for eachmenu itme , i did event handling and it is workign fine.
it was like this
menuItem = new JMenuItem("Exit",KeyEvent.VK_X);
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK));
menuItem.addActionListener(this);
menu.add(menuItem);
public void actionPerformed(ActionEvent e)
JMenuItem source = (JMenuItem)(e.getSource());
String s = "Action event detected. Event source: " + source.getText();
System.out.println(s);
public void itemStateChanged(ItemEvent e)
JMenuItem source = (JMenuItem)(e.getSource());
String s = "Item event detected. Event source: " + source.getText();
System.out.println(s);
now int he second menu i don't have any menu item and i want to do the event handling for the menu itself. any ideas how to do it. following is the code for the menu
//Build the second menu.
menu2 = new JMenu("Options");
menu2.setMnemonic(KeyEvent.VK_O);
menuBar.add(menu2);
menu2.addActionListener(this); //this does nto workYou were on the right track. However, selecting a menu is different from selecting a menu item. MenuItem chucks an ActionEvent and Menu will send an ItemEvent.
If you pile all action output to one actionPerformed method then be careful of your assumptions on what the source type will be. If by any chance the Menu has sent an ActinoEvent then your code will have caused a ClassCastException.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MenuTest implements ActionListener, ItemListener {
JMenuItem menuItem;
JMenu menu1, menu2;
JMenuBar menubar;
JFrame frame;
public MenuTest() {
frame = new JFrame("MenuTest");
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
menubar = new JMenuBar();
frame.setJMenuBar(menubar);
menu1 = new JMenu("File");
menu1.setMnemonic(KeyEvent.VK_F);
menuItem = new JMenuItem("Exit",KeyEvent.VK_X);
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK));
menuItem.addActionListener(this);
menu1.addItemListener(this);
menu1.add(menuItem);
menubar.add(menu1);
//Build the second menu.
menu2 = new JMenu("Options");
menu2.setMnemonic(KeyEvent.VK_O);
menu2.addActionListener(this); //this does not work
menu2.addItemListener(this); // use this instead
menubar.add(menu2);
JPanel panel = new JPanel();
panel.setPreferredSize(new Dimension(100,100));
frame.getContentPane().add(panel);
frame.pack();
frame.show();
public void actionPerformed(ActionEvent e)
String s = "Action event detected. Event source: " + e.getSource();
System.out.println(s);
public void itemStateChanged(ItemEvent e)
String s = "Item event detected. Event source: " + e.getSource();
System.out.println(s);
public static void main(String[] args) {
new MenuTest();
} -
Updating Swing components from a different class
I would like to use the JTextArea component in a JFrame to display fast updating text from my application. My application is very simple. When the app launches the GUI is created then my application engine would start processing and displaying text data into the GUI. After reading about Thread safety when using Swing components I concluded it would not be a good idea for my app engine class to update the JTextArea class directly using methods such as .append(String).
I would be grateful for any suggestions on how I should approach updating Swing components from different classes.
Many Thanks in advance SeanHi
Why don't you just implement a basic callback method?
To do this the right way you should probably define a simple Interface that has a public method like updateProcessText(String s). Your swing class then implements this interface, basically forcing it to provide the public method you defined (this is no different than implementing ActionListener, which forces you to define actionPerformed). Secondly modify your processing class, so that it take's a class that implements the interface you just created, as one of the arguments in it's constructor. Lastly assign the argument from your construnctor to a private var - this will enable your processing class to have a handle to your swing class and update it as it pleases.
This might sound very complex, but it's really simple once you've done it once. -
GetTreeLock during constructor for swing components
I've noticed some dead locks in our application that are showing up in the call to getTreeLock that exists in the constructor for various JComponents. Specifically, the updateUI method winds up calling validateTree.
I thought it was OK to construct JComponents from any thread, this suggests it is not.
Has anyone else experienced this?It goes like this:
On win32, thread 0 is our windows message pump. If dispatching one of our messages results in a call from C into Java that constructs a JComponent, we call getTreeLock from thread 0.
Imagine that at the same time, the awt event disptatch thread is trying to show a frame. Since the awt event dispatch thread is part of our process, when the native implemention of the frame calls SendMessage to show the frame, the call to SendMessage blocks until thread 0 calls GetMessage.
Since thread 0 is now blocking waiting for synchronized(getTreeLock()) to return and the awt event dispatch thread has the tree lock - fetched while executing the show() method - we are in a dead lock.
This is not a problem with AWT components, only swing components.
The stack looks like this:
at java.awt.Component.getTreeLock(Component.java:811)
at java.awt.Container.invalidateTree(Container.java:1116)
at java.awt.Container.setFont(Container.java:1148)
at javax.swing.JComponent.setFont(JComponent.java:2310)
at javax.swing.LookAndFeel.installColorsAndFont(LookAndFeel.java:89)
at javax.swing.plaf.basic.BasicButtonUI.installDefaults(BasicButtonUI.java:124)
at com.sun.java.swing.plaf.windows.WindowsButtonUI.installDefaults(WindowsButtonUI.java:63)
at javax.swing.plaf.basic.BasicButtonUI.installUI(BasicButtonUI.java:60)
at javax.swing.JComponent.setUI(JComponent.java:449)
at javax.swing.AbstractButton.setUI(AbstractButton.java:1616)
at javax.swing.JButton.updateUI(JButton.java:119)
at javax.swing.AbstractButton.init(AbstractButton.java:1952)
at javax.swing.JButton.<init>(JButton.java:109)
at javax.swing.JButton.<init>(JButton.java:64)
It seems like we could simply have the invalidateTree method return early if there is no parent or there are no children or somesuch.
A work around we've done is to have the updateUI method delegate to the event dispatch thread. This is a drag as we need to subclass all the JComponents and make sure developers use the safe subclass. -
How to use common event handler for selected movie clips?
I have a 50-state map in a flash movie. Each state is a movie
clip.
Goal: when mouse moves over a state or is clicked in a state,
the state will be highlighted in a bright color and a small box
will pop up near the state and display some information about the
state.
Question: I know I can add mouse event handler for each state
movie clip. But this is simply not good since this has to be done
50 times and codes thus scattered different places. Ideally, I only
want to have one script that determines where the mouse position is
when events trigged and then do right things (highlight the state
and display info. in a pop-up). How can this be implemented?
Thanks!There are a number of ways. Which way is best depends on how
you have things set up so far.
E.g. If they have an enumerable naming convention:
e.g. each clip is like state_0 , state_1 etc.
Then you can loop through them and assign them all to the
same mouse event handler via the loop. You would need properties
other than the name of the clip to identify the state. E.g. each
clip could contain its own data or the index could be a pointer to
the state data (objects with state name and info properties) in a
separate array.
//state clips named
for (var i=0;i<50;i++) {
this["state_"+i].stateindex=i;
this["state_"+i].onPress= statePressHandler;
var stateData:Array = [{name:"StateName,info:"this state
Info"}, name:"StateName,info:"this state Info"}, etc...]
function statePressHandler() {
trace(this);
trace(stateData[this.stateindex].name+"="+stateData[this.stateindex].info);
Other ways are possible too but the best approach depends on
how you have named the clips and whether you're creating them with
code or whether they're already on stage from authoring (my guess).
If they're already on stage and they're called "Alaska" etc, then I
would be inclined to put them all inside a container clip that
contains nothing else other than states. It would avoid the need
for an array of clip names or for checking some other specific
property of each clip to determine if its a 'state' clip and not
something else in a for..in loop. -
EmailRecieved Event handler for incoming email in Sharepoint 2013
Hi,
I am developing custom event handler to enable incoming email for custom document library. i have couple of questions.
1. Once i attached the event handler, i could see incoming email settings for the custom document library, but it displays only 2 options as below :
1. Allow this document library to recieve email
Yes No
2. E-mail address
All other properties are not displaying. Is this normal behaviour on custom event handler for custom document library or any issue anywhere?
2. So i have given other properties using powershell as below:
$list = $web.lists["invoice Documents"]
$list.EmailAlias ="TestDocument"
$list.EnableAssignToEmail = $true
$list.rootFolder.Properties["vti_emailusesecurity"] = 1
$list.rootFolder.Properties["vti_emailsaveattachments"] = 1
$list.rootFolder.Properties["vti_emailattachmentfolders"] = "root"
$list.rootFolder.Properties["vti_emailoverwrite"] = 0
$list.rootFolder.Properties["vti_emailsavemeetings"] = 0
$list.rootFolder.Properties["vti_emailsaveoriginal"] = 0
$List.RootFolder.Update();
$list.Update();
here i have given vti_emailusesecurity as 1, so it should allow incoming email for the user who has permission for the list.
But any user from the domain is sending mail to this list, the Emailrecieved event handler is triggered. I am expecting that this event handler should not be triggered and expecting access denied error in the ULS Log. But that is not happening, and emailrecived
is triggered and email is delivering to this address successfully.
Can you please anyone help if experience on this?
Thanks
Sathyahttp://www.coretekservices.com/2012/01/26/sharepoint-content-organizer-%25e2%2580%2593-emailing-your-drop-off-library-and-getting-it-to-work
Central Administration > Monitoring > Review Job Definitions (under Timer Jobs) > Content Organizer Processing
Also check below:
http://tutorial.programming4.us/windows_server/SharePoint-2010---Content-Organizer-as-a-Document-Routing-Tool.aspx
If this helped you resolve your issue, please mark it Answered -
Event handler for STDIN input?
Hi,
This question will probably require a bit of context - I'm attempting to re-implement in java an application that's currently written in perl. The application is a server helper app that rewriters urls; it receives a request ID and a URL on stdin, does the necessary munging (which can require an external SOAP query), then returns the resulting rewritten URL.
Since the results can be asynchronous due to the need for external queries to build the result, this is currently a multithreaded perl app implemented using perl's POE framework to register an event handler for stdin. That handler fires each time a line of input is received, then feeds the query to a thread pool manager (POE::Component::Pool::Thread, which is conceptually similar to the Executor frameworks). The thread returns the result as a callback registered to another function in the main thread, which then populates the query/result to a cache then outputs the result (with the original query ID) on stdout. Since stdin input and the result callbacks are event-driven, there's no while(true) main loop or other blocking mechanism in the main thread. Unfortunately, it's perl-ness is causing problems due to perl's threading implementation (three words: "copy on init"), so we need to reimplement in a language with a more robust threading implementation (preferably one with copy-on-write for shared objects). So, Java it is.
So far everything's been good - Executor, Callables, and Futures work as I hoped they would for proper thread management, and the internal worker thread logic (XML processing, SOAP, regular expressions, etc) is proving rather simple to adapt. However, the main roadblock I'm hitting is that so far, I have not found a way to register any sort of event handler for STDIN input (or more specifically, InputStreamReader/BufferedStreamReader events). This could be due to search engine pollution - everything I see when I search for documentation on event listeners appears to be GUI-specific (buttons, menus, text areas/forms, etc). I'm just looking for a way to handle a line of STDIN, not a text area on a form.
Any pointers in the right direction will be much appreciated!rekoil wrote:
Maybe I need to rethink the design here...
The main reason I used a callback in the original perl is that there's a large cache structure that gets checked before the thread dispatch, and only cache misses get pushed to a thread for processing. Callbacks from the threads will then add its results to the cache. Thanks to perl's thread model, when I attempted to make the cache a shared structure - in perl, you have to explicitly mark as "shared" variables that you want visible to all threads - the structure wound up getting copied to every thread, and this gave the app an unacceptable memory footprint. So the solution was to use a callback in the main thread to update the cache.
I'm now thinking that if Java's thread model is a bit saner (i.e. a shared object doesn't get copied into every thread), then I could just have each thread update the cache, print its output to STDOUT directly, and avoid the need for the callback. I can then make my input loop simply a while() loop, waiting for the next input to dispatch. Sound sane?Yes I think so.
There is some of this I still don't entirely understand. Your loop sounds better now but it sounds to me like the process is this.
1) read from in
2) call some stuff on the basis of what came in
3) do work
4) workers produce things
5) things written back out
6) read back in??
If you're just going in/out then great. If you are going in/out/in then maybe some sort of PipedInput/Output Streams? It may well be that I got lost in your explanation in which case never mind. -
Event Handling for Graphic Shapes
Hi guys,
I have a problem on the implementation of a piece of software that i'm making, to be more specific i implement a GUI. In this GUI i draw rectangles, lines and that kind of things.
The problem is that i want when clicking on a rectangle, an event to take place such as the drawing of something else, or a message, etc.
How am i to achieve that? I've tried many things but didn't succeeded it unfortunately. How am i going to "give" life to my rectangles by adding event handling for them? What code should i write?
Note: My class extends JPanel & i'm using paint(Graphics g) for drawing the shapes
Thanks,
John.Try this:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.util.*;
public class Shapes extends JFrame
DPanel pan = new DPanel();
public Shapes()
addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent ev)
dispose();
System.exit(0);
setBounds(10,10,400,350);
setContentPane(pan);
setVisible(true);
public class DPanel extends JPanel implements MouseListener
Vector shapes = new Vector();
Shape cs;
public DPanel()
addMouseListener(this);
shapes.add(new Rectangle(20,20,100,40));
shapes.add(new Rectangle(40,80,130,60));
shapes.add(new Line2D.Double(20,150,200,180));
public void paintComponent(Graphics g)
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
for (int j=0; j < shapes.size(); j++)
g2.draw((Shape)shapes.get(j));
g.setColor(Color.red);
if (cs != null) g2.draw(cs);
public void mouseClicked(MouseEvent m) {}
public void mouseEntered(MouseEvent m) {}
public void mouseExited(MouseEvent m) {}
public void mouseReleased(MouseEvent m){}
public void mousePressed(MouseEvent m)
for (int j=0; j < shapes.size(); j++)
Shape s = (Shape)shapes.get(j);
Rectangle r = new Rectangle(m.getX()-1,m.getY()-1,2,2);
if (s.intersects(r))
cs = s;
repaint();
public static void main (String[] args)
new Shapes();
}Noah -
An event handler for several subclasses.
I've been trying to write an event handler that is parameterized by a window
being passed to it. The event handler is intended to handle the exception event
that occurs when the window completes. I have had problems trying to write this.
The scenario is as follows.
I have a task that listens to events that respresent requests for a window being
opened. On receiving these, it starts the window, also as an asynchronous task.
The windows that may be opened (say window classes B, C, and D) are all
subclasses of window class A. The event handler that I register for (after
instantiating the window) takes a window of class A as parameter. It responds to
the exception events for the Display() method of window passed in.
Now the problems I have encountered are as follows :
To allow the event handler to respond to the exception event of a window of
class A, class A has the exception event defined for it. To allow me to start a
window of class B where completion = event, I also have to define the same
exception event. This hides the return and exception for class A. The
implications of this in the event handler is that the event cannot be trapped
unless I cast the parameter passed in into class B on the ' when return_event '
line. This makes the event handler specific to class B.
(This situation is also presumable caused by the fact that each subclasses
overrides the Display method of window class A, and the exception event is
defined for the Display method.)
An alternative approach I tried was using interfaces. I defined the exception
event as an event on an interface. This was defined with the same parameters as
the exception events of classes B, C, and D would have (ie. the exception
event had two parameters - one of type GenericException, and one of ErrorMgr). I
then made classes B, C, and D implement the interface. The event handler
parameter would be the interface rather than class A. However class B would not
compile as the GenericException parameter for the event in the interface uses
the input mechanism, but the GenericException parameter for the exception event
in the display event of classes B, C, and D uses copy input. I have ben unable
to find a way to change the mechanism for event parameters.
Has anybody got any ideas as to how I may be able to achieve the goals of an
event handler that can respond the exception event of a number of subclasses.
Thanks
Steve Elvin
Systems Developer
Frontline Ltd.
UK.
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>Steve,
Try this. Have a method in your super class A , say StubDisplay
which processes the event loop.
Also make this method return Exception and/or completion events you
desire.
Instead of overriding Display() in your sublclasses, override this
StubDisplay method.
You need not have to redefine the exception/completion events in
your sublclasses B,C ..because they naturally inherit from the super class
A.
Using interfaces may not be a good idea in this case because, you
will be forced to implement them in your subclasses even if you dont
need them in some specific cases.
Good luck!
Ajith Kallambella M.
Forte Systems Engineer,
Internationational Business Corporation.
From: [email protected][SMTP:[email protected]]
Reply To: [email protected]
Sent: Wednesday, May 13, 1998 4:42 AM
To: [email protected]
Subject: An event handler for several subclasses.
I've been trying to write an event handler that is parameterized by a
window
being passed to it. The event handler is intended to handle the exception
event
that occurs when the window completes. I have had problems trying to write
this.
The scenario is as follows.
I have a task that listens to events that respresent requests for a window
being
opened. On receiving these, it starts the window, also as an asynchronous
task.
The windows that may be opened (say window classes B, C, and D) are all
subclasses of window class A. The event handler that I register for (after
instantiating the window) takes a window of class A as parameter. It
responds to
the exception events for the Display() method of window passed in.
Now the problems I have encountered are as follows :
To allow the event handler to respond to the exception event of a window
of
class A, class A has the exception event defined for it. To allow me to
start a
window of class B where completion = event, I also have to define the same
exception event. This hides the return and exception for class A. The
implications of this in the event handler is that the event cannot be
trapped
unless I cast the parameter passed in into class B on the ' when
return_event '
line. This makes the event handler specific to class B.
(This situation is also presumable caused by the fact that each subclasses
overrides the Display method of window class A, and the exception event is
defined for the Display method.)
An alternative approach I tried was using interfaces. I defined the
exception
event as an event on an interface. This was defined with the same
parameters as
the exception events of classes B, C, and D would have (ie. the
exception
event had two parameters - one of type GenericException, and one of
ErrorMgr). I
then made classes B, C, and D implement the interface. The event handler
parameter would be the interface rather than class A. However class B
would not
compile as the GenericException parameter for the event in the interface
uses
the input mechanism, but the GenericException parameter for the exception
event
in the display event of classes B, C, and D uses copy input. I have ben
unable
to find a way to change the mechanism for event parameters.
Has anybody got any ideas as to how I may be able to achieve the goals of
an
event handler that can respond the exception event of a number of
subclasses.
Thanks
Steve Elvin
Systems Developer
Frontline Ltd.
UK.
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/> -
I would like to make ONE event-handler for users who
- presses Return/Enter from a field or
- uses the mouse to jump to another field or
- uses the tab-key to jump to another field.
Can this be handled by using only one event-handler, ex. focusLost ?
I appreciate your answer.
Have a nice day.I used a single FocusListener with 3 different TextFields to select all the text in a TextField whenever the TextField gained focus, plus updated the other 2 TextFields based on the contents of the third when the third lost focus. Is that like what you are looking for?
-
I would like to know how to handle events for messages i maintained in zmesg01.
messages are follow: when gv_spfli is initial
"No such flight available.
when gv_scarr is initial.
"Flight name not available with help of raise event ?
pls suggest.
* CLASS lcl_mytestclass DEFINITION
class lcl_mytestclass definition.
public section.
data: gt_spfli type table of spfli initial size 20,
gt_scarr type table of scarr initial size 20.
methods: get_data.
events: data_not_found.
endclass. "lcl_mytestclass DEFINITION
* CLASS lcl_mytestclass IMPLEMENTATION
class lcl_mytestclass implementation.
method: get_data.
select * from spfli into table gt_spfli.
if ( sy-subrc <> 0 ).
raise event data_not_found.
endif.
select * from scarr into gt_scarr
for all entries in gt_flight where carrname = gt_spfli-carrname.
if sy-subrc <> 0.
" How to call event for flight_name_not_found ?"
raise event flight_name_not_found.
endmethod. "get_data
endclass. "lcl_mytestclass IMPLEMENTATION
* CLASS handler DEFINITION
class handler definition.
public section.
methods handle_event
for event data_not_found of lcl_mytestclass.
endclass. "handler DEFINITION
* CLASS handler IMPLEMENTATION
class handler implementation.
method handle_event.
write: / 'Data not found'.
endmethod. "handle_excess
endclass. "handler IMPLEMENTATION
data: oref type ref to lcl_mytestclass,
h1 type ref to handler.
start-of-selection.
create object: oref, h1.
set handler h1->handle_event for all instances.
call method oref->get_data.
Thanks in advance.
Anee.Hello Anee
Events are not used for this kind of message handling.
If you want to collect all messages then use a message handler (see sample report ZUS_SDN_ABAP_OO_MSG_HANDLING ).
Alternatively, you may define an exception class and raise a class-based exception which contains the detailed error message.
The following sample report is based on the more elaborate Wiki posting
[Message Handling - Finding the Needle in the Haystack|https://wiki.sdn.sap.com/wiki/display/profile/2007/07/09/MessageHandling-FindingtheNeedleintheHaystack]
*& Report ZUS_SDN_ABAP_OO_MSG_HANDLING
*& Thread: Event Handling for messages
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1052131"></a>
REPORT zus_sdn_abap_oo_msg_handling.
TYPE-POOLS: abap.
* CLASS lcl_mytestclass DEFINITION
CLASS lcl_mytestclass DEFINITION.
PUBLIC SECTION.
DATA: gt_spfli TYPE TABLE OF spfli INITIAL SIZE 20,
gt_scarr TYPE TABLE OF scarr INITIAL SIZE 20.
METHODS: constructor.
METHODS: get_data
IMPORTING
value(id_carrid) TYPE s_carr_id.
METHODS: has_messages
RETURNING value(rd_result) TYPE abap_bool.
METHODS: display_messages.
EVENTS: data_not_found.
PROTECTED SECTION.
DATA: mo_msglist TYPE REF TO if_reca_message_list.
ENDCLASS. "lcl_mytestclass DEFINITION
* CLASS lcl_mytestclass IMPLEMENTATION
CLASS lcl_mytestclass IMPLEMENTATION.
METHOD constructor.
me->mo_msglist = cf_reca_message_list=>create( ).
ENDMETHOD. "constructor
METHOD has_messages.
IF ( me->mo_msglist->is_empty( ) = abap_false ).
rd_result = abap_true.
ENDIF.
ENDMETHOD. "has_messages
METHOD display_messages.
* define local data
DATA:
ld_handle TYPE balloghndl,
lt_log_handles TYPE bal_t_logh,
ls_profile TYPE bal_s_prof.
" Get log handle of collected message list
ld_handle = me->mo_msglist->get_handle( ).
APPEND ld_handle TO lt_log_handles.
* get a display profile which describes how to display messages
CALL FUNCTION 'BAL_DSP_PROFILE_DETLEVEL_GET'
IMPORTING
e_s_display_profile = ls_profile. " tree & ALV List
* set report to allow saving of variants
ls_profile-disvariant-report = sy-repid.
* when you use also other ALV lists in your report,
* please specify a handle to distinguish between the display
* variants of these different lists, e.g:
ls_profile-disvariant-handle = 'LOG'.
CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
EXPORTING
i_s_display_profile = ls_profile
i_t_log_handle = lt_log_handles
* I_T_MSG_HANDLE =
* I_S_LOG_FILTER =
* I_S_MSG_FILTER =
* I_T_LOG_CONTEXT_FILTER =
* I_T_MSG_CONTEXT_FILTER =
* I_AMODAL = ' '
* IMPORTING
* E_S_EXIT_COMMAND =
EXCEPTIONS
profile_inconsistent = 1
internal_error = 2
no_data_available = 3
no_authority = 4
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMETHOD. "display_messages
METHOD: get_data.
SELECT * FROM spfli INTO TABLE gt_spfli
WHERE ( carrid = id_carrid ).
IF ( sy-subrc NE 0 ).
** RAISE EVENT data_not_found.
IF 1 = 2. MESSAGE e154(bc_datamodel_service). ENDIF.
* Flight not found (table SFLIGHT)
CALL METHOD me->mo_msglist->add
EXPORTING
* is_message =
id_msgty = 'E'
id_msgid = 'BC_DATAMODEL_SERVICE'
id_msgno = '154'
* id_msgv1 =
* id_msgv2 =
* id_msgv3 =
* id_msgv4 =
id_detlevel = '1'
* IMPORTING
* es_message =
ENDIF.
IF ( gt_spfli IS INITIAL ).
ELSE.
SELECT * FROM scarr INTO TABLE gt_scarr
FOR ALL ENTRIES IN gt_spfli
WHERE carrid = gt_spfli-carrid.
ENDIF.
IF ( gt_scarr is initial ).
" How to call event for flight_name_not_found ?"
** RAISE EVENT flight_name_not_found.
IF 1 = 2. MESSAGE e159(bc_datamodel_service) WITH '&all'. ENDIF.
* Airline & not found
CALL METHOD me->mo_msglist->add
EXPORTING
* is_message =
id_msgty = 'E'
id_msgid = 'BC_DATAMODEL_SERVICE'
id_msgno = '159'
id_msgv1 = '&all'
* id_msgv2 =
* id_msgv3 =
* id_msgv4 =
id_detlevel = '2'
* IMPORTING
* es_message =
ENDIF.
ENDMETHOD. "get_data
ENDCLASS. "lcl_mytestclass IMPLEMENTATION
* CLASS handler DEFINITION
CLASS handler DEFINITION.
PUBLIC SECTION.
METHODS handle_event
FOR EVENT data_not_found OF lcl_mytestclass.
ENDCLASS. "handler DEFINITION
* CLASS handler IMPLEMENTATION
CLASS handler IMPLEMENTATION.
METHOD handle_event.
WRITE: / 'Data not found'.
ENDMETHOD. "handle_excess
ENDCLASS. "handler IMPLEMENTATION
DATA: oref TYPE REF TO lcl_mytestclass,
h1 TYPE REF TO handler.
PARAMETER:
p_carrid TYPE s_carr_id DEFAULT 'AA'.
START-OF-SELECTION.
START-OF-SELECTION.
CREATE OBJECT: oref, h1.
** SET HANDLER h1->handle_event FOR ALL INSTANCES.
CALL METHOD oref->get_data( p_carrid ).
IF ( oref->has_messages( ) = abap_true ).
oref->display_messages( ).
ENDIF.
END-OF-SELECTION.
Regards
Uwe -
Unable to get automatic event handling for OK button.
Hello,
I have created a form using creatobject. This form contains an edit control and Search, Cancel buttons. I have set the Search buttons UID to "1" so it can handle the Enter key hit event. Instead its caption changes to Update when i start typing in the edit control and it does not respond to the Enter key hit. Cancel happens when Esc is hit.
My code looks like this -
Dim oCreationParams As SAPbouiCOM.FormCreationParams
oCreationParams = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)
oCreationParams.UniqueID = "MySearchForm"
oCreationParams.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Sizable
Dim oForm As SAPbouiCOM.Form = SBO_Application.Forms.AddEx(oCreationParams)
oForm.Visible = True
'// set the form properties
oForm.Title = "Search Form"
oForm.Left = 300
oForm.ClientWidth = 500
oForm.Top = 100
oForm.ClientHeight = 240
'// Adding Items to the form
'// and setting their properties
'// Adding an Ok button
'// We get automatic event handling for
'// the Ok and Cancel Buttons by setting
'// their UIDs to 1 and 2 respectively
oItem = oForm.Items.Add("1", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
oItem.Left = 5
oItem.Width = 65
oItem.Top = oForm.ClientHeight - 30
oItem.Height = 19
oButton = oItem.Specific
oButton.Caption = "Search"
'// Adding a Cancel button
oItem = oForm.Items.Add("2", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
oItem.Left = 75
oItem.Width = 65
oItem.Top = oForm.ClientHeight - 30
oItem.Height = 19
oButton = oItem.Specific
oButton.Caption = "Cancel"
oItem = oForm.Items.Add("NUM", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oItem.Left = 105
oItem.Width = 140
oItem.Top = 20
oItem.Height = 16
Dim oEditText As SAPbouiCOM.EditText = oItem.Specific
What changes do i have to make to get the enter key to work?
Thanks for your help.
Regards,
SheetalHello Felipe,
Thanks for pointing me to the correct direction.
So on refering to the documentation i tried out a few things. But I am still missing something here.
I made the following changes to my code -
oForm.AutoManaged = True
oForm.SupportedModes = 1 ' afm_Ok
oItem = oForm.Items.Add("1", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
oItem.Left = 5
oItem.Width = 65
oItem.Top = oForm.ClientHeight - 30
oItem.Height = 19
oItem.SetAutoManagedAttribute(SAPbouiCOM.BoAutoManagedAttr.ama_Visible, 1, SAPbouiCOM.BoModeVisualBehavior.mvb_Default)
oButton = oItem.Specific
oButton.Caption = "OK"
AND
oForm.Mode = SAPbouiCOM.BoFormMode.fm_OK_MODE
oItem = oForm.Items.Add("1", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
oItem.Left = 5
oItem.Width = 65
oItem.Top = oForm.ClientHeight - 30
oItem.Height = 19
oItem.AffectsFormMode = False
I get the same behaviour OK button changes to update and enter key does not work.
Could you please tell me find what is it that i am doing wrong?
Regards,
Sheetal
Maybe you are looking for
-
How to remove a node from nlb at runtime?
hello, i need to temporally exclude a node from an nlb. May happen that a server is up and working but the web application i'm balancing is out of sinch with the same application in the others nodes. Eg. some static variables are not the same of the
-
Only Positive amount in Infotype 0015
Dear Gurus, I want users to enter only positive amount for wage types in Additional Payment..... No negative amount should be allowed for particular wage types in Additional Payment Can anyone help me out ? Regards Srijit R Menon
-
On a cold start, my modem doesn't recognize the Imac. I have to restart the modem to connect the computer to it. All connections are correct and tight. Ethernet to Ethernet. Absolutely no changes other than down loading Mavericks. Apple suggests tak
-
How much free storage on raid systems?
Hi, I have read that you are supposed to leave about 20 % of raided storage space free otherwise your data security might be affected. Is that true? Or only for certain environments (like Xsan)? The situation: 1x Xserve 1x Xserve RAID connected via f
-
Can files for older versions of Photoshop Elements be deleted
I am running Windows 8.1 (64-bit Version). I recently purchased and successfully downloaded and installed Adobe Photoshop Elements 13. Prior to installation, I de-installed Photoshop Elements 12. I had previously owned Version 10 and 11 which have be