How to assign the enter pressing to the button click event of swing button?
Hello to all you pro's,
I can't find how to make my button a default button so it will respond to an enter press.
any help will be most appreciated.
thanks in advanced.
get the RootPane and call setDefaultButton on it. Something like so:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
class SwingFu2 extends JPanel
private JButton buttonOK = new JButton("OK");
private JButton buttonCancel = new JButton("Cancel");
private JTextField textfield = new JTextField(12);
private JFrame frame;
SwingFu2(JFrame frame)
this.frame = frame;
ActionListener buttonActionListener = new ButtonActionListener();
buttonOK.addActionListener(buttonActionListener);
buttonCancel.addActionListener(buttonActionListener);
add(textfield);
add(buttonOK);
add(buttonCancel);
frame.getRootPane().setDefaultButton(buttonOK);
private class ButtonActionListener implements ActionListener
@Override
public void actionPerformed(ActionEvent e)
String command = e.getActionCommand();
if (command.equalsIgnoreCase("OK"))
System.out.println("OK pressed");
System.out.print("Text in textfield: ");
System.out.println(textfield.getText());
else if (command.equalsIgnoreCase("Cancel"))
frame.dispose();
private static void createAndShowUI()
JFrame frame = new JFrame("SwingFu1");
frame.getContentPane().add(new SwingFu2(frame));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
public static void main(String[] args)
java.awt.EventQueue.invokeLater(new Runnable()
public void run()
createAndShowUI();
}
Similar Messages
-
Identifying the Enter pressed by the user in the Inputfield
Hi all,
We have one Comment field on Portal screen that is given by the user (User may press enter while giving the comments). We are sending that field value to R3 through RFC and when we are getting back that comment field value from R3 we need to identify the Enter pressed by the user. We are writing the code for identifying "/n" in that comments field but that is not working. Can anyone help me out in this? This is really urgent.
Thanxs in advance!!!Hi Gurmat and Manoj,
Do you want to replace the TextEdit too? I thought only to print or send to backend. No problems. We can do change in TextEdit as well.
My input in TextEdit is:
How
are
you
Manoj?
After button click I got output in TextEdit and TextView(I used button to trigger event):
How are you Manoj?
In onActionButton() my code is:
StringBuffer buffer = new StringBuffer(wdContext.currentContextElement().getText());
for (int i = 0,index=buffer.indexOf("\n"); i < buffer.length(); i++) {
if(i==index){
buffer.replace(i-1, i+1," ");
index = buffer.indexOf("\n");
if (index==-1)
break;
In StringBuffer use "" only
regards,
Siva -
Pressing the enter key on the keyboard
Need to know the trigger or the way to attribute code to pressing de enter key on the Keyboard!!!???
Thanks!!!!!Hi Carlos,
By default, the ENTER key takes the cursor to the next navigable item in the block.
To override this default behaviour it is necessary to modify the forms resource file to revise the key mapping details.
Refer to article 209671.1 on Metalink: How to Change / Customize the Key Mappings for 6i and 9i Webforms?
Read the section 'B: Mapping for ENTER to fire KEY-ENTER-TRIGGER over the Web'
Regards,
Monica -
How can we trape the Keys Pressed on the Keyboard and do action depending on the keys
I want to know how we can capture the keys pressed on the keyboard by the user and do necessary action depending on the key pressed by the user....
For example.... If user press Alt+q the form should go in the Enter Query Mode.
Can anyone tell me how i can do this in Form 6i....
Please Help me out from this problem...
Thanks in Advance
ShanCan somebody point me to what I need to use to
intercept all the 'keys' for an application.
At the moment I have set Focus to parts of the
application when the Mouse is over it, and then get
the Keys with a KeyListener.
Is there a way to get the keys, as long as the Java
app is active.
- Its an image display program, and I want to use keys
for - next image , zooom etc etc.
If soemone could just point me to the right part of
the API to look in?java.awt.Toolkit.addAWTEventListener()
then use the mask defined in AWTEvent.KEY_EVENT_MASK to listen to all the events.
Steve -
How to assign a dynamic value to the value property of a button ?
Hi Folks,
I have a need, can i know how to assign a dynamic value to the value property of a button. Scenario is like follows...
This is a struts based web application
1. I have a file which consists of login user details (user name and his previlages) for a web application.
2. I got those user details, into a List.
3. When a user logged into the web app, in the home page there are few buttons. The type and number of buttons shown depends on the type of user/ user. (Buttons have different combination and the number of buttons available are not constant, they will vary from user to user).
4. for each button, there will be a different action. I can pass the value of a button to an action class, but here button must have a dynamic value.
Here is my test code:
<%
if (List != null)
for (int i = 0; i <List.length; i++)
%>
<html:submit property="rduname" value= "<%=List%>" onclick="return submitRdu('<%=List[i] %>');"/>
<%
%>
But my problem is how to assign a dynamic value to the value property of the button ( i know 'value= "<%=List[i]%>" ' will not work, just wanted show you guys).
Thanks in advance,
UV
Edited by: UV_Dev on Oct 9, 2008 2:15 PMLet me try i know am not good at JSP but do we need double quotes here
value= <%=List%>i think JSTL should help you about the dynamic thing -
How to assign project specific task with the newly created projects ?
Hi All,
I need help. I need to assign project specific tasks (which i will be taking from staging table) other than the default task which are assigned during project creation. How do I proceed with this within same package. I am attaching the code of my package below...
CREATE OR REPLACE PACKAGE body xxpa_proj_conv_pkg as
PROCEDURE xxpa_create_project_proc(O_ERRBUF OUT VARCHAR2,O_RETCODE OUT VARCHAR2)
is
variables need to derive global parameters
v_responsibility_id NUMBER; --- PA Supervisor responsibility id
v_user_id NUMBER;
deriving global parameters-
-- Variables needed for API standard parameters
v_api_version_number NUMBER := 1.0;
v_commit VARCHAR2(1) := 'F';
v_return_status VARCHAR2(1);
v_init_msg_list VARCHAR2(1) := 'F';
v_msg_count NUMBER;
v_msg_index_out NUMBER;
v_msg_data VARCHAR2(2000);
v_data VARCHAR2(2000);
v_workflow_started VARCHAR2(1) := 'Y';
v_pm_product_code VARCHAR2(10);
---variables for catching errors---
v_error_flag number:=0;
-- Predefined Composite data types
v_project_in PA_PROJECT_PUB.PROJECT_IN_REC_TYPE;
v_project_out PA_PROJECT_PUB.PROJECT_OUT_REC_TYPE;
v_key_members PA_PROJECT_PUB.PROJECT_ROLE_TBL_TYPE;
v_class_categories PA_PROJECT_PUB.CLASS_CATEGORY_TBL_TYPE;
v_tasks_in_rec PA_PROJECT_PUB.TASK_IN_REC_TYPE;
v_tasks_in PA_PROJECT_PUB.TASK_IN_TBL_TYPE;
v_tasks_out_rec PA_PROJECT_PUB.TASK_OUT_REC_TYPE;
v_tasks_out PA_PROJECT_PUB.TASK_OUT_TBL_TYPE;
v_CREATED_FROM_PROJECT_ID varchar2(20);
v_CARRYING_OUT_ORGANIZATION_ID varchar2(20);
v_person_id NUMBER;
v_project_role_type VARCHAR2(20);
API_ERROR EXCEPTION;
v_a NUMBER;
cursor for project in data
CURSOR cur_project_in_data IS SELECT * FROM XXPA_PROJECT_IN_STG;
cursor for task data
CURSOR cur_task_in_data IS SELECT * FROM XXPA_TASK_IN_STG;
------------------------Cursors used for validations----------------------------------
cursor for product code used for validation
cursor cprc is select distinct PROJECT_RELATIONSHIP_CODE from PA_PROJECT_CUSTOMERS;
cursor for distribution rule-
cursor cdr is select DISTRIBUTION_RULE from PA_DISTRIBUTION_RULES;
cursor for project status code
cursor cpsc is SELECT PROJECT_STATUS_CODE, PROJECT_STATUS_NAME FROM PA_PROJECT_STATUSES WHERE STATUS_TYPE = 'PROJECT';
cursor for template/created from project id
cursor ccpid is select project_id from pa_projects where template_flag='Y';
BEGIN
select user_id, responsibility_id into v_user_id, v_responsibility_id
from PA_USER_RESP_V
where user_name like 'amit_kumar%'
and responsibility_name like'PA SupervisorS';
-- --Fnd_global.apps_initialize(user_id,resp_id, resp_appl_id);
-- Fnd_global.apps_initialize(v_user_id,v_responsibility_id,275);
-- -------calling global parameters---
pa_interface_utils_pub.set_global_info
p_api_version_number =>v_api_version_number,
p_responsibility_id =>v_responsibility_id,
p_user_id =>v_user_id,
p_msg_count =>v_msg_count,
p_msg_data =>v_msg_data,
p_return_status =>v_return_status
dbms_output.put_line ('Set Global status ->' || v_return_status);
----Cursor for PRODUCT RELATED DATA-----------
FOR REC IN cur_project_in_data LOOP
-----PASSING VALUES TO THE COMPOSITE DATA TYPE(PROJECT_IN_REC_TYPE)-------
----retrieving product code-----
select lookup_code into v_pm_product_code
from pa_lookups
where lookup_type = 'PM_PRODUCT_CODE'
and meaning = 'Oracle Project Manufacturing';
-----retrieving and validating created from project id----
BEGIN
select project_id
into v_CREATED_FROM_PROJECT_ID
from pa_projects_all
where name=rec.created_from_project_name;
EXCEPTION
when others then
O_Retcode := '1';
O_Errbuf :='Incorrent CREATED_FROM_PROJECT_NAME';
Fnd_File.Put_Line (Fnd_File.LOG, O_Errbuf);
UPDATE XXPA.XXPA_PROJECT_IN_STG
SET ERROR_FLAG ='1' ,last_updation_date='sysdate' where created_from_project_name = rec.CREATED_FROM_PROJECT_NAME;
END;
-----retrieving & validating carrying out organization id-----
BEGIN
select distinct(CARRYING_OUT_ORGANIZATION_ID)
into v_CARRYING_OUT_ORGANIZATION_ID
from pa_projects_prm_v
where CARRYING_OUT_ORGANIZATION_NAME=rec.carrying_out_organization_name;
EXCEPTION
when others then
O_Retcode := '1';
O_Errbuf :='Incorrent Carrying Out Organization name';
Fnd_File.Put_Line (Fnd_File.LOG, O_Errbuf);
UPDATE XXPA.XXPA_PROJECT_IN_STG
SET ERROR_FLAG ='1' ,last_updation_date='sysdate' where carrying_out_organization_name = rec.carrying_out_organization_name;
END ;
v_project_in.pm_project_reference := rec.segment1;
v_project_in.project_name := rec.PROJECT_NAME;
v_project_in.created_from_project_id := v_CREATED_FROM_PROJECT_ID;
v_project_in.carrying_out_organization_id := v_CARRYING_OUT_ORGANIZATION_ID;
v_project_in.project_status_code := rec.PROJECT_STATUS_CODE;
v_project_in.description := rec.PROJECT_DESCRIPTION;
v_project_in.start_date := rec.PROJECT_START_DATE;
v_project_in.completion_date := rec.PROJECT_COMPLETION_DATE;
v_project_in.distribution_rule := rec.DISTRIBUTION_RULE;
v_project_in.project_relationship_code := rec.PROJECT_RELATIONSHIP_CODE;
-------------------------Validation of incoming project data--------------------------------
v_error_flag := 1;
project relationship code validation
BEGIN
for prc in cprc
loop
if (rec.PROJECT_RELATIONSHIP_CODE=prc.PROJECT_RELATIONSHIP_CODE) or (rec.PROJECT_RELATIONSHIP_CODE is null)--can be overridden from template
then
v_error_flag :=0;
else null;
end if;
end loop;
END;
project distribution rule validation
BEGIN
for dr in cdr
loop
if (rec.DISTRIBUTION_RULE=dr.DISTRIBUTION_RULE) or (rec.DISTRIBUTION_RULE is null) null since the value can be taken from template too
then
v_error_flag :=0;
else null;
end if;
end loop;
END;
project status code validation
BEGIN
for sc in cpsc
loop
if (rec.PROJECT_STATUS_CODE=sc.PROJECT_STATUS_CODE) or (rec.PROJECT_STATUS_CODE is null) null since the value can be taken from template too
then
v_error_flag :=0;
else null;
end if;
end loop;
END;
dbms_output.put_line ('Error at PROJECT_STATUS_CODE>' ||v_error_flag);
validation logic for project start date
BEGIN
if TRUNC(rec.PROJECT_START_DATE) >= TRUNC(rec.PROJECT_COMPLETION_DATE)
THEN
v_error_flag := 1;
O_Retcode := '1';
O_Errbuf :='Project start date cannnot be greater than completion date';
Fnd_File.Put_Line (Fnd_File.LOG, O_Errbuf);
END IF;
END;
validation logic for project completion date
BEGIN
if (TRUNC(rec.PROJECT_COMPLETION_DATE)<=TRUNC(rec.PROJECT_START_DATE))
then
if ( rec.PROJECT_STATUS_CODE='CLOSED' and rec.PROJECT_COMPLETION_DATE>sysdate)
THEN
v_error_flag := 1;
O_Retcode := '1';
O_Errbuf :='completion date cannot be greater than sysdate for closed projects';
Fnd_File.Put_Line (Fnd_File.LOG, O_Errbuf);
END IF;
v_error_flag := 1;
O_Retcode := '1';
O_Errbuf :='Project closed date cannot be less than start date';
end if;
END;
--------Update staging table for the error records--------
BEGIN
if v_error_flag =1
then
O_Retcode := '1';
O_Errbuf :='Incorrect project relationship code';
Fnd_File.Put_Line (Fnd_File.LOG, O_Errbuf);
UPDATE XXPA.XXPA_PROJECT_IN_STG
SET ERROR_FLAG ='1' ,last_updation_date='sysdate' where PROJECT_RELATIONSHIP_CODE = rec.PROJECT_RELATIONSHIP_CODE;
end if;
END;
-----------------------End of validation of incoming project data----------------------------------
---------------Project Task DATA-----------------
v_a:=0;
FOR tsk IN cur_task_in_data LOOP
v_tasks_in_rec.pm_task_reference :=tsk.task_reference ;
v_tasks_in_rec.task_name :=tsk.task_name;
v_tasks_in_rec.pm_parent_task_reference :=tsk.parent_task_reference ;
v_tasks_in_rec.task_start_date :=tsk.task_start_date ;
v_tasks_in_rec.task_completion_date :=tsk.task_completion_date ;
v_tasks_in(v_a) := v_tasks_in_rec;
v_a:=v_a+1;
end loop;
---------------end of task details------------------
--INIT_CREATE_PROJECT
pa_project_pub.init_project;
---------------------CREATE_PROJECT--------------------------
pa_project_pub.create_project(
p_api_version_number=> v_api_version_number,
p_commit => v_commit,
p_init_msg_list => v_init_msg_list,
p_msg_count => v_msg_count,
p_msg_data => v_msg_data,
p_return_status => v_return_status,
p_workflow_started => v_workflow_started,
p_pm_product_code => v_pm_product_code,
p_project_in => v_project_in,
p_project_out => v_project_out,
p_key_members => v_key_members,
p_class_categories => v_class_categories,
p_tasks_in => v_tasks_in,
p_tasks_out => v_tasks_out);
if v_return_status = 'S'
then
UPDATE XXPA.XXPA_PROJECT_IN_STG
SET INTERFACE_STATUS ='Success' where segment1 = v_project_out.pa_project_number; ---P->pending & S-> Success
dbms_output.put_line('New Project Id: ' || v_project_out.pa_project_id);
dbms_output.put_line('New Project Number: ' || v_project_out.pa_project_number);
else
UPDATE XXPA.XXPA_PROJECT_IN_STG
SET INTERFACE_STATUS ='Pending' where segment1 = v_project_out.pa_project_number;
raise API_ERROR;
end if;
END LOOP;
Commit;
------Handling Exception--------
EXCEPTION
WHEN api_error THEN
dbms_output.put_line('An error occured during project creation');
IF (v_msg_count > 0 ) THEN
FOR i IN 1..v_msg_count LOOP
apps.PA_INTERFACE_UTILS_PUB.get_messages(
p_msg_count => v_msg_count,
p_encoded => 'F',
p_msg_index => i,
p_msg_data => v_msg_data,
p_data => v_data,
p_msg_index_out => v_msg_index_out);
dbms_output.put_line('Error message v_data ->'||v_data);
dbms_output.put_line('Error message v_msg_data ->'||v_msg_data);
dbms_output.put_line('Error message v_msg_index_out ->'||v_msg_index_out);
dbms_output.put_line('Error message p_msg_index ->'||i);
APPS.fnd_file.put_line(APPS.FND_FILE.LOG,v_data);
END LOOP;
END IF;
WHEN OTHERS THEN
dbms_output.put_line('An error occured during conversion, SQLCODE ->'|| SQLERRM);
IF (v_msg_count >=1 ) THEN
FOR i IN 1..v_msg_count LOOP
PA_INTERFACE_UTILS_PUB.get_messages(
p_msg_count => v_msg_count,
p_msg_index => i,
p_encoded => 'F',
p_msg_data => v_msg_data,
p_data => v_data,
p_msg_index_out => v_msg_index_out);
dbms_output.put_line('Error message ->'||v_data);
APPS.fnd_file.put_line(APPS.FND_FILE.LOG,v_data);
END LOOP;
END IF;
end; --end procedure
END xxpa_proj_conv_pkg;
* Please tell me how to assign project specific task with the newly created projects??? *
Also please tell me how to assign multiple * Project_Relationship_Code * (ex: END CLIENT, GENERAL CONTRACTOR, PRIMARY) for a particular project during project creation?Are you not storing the project number in the staging table designed for storing the task data? You can use create_project API to create the project and tasks at the same time with one single call. You may want to try that option
-
How to assign a pricing type to the pricing procedure ?
Business Scenario : When the prices change from the time the order is taken to the time the invoice is created, how can setup the system to handle the changes automatically ?
I would like to know How to create a pricing type and How to assign a pricing type to the pricing procedure so that I can use the 'new pricing document' function in the sales document and 'Update prices' on the condition screens in the Billing document.
Thanks for your input in advance.
OscarHi !! Oscar,
1) For pricing type definition you would require the help of a developer.
2) However, most of the commonly occuring requirements are supplied with standard SAP.
You can assign a pricing type to pricing procedure as follows:-
IMG>S & D >Basic Functions>Pricing>Pricing Control>Define & Assign pricing procedures>Maintain pricing procedure> Here, locate your pricing procedure , in the fourth coloumn using the drop down list, you can assign a pricing type to the pricing procedure.
Now you can use the 'new pricing document' function in the sales document and 'Update prices' on the condition screens in the Billing document !
Regards,
PATHIK
Message was edited by:
Pathik Pandya -
How to assign static ip address to the server having solaris 10. i.e. nge0
hi,
how to assign static ip address to the server having solaris 10. i.e. nge0 i.e. 192.168.3.125 ipshold be persistantt across reboots. what steps do i need to follow to put all information including gateway,netmask etc..Also i want to integrate one init script ..can i integrate it using /etc/init.d/<service name> like linux. and do chkconfig on it?i am not getting complex procedure of SPF and FMRI etc..can u help me?Create a file in your /etc directory called hostname.nge0. Add the hostname of your system to this file. In your /etc/hosts file, assign the static IP address you want to the same hostname. You can then disable and enable the network-physical service to configure the network interface:
svcadm disable network-physical
svcadm enable network-physical -
How to assign single responsibity to all the applications user?
how to assign single responsibity to all the applications user?
Thanks in advanceUse FND_USER_PKG.AddResp
How to use FND_USER_PKG.AddResp
Re: How to use FND_USER_PKG.AddResp
single responsibility to all users
Re: single responsibility to all users -
How do I remove the enter key on the numeric keypad as a command key?
How do I remove the enter key on the numeric keypad as a command key. I want to use the enter key as a return key.
Don't. It will void the warranty. Take is to an Apple store or an AASP and have them do it.
-
Hello
As explained in the heading, I'm using LR 5.6 on a PC (Win 7). The Enter key should increase the exposure but it increases Contrast instead. How can I make the Enter key adjust the exposure, as it should? I have reset the settings to Default in the Develop module but to no avail. Please help! Thanks.
Kind Regards
Farrukh HyderI am not aware that the ENTER key should increase exposure, and it certainly does not increase exposure (or any other slider) on my Lightroom 5.6 (Windows 7)
If you click on the word Exposure, then the + and - keys increases or decrease exposure by 0.1 or -0.1 -
Track the entered answer using the Regular expression
Hi,
I am building a Q&A application which does have user to answer descriptive answer for the question(Text based answer rather than objective)
in this case how we can track the entered answer by the user is the correct one? how we can capture the entered answer and then check with the correct
answer in the DB? Yes we need to use a regular expression , but how we know that entered one is matching with the one in the DB
as the user can answer in lengthy or short form ? Hence please clarify how we can proceed?
Thanks.797836 wrote:
Hi,
I am building a Q&A application which does have user to answer descriptive answer for the question(Text based answer rather than objective)
in this case how we can track the entered answer by the user is the correct one? how we can capture the entered answer and then check with the correct
answer in the DB? Yes we need to use a regular expression , but how we know that entered one is matching with the one in the DB
as the user can answer in lengthy or short form ? Hence please clarify how we can proceed?
I don't see how regular expressions help at all with this problem ! What made you think they can help? -
The "enter" key on the numeric keypad of my external mac keyboard has stopped working with my Macbook pro. If I plug the keyboard into any other computer, that entier key works fine. I'm using a standard Mac wired keyboard, & it's worked fine for 2 years now. Help!
This is the keyboard I am using: http://store.apple.com/us/product/MB110LL/B/apple-keyboard-with-numeric-keypad
Not sure what I might have accidentily done to disable the enter key. (The normal enter key works fine, just the one on the numeric keypad.)
Thank you for your help.Hi there,
Do you have any resolution to this problem in the end? Because it happened to me an exact same thing.
Please share if you have found a solution to your problem. I also cannot think of what I did wrong to disable the Enter key.
Best Regards,
Jeffri -
My problem is after updating to Yosemite does my mail client any longer. I can not even open the mail, and when I "forced closes" mail and try to open it again to go in the entered settings running the colored wheels around and allows me only to forcing close again? does anyone have a solution to the above problem?
You mean the default OS X mail app? Try reinstalling OS X Yosemite if that's the case.
If you are referring to 3rd party mail applications, that's a compatibility issue. Some apps don't work in the new operating system. You have to wait until the developer updates the app, or you have to revert back to Mavericks to continue using it. -
FileDialog.SAVE: trap the "Save" button click event
Hello All
Can anyone help me with FileDialog.SAVE, as to how we could trap the Save button click event? Is it possible to actually trap that particular event, rather than just checking for FileDialog.getFile() == null -> which indicates that "Cancel" button was selected.
Any help would be highly appreciated
Regards
NaushinYou can not do this, because FileDialog uses native dialog and all
buttons on it are native (there are no java-components for them).
Thus checking FileDialof.getFile() for null is only way to figure out
whether user choose some file or not.
Maybe you are looking for
-
Problem recording with WaveStu
Hi all! I can't figure out why I'm not getting a signal when I'm recording. I believe my soundcard is working fine because I can play back old recordings through the external amplifier and also can get an imput signal off the card. When I select "rec
-
Could someone tell me which IDOC is vendor master idoc?? Ashish
-
Hello Everybody, I have a unique requirement . I need to modify more than 1000 roles . Modification is as following I need to change the "BSART" field of "M_BEST_BSA" object from "*" to new values. In fact document type restriction is now going to be
-
JDeveloper ADF Change title validation error messages
Im using JDeveloper 12c with ADF and i was wondering how can i change those titles.
-
1. Cannot synch contacts with between Treo 650 and oracle. I have Vista.
Any ideas how to fix this?