Focus events for JFormattedTextFields
I have a form with 2 JFormattedTextFields for width and height values. I only want numbers entered in the fields so I configure a formatter like
NumberFormat numFormat;
numFormat = NumberFormat.getInstance();
numFormat.setMinimumFractionDigits(2);
numFormat.setMaximumFractionDigits(2);
nonscaledWidthField = new JFormattedTextField(numFormat);
nonscaledHeightField = new JFormattedTextField(numFormat);
This works as desired. Additionally, I want to catch constrain the width and height values to a certain aspect ratio. So if the user enters a value for width, when they tab out and/or lose focus on that field, it should calculate and set the value for height. I'm able to do that by implementing FocusListener or using the PropertyChangeListener but then the NumberFormat doesn't seem to respond on the fields.
How can I get both behaviours?
-Phil
It's hard to comment without a better knowledge of your situation. If you would create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program that demonstrates the problem you are experiencing, that would help us help you.
That said, what you describe certainly sounds like it ought to work. That's where the example program would come in handy. My first thought is that your focus listener is firing before the formatted text field has updated its value; you can ensure this is not the case by invoking the field's commitEdit() method.
: jay
Similar Messages
-
Please very urgent How can i call focus event for dynamic created txtbox
Hi,
I create a one texbox using javascript .now i want to call onFocus event that textbox.How is itHi,
I create a one texbox using javascript .now i want to
call onFocus event that textbox.How is itJust for you, slowly, so you can understand:
Javascript was invented by Netscape and is a scri�ting language for browsers.
Java is a programming language invented by Sun.
Compare:
Netscape. Sun.
Notice a difference? -
Radiobuttons and the focus event
This is in AS2.
Is there a 'onFocus' event for individual radio buttons, or is it limited to the radiobutton group ?
If there is a focus event for the buttons, how to I set it up ? I've set up an event listener with an 'onFocus' event, 'gotFocus' event, 'focus' event and nothing is triggered.....
Regards,
RichIf you look thru the help documents, all of the events associated with the radio button class are listed. There is a focusIn event that the radio button inherits from the UIComponent class. Here is an example for using it...
var listenerObject:Object = new Object();
listenerObject.focusIn = function(eventObj:Object) {
trace("radiobutton1 just got focus");
radiobutton1.addEventListener("focusIn", listenerObject); -
I can't for the life of me figure out how iCal orders the display of multiple items at the same time. Does anyone have a clue? It's not alphabetical. It's not according the the order of the calendars in the left pane. Is it just random? Any help would be greatly appreciated.
In the focus lost eventhandling start a thread which does
the actual handling.
the new thread waits for a little time (0.1 seconds)
the click event of the button checks for a thread like the one above and tells it not to execute
This way you execute the for the lost focus event only if
the ok button isn't clicked in the same process ... not
realy good, because it kind of relies on the ordering of threads ... but maybe it still works for you? -
Flex 4 does not dispatch keyboard events for ENTER key.
Hello everyone. I think I have a strange problem with Flex 4 Beta (4.0.0.8909). My application has had event listener for keyUp event for a month now and suddenly (two days ago) I've noticed that keyUp event is not dispatched for ENTER (ALT also) key. Anyone know why? By the way, I've tried this with keyDown event, also 4.0.0.8847 version of SDK - still the same: no keyboard events for ENTER (and ALT) key.
Here is the sample application that has got this issue:
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo"
minWidth="640" minHeight="480"
keyUp="application1_keyUpHandler (event)">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
protected function application1_keyUpHandler (event: KeyboardEvent):void
Alert.show ("Key up: " + event.keyCode);
]]>
</fx:Script>
<s:layout>
<s:BasicLayout/>
</s:layout>
<s:TextArea verticalCenter="0" horizontalCenter="0" width="200"/>
</s:Application>
If you run this application and try typing anything in a TextArea you will get alerts with key codes. However, if you press ENTER (or ALT), you will get no alert.
I'm pretty sure the code above is right so that means there is a bug in latest nightly builds of SDK (i would swhitch to an older build if i knew which one does not have this bug).
Any ideas?Flex harUI wrote:
That's true, but in this case, I think the text editing code is eating ENTER key in order to prevent parents from seeing it and acting on it (like a submit button). We'll see if we can find a way around that.
You can get the ENTER key now by listening in capture phase.
Alex Harui
Flex SDK Developer
Adobe Systems Inc.
Blog: http://blogs.adobe.com/aharui
The enter key isn't being disposed of by textedit, the attached example code works without error if you a- remove the alert box and b-set the focus to your text area on initialisation. I agree that pressing the enter key then calling a dialog box will result in the enter key being "gobbled up" as the enter key is overridden by the dialog box code.
I think the first suggestion should be to anyone don't use dialogboxes for testing code. If for some reason debugging isn't desirable instead of a trace statement a simple label can be used as a 'fake' trace.
David
Message was edited by: David_F57: I worded this wrong, imho there is no need for a work around, the textarea component works as it should. When intercepting 'system' keycodes there is a need to consider the effect of the intercept and code appropriately to that end. -
Using Child Panels - cannot FOCUS events are lost?
Hi all,
I am working with some legacy code that my boss would like updated. We have a background (parent) panel with many child panels that can come and go. Typically, we have two panels - one with controls and one with a graph - visible almost all the time. I have been trying to use FOCUS events to do some things, but one child panel (the control) appears to constantly get and lose focus. I'm seeing this in debug mode with the breakpoints at the event code for the panel callback. I'm careful to move the code windows away from this panel so the mouse isn't over it, but that seems to make no difference. Do child panels get the events of the parent panels? Also, the child panels do not appear to have max/min or close buttons in the title bar like standard windows. Is there some way to put them there without taking the child panel out of the parent panel?
Other things:
1. The boss would like to be able to resize a panel down to the point where clipping occurs, then automatically rearrange the controls so they line up vertically on one side of the panel and stop the resizing when they begin to be clipped. I have seen this done in Java with the Layout Manager, but never in C. Any suggestions? I know we can set a minimum resize value for a panel, but are there any easy ways to move the controls the way he wants?
2. An alternative is to make a toolbar with the controls inside, but he likes the windows icon tool buttons which I don't believe we have access to in CVI. I know we can make a command button and import an image to it, but is there a package that has the standard windows tool buttons that we can use?
Thank you for any and all help.
Judy HarriganHi Roberto Bozzolo
For the parent panels and the children panels,I have some questiones to ask you ,could you tell me how I should do? Monthes ago ,I have asked the same question in NI.COM ,you cansee the uir:http://forums.ni.com/t5/LabWindows-CVI/menubar-and-toolbar-enveloped-by-the-childpanel/m-p/1112563,
I use :GetPanelAttribute (mainPanel, ATTR_SYSTEM_WINDOW_HANDLE, &parent);
GetPanelAttribute (mlsPanel, ATTR_SYSTEM_WINDOW_HANDLE, &child);
oldparent = SetParent((HWND)child, (HWND)parent); to create an mainPanel and a childPanel.
For the mainPanel ,it contain the menubar and the toolbar,when I load the childPanel and move it,or
click the maximize,the menubar and toolbar for mainPanel enveloped by the childpanel.I want the
menubar and toolbar on top of the childPanel,can you tell me what I shoud do?
you can see ,when I maximize the child panel,the menubar and the toolbar for the parent panel are enveloped by the child panel,also the title for child panel display under the parent title,this are very inaesthetic.and how I should do to make the child panel and the parent panel works as the windows style like the under-side example?
When click the maximize button for the child panel,the title for child panel disappeared and the "minimize button","renert button",and "close button" for the child panel display on the top right of the parent menubar.To all of this,how I should do,could you please help me?
Attachments:
result.JPG 91 KB -
Event for the List Box in ALV Grid Control
Hello,
I have the below urgent requirment.
I have an ALV Grid Control built using ABAP Objects. In the grid, I have few fields and one of these fields is a List Box. Depending on the values selected, I need to enable or disable some fields. So, is there any event for the List box in ALV Grid Control.
For ex: I have 2 Fields, Designation and Commission. The designation field is a List Box field having 'Software Engineer' and 'Manager' as values. When I select 'Software Engineer', the commission field should be disabled. When I select 'Manager', the comission field should be enabled.
Early reply is hightly appreciated.
PriyaREPORT ZTEST1234 MESSAGE-ID ZZ .
DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA: L_VALID TYPE C,
V_FLAG,
V_DATA_CHANGE,
V_ROW TYPE LVC_S_ROW,
V_COLUMN TYPE LVC_S_COL,
V_ROW_NUM TYPE LVC_S_ROID.
DATA: OK_CODE LIKE SY-UCOMM,
SAVE_OK LIKE SY-UCOMM,
G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST',
GS_LAYOUT TYPE LVC_S_LAYO.
DATA:BEGIN OF ITAB OCCURS 0,
VBELN LIKE LIKP-VBELN,
POSNR LIKE LIPS-POSNR,
COMISN(10),
CELLCOLOR TYPE LVC_T_SCOL, "required for color
DROP(20),
<b> HANDLE_STYLE TYPE LVC_T_STYL,</b>
END OF ITAB.
* CLASS lcl_event_handler DEFINITION
CLASS LCL_EVENT_HANDLER DEFINITION .
PUBLIC SECTION .
METHODS:
**Hot spot Handler
HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,
<b>**Handler to Check the Data Change
HANDLE_DATA_CHANGED FOR EVENT DATA_CHANGED
OF CL_GUI_ALV_GRID
IMPORTING ER_DATA_CHANGED
E_ONF4
E_ONF4_BEFORE
E_ONF4_AFTER,</b>
**Double Click Handler
HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW E_COLUMN ES_ROW_NO.
ENDCLASS. "lcl_event_handler DEFINITION
* CLASS lcl_event_handler IMPLEMENTATION
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
*Handle Hotspot Click
METHOD HANDLE_HOTSPOT_CLICK .
CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
V_ROW = E_ROW_ID.
V_COLUMN = E_COLUMN_ID.
V_ROW_NUM = ES_ROW_NO.
MESSAGE I000 WITH V_ROW 'clicked'.
ENDMETHOD. "lcl_event_handler
*Handle Double Click
METHOD HANDLE_DOUBLE_CLICK.
ENDMETHOD. "handle_double_click
<b>**Handle Data Change
METHOD HANDLE_DATA_CHANGED.
DATA: X_CHANGE TYPE LVC_S_MODI,
X_FINAL TYPE ITAB,
L_FLAG,
LS_OUTTAB LIKE LINE OF ITAB.
DATA: LS_EDIT TYPE LVC_S_STYL,
LT_EDIT TYPE LVC_T_STYL.
LOOP AT ER_DATA_CHANGED->MT_GOOD_CELLS INTO X_CHANGE.
IF X_CHANGE-FIELDNAME = 'DROP' AND X_CHANGE-VALUE = 'S/W ENGINEER'.
LS_EDIT-FIELDNAME = 'COMISN'.
LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
LS_EDIT-STYLE2 = SPACE.
LS_EDIT-STYLE3 = SPACE.
LS_EDIT-STYLE4 = SPACE.
LS_EDIT-MAXLEN = 8.
INSERT LS_EDIT INTO TABLE LT_EDIT.
INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-HANDLE_STYLE.
MODIFY ITAB INDEX X_CHANGE-ROW_ID FROM LS_OUTTAB TRANSPORTING
HANDLE_STYLE .
else.
LS_EDIT-FIELDNAME = 'COMISN'.
LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
LS_EDIT-STYLE2 = SPACE.
LS_EDIT-STYLE3 = SPACE.
LS_EDIT-STYLE4 = SPACE.
LS_EDIT-MAXLEN = 8.
INSERT LS_EDIT INTO TABLE LT_EDIT.
INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-HANDLE_STYLE.
MODIFY ITAB INDEX X_CHANGE-ROW_ID FROM LS_OUTTAB TRANSPORTING
HANDLE_STYLE .
ENDIF.
ENDLOOP.
CALL METHOD G_GRID->REFRESH_TABLE_DISPLAY
EXCEPTIONS
FINISHED = 1
OTHERS = 2.
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. "HANDLE_DATA_CHANGED</b>
ENDCLASS. "LCL_EVENT_HANDLER IMPLEMENTATION
*& Global Definitions
DATA: G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"Container1
G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler
*- Fieldcatalog for First and second Report
DATA: IT_FIELDCAT TYPE LVC_T_FCAT,
X_FIELDCAT TYPE LVC_S_FCAT,
LS_VARI TYPE DISVARIANT.
* START-OF_SELECTION
START-OF-SELECTION.
SELECT VBELN
POSNR
FROM LIPS
UP TO 20 ROWS
INTO CORRESPONDING FIELDS OF TABLE ITAB.
END-OF-SELECTION.
IF NOT ITAB[] IS INITIAL.
CALL SCREEN 100.
ELSE.
MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).
ENDIF.
*& Form CREATE_AND_INIT_ALV
* text
FORM CREATE_AND_INIT_ALV .
DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING CONTAINER_NAME = G_CONTAINER1.
CREATE OBJECT G_GRID
EXPORTING I_PARENT = G_CUSTOM_CONTAINER.
* Set a titlebar for the grid control
CLEAR GS_LAYOUT.
GS_LAYOUT-GRID_TITLE = TEXT-003.
<b>GS_LAYOUT-STYLEFNAME = 'HANDLE_STYLE'.</b>
GS_LAYOUT-ZEBRA = SPACE.
GS_LAYOUT-CWIDTH_OPT = 'X'.
GS_LAYOUT-NO_ROWMARK = 'X'.
GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
<b> CALL METHOD G_GRID->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.</b>
CREATE OBJECT G_HANDLER.
SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.
SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.
<b> SET HANDLER G_HANDLER->HANDLE_DATA_CHANGED FOR G_GRID.</b>
DATA: LS_CELLCOLOR TYPE LVC_S_SCOL. "required for color
DATA: L_INDEX TYPE SY-TABIX.
"Here i am changing the color of line 1,5,10...
"so you can change the color of font conditionally
LOOP AT ITAB.
L_INDEX = SY-TABIX.
IF L_INDEX = 1 OR L_INDEX = 5 OR L_INDEX = 10.
LS_CELLCOLOR-FNAME = 'VBELN'.
LS_CELLCOLOR-COLOR-COL = '6'.
LS_CELLCOLOR-COLOR-INT = '0'.
LS_CELLCOLOR-COLOR-INV = '1'.
APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
LS_CELLCOLOR-FNAME = 'POSNR'.
LS_CELLCOLOR-COLOR-COL = '6'.
LS_CELLCOLOR-COLOR-INT = '0'.
LS_CELLCOLOR-COLOR-INV = '1'.
APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
ENDIF.
ENDLOOP.
* setting focus for created grid control
CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
EXPORTING
CONTROL = G_GRID.
* Build fieldcat and set editable for date and reason code
* edit enabled. Assign a handle for the dropdown listbox.
PERFORM BUILD_FIELDCAT.
PERFORM SET_DRDN_TABLE.
* Optionally restrict generic functions to 'change only'.
* (The user shall not be able to add new lines).
PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
**Vaiant to save the layout
LS_VARI-REPORT = SY-REPID.
LS_VARI-HANDLE = SPACE.
LS_VARI-LOG_GROUP = SPACE.
LS_VARI-USERNAME = SPACE.
LS_VARI-VARIANT = SPACE.
LS_VARI-TEXT = SPACE.
LS_VARI-DEPENDVARS = SPACE.
CALL METHOD G_GRID->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.
**Calling the Method for ALV output
CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
IS_VARIANT = LS_VARI
IS_LAYOUT = GS_LAYOUT
I_SAVE = 'A'
CHANGING
IT_FIELDCATALOG = IT_FIELDCAT
IT_OUTTAB = ITAB[].
* Set editable cells to ready for input initially
CALL METHOD G_GRID->SET_READY_FOR_INPUT
EXPORTING
I_READY_FOR_INPUT = 1.
ENDFORM. "CREATE_AND_INIT_ALV
*& Form EXCLUDE_TB_FUNCTIONS
* text
* -->PT_EXCLUDE text
FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
* Only allow to change data not to create new entries (exclude
* generic functions).
DATA LS_EXCLUDE TYPE UI_FUNC.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
ENDFORM. " EXCLUDE_TB_FUNCTIONS
*& Form build_fieldcat
* Fieldcatalog
FORM BUILD_FIELDCAT .
DATA: L_POS TYPE I.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-NO_ZERO = 'X'.
X_FIELDCAT-OUTPUTLEN = '10'.
X_FIELDCAT-HOTSPOT = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Item'(025).
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '5'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Drop'(025).
X_FIELDCAT-FIELDNAME = 'DROP'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '5'.
X_FIELDCAT-EDIT = 'X'.
X_FIELDCAT-DRDN_HNDL = '1'.
X_FIELDCAT-DRDN_ALIAS = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Comissn'(025).
X_FIELDCAT-FIELDNAME = 'COMISN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '10'.
X_FIELDCAT-EDIT = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
ENDFORM. " build_fieldcat
*& Module STATUS_0100 OUTPUT
* text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
IF G_CUSTOM_CONTAINER IS INITIAL.
**Initializing the grid and calling the fm to Display the O/P
PERFORM CREATE_AND_INIT_ALV.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form SET_DRDN_TABLE
* text
FORM SET_DRDN_TABLE.
DATA:LT_DRAL TYPE LVC_T_DRAL,
LS_DRAL TYPE LVC_S_DRAL.
LS_DRAL-HANDLE = '1'.
LS_DRAL-VALUE = 'S/W Engineer'.
LS_DRAL-INT_VALUE = 'S/W Engineer'.
APPEND LS_DRAL TO LT_DRAL.
LS_DRAL-HANDLE = '1'.
LS_DRAL-VALUE = 'Manager'.
LS_DRAL-INT_VALUE = 'Manager'.
APPEND LS_DRAL TO LT_DRAL.
**Setting the Drop down table for Reason Code
CALL METHOD G_GRID->SET_DROP_DOWN_TABLE
EXPORTING
IT_DROP_DOWN_ALIAS = LT_DRAL.
ENDFORM. " set_drdn_table
Regards
vijay -
I have a problem like this:
I have a form with 2 text fields: Text1, Text2. If focusing on Text1 and pass focus-event to Text2, a Message_Box will show to confirm: "Do you want to change focusing from Text1 to Text2 (Y/N)?". If you choose Yes then focus on Text2, otherwise keep focusing on Text1.
I have tried with following codes but it shows Message_Box 2 times when choosing No.
Please help me to solve this issue.
Thanks alot.
import com.fss.swing.*;
import javax.swing.JFrame;
import javax.swing.JTextField;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import javax.swing.*;
import javax.swing.JButton;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.Dimension;
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: FSS-FPT</p>
* @author not attributable
* @version 1.0
public class test extends JFrame
public test()
try
jbInit();
catch(Exception ex)
ex.printStackTrace();
private void jbInit() throws Exception
jTextField1.setText("jTextField1");
jTextField1.setBounds(new Rectangle(21,65,226,19));
this.getContentPane().setLayout(null);
this.getContentPane().add(jTextField1,null);
jButton1.setBounds(new Rectangle(132,128,73,23));
jButton1.setText("jButton1");
this.getContentPane().add(jTextField2);
this.getContentPane().add(jButton1);
jTextField2.setText("jTextField2");
jTextField2.setBounds(new Rectangle(267,66,64,19));
jTextField1.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e){
if(e.isTemporary())
return;
int i = MessageBox.showConfirmDialog(test.this,"Do you want to change focusing from Text1 to Text2 (Y/N)?","Confirm");
if(i == MessageBox.YES_OPTION)
jTextField2.requestFocus();
else
jTextField1.requestFocus();
JTextField jTextField1 = new JTextField();
JTextField jTextField2 = new JTextField();
JButton jButton1 = new JButton();
public static void main(String args[]) {
test t = new test();
t.setTitle("Test");
t.setSize(new Dimension(400,300));
t.setVisible(true);
Edited by: googlecomvn on Jul 4, 2008 3:23 AMThe way I've seen to cancel focus events is using a VetoableChangeListener:
[http://java.sun.com/j2se/1.5.0/docs/api/java/awt/doc-files/FocusSpec.html#FocusAndVetoableChangeListener]
import java.awt.KeyboardFocusManager;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class FocusTest extends JFrame {
public FocusTest() {
final JTextField field1 = new JTextField("type \"text\"");
final JTextField field2 = new JTextField("then click on me!");
setLayout( new BoxLayout( this.getContentPane(), BoxLayout.Y_AXIS ) );
add(field1);
add(field2);
pack();
KeyboardFocusManager.getCurrentKeyboardFocusManager().addVetoableChangeListener(
new VetoableChangeListener() {
public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
if ( evt.getOldValue() == field1 ) {
if ( !"text".equals(field1.getText()) ) { //simple validation
throw new PropertyVetoException("Invalid value for field1", evt);
public static void main(String[] args) {
new FocusTest().setVisible(true);
}You'd definitely get in trouble with using a JOptionPane in the change listener, though (as it would throw more focus events, requiring more JOptionPanes, etc).
Edited by: endasil on 4-Jul-2008 8:50 AM -
Catching a table cell focused event
I have a JTable that I want users to input data into. One of the columns is a date field. In order to make sure the date is formatted and entered correctly, I've used a custom cell editor and renderer so the column looks like a DateTextField(a custom date field class). It works fine when the user clicks on the cell. But if the user hits the down arrow it doesn't set off the event that allows it to be edited as a DateTextField. Can you capture somekind of focus event on a particular cell and when you get a focus gained, programatically send the event that allows the cell to be edited? In case that didn't make sense, I'm trying to programatically simulate a mouse click on a table cell when it gets focus. Can it be done? If so, how? Thanks.
Yes, I've tried that. The problem is what some people have described as a bug. There are two editing methods for JTable cells. One happens if the cell gets focus. There is no cursor and any underlying components are ignored. The second(the REAL edit) is when there is a cursor and the JTable understands that the cell is really a DateTextField. The only way I've found to achieve this is click on the cell. The number of clicks it takes depends on what the clickCountToStart is set to. However, if it's set to zero, it still takes one click.
-
Keypressed event for a particular edited cell of jtable
hi friend,
how to write the key pressed event for the edited cell of jtable which having focus on that particular cell.
pls help me out.[http://catb.org/~esr/faqs/smart-questions.html]
[http://mindprod.com/jgloss/sscce.html]
db -
Getting onchange event for inputfield
Hi all,
How can I get onChange() event for inputfield in webdynpro
and how can i use that.
Thanks
FahadHi anil,
In my application, I am having one inputfield and a dropdown.As per the input field entry, I have to load values in dropdown even if the end user is using Tab button or mouse for changing the focus.
How can I do that? -
How the PCUI event for export button works?
Hi All,
After get the order search result in PCUI, when I click the Export button.
It show me the message that : Microsoft office 2003 or higher is not installed on your computer.
In fact, I have the office 2003. And I found that the event for Export button is PCF_DL_EXPORT.Have you tried double-clicking on the auto complete component in the designer? You should be taken to a method like "autocomplete1_complete". This method is called when the autocomplete gets focus and also for each character typed in the field.
Cheers!
-David -
How to handle LostFocus event for TextField in J2ME?
Hi:
I want to handle LostFocus event for TextField in J2ME.
So can anybody help me.....
Thank YouMIDP API does not have LostFocus event.
You can try setting ItemStateListener for the TextField ([if needed, click here for details|http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/ItemStateListener.html]). API requires that +"...For implementations that have the concept of an input focus, the listener should be called no later than when the focus moves away from an item whose state has been changed. The listener should be called only if the item's value has actually been changed...."+ -
An unnatural focus event is killing MOUSE_RELEASE on XP
I only have this error being reported from people with XP PRO.
So I overrode the dispatchEvent method so that I could monitor every event
that was occuring because for some reason when a window lost focus then
gained focus java acted like the mouse was still held down. These are the
results I found:
So this is in reference to a TEXT_AREA. A person clicks on the desktop so the text_area has lost focus and then they click back on the text_area. Below are the events that are fired when the user clicks back on the text_area and it regains focus..
WIN98 WORKING:
WINDOW_ACTIVATED,opposite=null,oldState=0,newState=0
WINDOW_GAINED_FOCUS,opposite=null,oldState=0,newState=0
FOCUS_GAINED,permanent,opposite=null
MOUSE_PRESSED,(11,8),button=1,modifiers=Button1,extModifiers=Button1,clickCo
unt=1
MOUSE_RELEASED,(11,8),button=1,modifiers=Button1,clickCount=1
MOUSE_CLICKED,(11,8),button=1,modifiers=Button1,clickCount=1
Focus gained and 3 proper mouse events are fired
NOW
WINXP PRO:
FOCUS_GAINED,permanent
MOUSE_PRESSED,(353,221),mods=16,clickCount=1
FOCUS_LOST,permanent
FOCUS_GAINED,permanent
MOUSE_CLICKED,(353,221),mods=16,clickCount=1
INVOCATION_DEFAULT,runnable=sun.awt.GlobalCursorManager$1@3e0e27,notifier=nu
ll,catchExceptions=false
MOUSE_MOVED,(353,220),mods=0,clickCount=0
MOUSE_MOVED,(352,218),mods=0,clickCount=0
Focus is gained, mouse is pressed, then focus is lost?????? then immediately
gained???? and then mouse is clicked. The mouse released never gets fired
thus when I move the mouse around the text field it just highlights things
as if I'm holding down the mouse button. Somewhere in that odd gain and then focus the event is getting lost.
ideas?? or workarounds??Hmmm that could be it. I've had a couple people report the problem though and they were all on XP PRO, maybe the drivers in XP are acting funny. Thanks for the idea, hopefully that's the problem.
I did find out a little more out about the focus events.
I have a class called AsmEditWindow that extends Frame.
In this frame I have two different TextAreas, each of these textAreas have there own separate focus listeners that I've set up using inner classes. So like:
msgarea.addFocusListener(new MsgAreaFocusListener());
textarea.addFocusListener(new TextAreaFocusListener());
Now on the functioning windows 98 system I Get:
java.awt.event.FocusEvent[FOCUS_GAINED,permanent,opposite=null] on text0
java.awt.SequencedEvent[] on text0
java.awt.event.MouseEvent[MOUSE_PRESSED,(11,8),button=1,modifiers=Button1,extModifiers=Button1,clickCount=1] on text0
java.awt.SentEvent[] on sun.awt.windows.WToolkit@11946c2
java.awt.SentEvent[] on sun.awt.windows.WToolkit@11946c2
java.awt.event.MouseEvent[MOUSE_RELEASED,(11,8),button=1,modifiers=Button1,clickCount=1] on text0
The first focus event is on text0 then the mouse listeners proceed without a problem.
On the non-functioning windows XP system I get:
java.awt.event.FocusEvent[FOCUS_GAINED,permanent] on frame1
java.awt.event.MouseEvent[MOUSE_PRESSED,(353,221),mods=16,clickCount=1] on text0
java.awt.event.FocusEvent[FOCUS_LOST,permanent] on frame1
java.awt.event.FocusEvent[FOCUS_GAINED,permanent] on text0
So frame1 gains, then mouse is pressed, then frame 1 loses and text0 gains focus and the mouse_release event never gets thrown.
Is there something more that I should be posting to give insight? The code section to setup the Frame is about 95 lines so I was thinking that was too long to put in the post. If this assumption is incorrect tell me what part of the code would be useful, and I'll post it.
Thanks -
How to catch cell lost focuse event of matrix
Dear all
can you tell me how to catch the cell lost fouc event of matrix.
i want to check the value is entered the that cell, which is not greter than the extising value..
thanks in advance......Hi
For that you can use either validate or lost focus event
Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
' BubbleEvent sets the behavior of SAP Business One.
' False means that the application will not continue processing this event.
' Validate event
If (pVal.FormType = 133) And (pVal.ItemUID = 38) And (pVal.ColUID = 1) And _
(pVal.EventType = SAPbouiCOM.BoEventTypes.et_VALIDATE) Then
If (pVal.Before_Action) Then
'write your code
End If
End If
'Lost focus event
If (pVal.FormType = 133) And (pVal.ItemUID = 38) And (pVal.ColUID = 1) And _
(pVal.EventType = SAPbouiCOM.BoEventTypes.et_LOST_FOCUS) Then
If (pVal.Before_Action) Then
'write your code
End If
End If
End Sub
Hope this helps
Regards
Arun
Maybe you are looking for
-
How to define join in physical layer between cube and relational table
Hi I have a aggregated data in essbase cube. I want to supplement the information in the cube with data from relational source. I read article http://community.altiusconsulting.com/blogs/altiustechblog/archive/2008/10/24/are-essbase-and-oracle-bi-ent
-
Is it possible to change the background color in EVENTS view?
I know that you can change the color once you enter into an event. But it seems like the main 'events' page only has a charcoal background with no facility to change it. Is this correct? Or is there a way to change it? I'm not a huge fan of black bac
-
Server crashes after router restarts, different routers, same result!
Hello team, I've had this problem before, and it's getting really annoying. Every time I restart my router, my server will crash. It's almost always the case. I don't know why. It's not my router, I have tried 3 different routers. I thought maybe my
-
I need help getting this program to work.
K. I don't pay much attention in my AP Comp Science Class.. but my teacher said if i can get this program to work i get an a for the semester... The program is Metrowerks Codewarrior IDE.. we are running it on windows 98 i think. She said she can't g
-
How to authenticate BPEL process to a PL with Client SSL Cerificate
Hi, I need to invoke a partner link which requires authentication with Client SSL certificate. So, here is the use case: - The PL's endpoint is https://some.server.com/web_service; - I have a client SSL certificate supplied by the web service provide