Add Drop Shadow to JMenu Problem

Hi,
I got this code from "Swing Hacks", for some reason it does not run for me, but throws exceptions. I can not figure out why this is happening. This code straight out of the book, should be runnable. Below is the custom class, then the driver-test class, then the Exception:
import javax.swing.plaf.basic.*;
import javax.swing.plaf.*;
import javax.swing.border.*;
import javax.swing.*;
import java.awt.*;
public class CustomPopupMenuUI extends BasicPopupMenuUI{
     public static ComponentUI createUI(JComponent c){
          return new CustomPopupMenuUI();
     public Popup getPopup(JPopupMenu popup, int x,
               int y){
          Popup pp = super.getPopup(popup, x,y);
          JPanel panel = (JPanel)popup.getParent();
          panel.setBorder(new ShadowBorder(3,3));
          panel.setOpaque(false);
          return pp;
class ShadowBorder extends AbstractBorder{
     int xoff,yoff;
     Insets insets;
     public ShadowBorder(int x, int y){
          this.xoff = x;
          this.yoff = y;
          insets = new Insets(0,0,xoff,yoff);
     public Insets getBorderInsets(Component c){
          return insets;
     public void paintBorder(Component comp, Graphics g,
               int x, int y, int width, int height){
          g.setColor(Color.BLACK);
          g.translate(x,y);
          // draw right side
          g.fillRect(width-xoff,yoff,xoff,height-yoff);
          // draw bottom side
          g.fillRect(xoff,height-yoff,width-xoff,yoff);
          g.translate(-x,-y);
// Driver Below
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import java.awt.*;
public class MenuTest {
     public static void main(String[] args)throws Exception{
          UIManager.put("PopupMenuUI","CustomPopupMenuUI");
          //UIManager.put("MenuItemUI","LucentMenuItemUI");
          JFrame frame = new JFrame();
          JMenuBar mb = new JMenuBar();
          //mb.setUI(new CustomMenuUI());
          frame.setJMenuBar(mb);
          JMenu menu = new JMenu("File");
          mb.add(menu);
          menu.add(new JMenuItem("Open"));
          menu.add(new JMenuItem("Save"));
          menu.add(new JMenuItem("Close"));
          menu.add(new JMenuItem("Exit"));
          menu = new JMenu("Edit");
          mb.add(menu);
          menu.add(new JMenuItem("Cut"));
          menu.add(new JMenuItem("Copy"));
          menu.add(new JMenuItem("Paste"));
          menu.add(new JMenuItem("Paste Special.."));
          frame.getContentPane().setLayout(new BorderLayout());
          frame.getContentPane().add("North",new JButton("Button"));
          frame.getContentPane().add("Center",new JLabel("Label"));
          frame.getContentPane().add("South",new JCheckBox("checkbox"));
          frame.pack();
          frame.setSize(200,150);
          frame.show();
}Exception:
UIDefaults.getUI() failed: no ComponentUI class for: javax.swing.JPopupMenu[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,desiredLocationX=0,desiredLocationY=0,label=,lightWeightPopupEnabled=true,margin=,paintBorder=true]
java.lang.Error
     at javax.swing.UIDefaults.getUIError(Unknown Source)
     at javax.swing.MultiUIDefaults.getUIError(Unknown Source)
     at javax.swing.UIDefaults.getUI(Unknown Source)
     at javax.swing.UIManager.getUI(Unknown Source)
     at javax.swing.JPopupMenu.updateUI(Unknown Source)
     at javax.swing.JPopupMenu.<init>(Unknown Source)
     at javax.swing.JPopupMenu.<init>(Unknown Source)
     at javax.swing.JMenu.ensurePopupMenuCreated(Unknown Source)
     at javax.swing.JMenu.add(Unknown Source)
     at hacks.MenuTest.main(MenuTest.java:23)
advTHANKSance

I am also using xp and java version 1.4.2_08, but to no avail.. see below:
C:\workspace\Swing Hacks\src>java -version
java version "1.4.2_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
C:\workspace\Swing Hacks\src>java hacks.MenuTest
UIDefaults.getUI() failed: no ComponentUI class for: javax.swing.JPopupMenu[,0,0
,0x0,invalid,alignmentX=null,alignmentY=null,border=,flags=0,maximumSize=,minimu
mSize=,preferredSize=,desiredLocationX=0,desiredLocationY=0,label=,lightWeightPo
pupEnabled=true,margin=,paintBorder=true]
java.lang.Error
at javax.swing.UIDefaults.getUIError(UIDefaults.java:689)
at javax.swing.UIDefaults.getUI(UIDefaults.java:719)
at javax.swing.UIManager.getUI(UIManager.java:784)
at javax.swing.JPopupMenu.updateUI(JPopupMenu.java:204)
at javax.swing.JPopupMenu.<init>(JPopupMenu.java:169)
at javax.swing.JPopupMenu.<init>(JPopupMenu.java:154)
at javax.swing.JMenu.ensurePopupMenuCreated(JMenu.java:521)
at javax.swing.JMenu.add(JMenu.java:556)
at hacks.MenuTest.main(MenuTest.java:23)
UIDefaults.getUI() failed: no ComponentUI class for: javax.swing.JPopupMenu[,0,0
,0x0,invalid,alignmentX=null,alignmentY=null,border=,flags=0,maximumSize=,minimu
mSize=,preferredSize=,desiredLocationX=0,desiredLocationY=0,label=,lightWeightPo
pupEnabled=true,margin=,paintBorder=true]
java.lang.Error
at javax.swing.UIDefaults.getUIError(UIDefaults.java:689)
at javax.swing.UIDefaults.getUI(UIDefaults.java:719)
at javax.swing.UIManager.getUI(UIManager.java:784)
at javax.swing.JPopupMenu.updateUI(JPopupMenu.java:204)
at javax.swing.JPopupMenu.<init>(JPopupMenu.java:169)
at javax.swing.JPopupMenu.<init>(JPopupMenu.java:154)
at javax.swing.JMenu.ensurePopupMenuCreated(JMenu.java:521)
at javax.swing.JMenu.add(JMenu.java:556)
at hacks.MenuTest.main(MenuTest.java:30)
I don't understand what the issue could be..
Can anyone reproduce this error??

Similar Messages

  • How can I add drop shadow to a vehicle that changes direction ?

    Hi,
    Flash CS5
    Is it possible to add drop shadow to plan views of vehicles (vehicles are png images as MovieClips) such that as the vehicles change direction along roads (also png images) the shadow is always cast to north west ot the vehicle ? Buildings in the base png image have shadows but vehicles also need them so as to belong to the scene and not appear false.
    How is it done ?
    Is there control over opacity and softness ?
    If I were to have plan views of humans walking would the shadows follow the leg movements ?
    Envirographics

    you can control the dropshadow's angle property dynamically.  and, yes the dropshadowfilter has an alpha and strength properties you can use.
    use the help files to see all the properties you can use.

  • How to add DROP SHADOW

    I posted earlier but figured I'd give it another shot due to the flood of other posts.  Has anyone figured out how to add a drop shadow (preferably to video clip with an alpha channel, but other applications such as psd files, etc. would good to know for as well).  I mean, if iWeb can have drop shadows, SURELY Final Cut Pro X does...right?

    The solution is do do it in Motion. Only took me a minute to figure it out.
    Basically, you create a "Final Cut Effect" in the project browser of Motion, and take a clip (any clip will work, it seems), scale it down to 50% or whatever, add the drop shadow (easy to find), and hit Save.
    Motion will tell you it's "publishing" it, and ask you for a category. I created one with my name.
    Go back to FCPX, my new category appears instantly in the Effects browser, and there's my shadow effect in that category. Drag your newly created effect to the clip you want to effect, and there you go.
    The nice thing is, having your own saved effects makes it easy to be consistent when you want to apply that effect to several things.

  • Add drop shadow with css?

    is there a way to add a dropshadow with css? (specifically to
    a label component)
    Thanks!

    "Phrankie" <[email protected]> wrote in
    message
    news:gop31l$24j$[email protected]..
    >
    quote:
    Originally posted by:
    ashtangakasha
    >
    quote:
    Originally posted by:
    danger42
    > No, drop shadows are implemented as filters, not styles.
    They cannot be
    > set
    > via CSS in Flex 3.
    >
    > matt horn
    > flex docs
    >
    > Although Matt's reply is true with respect to label
    components, which is
    > what
    > the original question addressed, it's worth pointing out
    that MXML Styles
    >
    can
    set dropshadows on components which happen to expose the
    > dropShadowEnabled property. Perhaps this is new to Flex
    3.2.
    >
    > For example, CSS can apply dropshadows to TextArea,
    Canvas, DataGrid,
    > AdvancedDataGrid, and other list-based containers, but
    not to Buttons,
    > Labels,
    > ComboBoxes, Images, etc. The rationale for exposing or
    not exposing the
    > dropShadowEnabled (and dropShadowColor) property is not
    clear, so you have
    > to
    > refer to the docs.
    I think it depends on whether the component has a HaloBorder
    or not.

  • Add drop shadow to vector map

    Hi,
    I have troubles in adding a drop shadow to a vectorized map (in *.ai format).
    All countries are separated by a white thin line, so that it is possible to highlight a certain country of interest in another colour.
    When these countries have been selected, I would like to add a drop shadow under the map outlines, ie under each continent.
    But everytime I try to do so, the drop shadow also gets under each country.
    My guess is that I have to group the countries within a continent or something else, but I fail each time I try.
    Does anybody have a clue?!
    Many thanks in advance
    Annika

    Annika,
    What happens if you:
    1) Select all countries in the continent and copy to the back (Ctrl/Cmd+C+B);
    2) Pathfinder>Merge the copy;
    3) Effects>Stylize>Drop Shadow applied to the merged copy?

  • Can't add drop shadow to text in PSE 6

    Everyone says to do Layer > Layer Style > Style Settings.
    But when I go to Layer Style and try to get to Style Settings, Style Settings is greyed out.   (The text in quesiton is already selected.)
    In fact, I've tried everything possible to get Style Settings to become engaged and have not been able to do that.
    Also, when I go into Effects and try to add cool effect (torn paper, glowing edges, etc.) to the text, it automatically changes the color of my text.  For example, my text is orange and when I tried "glowing edges" it changed the text to olive drab... and it certainly didn't glow.
    Any guidance you can give with these issues... thanks!

    Style Settings is for adjusting styles you've already added. The effects you listed are all filters, not effects or layer styles and they use the foreground/background colors, so yes, they will change the color of your text. To apply a drop shadow click the Layer styles button on the effects panel, choose drop shadows from the pulldown menu and double click the one you want. If you don't like it, undo it and try a different one. Then you should be able to adjust things like the angle and distance of the shadow by adjusting the style settings.

  • Why Cant I Add Drop Shadow? artwork size & resolution exceeds the maximum that can be rasterized

    I am making a sign for sign writing. The overall size is 2400mmx1800mm. so its quiet big.
    But When I go to put a drop shadow behind it it comes up with this -
    " The combination of artwork size & resolution exceeds the maximum that can be rasterized"
    Why is it saying this? How do I put a drop shadow on it?

    Try scaling the sign down to 600 x 450mm and building your drop shadow at a more manageable size.  When you deliver your file for output, tell the vendor to enlarge the file 400% in the RIP.  If it still will not work, check your HD for scratch space.  If there is not enough memory available to run the operation, you will continue getting the message until you clear some space and/or increase your RAM ( if necessary ).

  • Drop shadows with mask problem

    I've got a vector image that I've applied a drop shadow to,
    I've then used a mask on it to square it off but unfortunately the
    drop shadow follows the mask after applying.
    Is there any way the mask can cut off the the drop shadow
    effect as well?

    Garry Bradley wrote:
    > I've got a vector image that I've applied a drop shadow
    to, I've then used a
    > mask on it to square it off but unfortunately the drop
    shadow follows the mask
    > after applying.
    >
    > Is there any way the mask can cut off the the drop
    shadow effect as well?
    It's pretty hard to guess what it looks like from your
    description. Can
    you upload a copy of your document to a website where we can
    see it?
    Linda Rathgeber - Adobe Community Expert
    http://www.adobe.com/communities/experts/members/8.html

  • Trying to add drop shadow to home slider app

    Does anyone know how to do such a thing?

    Thanks for that but I wasnt clear enough in my question.
    I have the code but I havent been able to find where to place it in the home slider app.
    From my attempts I have determined that a class like the one in this post .shadow needs to be placed
    somewhere in the javascript code unless there is a way  to combine a drop shadow and a glow effect in  one box-shadow statement.

  • Add drop shadow curled page like default photo boxes in books.

    When I pick a theme in Books in Aperture, I see the photo boxes have rotation and a shawdowed, buttom edge curled effect to the photo plaeholder boxes. I figured out how to add photo boxes and even size and rotate them, but cannot see how to add the shawdow/curled effects to the placeholder. Nor can I 'edit' existing placeholders to change there size or rotation. Seems it should be easy... but not. Also, how to add a custom page background color other than the very limited selection allowed/offered?
    Thanks!

    LewisO,
    if one could adjust the size and rotation of these theme supplied containers. That too, I have not been able to figure out how to do.
    which theme are you using? Each theme is behaving differently and some are very restrictive. For example, the "Formal" theme does not allow to rotate the photo boxes or to change the aspect ration.
    The "angle" slider in the layout options and part of the size options will be dimmed for hese themes.
    Regards
    Léonie

  • Having a strange problem with Drop Shadows in Ai CS5

    Hi there Adobe experts!
    I have tried eveything... this is my first post here, but it's my only hope. I have a project where I apply drop shadows to linked images to give a sense of depth. A few days ago, the drop shadows just stopped feathering. It doesn't matter what the blur is set to, its just one colour. Transparency still applies. Here's the kicker...I can open files with applied drop shadows to them and they look fine. But if I try to edit that existing shadow, even by 0.0001 of a pt, it will lose its feathering.
    I've deleted the AiPrefs file, and played with just about every setting in document raster effects settings. I have no clue what would cause this.
    Oh, and whatever the issue is, it starts in my computer, and then attaches to the files... I sent the ai file to a friend, and when he tried to add drop shadows, they screwed up on his machine too. But it isn't the file. I've attached a brand new (and CMYK, just to see if that would make a difference...) file of a sphere showing the problem. Even with the blur super high, the shadow remains flat and monochromatic.
    Any geniuses seen this before or have a remote clue how to solve this one?
    Thanks in advance,
    Luke

    All my ram is tripple channel DDR3, same clock speeds, but some is 2GB and some is 4GB.
    I just pulled the 2GB sticks (which I had in originally) and left in the 4GB sticks (the ones I recently purchased) and the problem goes away. It's quite odd, I've never had a problem like this before with any other application. I know it's not the best thing in the world to have different types of RAM installed, but my motherboard supports it and I've never had a problem doing it before.
    I would be interested to see if this problem is reproducable in the OP's senario, or if this problem can be reproduced by others.
    Conclusion: the 2GB sticks work on their own, and the 4GB sticks work on their own. I definitly would not call this a hardware problem, it's an adobe problem and they need to fix their software.

  • Problem with Chroma/Lume Keys while using Drop Shadows

    I have been using the box now for almost two years and I still am getting problems with green/blue/purples artifacts showing up after a chroma/luma key has been applied with a drop shadow. The artifacts do not show up under a preview but only when the sequence has been rendered. As soon as I take the drop shadow off, the artifacts go away. This is happening with both still graphics with or without Alphas and green/blue screen video. Please help, am I just missing something or is there a work around that I could be using.
    Thanks,
    Alex

    c'mon, Bogie - tell us what you really feel - don't hold back... < </div>
    Oh, Patrick, buddy, I am so totally torqued out of shape today. Don't get me started. Too late. FCP's insane render handler is dropping my files, seemingly at random. The nests, Motion and LiveType material are not rendering in the correct order which makes the effects all wonky.
    I add drop shadows in the last stage and FCP just ain't holding it together. I get glitches. And then I keep getting these Media Offline notices because FCP cant' track the render files that are actually in use in the upstream nests.
    I'll certainly admit a likely a user error. I just don't know what it could be. I've somehow told FCP to destroy its children.
    bogiesan

  • Indesign CS6 text drop shadow changes background colour

    I have two layers, one for a background image linked to a photoshop document and another layer for text. When i add drop shadow to the text, the background colour goes sort of dark, and the same happens in overprint view whereas with 5.5 it didn't do that. Is there a way to fix this?
    Before:
    After:

    Looks like maybe an RGB image with a CMYK transparency blend space applied.

  • Exporting to flash/swf, losing drop shadow?

    Hi guys, when I add drop shadow to 2d text in AE it looks fine in the RAM preview, but when I export to a SWF object its gone.  I tried both the effect and layer style versions of drop shadow.. not really sure what the difference is anyways.  Any ideas?  Googled a bunch and couldn't find an answer.

    We usually need to ask for clarification: how do you know the drop shadow really isn't there? If you're looking at a sample of the clip over black, it might be invisible. But Rick's usually got these things nailed. Drop shaodws from text require AE to create rasterized frames and that will change the processing of the output. As Rick says, it will be much larger because it will be a pixel-based movie of images rather than instructions for vectors.

  • Drop Shadow pdf issue

    Hi there
    I'm trying to export a High Quality print Photoshop pdf with 7.5pt Helvetica LT Std white text with a 0.1mm drop shadow. The problem is that when I export it the drop shadow comes out unevenly (some letters/words/lines are bolder than others). I have tried changing font to Gautami, and also reducing the shadow to 0.075mm but with no joy. I have tried it in Illustrator and InDesign as well but with the same result.
    Has anyone come across this before or got any ideas?
    Cheers
    Sean

    Just to make sure: The issue persists at larger zoom values?
    I am not sure but it might be an unfortunate combination of type/vector and pixels.
    If you could tolerate a sharp shadow one possible workaround might be to duplicate the Type Layer, make the lower one black and offset it manually.
    Another possibility would be to use
    Type > Convert to Shape
    and check if the shadow goes better with this in the pdf. Of course the text would not be searchable anymore …

Maybe you are looking for

  • Problems with drive mapping

    We have changed the server of linux that supports tarantella. We have installed tarantella on redhat 8 and worked perfectly. I have installed the tarantella enhancement module for windows and activated in the array manager the option " let users acce

  • Connection error in Performancepoint service in sharepoint

    hi All, i am using sharepoint Performance point services 2010 for creating Dashboard.Datasource for Listitem is working fine, but when i am creating a datasource of tye (Analysis services) .while selecting the database after entering the Server name.

  • MBP almost burning after 3 hours shut down.

    Hi, Just to share a recent and alarming experience with my MBP. And see if someone found a similar behavour. Yesterday evening I shut my MBP down aroud 18:30 (waited for black screen), placed the laptop on the backpack and around 21:30 at home (three

  • Interest Calculation on Vendors

    Hi, while excecuting the  batch input for inetrest calculation  on vendors system not updating the with holding tax after completion of the transaction from f.44. but it has to calculate the tax. kindly send me solution  how many way's it will be. Th

  • What phone number can I ring to speak to a English person

    Which phone number can I call to get a English person