How to show a JPopupMenu on a JMenuItem?
I am trying to add a RMB context menu to an existing JMenuItem. For example Firefox has bookmark popup menus that can be "edited" by right clicking on the popup menu to say delete an entry.
The code below is a sample app that demonstraits the problem. Open up the main menu and attempt to right click on various things.
It seems like it might will work for "sub" JMenus but not JMenuItems (meaining no exception in thrown). In either case the menu to which the popup should be attached disappears when the RMB is clicked (at least on windows). This is likely the cause of the exception that is thrown below when the RMB is clicked on a JMenuItem. Furthermore if the popup is shown it is not properly hidden.
How would one properly accomplish this or is it just plain impossible?
java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
at java.awt.Component.getLocationOnScreen_NoTreeLock(Component.java:1507)
at java.awt.Component.getLocationOnScreen(Component.java:1481)
at javax.swing.JPopupMenu.show(JPopupMenu.java:921)
at sample.App$MouseHandler.checkPopup(App.java:76)
at sample.App$MouseHandler.mouseReleased(App.java:69)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:232)
at java.awt.Component.processMouseEvent(Component.java:5100)
at java.awt.Component.processEvent(Component.java:4897)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
at java.awt.Container.dispatchEventImpl(Container.java:1613)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
package sample;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class App {
private JFrame frame;
private JPopupMenu popup;
public static void main( String[] args ) {
try {
new App();
catch( Exception e ) {
e.printStackTrace();
public App() {
popup = createPopupMenu();
frame = new JFrame( "Sample" );
frame.addWindowListener( new WindowHandler() );
frame.setSize( 200, 200 );
frame.setJMenuBar( createMenuBar() );
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation(
screenSize.width/2-frame.getWidth()/2,
screenSize.height/2-frame.getHeight()/2 );
frame.setVisible( true );
private JMenuBar createMenuBar () {
JMenuBar bar;
JMenu menu, submenu;
JMenuItem item;
bar = new JMenuBar();
menu = new JMenu ( "Menu" );
bar.add ( menu );
item = new JMenuItem( "Item" );
item.addMouseListener( new MouseHandler() );
menu.add( item );
submenu = new JMenu ( "SubMenu" );
submenu.addMouseListener( new MouseHandler() );
menu.add ( submenu );
item = new JMenuItem( "SubItem" );
item.addMouseListener( new MouseHandler() );
submenu.add( item );
return bar;
private JPopupMenu createPopupMenu() {
JPopupMenu popup = new JPopupMenu();
popup.add( "Popup" );
return popup;
private class MouseHandler extends MouseAdapter {
private void checkPopup( MouseEvent e ) {
if( e.isPopupTrigger() ) {
popup.show( e.getComponent(), e.getX(), e.getY() );
public void mousePressed( MouseEvent e ) {
checkPopup( e );
public void mouseReleased( MouseEvent e ) {
checkPopup( e );
public void mouseClicked( MouseEvent e ) {
checkPopup( e );
private class WindowHandler extends WindowAdapter {
public void windowClosing( WindowEvent e ) {
System.exit( 0 );
I've looked there. If there is help there for popping up a context menu on top of another menu I can't find it. Could you please be a bit more specific? Did you try the sample code?
Similar Messages
-
How to show more than one record at a form-like style report?
Hi All,
I developed a form-like style report
I want it to show more than one record at once (At the same page)
I tried that by setting the value to "Maximum records per page" property for the repeating frame to 10
but when I close the property palete and open it agian the value is returned to 1 !!!
how to show more than one record at the same page?????
Thank uHi,
there's perhaps another property like "page protect". If than 2 records didn't fit at one page there's a page break. Or is there any object inside the repeating frame with page-break properties? Sorry .. it's like looking into a chrystal ball ...
Regards
Rainer -
How to show custom error message in WebADI Excel template?
Hi,
I've created a custom Web ADI integrator and associated it with a 'Procedure' based custom interface.
WebADI Interface API Returns is set to "Error Message".
I'm using raise_application_error(-20001, "Actual Error Message") for invalid rows,but custom error message from PL/SQL is not populated on the excel template.
Instead it is showing "SQL exception occurred during PL/SQL upload".
Am I missing anything? How to show custom error message from Pl/SQL procedure to WebADI Excel template?
TIA
NarasimhaThe custom API errors are visible in the BNE log but not on the Excel.
BNE Log=>
12/10/13 2:52 PM Web ADI Upload Job 13008 ERROR BnePLSQLUpload.doUpload: Exception while uploading to PL/SQL API. Error Code: 20001, Message: ORA-20001: -Please enter CONTAINER_ID - Enter PO_NO -
ORA-06512: at "APPS.XXPO_COSTFACTS_WEBADI_PKG", line 264
ORA-06512: at line 1
12/10/13 2:52 PM Web ADI Upload Job 13008 ERROR BnePLSQLUpload.doUpload: Stack trace: java.sql.SQLException: ORA-20001: -Please enter CONTAINER_ID - Enter PO_NO -
ORA-06512: at "APPS.XXPO_COSTFACTS_WEBADI_PKG", line 264
ORA-06512: at line 1
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:202)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1005)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1307)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3449)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3550)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4710)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1374)
at oracle.apps.bne.integrator.upload.BnePLSQLUpload.doUpload(BnePLSQLUpload.java:284)
at oracle.apps.bne.integrator.upload.BneSAXUploader.processDeepestLevel(BneSAXUploader.java:2346)
at oracle.apps.bne.integrator.upload.BneSAXUploader.startElement(BneSAXUploader.java:1182)
at oracle.xml.parser.v2.XMLContentHandler.startElement(XMLContentHandler.java:181)
at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1288)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:336)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:303)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:234)
at oracle.apps.bne.integrator.upload.BneUploader.processUpload(BneUploader.java:301)
at oracle.apps.bne.integrator.upload.BneAbstractUploader.processUpload(BneAbstractUploader.java:114)
at oracle.apps.bne.integrator.upload.async.BneAsyncUploadThread.run(BneAsyncUploadThread.java:140)
12/10/13 2:52 PM AJPRequestHandler-HTTPThreadGroup-5 WARNING BneOracleWebAppsContext.getTimeZone CLIENT_TIMEZONE_ID has not been set
12/10/13 2:52 PM AJPRequestHandler-HTTPThreadGroup-5 ERROR BneOracleWebAppsContext.getExtraJDBCConnection recieved the same connection as the base connection. There may be transaction problems.
How to show the same error in the excel template?
Here is the package:
CREATE OR REPLACE PACKAGE BODY APPS.XXPO_COSTFACTS_WEBADI_PKG
AS
PROCEDURE upload_data (
P_CONTAINER_ID IN VARCHAR2
, P_SAIL_DATE IN DATE
, P_PO_NO IN VARCHAR2
) IS
--declare
lv_err_msg VARCHAR2(240);
lf_err_flag NUMBER := 0;
ln_temp NUMBER;
BEGIN
--------------------- checking for mandatory parameters---------------------------
IF (P_CONTAINER_ID IS NULL) THEN
lf_err_flag := 1;
lv_err_msg := lv_err_msg||'-'||'Please enter CONTAINER_ID - ';
END IF;
-------------Validation for Sail Date Format----------------------
IF (P_SAIL_DATE IS NULL) THEN
lf_err_flag := 1;
lv_err_msg := lv_err_msg || ' ' || 'Enter Sail Date - ';
ELSE
BEGIN
SELECT 1
INTO ln_temp
FROM DUAL
WHERE P_SAIL_DATE = TO_DATE (TO_CHAR (P_SAIL_DATE, 'DD-MON-YYYY'), 'DD-MM-YYYY');
EXCEPTION
WHEN NO_DATA_FOUND THEN
lf_err_flag := 1;
lv_err_msg := lv_err_msg || ' Enter Sail date in DD-MON-YYYY Format';
WHEN OTHERS THEN
lf_err_flag := 1;
lv_err_msg := lv_err_msg || ' Enter Sail date in DD-MON-YYYY Format'|| SQLERRM;
END;
END IF;
-------------Validation for PO_Number----------------------
IF (P_PO_NO IS NULL) THEN
lf_err_flag := 1;
lv_err_msg := lv_err_msg || ' ' || 'Enter PO_NO - ';
ELSE
BEGIN
SELECT count(1)
INTO ln_temp
FROM PO_HEADERS
WHERE Attribute4 = P_PO_NO;
EXCEPTION
WHEN NO_DATA_FOUND THEN
lf_err_flag := 1;
lv_err_msg := lv_err_msg || ' No Oracle PO for Biceps PO#'||P_PO_NO;
WHEN OTHERS THEN
lf_err_flag := 1;
lv_err_msg := lv_err_msg || ' Error getting the Oracle PO for Bicpes PO#'||P_PO_NO||' Error-' || SQLERRM;
END;
END IF;
-----------------------Insert Record----------------------------
IF lv_err_msg is NULL THEN
BEGIN
INSERT
INTO XXP2P_HW_COST_FACTORS_STG
CONTAINER_ID
,SAIL_DATE
,PO_NO
, ERROR_FLAG
, ERROR_MSG
,CREATED_BY
,CREATION_DATE
,LAST_UPDATED_BY
,LAST_UPDATE_DATE
,LAST_UPDATE_LOGIN
VALUES
P_CONTAINER_ID
,P_SAIL_DATE
,P_PO_NO
,lf_err_flag
,lv_err_msg
,FND_GLOBAL.USER_ID
, trunc (sysdate)
,FND_GLOBAL.USER_ID
, trunc (sysdate)
,FND_GLOBAL.LOGIN_ID
-- commit;
DBMS_OUTPUT.put_line
'-' || 'After ap_invoices_interface'
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
lf_err_flag := 1;
lv_err_msg := lv_err_msg || ' ' || 'error loading CONTAINER_ID-' || P_CONTAINER_ID || SQLERRM;
raise_application_error(-20001, lv_err_msg);
END;
ELSE
raise_application_error(-20001, lv_err_msg);
END IF;
END upload_data;
END XXPO_COSTFACTS_WEBADI_PKG; -
How to show modal window without popup in a web page using javascript
Hi,
How to show modal window without popup in a web page using javascript, means when the modalwindow is opened it should not ask for popup blocker alert......
pls help me.....Thanx for ur reply,
Actually the senario is when i click on a button, another jsp page should be displayed in a modal window without popup, but the functions alert() and confirm() will not accept the url path of the another jsp page... -
How to show "ALL" Values by default in Page Drop-Down Lists in Pivot Tables
Hi Everyone,
Iam stuck with 1 problem please can any 1 help me if u know the solution.
Here is my problem:
How to show "ALL" Values by default in Page Drop-Down Lists in Oracle BI Pivot Tables?
For example, if you place Region in the pages area, a Region drop-down list allows the user to select a particular region, and see the data for only that region, rather than seeing all the Regions,But by default its not showing "ALL" option in the drop down list ,rather than doing that its showing result for only 1 region by default.
And an other problem with this pages area is, if we palce the multiple attributes in the Pages area in the pivot table, the (Fields)result is showing in vertically, the attributes 1 by 1(Every attribute in a new line) ,rather than showing like that, is there any way to show the results in horizantally?(We want to have it as a seperate drop drown list for every field horizantally not as a concatenated list).Thanks Nikhil. But I am fetching the values from the LOVCache.java.
I am using <af:selectManyChoice>. Is there any way I can use LOVCache.java value for selecting default values instead of hard coding?
I mean to say can I write
unselectedLabel="#{LOVCache.entityTypeSelectionList.anyValue}"
where LOVCache.entityTypeSelectionList is used to populate the drop down box.
Regards,
Aseet -
How to show all view tab (Main Report and all Sub Report) in Visual FoxPro 9
I use ActiveX from Crystal Report Developer XI for viewer in Visual FoxPro 9 and I already know how to show Main Report by using command:
oRptRun=createobject("CrystalRuntime.Application")
oRptView=thisform.oleRptViewer
oRptOpen=oRptRun.OpenReport('MyReport.rpt')
oRptView.ReportSource=oRptOpen
oRptView.ViewReport
Inside the MyReport.rpt there is two subreport name :
1. MySubReport1
2. MySubReport2
My Question is :
How to show all view tab (Main Report and all Sub Report) at the 1st time we call ViewReport?
I try to using command :
oRptRun=createobject("CrystalRuntime.Application")
oRptView=thisform.oleRptViewer
oRptOpen=oRptRun.OpenReport('MyReport.rpt')
oRptSub=oRptOpen.OpenSubreport("MySubReport1")
oRptSub=oRptOpen.OpenSubreport("MySubReport2")
oRptView.ReportSource=oRptOpen
oRptView.ViewReport
but only show Main Report (view tab name : Preview)?
Did I miss any command before I call oRptView.ViewReport?Your right, there is only one tab to view the report.
To open the subreports you will need to click on them in the main report. I don't know of a way to open them programmatically like you are doing here
http://diamond.businessobjects.com/robhorne</a> -
How to show all the search result in a report page
I have a report page which the user can enter first or last name to find the matched employees. The current report only show maximum of 15 matched results. How to show all of them in one page if more than 15.
Also, the employee name on the report is a link, how to make the link to be conditional. ( I mean it can be a link or not based on another column)
Thanks.
JenHi, you can change the number of rows on the report definition page (15 is the default value)- that's also where you can change pagination and max. number of rows etc.
About the second question - you will have to use Case or Decode in your report query and have the value as link or not based on the condition column, something like:
Select Decode(condition_column, 'link_value', '<a href="f?p=YOUR_APP:PAGE_TO_LINK_TO:' || :SESSION || ':::::">display_column</a>' , display_column) From .....
Hope this helps. -
How to show filtered parameter in dropdown form in crm 2013
Hi,
I want to create a report in crm 2013. When I report is run then filtered parameter fill record from database in dropdown form and when I select record from dropdown then generate report of selected record. Please tell me how to show record in filtered parameter
from database within crm. In below image paramter is text field. How to auto fill filtered parameter from database.Hi Aamir,
Check if the below link helps!!
https://social.microsoft.com/Forums/en-US/ad8a3bc2-dbec-4597-adfd-8bd6c34f5e9a/drop-down-parameter-in-crm-2011-custom-report?forum=crm
Thanks,
Prasad
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question. -
How to show GL Account Balance amount in Ledger Report.
Hi,
We need to show General Ledger balance based transaction wise how we can show GL Account Balance where it will store which table and which filed.here below query is there here only I need to add balance after Total please guide me.
select T0.transid,T0.number,T2.seriesname,T0.refdate,T0.baseref,T1.account,T1.shortname,T3.acctname,T1.credit,T1.debit,T1.credit+T1.debit as Total,T3.CurrTotal,T0.ref1,T0.ref2,T1.ref3line,T0.memo,T1.paymentref, T1.ProfitCode, T1.OcrCode2, T1.OcrCode3,
T1.OcrCode4, T1.OcrCode5,T1.U_Naration as RowNarration,T0.U_naration as DocumentNarration from OJDT T0
inner join jdt1 T1 on T0.transid=T1.transid
inner join nnm1 T2 on T2.series=T0.series
inner join oact T3 on T3.acctcode=T1.account
where T3.acctcode='1030101003'
Regds,
Sampathhi sampath,
I giving u fair idea how to show g/l account balance
There is a field in JDT1 - journal entry rows - JDT1.DebCred which is indicator when g/l account
is debited / credited,it is filled with value D or C.
You can add Case syntax in existing query with condition JDT1.DebCred = 'D' then
JDT1.Debit + Opening/Closing balance and if JDT1.DebCred = 'C' then
JDT1.Credit - Opening/Closing balance.
It requires much time & effort to build this query.
Edited by: Jeyakanthan A on May 14, 2009 3:54 PM -
How to show delivery date in Bex Analyzer
Hi Gurus!
I have to create a report in logistic scenario and my client wants that the report shows a column with the "Scheduled delivery date". I don't know how to show it in a column because in my KF structure, I can't put just this time characteristic.
Does anybody know how can I solve it?
Many thanks!Hi,
Create a Formula Variable on Scheduled DeliveryDate with processing as replacement path, replace variable with InfoObject, replace with Key and use it in the new formula in the columns.
in this way query designer will accept you to use the char as in column,
hope it helps you.
Regards
Reddy A -
How to show alv report in tree structure
hi all,
how to show data or create a alv report in tree structure.
thanks in advance.
HarshaHi Harsha,
Its done using FM 'RS_TREE_CONSTRUCT'
and FM for displaying the tree: 'RS_TREE_LIST_DISPLAY'
Thanks
Shrila -
How to show deductions in ap invoice
Hi all,
how to show deductions in ap invoice
Scenario is:
We raise A/p Invoice for services provided by vendor,
ex:When the bill amount as 1000.00.
Invoice will be raised for 800.00, and paid, but
Remaining 200.00 will be deducted from the bill as Redemtion deposit (100.00), work control tax(100.00)
and this will be paid to vendor after certain period of time.
We want to show the above scenario in A/P invoice.
any idea how to work on the issue.
regards,
KumarHi Kumar,
This scenerio can be handled by making use of the Freight Screen, In freight create the Freight Items, Redemption Deposit and WCT. Map the respective GL accounts in the AP Column in Freight Window. When you are creating the invoice u can enter the respective amounts in the Freight window with a negative sign.
This should solve your issue.
Regards,
Reno -
HOW TO SHOW ONE PAGE AT A TIME
Does anybody have a clue how to show one page at a time? I clicked Facing Pages in the Inspector and 2 columns of pages showed up. Now, I can't get it back to just one page showing up at a time. There must be a fix, but I don't' want to spend days on this. Many thanks.
Frank,
At the bottom left of the page, click on the zoom percentage, then select One-up from the menu.
-Dennis -
How to show a picture both on client and server at the same time (X11?)
Hi Guys
I want show a picture on my client as well as on the server(in another location) at the same time, pretty much like showing something both on laptop and on a projector. Assume I have a picture sssss.jpg on the server A1, if I want to open that picture to my client, I can simply to do the following from client A2:
xhost A1
telnet to and login A1
setenv DISPLAY "ipaddress of A2":0.0
Anyone can direct me how to show picture the client that I am sitting at an also show on the server at the same time?
ThanksVNC would let you do that. With a shared connection, both machines could run a VNC client to the same session.
Darren -
How to "Show options" in every window at once?
In many Illustrator windows, useful tools and settings are hidden by default unless you open the flyout menu in the top corner and choose "show options".
I always want to "show options", everywhere, all the time.
Whenever I come to use or help someone with Illustrator on a new machine, new user account, new install, or after trashing preferences for any reason, it's necessary to click through every window showing its options. It's a nuisance and I always forget some windows, which means when I then use that window I'll be puzzled that a tool I'm used to isn't where I remember it being.
Is there any way to "Show options" everything at once? Or set it to never hide options anywhere? I've been right through Preferences and found nothing that looks relevant.
It'd be really useful for the above situations and also for helping beginners ("Let's see, is 'Scale strokes and effects' ticked in the transform window?", "There is no 'Scale strokes and effects' in the transform window!", "What, are you sure?" etc etc...)I think you're misunderstanding the question, I'm asking how to open out all the options in every window.
Your answer is how to save it as a custom workspace after I've shown options. It saves them as being open by default, so that isn't a problem. A custom workspace might be useful as a backup or to transfer to another computer but I often want different workspaces on different computers (e.g. because of screen size differences). I just want to know how to "show options" in every window at once.
My question is 'How to "Show options" in every window at once?'
Maybe you are looking for
-
Using folders to sort iTunes by location of files
I recently got an iTunes Shuffle and like it. I like iTunes but am extremely disappointed with a few glaring problems with it. 1. There is no way to set up a sort or playlist based on location; 2. Any other sort or criteria for a playlist mixes music
-
Org Structure - "No attribute found for scenario BBP"
SRM 7.0 Extended Classic Scenario Hi, On the check tab for the Central Person (SRM 7.0 shows CP instead of BP in org structure) I have the message "No attribute found for scenario BBP". This is SAP message number 5AT103 Transaction BBP_BP_OM_INTEGRA
-
I am getting an extra blank line in my table rows using the following statement: <?for-each-group@column:TC_CELL;ITEM_DATE?> <?for-each-group:current-group();PAY_TYPE?> <?if: PAY_TYPE = R?> <?if: sum(current-group()//HOURS)!= 0?> <?sum(current-gr
-
Blackberry 8330 keyboard doesn't work for the 2nd time
Hi, this is the second time that this has happened to me. The first time, I had finished a text message, and left it on my bed, only to come back an hour later, and the entire keyboard didn't work. The only thing that worked was the trackball, but it
-
hi all, I am using ucm10gr3 plus wc11.1.1.3. I checked in a content with both Primary File and Alternate File , I used webcenter search taskflow to search word in alternate file, but search result show me the Primary File, how to resolve this issue?