JPopupMenu behavior in an applet
Hi all,
When I click on an applet a JPopupMenu appears.
The trouble is when I don't want to click on a JMenuItem : if I just want to return to the web page content by clicking on it the JPopupMenu doesn't hide.
A solution is to click in an other area of the applet but mine is very small as its purpose is to provide a popup menu.
I could provide a JMenuItem to hide the JPopupMenu but I don't find this solution very elegant.
Anyone have an idea of how to resolve this problem, without hacking with javascript which would give me other problems of compatibility between browsers...
Regards,
Jean-Hugues de Raigniac
Try adding a focus listener to the JPopupMenu. I am not positive on this but see if the popup menu is getting a focusLost event when you click outside if it ( even outside of the applet ).
Bryan
Similar Messages
-
Has anyone experienced this: I'm using a JPopupMenu on a table, if I right-click on a cell in the table the menu will appear. If I don't choose an item from the menu at that time and move to another cell with the menu still up and right-click on that cell, the menu disappears and it doesn't reappear at the new cell. I hope that wasn't too confusing.
Nopeimport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test extends JFrame {
JPopupMenu jpm = new JPopupMenu();
JTable jt;
public Test() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container content = getContentPane();
String[] menu = {"Item 1","Item 2","Item 3"};
for (int i=0; i<menu.length; i++) jpm.add(new JMenuItem(menu));
String[] head = {"Zero","One","Two","Three","Four"};
String[][] data = new String[20][head.length];
for (int i=0; i<data.length; i++) {
for (int j=0; j<head.length; j++) data[i][j]="R"+i+"-C"+j;
jt = new JTable(data, head);
content.add(new JScrollPane(jt), BorderLayout.CENTER);
jt.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent me) {
if (me.isPopupTrigger()) jpm.show(jt,me.getX(),me.getY());
setSize(300,300);
setVisible(true);
public static void main(String args[]) { new Test(); } -
Hi all!
I have a problem with the JPopupMenu behavior. My popup menu has a submenu:
JPopupMenu p = new JPopupMenu();
JMenu menu = new JMenu();
menu.add(new JMenuItem("1"));
menu.add(new JMenuItem("2"));
p.add(menu);
p.setVisible(true);
It works, but it doesn't have the 'normal' menu behavior, like the ones in a JMenuBar. I mean when I click on the submenu, the components don't popup. Is there a way to change this with a specific method ?
Thanks!Hello
Try this:
JTextArea text = new JTextArea(10,20);
JMenu menu = new JMenu("Menu");
JPopupMenu popup = new JPopupMenu();
JMenuItem mnitm1 = JMenuItem("1");
JMenuItem mnitm2 = JMenuItem("2");
menu.add(mnitm1);
menu.add(mnitm2);
popup.add(menu);
// add mouse listener to pop up menu
MouseListener popuplistener = new popupListener();
text.addMouseListener(popuplistener);
class popupListener extends MouseAdapter {
public void mousePressed(MouseEvent e) {
showPopup(e);
try{
}catch(Exception ex){
public void mouseReleased(MouseEvent e) {
showPopup(e);
private void showPopup(MouseEvent e) {
if (e.isPopupTrigger()) {
popup.show(e.getComponent(),
e.getX(), e.getY());
This will work!!!!
Rana -
I have an applet hosted in a webserver and since I installed Java 6 update 24, a window is shown asking for Network Credentials every time I open the page.
If I access it from a computer with an older Java version, it runs the applet without asking the credentials.
I'm using integrated authentication so, I don't want to ask any credentials as the user is already authenticated by the OS.
Does anyone can help me?i found the Bug listed for this issue, but they claim the fix mentioned in this thread doesn't fix the problem. yet for most if not all of us... it does:
Bug 6936012: In Microsoft Internet Explorer Java Plug-In re-challenges for authentication
Bug Attributes
Type B - Defect Fixed in Product Version
Severity See FR
Status 3-Accepted
Created 18-Mar-2010
Updated 27-Jul-2011
Product Source Sun
Related Products
Fix Request Attributes:
Fix Request # 6936012/
Target
Customer Status 3-Accepted
Severity 3-Medium
Duplicate Of
Committed Version
Fixed Version
Integrated Version
Verified Version
Last Updated 2011-07-27 00:00:00 GMT+00:00
Description:
FULL PRODUCT VERSION :
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
For various versions of Microsoft Internet Explorer (MSIE), the Java Plug-In (various versions of recent Java 6 Updates, including 18) re-challenges for authentication when an applet makes an HTTP(S) request for an authenticated resource from a web site and realm for which the browser session is already authenticated. [This web site is the source of the applet as well.] This occurs despite having checked the "Remember my password" checkbox in the browser authentication dialog.
We have had numerous customer complaints about this with MSIE 6, 7, and 8. Internally this has only been reproduced with MSIE 7 and HTTPS.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Write an applet that makes an HTTP(S) request for an authenticated resource from a web site and realm for which the browser session is already authenticated. Test the applet in various MSIE versions with HTTP and HTTPS, checking the "Remember my password" checkbox in the browser authentication dialog.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The applet should re-use the authentication credentials already established by the browser.
ACTUAL -
The applet re-challenges for authentication -- causing great user annoyance and frustration.
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
This works fine in Firefox, but that's not acceptable to many customers.
This reportedly occurs irrespective of whether the next generation plug-in is enabled or not.
Date Modified 2010-03-18 00:00:00 GMT+00:00
Back to top -
Hi,
I need this applet as a class that extends JPanel, I will be very very thankful to you if any one kindly change this Applet code into a class that extends JApplet.
I will be very thankful to you if some one can reserve few minutes & do this favor early.
Thanks a lot for any help.
My Pong Code
import java.applet.*;
import java.awt.*;
import java.io.*;
import java.awt.event.*;
public class Class1 extends Applet implements Runnable
{ private final int APPLET_WIDTH = 900;
private final int APPLET_HEIGHT = 600;
private int px = 15;
private final int py = 560;
private final int ph = 10;
private final int pw = 75;
private int old_px = px;
private int bx = 450;
private int by = 15;
private final int bh = 20;
private final int bw = 20;
private int move_x = 2;
private int move_y = 2;
private boolean done = false;
Thread t;
private final int delay = 25;
public void init()
{ setBackground(Color.black);
setSize(APPLET_WIDTH, APPLET_HEIGHT);
requestFocus();
addKeyListener(new DirectionKeyListener());
(t = new Thread(this)).start();
public void run() {
try { while((t == Thread.currentThread()) && (done == false)) {
if ((bx < 15) || (bx > APPLET_WIDTH-30)) move_x = -move_x; if ((by < 15) || ((by > APPLET_HEIGHT-60)&& ((px<=bx)&&(bx<=px+pw))))
move_y = -move_y;
if (by > APPLET_HEIGHT)
done = true;
bx = bx + move_x;
by = by + move_y; repaint();
t.sleep(delay);
catch(Exception e) {}
}//end run
/*public void move_paddle(int amount)
old_px = px;
//if (amount > 0)
//if (px <= APPLET_WIDTH-15)
px = px + amount;
//else if (amount < 0)
// if (px >= 15)
px = px + amount;
public void paint(Graphics page)
// page.setColor(Color.black);
// page.drawRect(old_px, py, pw, ph);
page.setColor(Color.blue);
page.drawRect(px, py, pw, ph);
page.setColor(Color.white);
page.drawOval(bx, by, bw, bh);
if ((done == true) && (by > APPLET_HEIGHT))
page.drawString("LOSER!!!", APPLET_WIDTH/2, APPLET_HEIGHT/2);
else if (done == true)
page.drawString("Game Over, Man!", APPLET_WIDTH/2-10, APPLET_HEIGHT/2);
private class DirectionKeyListener implements KeyListener
public void keyPressed (KeyEvent event)
switch (event.getKeyCode())
case KeyEvent.VK_LEFT:
old_px = px;
if (px >=15)
px -=10;
break;
case KeyEvent.VK_RIGHT:
old_px = px;
if (px+pw <= APPLET_WIDTH-15)
px += 10;
break;
case KeyEvent.VK_Q:
done = true;
default:
} //end switch
repaint();
}//end keyPressed
public void keyTyped (KeyEvent event)
public void keyReleased (KeyEvent event)
} //end class
}thank you sir for your advice.
Its not like that I without any attempt, just past code here & asked for its conversion. I spent about 5 hours on it, can say spoil whole day but to no avail. You then just guide me, give some hint so that I do it. I will most probably wanted to do it by myself but asked for help when was just disappointed.
I try to put all init() in default constructor of identical copy of this applet that extends JPanel. Problem.....ball tend to fell but pad not moving. Also out out was not getting ant color input. That was like my best effort.....other tried that I found by search like just do nothing only extend panel OR frame in spite of applet, start applet from within main of another class.... these are few I remember what I tried.
I will be very very thankful to you if you can help/guide me how can I do it. Behavior of the Applet is like a normal PONG game with on pad controlled by arrow keys, & one ball colliding with walls of boundary & falling down.
Thanks a lot again for your attention & time. -
Hi all,
I know many have posted about the different version of java plugin will cause some strange behavior of an applet in loading. In my case, it can't load at all. (with plugin version 1.4.1)
SO anyone find the final solution?
thanks in advanceSorry, not here to offer a solution but to report a similar problem. But in my case, the version is 1.3.0_03 and the error message is "PrintApplet.class not found." which appeared at the foot of the browser. (using WINDOWS 98; I/E 5.5) Can anyone help?
-
Looking for Image Button Applet
I'm looking for a simple image button applet (normal state, mouse-over and mouse-click) which can refer to a HTML or start a Javascript function. Can anyone help?
KippieHi,
This is the source code. I don't quite understand what I should do with the tokens. I hope this is allright. Thanks for your help
Kippie.
import java.net.URL;
import java.awt.Color;
import java.util.Vector;
import java.util.Enumeration;
import java.util.StringTokenizer;
import java.applet.Applet;
import java.applet.AudioClip;
Program Name: ImageURLButtonBar
Author: Paul Whitelock
Version: 1.1
Copyright: (c) 1997 by Paul Whitelock and Modern Minds, Inc.
Requires: ImageURLButtonBar.class
ButtonBar.class
ButtonBarObserver.class (Interface definition)
ButtonRegion.class
ButtonAnimate.class
Modifications: v1.01 (15 April 97)
* Added "sticky" button behavior (controlled
by applet "stick" parameter)
v1.03 (25 June 97)
* Added applet parameter "useCodeBase". If useCodeBase
is true, then image file locations will be based on the directory
in which the Java class files are located. If useCodeBase is false, then
the locations will be based on the HTML directory. Note that audio
file locations are always based on the Java directory. The default
for useCodeBase is false (use HTML directory for base).
* The "stick" parameter will now accept a button number in
addition to the value of "true" or "false". If a button number
is specified, then that button will be "stuck" down
when the button bar initializes.
* Added the capability of loading multiple URLs for each button
with an optional target for each URL.
v1.1 (25 September 97)
* Added "baseBrighten" and "baseBrightenTint" parameters to control
highlighting for base button bar.
* Added "mouseOverBrighten" and "moBrightenTint" parameters to control
highlighting for base button bar.
* Added "mdBrightenTint" and "mdBrightenAll" parameters to control
highlighting for base button bar. Previous versions of the applet
supported "mouseDownBrighten," but only if button borders were not
drawn for the button-down button bar (the "mdBrightenAll" can be set
to "true" to override the this default behavior).
* An "appletBGColor" parameter has been added to set the
applet background color. The applet background color is
sometimes visible during scrolling or during a page repaint.
NOTE: This source code was composed using Microsoft Visual J++
with tab stops of 4. Text may not be formatted correctly
if another editor is used.
******************************** PARAMETERS ********************************
Applet Parm ButtonBar Class Parm Default Value
================== ======================= ==================
appletBGColor
disableBadURL true
mouseEnterAudio null (audio disabled)
mouseClickAudio null (audio disabled)
buttonDownAudio null (audio disabled)
stick false
* useCodeBase base false (i.e., use getDocumentBase())
orient barHorizontal horizontal if applet width > height
base baseBarName none - parameter REQUIRED
mouseOver mouseOverBarName null
mouseOver2 mouseOverBar2Name null
mouseDown mouseDownBarName null
mouseDownOver mouseDownOverBarName null
buttonsDisabled buttonsDisabledBarName null
background backgroundImageName null
barXPos barXBackgroundPos 0
barYPos barYBackgroundPos 0
buttonBorders drawButtonBorders ButtonBar.BORDERS_NONE
borderColorTL borderColorTopLeft null (Color.white if error)
borderColorBR borderColorBottomRight null (Color.gray if error)
borderIntensity borderIntensityPercent 50 (used only if borders)
borderSize buttonBorderSize 1 (used only if borders)
downShift downShift false
downShiftAmt downShiftAmt buttonBorderSize
baseBrighten baseBrightenPct
baseBrightenTint baseBrightenTint
mouseOverBrighten mouseOverBrightenPct
moBrightenTint mouseOverBrightenTint
mouseDownBrighten mouseDownBrightenPct
mdBrightenTint mouseDownBrightenTint
mdBrightenAll mouseDownBrightenAll
buttonsDisabledDim buttonsDisabledDimPct 25 (used only if no buttonsDisabled)
grayBarBrighten grayBarBrighten 0
frameRate frameRate 150 (used only if mouseOver2)
* If useCodeBase is true, then all file locations are based on the Java class file
directory (i.e., use getCodeBase()).
public class ImageURLButtonBar extends Applet implements ButtonBarObserver {
// Instance Variables
ButtonBar buttonBar;
Vector buttonURL = new Vector(10, 10);
Vector buttonURLTarget = new Vector(10, 10);
Vector buttonDescription = new Vector(10, 10);
AudioClip mouseEnterAudio = null;
AudioClip mouseClickAudio = null;
AudioClip buttonDownAudio = null;
// Applet Initialization
public void init() {
// =================================================================
// Applet ImageURLButtonBar specific parameters
// =================================================================
// appletBGColor
// Set applet background color
String parm = getParameter("appletBGColor");
if (parm != null) {
try {
setBackground(new Color(Integer.parseInt(parm, 16)));
catch (Exception e) {
reportError("appletBGColor");
// disableBadURL
// If true, then any button with an invalid URL will be disabled
parm = getParameter("disableBadURL");
boolean disableBadURL;
if (parm == null || !parm.equals("false")) disableBadURL = true;
else disableBadURL = false;
// mouseEnterAudio
// Sound to play each time the mouse enters any of the buttons
parm = getParameter("mouseEnterAudio");
if (parm != null) {
mouseEnterAudio = getAudioClip(getCodeBase(), parm);
if (mouseEnterAudio == null) reportError("Can't load " + parm);
// mouseClickAudio
// Sound to play each time a mouse down click occurs in a button
parm = getParameter("mouseClickAudio");
if (parm != null) {
mouseClickAudio = getAudioClip(getCodeBase(), parm);
if (mouseClickAudio == null) reportError("Can't load " + parm);
// buttonDownAudio
// Sound to play each time a mouse up occurs in a button (i.e, the
// button has be toggled through it's "down" position)
parm = getParameter("buttonDownAudio");
if (parm != null) {
buttonDownAudio = getAudioClip(getCodeBase(), parm);
if (buttonDownAudio == null) reportError("Can't load " + parm);
// stickyBar
// If the "stick" applet parameter is "true", then buttons will stay
// "stuck" in the down position until another button is clicked.
// If the "stick" applet parameter is the number of a button in the
// button bar, then that button will be "stuck" down when the
// button bar initializes.
int stickyBar = -1;
parm = getParameter("stick");
if (parm != null && !parm.toLowerCase().equals("false")) {
try {
stickyBar = Integer.parseInt(parm);
catch (Exception e) {
stickyBar = 0;
// =================================================================
// Class ButtonBar specific parameters
// =================================================================
// orient (barHorizontal)
// If this parameter = 'h' then the button bar is horizontal
// If this parameter = 'v' then the button bar is vertical
// If this parameter is not specified, then the button bar is
// horizontal if the applet width is greater than the applet height
boolean horizontal;
parm = getParameter("orient");
if (parm == null) horizontal = size().width > size().height;
else horizontal = parm.equals("h") ? true : false;
// base (baseBarName)
// The base image file for the buttons. This is the only image
// file that MUST be specified.
String baseBar = getParameter("base");
if (baseBar == null) {
reportError("Parameter 'base' REQUIRED!");
return;
// barXPos (barXBackgroundPos)
// barYPos (barYBackgroundPos)
// If a background image is specified then these to parameters
// represent the top-left corner location where the button bar
// should be placed on the background
int barXPos = 0, barYPos = 0;
try {
parm = getParameter("barXPos");
if (parm != null) barXPos = Integer.parseInt(parm);
parm = getParameter("barYPos");
if (parm != null) barYPos = Integer.parseInt(parm);
catch (Exception e) {
reportError("barXPos or barYPos");
barXPos = barYPos = 0;
// buttonBorders (drawButtonBorders)
// "none" = do not draw any button borders
// "all" = draw borders around all button bar buttons
// "base" = draw borders only around buttons on base button bar
// "other" = draw borders around all button bar buttons EXCEPT base button bar buttons
parm = getParameter("buttonBorders");
int drawButtonBorders = ButtonBar.BORDERS_NONE;
if (parm != null) {
if (parm.equals("base")) drawButtonBorders = ButtonBar.BORDERS_BASE;
else if (parm.equals("other")) drawButtonBorders = ButtonBar.BORDERS_OTHER;
else if (parm.equals("all")) drawButtonBorders = ButtonBar.BORDERS_ALL;
// borderColorTL (borderColorTopLeft)
// borderColorBR (borderColorBottomRight)
// Normally, borders are drawn around buttons by lightening or darkening
// the image in the border region. A specific color can be used instead
// for the top and left borders and/or the bottom and right borders. The
// value specified for either of these two parameters should be a hexadecimal
// number (e.g., "FF0000" for red, "888888" for medium gray, etc.).
Color borderColorTopLeft = null;
Color borderColorBottomRight = null;
try {
parm = getParameter("borderColorTL");
if (parm != null) borderColorTopLeft = new Color(Integer.parseInt(parm, 16));
parm = getParameter("borderColorBR");
if (parm != null) borderColorBottomRight = new Color(Integer.parseInt(parm, 16));
catch (Exception e) {
reportError("borderColorTL or borderColorBR");
borderColorTopLeft = Color.white;
borderColorBottomRight = Color.gray;
// borderIntensity (borderIntensityPercent)
// If borders are drawn for buttons, and if a border color is not specified
// (see above), then the image in the border region will be lightened or
// darkened by this percentage to create the borders.
int borderIntensityPercent = 50;
try {
parm = getParameter("borderIntensity");
if (parm != null) borderIntensityPercent = Integer.parseInt(parm);
catch (Exception e) {
reportError("borderIntensity");
borderIntensityPercent = 50;
// borderSize (buttonBorderSize)
// The size of borders, if borders are specified.
int buttonBorderSize = 1;
try {
parm = getParameter("borderSize");
if (parm != null) buttonBorderSize = Integer.parseInt(parm);
catch (Exception e) {
reportError("borderSize");
// downShift
// If true, then the button image is shift down and right downShiftAmt
// (see below) pixels when the mouse is clicked on the button.
parm = getParameter("downShift");
boolean downShift = (parm == null || !parm.equals("true")) ? false : true;
// downShiftAmt
// If downShift is true, then the button image is shift down and right
// downShiftAmt (see above) pixels when the mouse is clicked on the button.
int downShiftAmt = buttonBorderSize;
try {
parm = getParameter("downShiftAmt");
if (parm != null) downShiftAmt = Integer.parseInt(parm);
catch (Exception e) {
reportError("downShiftAmt");
// baseBrighten (baseBrightenPct)
// The base bar will be lightened by this percentage
int baseBrightenPct = 0;
try {
parm = getParameter("baseBrighten");
if (parm != null) baseBrightenPct = Integer.parseInt(parm);
catch (Exception e) {
reportError("baseBrighten");
// mouseOverBrighten (mouseOverBrightenPct)
// A button will be lightened by this percentage when the mouse
// moves over a button.
int mouseOverBrightenPct = 0;
try {
parm = getParameter("mouseOverBrighten");
if (parm != null) mouseOverBrightenPct = Integer.parseInt(parm);
catch (Exception e) {
reportError("mouseOverBrighten");
// mdBrightenAll (mouseDownBrightenAll)
// A button will be lightened by this percentage when the mouse
// moves over a button.
boolean mouseDownBrightenAll = false;
parm = getParameter("mdBrightenAll");
if (parm != null && parm.charAt(0) == 't') mouseDownBrightenAll = true;
// mouseDownBrighten (mouseDownBrightenPct)
// A button will be lightened by this percentage when it is
// clicked.
int mouseDownBrightenPct = 0;
try {
parm = getParameter("mouseDownBrighten");
if (parm != null) mouseDownBrightenPct = Integer.parseInt(parm);
catch (Exception e) {
reportError("mouseDownBrighten");
// baseBrightenTint (mouseOverBrightenTint)
// moBrightenTint (mouseOverBrightenTint)
// mdBrightenTint (mouseDownBrightenTint)
Color baseBrightenTint = null;
Color mouseOverBrightenTint = null;
Color mouseDownBrightenTint = null;
try {
parm = getParameter("baseBrightenTint");
if (parm != null) baseBrightenTint = new Color(Integer.parseInt(parm, 16));
parm = getParameter("moBrightenTint");
if (parm != null) mouseOverBrightenTint = new Color(Integer.parseInt(parm, 16));
parm = getParameter("mdBrightenTint");
if (parm != null) mouseDownBrightenTint = new Color(Integer.parseInt(parm, 16));
catch (Exception e) {
reportError("baseBrightenTint, moBrightenTint or mdBrightenTint");
// buttonsDisabledDim (buttonsDisabledDimPct)
// If a button is disabled and if there is no buttonsDisabled image,
// then the button will be dimmed by this percentage.
int buttonsDisabledDimPct = 25;
try {
parm = getParameter("buttonsDisabledDim");
if (parm != null) buttonsDisabledDimPct = Integer.parseInt(parm);
catch (Exception e) {
reportError("buttonsDisabledDim");
// grayBarBrighten
// If there is no mouseOver image, then the base image will be used for
// the mouseOver image, and a grayscale version of the base image will
// be used for base button images. This parameter can be used to lighten
// COLORS (not grays) in the image before it is converted to grayscale.
// This can help if the standard conversion produces buttons that are
// too dark.
int grayBarBrighten = 0;
try {
parm = getParameter("grayBarBrighten");
if (parm != null) grayBarBrighten = Integer.parseInt(parm);
catch (Exception e) {
reportError("grayBarBrighten");
// frameRate
// If a mouseOver2 image is specified, then this parameter controls
// how quickly animation will be performed (using mouseOver and mouseOver2
// images) in milliseconds when the mouse is moved over a button.
int frameRate = 150;
try {
parm = getParameter("frameRate");
if (parm != null) frameRate = Integer.parseInt(parm);
catch (Exception e) {
reportError("frameRate");
// =================================================================
// Instantiate the button bar
// =================================================================
try {
// Allow the use of documentBase (default) or codeBase for image file
// base directory.
URL documentBase;
parm = getParameter("useCodeBase");
if (parm == null || parm.equals("false")) documentBase = getDocumentBase();
else documentBase = getCodeBase();
// Create the button bar
buttonBar = new ButtonBar(
horizontal, /* barHorizontal */
documentBase, /* base */
baseBar, /* baseBarName */
getParameter("mouseOver"), /* mouseOverBarName */
getParameter("mouseOver2"), /* mouseOverBar2Name */
getParameter("mouseDown"), /* mouseDownBarName */
getParameter("mouseDownOver"), /* mouseDownOverBarName */
getParameter("buttonsDisabled"),/* buttonsDisabledBarName */
getParameter("background"), /* backgroundImageName */
barXPos, /* barXBackgroundPos */
barYPos, /* barYBackgroundPos */
drawButtonBorders, /* drawButtonBorders */
borderColorTopLeft, /* borderColorTopLeft */
borderColorBottomRight, /* borderColorBottomRight */
borderIntensityPercent, /* borderIntensityPercent */
buttonBorderSize, /* buttonBorderSize */
downShift, /* downShift */
downShiftAmt, /* downShiftAmt */
baseBrightenPct, /* baseBrightenPct */
baseBrightenTint, /* baseBrightenTint */
mouseOverBrightenPct, /* mouseOverBrightenPct */
mouseOverBrightenTint, /* mouseOverBrightenTint */
mouseDownBrightenAll, /* mouseDownBrightenAll */
mouseDownBrightenPct, /* mouseDownBrightenPct */
mouseDownBrightenTint, /* mouseDownBrightenTint */
buttonsDisabledDimPct, /* buttonsDisabledDimPct */
grayBarBrighten, /* grayBarBrighten */
frameRate /* frameRate */
// =================================================================
// Add buttons to the button bar
// =================================================================
ButtonRegion buttonToAdd;
String buttonNbr, urlString;
URL urlForButton;
int nbr = 0;
int buttonStart, buttonSize;
// Initialize button on bar flag (used to determine if at least one button
// was successfully added to the button bar)
boolean buttonOnBar = false;
// This loop will be exited when no more buttons can be found in the HTML
while (true) {
// Construct the prefix for the button parameters
buttonNbr = "button" + ++nbr;
// Find the starting offset and the size of the button
// If null is returned as the starting offset parameter value for the
// button, then all buttons should have been read so the loop can
// be exited.
try {
parm = getParameter(buttonNbr + "Start");
if (parm == null) break;
buttonStart = Integer.parseInt(parm);
buttonSize = Integer.parseInt(getParameter(buttonNbr + "Size"));
catch (Exception e) {
reportError("Button" + nbr + " start or size in error or missing");
buttonStart = 0;
buttonSize = 0;
// Create a ButtonRegion for the button
// The button ID will be set to the number of the button (this will
// be converted to an integer later when a buttonBarEvent is received).
buttonToAdd = new ButtonRegion("" + nbr, buttonStart, buttonSize);
// If the buttons on this button bar are "sticky" buttons, then
// enable "sticky" behavior for this button. The button will always
// "pop-up" whenever another button is clicked.
if (stickyBar >= 0) {
buttonToAdd.stickyButton(true, ButtonRegion.POPUP_ALWAYS, false);
// If the current button number matches the value of stickyBar, then the
// current button should be "stuck" down for its initial state.
if (stickyBar == nbr) buttonToAdd.setStuck(true);
// Try to add the button (i.e., the ButtonRegion) to the buttonBar
if (buttonBar.addButton(buttonToAdd)) {
// Set flag to indicate that at least one button has been added
buttonOnBar = true;
// The button was successfully added, so save the button's description
// (which will be displayed in the status bar) and the target frame
// for the button URL in the appropriate Vector.
buttonDescription.addElement(getParameter(buttonNbr + "Desc"));
buttonURLTarget.addElement(getParameter(buttonNbr + "Target"));
// Try to create a URL for the button.
// If the URL is invalid, then place an error message in the
// buttonURLTarget Vector (this will be used to warn the user
// when the button is clicked). Also, if disableBadURL is true, then
// disable the button.
String theURL;
urlString = getParameter(buttonNbr + "URL");
if (urlString != null) {
Enumeration urls = new StringTokenizer(urlString);
while (urls.hasMoreElements()) {
theURL = (String)urls.nextElement();
try {
urlForButton = new URL(theURL);
catch (Exception e) {
try {
urlForButton = new URL(getDocumentBase(), theURL);
catch (Exception e2) {
reportError("Button" + nbr + " has invalid URL");
buttonURLTarget.setElementAt("Invalid URL", nbr - 1);
urlString = null;
break;
else {
reportError("Button" + nbr + " has no URL");
buttonURLTarget.setElementAt("No URL", nbr - 1);
buttonURL.addElement(urlString);
// Remove any unused elements in the Vectors
buttonURL.trimToSize();
buttonURLTarget.trimToSize();
buttonDescription.trimToSize();
// If no buttons were added, throw exception
if (!buttonOnBar) throw new IllegalArgumentException("No buttons on bar");
// Let the buttonBar know that all buttons have been defined. This is
// really only necessary if downShift is true, but it won't hurt calling
// the method in either case.
buttonBar.allButtonsDefined();
// Add the applet as an observer so that the applet will be notified
// when button events occur.
buttonBar.addButtonObserver(this);
// Enable the button bar now that all buttons have been defined.
// (the buttonBar is disabled when it is created and must be
// specifically enabled).
buttonBar.enable(true);
// Add the buttonBar to the applet
setLayout(null);
add(buttonBar);
catch (Exception e) {
reportError("Can't create ButtonBar\n" + e);
// buttonBarEvent
// This method is called by the ButtonBar whenever a button event occurs
// It provides the ButtonBar that the event occurred for, the button ID
// that the event occurred for, and the event type.
public void buttonBarEvent(ButtonBar barID, String buttonID, int buttonEvent) {
String description;
// The buttonBar will send an IMAGES_READY event when all button bar images
// have been prepared. We are not interested in this event, but only in
// certain "action" events that occur for a button.
if (buttonEvent != ButtonBar.IMAGES_READY) {
// A number in String format was assigned as the buttonID when each
// ButtonRegion was created. The buttonID String will now be converted
// back into a number that can be used as a Vector index to retrieve
// button specific information (i.e., URL, target frame, and description).
int buttonNbr = Integer.parseInt(buttonID) - 1;
switch (buttonEvent) {
// If a mouseDown event has occurred for the button, and if an
// AudioClip is available for this event, play the AudioClip.
case ButtonBar.MOUSE_CLICK:
if (mouseClickAudio != null) mouseClickAudio.play();
break;
// If the mouse has been moved over a button, display the button's
// description in the browser's status area. If the button that the mouse
// is over is an active button, and if there is an AudioClip available
// for this event, then play the audio clip.
case ButtonBar.MOUSE_ENTER:
case ButtonBar.MOUSE_ENTER_DISABLED:
description = (String)buttonDescription.elementAt(buttonNbr);
if (description != null) showStatus(description);
if (mouseEnterAudio != null && buttonEvent == ButtonBar.MOUSE_ENTER) {
mouseEnterAudio.play();
break;
// If the mouse has been moved off of a button and if the button has
// description text associated with it, then clear the browser's
// browser's status area.
case ButtonBar.MOUSE_EXIT:
case ButtonBar.MOUSE_EXIT_DISABLED:
description = (String)buttonDescription.elementAt(buttonNbr);
if (description != null) showStatus("");
break;
// If the button has been depressed (i.e., a mouseDown followed by
// a mouseUp for the same button) then load the URL(s) for the button
// in the target frame(s), if specified. If the URL is null, then the
// URL was found to be missing or invalid, so display the text stored in
// the buttonURLTarget Vector in the brower's status area. If there is
// an AudioClip for the event, play the audio.
case ButtonBar.BUTTON_DOWN:
// Get the string of URLs and Targets for the button
String urlString = (String)buttonURL.elementAt(buttonNbr);
String targetString = (String)buttonURLTarget.elementAt(buttonNbr);
// If there is at least one URL for the button
if (urlString != null) {
URL urlForButton;
String theURL;
String theTarget;
Enumeration urls = new StringTokenizer(urlString);
Enumeration targets = null;
if (targetString != null) targets = new StringTokenizer(targetString);
// While there is another URL for the button
while (urls.hasMoreElements()) {
// Get the next String token that represents a URL
theURL = (String)urls.nextElement();
// Convert the String to a URL
try {
urlForButton = new URL(theURL);
catch (Exception e) {
try {
urlForButton = new URL(getDocumentBase(), theURL);
catch (Exception e2) {
urlForButton = null;
break;
// If the String was successfully convert to a URL
if (urlForButton != null) {
// If there is a target for this URL
if (targets != null && targets.hasMoreElements()) {
// Get the String that represents the target
theTarget = (String)targets.nextElement();
// If the target String does NOT begin with a "-",
// then load the URL in the target
if (theTarget.charAt(0) != '-') {
getAppletContext().showDocument(urlForButton, theTarget);
// Else a target for this URL should not be used
else {
getAppletContext().showDocument(urlForButton);
// Else there is no target for this URL, so just show
// the URL.
else {
getAppletContext().showDocument(urlForButton);
// Else URL is missing or invalid
else showStatus((String)buttonURLTarget.elementAt(buttonNbr));
if (buttonDownAudio != null) buttonDownAudio.play();
break;
// Error reporting
private void reportError(String message) {
message = "[ImageURLButtonBar] Error - " + message;
System.out.println(message);
showStatus(message);
} -
Here�s my story
I�ve downloaded the latest JDK (including JRE 1.5_06) and install goes fine. For example I can run java programs I've written locally.
The problem is with my Browsers and the JRE (both IE 6 and Firefox)
I run XP SP2 and am up to date on everything
I thought the problem was with the Microsoft VM (MSJVM) and removed it so that ALL I have is the Sun JRE. I even found a site (at Penn State) that talked about how before installing the JRE
You have to remove a left over registry key so that the Sun package installs correctly. http://www.oit.state.pa.us/oaoit/cwp/view.asp?a=172&q=194113&oaoitNavDLTEST=%7C9138%7C
I did all of that and it appears to work fine.
So now the MSJVM is gone and cannot be reinstalled but I cannot run ANY applet. I�ve checked EVERYTHING I can possibly think of but I�m missing something.
The MSJVM did work before so I don�t think it�s a firewall problem.
Every applet gives me the following types of errors (seen in the java console)
The following happens on the Sun jre verify page at
http://www.java.com/en/download/help/testvm.xml
load: class testvm.class not found.
java.lang.ClassNotFoundException: testvm.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed.
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 10 more
Exception in thread "Thread-4" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "thread applet-testvm.class" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
This is similar behavior for EVERY applet no matter what site it's located on. I�ve checked cache, paths, registry setting. I can�t think of anything else to try. It's as if every applet cannot access the �jar� files needed from its server.
Behavior is the same from IE or Firefox. I�ve uninstalled and reinstalled many times.
Any help would be greatly appreciated.
Thanks
MarcIf anyone should happen by here with this problem the following is the solution. Even if you have not installed MSN make sure to check this (I did not have MSN installed so there must be other programs that change this)
When MSN Messenger 7.5 installs it changes a registry entry: HKLM\System\CurrentControlSet\Services\TCPIP\Parameters\DatabasePath from REG_EXPAND_SZ to REG_SZ which causes it to fail to expand %SystemRoot%, therefore breaking the path.
Changing the key back to REG_EXPAND_SZ solves the problem on the machine, but to do so you have to delete the entry and re-create it!
If you feel uncomfortable making registry changes I suggest you follow these directions:
1. Open REGEDIT
2. Navigate to HKLM\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters
3. RIGHT click in the right pane and create a New Expandable String Value
4. Name it DataBasePathExpand
5. Right click on DataBasePathExpand and click Modify
6. Enter the value of %systemRoot%\System32\drivers\etc and save
7. Now right click on DataBasePath and delete it
8. Right click on DataBasePathExpand and rename it to DataBasePath -
Java Applet re-creation problem
Hi skilled,
At our project we use an Applet that resides in the iFrame. On the main page the iFrame is used to show an Applet.
There is a table with two cells, there is DIV in every cell with IDs �div1� and �div2� accordingly. The iFrame is in the "div1".
When we move an iFrame from �div1� to �div2� using the JavaScript code below:
div2.appendChild(
document.getElementById('myframe')
where �myframe� is the iFrame ID, the Applet destroys and new one is being created. This leads to the loss of data that was stored in the applet before.
We need to avoid such a behavior of the Applet somehow or find a workaround to this problem.
This problem reproduces on SUN JVM 1.5.0.11 and 1.6.0.x.
Please share your ideas/suggestions with me � you will help us a lot.I can save the data from the old applet when it is going to destroy, however I cannot pass it to the new one.
Here is the problem:
- until the <iframe/> is moved, my browser has a right reference to the applet - I can use any public methods of an applet;
- then, I move an <iframe/> tag to another cell/div, JVM destroys my applet and creates a new one, however the browser have lost the reference (or it holds the reference to the old applet which is destroyed) - so, I cannot call any applet method from JavaScript anymore.
And one more thing, when applet is being recreated in this way, it is no longer re-draws itselft. Update and Paint methods are no longer called inside an applet even if to call them by hand (repaint function).
Btw, this is not reproduces on MS JVM :) That's strange problem...
Any help will be really appreciated.
Thanks, -
Pls help me with smart card problem
Hi,
currently, i'm developing a system for my final year project. i've developed a webpage in PHP for clinic management. i also implement smart card in my system. the point of it is to make it easier for both parties - doctor and patient. each time patient comes to receive treatment, doc will check patient's smart card on previous drugs prescription. so then, doc will update it based on the treatment given on that day.
the problem is, how i want to transmit the data from smart card to be displayed in the php page? maybe i should use applet but i don't know how.
does anybody has applet source code on transmitting data from smart card to php page?
i wud b really appreciate it...... thanks in advance.Have you checked the Schlumberger web site?
What do you mean by "parsing from applet to php"? Parsing really isn't a data transfer method except maybe in a very tenuous sense.
And do you really mean an applet (a small program run on the client and embedded in a web page) or are you using it as shorthand for any java program?
If an applet, I suppose you could:
1) use javascript to connect the applet to the web page, which would just happen to be created using PHP. So it would be all client-side operation.
2) use HttpURLConnection (or, God help you, direct socket connections) to connect to a web server and interact with PHP to give/get data. In this case it would be client/server behavior, but the applet would have minimal interaction with the PHP page it's embedded in.
3) Make it really fun (i.e.: complicated) by using javascript to connect to the page, and then use AJAX to connect to the server. I have no idea whether that's even possible using PHP.
Maybe there are other options I haven't thought of. -
Help me with smart form name s pls
Hi Experts ,
Pls tell me the smartform names.
I shall give u the reportname.
Quantity Contract
Rejection letter pertaining to purchase RFQ
Returns Delivery
Returns (Pur Ord)
Acceptance of RFQ
RMA Request
Value Contract
Lean WM Transfer packing slip
Please tell me.
I shall reward u with full pointsHave you checked the Schlumberger web site?
What do you mean by "parsing from applet to php"? Parsing really isn't a data transfer method except maybe in a very tenuous sense.
And do you really mean an applet (a small program run on the client and embedded in a web page) or are you using it as shorthand for any java program?
If an applet, I suppose you could:
1) use javascript to connect the applet to the web page, which would just happen to be created using PHP. So it would be all client-side operation.
2) use HttpURLConnection (or, God help you, direct socket connections) to connect to a web server and interact with PHP to give/get data. In this case it would be client/server behavior, but the applet would have minimal interaction with the PHP page it's embedded in.
3) Make it really fun (i.e.: complicated) by using javascript to connect to the page, and then use AJAX to connect to the server. I have no idea whether that's even possible using PHP.
Maybe there are other options I haven't thought of. -
When I run my applet, it runs just fine. About once in maybe 20 launches, however, it throws the following exception. Even when this happens, it launches without any trouble, but it bothers me.
None of the objects referred to belong to my code - which is way to large to include here, and without a clue as to where this might be coming from it's hard to narrow things down.
Any ideas what may be causing this?
java.lang.IllegalArgumentException: null source
at java.util.EventObject.<init>(EventObject.java:34)
at java.awt.AWTEvent.<init>(AWTEvent.java:252)
at java.awt.event.ComponentEvent.<init>(ComponentEvent.java:94)
at java.awt.event.WindowEvent.<init>(WindowEvent.java:174)
at java.awt.event.WindowEvent.<init>(WindowEvent.java:211)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:576)
at java.awt.Component.dispatchEventImpl(Component.java:3506)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:480)
at java.awt.SequencedEvent.dispatch(SequencedEvent.java:93)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:478)
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)I have searched for bug reports; it's hard to know what to look for, though. I will have a another look, this time focusing on focus.
It seems that this happens fairly frequently; since I've been testing my applet, I've gotten into the habit of leaving my Java console open all the time, and I see this same behavior on other applet-containing pages. As in my case, it is sporadic, and doesn't seem to prevent the applet from running. It's just that past, and often bitter experience have taught me to view such things suspiciously. And a surprising number of users watch the console and send exception reports and stack traces. -
Unwanted reloading Applet behavior
I have a dynamic JTree component on an applet and as and when the user uses the application, nodes are added to or deleted from the JTree. But looks like the Applet behavior is to reload the applet everytime it is revisited or minimized/maximized, and hence the JTree goes back to the initial empty tree state. The JTree's root is initialized in the init() and every time the user adds/deletes a node, the JTree is modified to reflect those node changes. But since the applet is part of a multi-frame HTML, the applet gets reloaded each time and reverts back to its initial state.
How can I stop the applet from invoking the init(), start() and stop() method each time? Or is the alternative to using a custom JTree Data model, one that reads its data from a Database make more sense? In that way, everytime the applet is reloaded, the JTree reads the latest data from the database and does not go back to initial empty tree state?
Thanks for all your replies in advance!If your applet is reloading, then it will go back to the initial state - invokes init method. To create persistent objects, you may be better off to store the state of the object on your server as a file (object serialization) or a data base. So, that you can reload the previous state even when the init method is invoked - applet reloaded.
But if you are just maximizing, minimizing, cover/uncover the broswer that has the JApplet with the JTree it should be able to maintain it's current state since only repaint methods are invoked and not init. -
Applet Behavior in (IE6/JRE1.5u11) vs (IE8/JRE1.6u32)
Hi,
i observed different applet behavior between the following environments
1. Internet Explorer 6 with JRE 1.5 u11
2. Internet Explorer 8 with JRE 1.6 u32
I setup the following test environment.
1. Create a page that loads an applet.
2. There is a button in the page that allow me to navigate to another page.
3. In my applet init() method, I place a sleep(5000) to simulate some activities.
I ran the following test.
1. Load the page
2. while the init() method is still running, I click on the button to navigate to another page.
Results as follows.
1. IE 6 Environment -- Applet will complete init(), execute start() , stop() before navigate to the new page.
2. IE8 Environment - Init() method will throws an InterruptedException.
Question is:
1. I tried searching for documentation for the above behavior but was unable to find any, can any kind souls help?
2. How do I achieve the behavior in IE6 env in the IE8 env? ie. ensure that the applet is successfully executed before allow it to be interrupted.
Thanks.
Edited by: user4546295 on Feb 26, 2013 1:42 AM -
Applet signed w/ self-signed cert - different behaviors w different servers
Folks,
I'd really appreciate your help with the following.
I'd like to deploy an applet as a signed jar. Probably at least in the beginning, and maybe indefinitely, I'd like to sign it with a self-signed cert. When I've tested this under Linux, loading the applet in a browser running on my desktop, from an apache2 webserver also running on the desktop, I get the expected behavior - I get a security dialog reporting that the applet was signed by an unrecognized CA, but allowing me to accept the applet's signature. However, when I try loading the applet from my server (i.e, browser still running on my desktop, but now loading the applet from the real webserver, which is also apache2), I don't get a security dialog, and the applet fails silently.
Is there some way of configuring the webserver so that the security dialog is presented for a self-signed applet? What explains this difference?
Thanks much,
Matthew Fleming
DermVision, LLCDouble post answer has been given and ignored:
http://forum.java.sun.com/thread.jspa?threadID=569012&messageID=2812525#2812525
Maybe you are looking for
-
MIR6 not matching to correct PO number
Hi, We have an issue (occasionally), when attempting to process parked documents. I am informed that this does not happen all the time, but is getting more and more frequent. We are using MIR6 to match deliveries to parked documents. I run my list
-
Creating trace file in oracle 10g forms
hii there, I have developed an application in oracle 10g. but it's too slow . Now i have to trace forms . How can trace oracle forms. please send it in details as early as possible. I don't know about this trace file generation. -----Sachin
-
Table Pagination for Dynamic Table UI
Hi Everyone, I have add pagination to webdynpro java table UI that displays over 10k records. I went through article "Web Dynpro Java Table Paging Unleashed: Optimizing Heavy Table Performance" by Bertram Ganz - http://www.sdn.sap.com/irj/scn/go/port
-
Lost my ipod touch can i find it if someone uses it
I lost my ipod touch can i find it if someone uses it
-
After update 4.2.1 unable to access mobile data network
Hello, yesterday, i have updated to 4.2.1 Today, i have activated the flight modus for a while... Then go back into the normal modus (flight modus off). Now, the access to the mobile data network is never possible. Access via WIFI is allways ok. Now,