Custom Shape for JFrame

HI,
I need to give the custom shape for the JFrame. I used the setWindowShape method and i got the shape for the window. In my application, many custom shaped windows are occurring but all are same shapes. So i plan to keep the Custom Shaped window class as base class. If i need shaped window then i will create the class which extends the Custom Shaped window class through that i can get the custom shaped window, but i am not getting the custom shaped window.
Here is the code for the custom shaped window. It is working fine.
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Ellipse2D;
import javax.swing.*;
public class ShapedWindow extends JFrame {
     public ShapedWindow() {
          super("ShapedWindow");
          try {
               UIManager
                         .setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
          } catch (ClassNotFoundException e) {
               e.printStackTrace();
          } catch (InstantiationException e) {
               e.printStackTrace();
          } catch (IllegalAccessException e) {
               e.printStackTrace();
          } catch (UnsupportedLookAndFeelException e) {
               e.printStackTrace();
          JPanel jpnl = new JPanel() {
               public void paintComponents(Graphics g) {
                    g.setColor(new Color(64, 144, 196));
                    g.setColor(Color.WHITE);
                    g.drawLine(270, 120, 395, 120);
          jpnl.setLayout(new FlowLayout(FlowLayout.RIGHT, -2, 2));
          jpnl.setBackground(new Color(1, 107, 177));
          this.setLayout(new BorderLayout());
          JButton jbtn1 = new JButton("Cancel");
          jbtn1.setBackground(new Color(1, 107, 177));
          jbtn1.setForeground(new Color(255, 255, 255));
          jbtn1.setFocusPainted(false);
          jbtn1.setBorderPainted(false);
          jbtn1.setContentAreaFilled(false);
          // jbtn1.setBounds(325, 90, 75, 25);
          jbtn1.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent evt) {
                    JOptionPane.showMessageDialog(null, "Cancel");
          JButton jbtn2 = new JButton("OK");
          jbtn2.setBackground(new Color(1, 107, 177));
          jbtn2.setForeground(new Color(255, 255, 255));
          jbtn2.setFocusPainted(false);
          jbtn2.setBorderPainted(false);
          jbtn2.setContentAreaFilled(false);
          // jbtn2.setBounds(285, 90, 55, 25);
          jbtn2.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent evt) {
                    JOptionPane.showMessageDialog(null, "OK");
          jpnl.add(jbtn2);
          jpnl.add(jbtn1);
          JPanel jpnl1 = new JPanel();
          jpnl1.setBackground(new Color(1, 107, 177));
          this.add(jpnl1, BorderLayout.CENTER);
          this.add(jpnl, BorderLayout.SOUTH);
          this.setResizable(false);
          this.setBackground(new Color(1, 107, 177));
          this.setSize(new Dimension(500, 150));
          this.setLocationRelativeTo(null);
          this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          Polygon poly = new Polygon();
          poly.addPoint(1, 1);
          poly.addPoint(ShapedWindow.this.getWidth() - 1, 1);
          poly.addPoint(ShapedWindow.this.getWidth() - 1, ShapedWindow.this
                    .getHeight() - 1);
          poly.addPoint(ShapedWindow.this.getWidth() - 100, ShapedWindow.this
                    .getHeight() - 1);
          poly.addPoint(ShapedWindow.this.getWidth() - 130, ShapedWindow.this
                    .getHeight() - 30);
          poly.addPoint(1, getHeight() - 30);
          poly.addPoint(1, 1);
          com.sun.awt.AWTUtilities.setWindowShape(ShapedWindow.this, poly);
     public static void main(String[] args) {
          JFrame.setDefaultLookAndFeelDecorated(true);
          Window w = new ShapedWindow();
             w.setVisible(true);
}In the below code, i kept the base class jfrmShape class, for this i set the custom shape. childShape class which extends the jfrmShape. But i didn't get the shape. Please find the mistake and help me.
package SWindow;
import java.awt.Polygon;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import PWGUI.ShapedWindow;
public class jfrmShape extends JFrame {
     public jfrmShape() {
          Polygon poly = new Polygon();
          poly.addPoint(1, 1);
          poly.addPoint(jfrmShape.this.getWidth() - 1, 1);
          poly.addPoint(jfrmShape.this.getWidth() - 1,
                    jfrmShape.this.getHeight() - 1);
          poly.addPoint(jfrmShape.this.getWidth() - 100, jfrmShape.this
                    .getHeight() - 1);
          poly.addPoint(jfrmShape.this.getWidth() - 130, jfrmShape.this
                    .getHeight() - 30);
          poly.addPoint(1, getHeight() - 30);
          poly.addPoint(1, 1);
          com.sun.awt.AWTUtilities.setWindowShape(jfrmShape.this, poly);
          com.sun.awt.AWTUtilities.setWindowOpacity(jfrmShape.this, 0.56f);
                setDefaultLookAndFeelDecorated(true);
          setTitle("Shaped Window");
          setSize(300, 300);
          setVisible(true);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
package SWindow;
import javax.swing.JFrame;
public class childShape extends jfrmShape{
     public static void main(String [] args)
          new childShape().setVisible(true);
}

In Keynote 6 there is no facility to save shape styles.

Similar Messages

  • Tutorial:  Creating, saving and re-using Custom Shapes

    I've beeen experimenting with custom shapes for the last couple of days, and thought I'd share some of the tips and techniques I found.
    First of all, what are custom shapes?
    Well, they're vector objects.  That means that they are not built out of millions of individual pixels (like images are), but rather they're a series of mathematical statements that describe how to draw a line from point to point to create the vector shape.  This means that custom shapes are "resolution independent", and that they can be grossly shrunk or enlarged and still retain razor sharp edges, curves and corners.
    What are custom shapes good for?
    Pretty much anything where you want to use a good, sharp object.  In particular, using a custom shape as a clipping mask for an image that's been placed as a Smart Object is an outstanding technique, and really shows off the power that PSE is capable of.
    PSE comes with a lot of ready-to-use custom shapes for its Custom Shape tool, and there are probably hundreds of thousands available on the Web -- just search for "photoshop shapes".  Typically, those shapes will be supplied as Adobe CSH (Custom SHape) files, and simply copying the CSH files into the
    "C:\Program Files (x86)\Adobe\Photoshop Elements 10\Presets\Custom Shapes"
    directory will make them available for use with the Custom Shape tool.
    Sooner or later, though, you'll get the itch to create your own custom shapes.  Out of the box, PSE does not have the capability to let you create custom shapes and add them to the CSH files like the "big" Photoshop does, so we'll need to use a workaround:  store your custom shapes as layers in a PSD file, and when you want to use them simply copy them into your image. 
    N.B.:  To create custom shapes you'll have to use the reasonably priced Elements+ add-in:
    http://elementsplus.net/
    So, the procedure goes like this:
    Create a new image, using the PSE defaults, and save it as "CustomShapes01.psd", keeping it open.
    Open an image containing an object that you want to use as a custom shape.
    Use any of the selection tools to make an accurate selection of the object:
    In the Effects panel, use the Elements+...Paths effect and choose the Create New Path...From Current Selection:
    Use the Elements+...Paths again, choosing "Convert to Shape", giving it a name and colour of your choosing.  This will create a Shape Layer using that name.
    Important:  If your shape has "holes",
    use the Shape Selection tool and click on the shape to select it.  Then hit the "Combine" button in the Options Bar.  This will combine all the individual shapes used to create the shape and its "holes" into one shape, and prevent beaucoup problems later.
    Switch to the Move tool and drag the shape onto the tab of your "CustomShapes01.psd" image, keeping your mouse button pressed.  That image will become activated and you can move your cursor onto the image itself and drop your shape onto it.  Your PSD file will now have your custom shape as a shape layer:
    Save that "CustomShapes01.psd" file.
    You can repeat the process for as many custom shapes as you want, and they will each become a layer in the "CustomShapes01.psd" file.
    To use your custom shape, open the "CustomShapes01.psd" file and your target image and do the drag and drop with the Move tool to copy the custom shape onto your target image.
    I mentioned that using a custom shape as a clipping mask for an image placed as a Smart Object is a very powerful technique.  It's powerful because the custom shape can be altered at any time and still keep its sharpness, and because the Smart Object can also be resized without becoming pixellated.  Of course, that custom shape layer can have any number of layer styles applied to it and those layer styles will "follow" the shape if the shape is moved, resized or rotated.
    Here are three examples of using the custom shapes as clipping masks for Smart Objects:
    In this example, each custom shape is used as a clipping mask for an image Smart Object, as usual:
    Here, one custom shape was used as a clipping mask for an image Smart Object and they were linked. 
    Then the shape and image were duplicated and moved, rotated and resized.  Because of the linking, the Smart Object automatically kept its orientation and size relative to the custom shape throughout:
    If you want to use custom shapes as a "combined" clipping mask, the procedure is a little more complicated because you need to get all your custom shapes on one shape layer. 
    So, after copying your shapes into the target image (as separate shape layers), use the Shape Selection tool to select one of the shapes.  Using Edit...Cut will cut that shape layer to the Clipboard, and you can select one of the other shape layers and use Edit...Paste to paste the custom shape into that shape layer.  Repeat as necessary, and you will get all of your custom shapes on one shape layer.  Then use that single shape layer as your clipping mask:
    The neat thing is that the individual shapes can be selected with the Shape Selection tool and independently moved, resized or rotated as necessary.
    Enjoy!
    Ken

    Thanks, Michel.
    I forgot to mention one point about copying shape layers into one shape layer:  when you initially use the Shape Selection tool to select a shape for cutting, make sure the option for the Shape Selection tool is set to "Add to Selection".
    MichelBParis wrote:
    The problem with Elements+ is that it has so many features you soon forget what it can give you !
    Truer words were never spoken! 
    Ken

  • How to create Custom shapes in Crystal Reports ?

    All,
    i need to create two thickish semi circles like half donuts... each of the donut needs to be conditionally formatted depending on some values. am wondering is it possible to create half donuts ? or custom shapes for that matter to suit my requirement.

    here's what i would recommend and it's a bit of work:
    create a bunch of formulas that you can populate dynamically.
    @green
    if yourcondition1 then 1 else 0
    @red
    if yourcondition2 then 1 else 0
    @blue
    if yourcondition3 then 1 else 0
    etc.
    as Abhilash mentioned you need to use a Donut type chart. you create 1 formula for every colour that you want to use in the chart. you then add all of them as Show Values. you'll get a message / warning about adding all of the values but you can ignore that warning.
    now you have to manually colour each part of the chart. there is a Color Expert in the chart but i would not recommend using it as it is very limited. you are better off creating one series / show value in the chart for every colour that you use and populating those formulas conditionally.
    when you run the report, you need to ensure that only 2 of the formulas meet a TRUE condition. that way you'll have two halves all the time.
    -jamie

  • Import multiple photoshop custome shape at once

    Hi,
    I have about 100 CHS files. how can I load them all in photoshop at once instead of clicking individual files which is time wasting?

    The CSH file simply stores a Custom Shape for Photoshop to re-use.
    By its nature you can only have one active at any one time but you can view them all together in the drop-down from the Options Bar or in the Preset Manager.

  • How to make custom start end shapes for stroke (arrowheads)...

    hello...
    Indesign cs4 have nice start end stroke shapes like arrowheads, circles, squares...circles is clear, without fill. I need fill in it.
    How to make custom shapes or edit existings start/end shapes to functioning like original provided with indesign?
    Maybe illustrator cs4 have this?

    There's no way to edit line endings in ID. You would have to make a compound path from a line with no ending and a second path or shape for the end.

  • When I click on Define Custom Shape, I get an error message: "could not complete your request because of a program error."

    I'm using Photoshop CC 2014. When I click on Define Custom Shape, there is an error box that says "could not complete your request because of a program error."  How can I solve this problem or work around it? I've looked on the internet for answers but could find no solutions to this. The custom shape tool is 99% of what I use!

    Consider resetting the Pen tool by right clicking here
    and if that doesn't solve the problem a logical next step would be to reset your Preferences.
    To reset Preferences:
    If Photoshop is already open on your screen, close it (Quit). Then hold down Shift+Ctrl+Alt (Win) / Shift+Command+Option (Mac) on your keyboard and start Photoshop.
    A dialog box will pop up asking if you want to delete the existing Preferences file (the "Settings"). Click Yes in the dialog box. The existing Preferences file will be scrapped and a new one will be created.
    By the way, if "The custom shape tool is 99% of what I use!" have you considered Illustrator?

  • Custom Shape not showing up in animated gif

    Hi guys,
    I'm fairly new to this/to PS so apologies upfront and send me elsewhere if I'm in the wrong discussion. But here's my problem: I'm trying to create an animated gif. It's pretty simple and only involves 3 layers, with some tweening for a fade in. Then 2 of the 3 layers are text layers with vector masks (the custom shape talk bubble with some text). But when I add a frame to the animation, select that text/vector mask layer, then add another frame, and select the other layer with the second text/talk bubble and then play the animation, the bubble never appears.
    Also when just working with the layers in my psd, I see that when I click away to a basic layer and come back to a layer with the vector mask, I always have to actually click the vector mask thumbnail to see the whole thing on the screen.
    Any ideas? (I said I was new . . . .)
    Thanks.
    (Using iMac with os 10.5.7, ps cs4 with latest update.)

    You need to sign your app with a certificate that chains up to a trusted root certificate. In general that means you need to get a cert from verisign or someone like that. If you get the friendly warning dialog on the first installer screen rather than the scary one with lots of red x's, you should then see your image

  • Question about Custom Shape Files from newbie to PS

    My husband bought me PS CS4 Extended. That said, I have never used PS at all. I have always used PSP. Please don't hate me!
    I have figured out that one loads actions and presets. OK, got that. The question I have is if I can have my Custom Shapes and Actions on a completely different partition? I ask this because there is not enough room on the partition for me to continue adding shapes and such to PS in the program itself. I am figuring that I can since I have tio load them into the program anyway, but am asking to be sure so that I don't screw anything up.
    Another question I have is if I am able to point PS to where all of my plugins are that I already have installed in PSP, which also happen to be on a different partition. In PSP all one has to do is to point the program to where they are and all is good and they can be used within said program. Does PS allow for this also? If not, do I have to re-install all of the plugins into the PS program itself? I just don't have that much room on the partition that my PS resides on because of all of the other pregrams that I have. Also, does everything I load into PS just stay loaded or do I have to reload each time I want to use that particular preset?
    I do hope that ya'll can understand my questions and thank you for any help in advance.

    the benefit of having the presets in the proper folders is that you can select them from the fly-out menus instead of having to search for them using the Load command so yes, you can have them wherever you want. I doubt though that you don't have enough disk space for them, for instance, all the actions that come with Photoshop take up about 200kb, the custom shapes are about 700kb but that's because they come in duplicates. And yes, all that you load up stays in Photoshop until you remove them, no need to reload them at program start. For plug-ins you have the option to set an additional plug-in folder by going to Edit->Preferences->Plug-ins, don't know about needing to install them though as i don't use any

  • Export Flexibility of Custom Shapes & Layer Styles?

    Over the past few years I've developed a workflow for icon creation that involves purely custom shapes and layer styles. This has been fantastic from a number of points of view
    - Vector based workflow for easy scaling, resizing
    - Easy maintenance of style coherence with layer style presets
    - Custom shape library means rapid prototyping of common elements
    While this approach in Photoshop helps me rapidly develop icons, it's now presenting some challenges from an export point of view. Specifically the path to vector based formats like svg and xaml is hindered by the fact that Photoshop and Fireworks/Illustrator don't share a common layer styles approach. (Fireworks having a XAML export plugin and Illustrator having both XAML plugin and SVG export capability)
    While the above programs are more geared towards vector work, they don't offer the flexibility of Photoshop when it comes to creating photorealistic icons with texturing.
    Is anyone aware of a method for exporting a vector element from photoshop while maintaing the editability of layer styles? (Exporting simple shapes in PDF works but falls down once masks and layer styles come into the equation)
    Fireworks CS4 seems to import select PSD's decently but there is not a 1:1 relationship between the layer effects from Photoshop. Illustrator seems to assume that anything coming out of Photoshop will be bitmap based and acts accordingly.
    Any feedback or similar experiences would be appreciated.
    Cian Walsh
    [link deleted]

    Hi guys,
    From last week am I trying to do what I mentioned in post above, I just find it very difficult to do. Now I beginning to doubt whether it is possible or not, provided the SDK we have for CS4.
    What do you think, is it a doable item and I am missing some simple thing ??
    Please let me know of your views its really very important.
    Thanks,
    D

  • Installing custom shapes in PSE 7

    I have some .csh files I used when I had PSE 4 and have just upgraded. I've been able to successfully edit the meta data files and install layer styles but can't figure out how to access the custom shapes files. I had expected to click on the double arrow from the custom shape dropdown to get to a "Load shapes" menu but I don't see one. I have Windows XP.

    Well, I figured it out by trial and error I guess. Here is the path where you put the custom shapes (Windows and PSE 7.0).
    C:\Documents and Settings\Lisa\Application Data\Adobe\Photoshop Elements\7.0\Presets\Custom Shapes
    The difference is that we put the layer styles in the path C:\Documents and Settings\All Users\Application Data\Adobe\Photoshop Elements\7.0\Photo Creations\shapes.
    Note the difference between "Lisa" and "All Users".
    After doing this and deleting the ThumbDatabase.db3 and MediaDatabase.db3 files, PSE rebuilt them and my custom shapes now showed up. WHEW!!!! What a pain. I guess the confusing part was the difference in that some things are for A user and not All Users.

  • Disappearing custom shapes

    i've posted about this before, but never received a single answer.
    hopefully meanwhile someone's figured out what's going on
    so, i followed, step by step, the ken stone tutorial on making custom shapes - highly recommended set of tutorials on this and other topics - but am having a problem applying them.
    that is, i can apply them and save my project.
    if i then close the project, dvdsp clears the "custom shapes" palette - even though i did __not select "for this project only" when importing the shapes....
    now when i re-open the project, dvdsp will complain about the shape it itself has made disappear and removes the shapes from dvd-menu.
    re-importing the shape into the "custom shapes" palette triggers another error message about the shape already being there even though the shapes palette is totally empty...
    what am i missing here????
    thanks

    Okay, Problem solved. In the toolbar I had hit "Paths" somehow, instead of it being set to "Shape Layers"
    Doh!!
    Thanks for your time if you've looked here though!

  • Define Custom Shape Option is Greyed out

    I'd appreciate any help that could be provided, I have not been able to define custom shapes in CS6. I'm using the pen tool in shape mode, I've used the path selection tool and switched between the path operations. I've made sure that the shape is selected in the paths work bar. Nothing seems to open up the define custom shape option. Is there a setting I'm neglecting to check? Thanks in advance for your thoughts.

    I just tried deleting first just the tool preferences, and then all the photoshop preferences. There has been no change...Still unable to get define custom shape as an option.
    I've also tried using the path option instead of the shape selection and that also makes no difference.
    Just as a note I have used the same steps on another computer running CS6 and it functions 100% properly.

  • Trying to make a custom shape

    I'm attempting to create an object out of a square but I need to change the dimensions of all 4 sides, is it possible to manually input the dimensions of each side? 4 by 6 1/2 by 7 3/4 by 6

    If Photoshop is your only Adobe product like me. Its not the best tool for something like what you want to create.  To do what you want I would open a new Document or your jpeg. The Jpeg I would use the perspective crop tool to crop the EPS Design to square it up some. Then transform that to the correct aspect ratio you want.  I would then add text layers to on it to get as close as I could to the three line using a font that matches the logo.  I would then make shape layers for the three text layer and merge then into a single shape.  I would then edit the shapes path to make it closer to your image design. Then define a custom shape named EPS.

  • Custom shapes: zooming and picking

    I need design advice regarding a screen-full of custom shapes I am making: my app will draw literally thousands of primitive octagons. I have seen this issue in other threads, but answers didn't fully apply to my situation.
    Using Graphics2D's scale, I will enable zooming ability. The current problem involves zooming: getting contains() to work in the event I'm zoomed in or out. I've heard of a method that AffineTransform has that returns you a transformed shape?
    Assuming that works, then I still have to run contains(), followed by AffineTransform's transformed shape method roughly 4000 times. Any advice on this? If performance isn't instantaneous I'm going to have to choose a clever data structure/alg.
    The octagons are more or less in "grid format" and it forms a big rectangular array. Thanks!

    Yes, you shouldn't need to transform your shapes either for rendering or hit tests.
    Note that if you frequently have to perform that many tests and a significant number of your shapes are non-rectangular, you may (depending on how contains() is implemented for each shape) get a performance benefit by caching the bounding boxes of each shape - rectangles are of course the quickest hit-test available and once you've tested those you can perform a proper contains() on the shapes themselves. You could perhaps optimise the test further by storing lists/arrays of bounding boxes sorted by positions of each edge so that you don't need to test all 4000.
    How much benefit you get from these strategies depends on both your use case and your data, which obviously I can only guess at.

  • SSRS reports : custom shapes

    Hello,
    I have to generate DOCX, XLSX and PDF format with custom shapes. Attached is a sample of the report expected. The shapes contain data from DB. The color of the shapes will vary depending on the data from DB. e.g. the shape can be gray in one report and can
    be green in another, depending on user selection.
    How can I create such a report using SSRS? Should the shapes be generated at runtime or I should add the shapes to the template? 
    If I add the shapes as image to the template, then how can I superimpose the text from the DB? also how Can I control thecolor?
    if SSRS is not the best way to do this please suggest.

    Hi RachanaD,
    Reporting Services provides a rich set of tools for building and publishing enterprise reports, managing security and subscriptions, and extending the reporting functionality through a comprehensive API. So if we want to extend existing functionality with
    alternative versions of controls that are already included with Reporting Services, we can custom some report items run-time component and design-time component that can be used in Report Builder.
    To custom a report item like polygons in Reporting Services 2008 R2, we should be familiar with Visual Studio and Microsoft Visual C#, and our system must meet the following requirements to use the PolygonsCRI sample:
    Microsoft SQL Server 2008 R2 with Reporting Services.
    Microsoft SQL Server Business Intelligence Development Studio.
    Microsoft Visual Studio 2008 or later.
    Microsoft .NET Framework 2.0.
    Reporting Services samples.
    A report server that you have permission to access on your network.
    Then we can refer to the following document to use the custom item in report:
    http://msftrsprodsamples.codeplex.com/wikipage?title=SS2008R2%21Custom%20Report%20Item%20Sample&referringTitle=Home
    Hope this helps.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

Maybe you are looking for