How do you create different shaped borders?

I need to create lots of different shaped borders that can be selected for a particular component, I know that you have to either extend AbstractBorder or implement Border interface, but I don't really know how to get the shape that I want, the most basic of which is a circle.
Also will the component 'know' how to size the border so that the child components fit within it with no overlap?
if anyone has an example border class they could donate to ease my confusion, i would be most grateful

I have attached code for a border that draws a circle. If the insets are not large enough, then the child component will overlap. The large the child component needs to be, the large the insets should be in order for the oval to not be broken.
// Border class
public class OvalBorder implements javax.swing.border.Border {
    // insets used by the parent component for sizing the child component
    java.awt.Insets insets;
    public OvalBorder( ) {
        this( new java.awt.Insets( 20, 20, 20, 20 ) );
    public OvalBorder( java.awt.Insets insets ) {
        this.insets = insets;
    // Tell the parent component not to pain a backgroun underneath the border.
    public boolean isBorderOpaque( ) {
        return false;
    // Paint a simple oval border.
    public void paintBorder( java.awt.Component component, java.awt.Graphics g, int x, int y, int width, int height ) {
        g.setColor( java.awt.Color.white );
        g.fillOval( x, y, width, height );
        g.setColor( java.awt.Color.black );
        g.drawOval( x, y, width, height );
    // Return the insets that the parent component will use to size
    // the child component
    public java.awt.Insets getBorderInsets( java.awt.Component p1 ) {
        // Must do a clone so an outside source does not mess up the inset object.
        return (java.awt.Insets)insets.clone( );
    // A simple frame example of the border
    public static void main( String[ ] args ) {
        javax.swing.JFrame frame = new javax.swing.JFrame( );
        frame.setDefaultCloseOperation( javax.swing.JFrame.EXIT_ON_CLOSE );
        javax.swing.JPanel panel = new javax.swing.JPanel( new java.awt.GridLayout( 2, 1, 0, 0 ) );
        panel.setBorder( new OvalBorder( ) );
        frame.setContentPane( panel );
        javax.swing.JButton add = new javax.swing.JButton( "Add" );
        javax.swing.JButton minus = new javax.swing.JButton( "Minus" );
        frame.getContentPane( ).add( add );
        frame.getContentPane( ).add( minus );
        Inc inc = new Inc( add, minus, frame );
        add.addActionListener( inc );
        minus.addActionListener( inc );
        frame.pack( );
        frame.setVisible( true );
// A support class that will cause the frame to resize equaly in both directions.
class Inc implements java.awt.event.ActionListener {
    javax.swing.JButton add;
    javax.swing.JButton minus;
    javax.swing.JFrame frame;
    java.awt.Dimension pref;
    public Inc( javax.swing.JButton add, javax.swing.JButton minus, javax.swing.JFrame frame ) {
        this.add = add;
        this.minus = minus;
        this.frame = frame;
        pref = minus.getPreferredSize( );
        pref.width = pref.height<<1;
    public void actionPerformed( java.awt.event.ActionEvent event ) {
        if ( event.getSource( ) == add ) {
            pref.width+=2;
            pref.height++;
        } else {
            pref.width-=2;
            pref.height--;
        add.setPreferredSize( pref );
        minus.setPreferredSize( pref );
        System.out.println( pref );
        frame.pack( );
}

Similar Messages

  • HT5538 How do you created different apple ID's on same iTunes account? Wife and 2 kids contacts are all linked on my phone and got to separate! Any help would be appreciated!

    My contacts are merging with wife, son and daughter. How do we create separate ID's but still maintain same iTunes account?

    You can use separate AppleIDs for iCloud, iMessage and iTunes - you just need to create unique AppleIDs for the iCloud accounts if syncing contacts that way (you will need an email address that is not already registered as an AppleID though to get another AppleID).
    Apps are different: purchases are tied to the AppleID used to log in to the store to make the purchase.  So you can create another AppleID for iTunes as well and use different ones on the different phones, but any apps you have already purchased with your existing AppleID are permanently tied to that AppleID.
    So,  unless you are sharing apps, content and such, there is no reason to use the same AppleID on each  So the simplest solution is to create new AppleID(s) for other devices.  If you need an email address to do that, just get a gmail account (or any other free email account).
    Good luck

  • How do you create different headers on each page of a document in icloud pages?

    I have to have a different header on my title page than the rest of my paper.  I believe I did it once before but it may have been in the regular pages program on my Macbook Pro.  I was wondering if there was a way to do it on the icloud and ipad versions of pages due to I do most of my work away from my laptop.
    Thanks!

    I found on my computer, if you click on the header you can change it on each page.  There is also a place in Set Up under Sections at the bottom of the page that has a drop down to create a new Section either 'Starting with this section' or 'After this section'.  Hope this helps.  Also at the top there is a place under Headers & Footers to  choose either 'hide on first page of section' or 'match previous section'.  I believe if you deselect the 'match previous section' you can easily change the header or footer for each page.

  • How do I create different iTunes library for different Iphones in a family

    how do I create different iTunes library and Syncing Iphone separately using same desktop PC?

    The best way to set it up in my opinion is to have each user have there own user account on the computer. This way information is stored separately and easier to locate and navigate through.
    If you want to have it this way but would rather go through and log into different iTunes libraries on the same user account follow this article. If you do it this, it would work the same you just want to make sure the correct library is open before syncing the device.
    http://support.apple.com/kb/HT1589
    Hope this helps!!

  • How do you create new maps in Mail on iPad?

    How do you create new maps in Mail on iPad?
    In the iPad-manual they mention you can put messages in other mailboxes or maps (to free up the Inbox).
    But they don't mention how to create such maps.
    In the app itself I can't find a way to do it.
    thanks for all replies
    Kamiel

    Maybe you are confused by the fact I used the word 'maps' instead of 'folders' (my natural Ianguage is Dutch).
    For your question about the manual: on page 59 in the 'iPad 2 user guide' under 'organizing Email' they say you can move messages to a different mailbox or folder.

  • How do you create separate iCloud accounts

    not real computer savy. How do I create different iCloud accounts, so we are not sharing everything?

    on iPhone? If you share an iPhone I amafraid you will have to share "everything" unles every time you will be going to settings and reconfigure it.
    Otherwise, go to your computer and from different account create an iCloud account.

  • How do you create aligned interactive text boxs in a PDF with the same width and height?

    how do you create aligned interactive text boxs in a PDF with the same width and height?
    Without free hand creating the sizing?

    Assuming by "interactive text boxes" you mean form fields; in Acrobat, make a form field, then copy it and paste. (GIve the pasted copy a different name so they don't genetate the same field feedback.) Now you have two fields of the exact same size. Shift-click or marquee-drag to select both, then right-click and choose a command from the Align, Distribute or Center menu.

  • How do you create a link to a pdf in Muse? Thought it was going to show that with Katie's menu and can"t find in any of the tutorials.

    How do you create a link to a pdf in Muse? Thought it was going to show that with Katie's menu and can't find in any of the tutorials.

    The steps would be :
    - Add files from file menu > select pdf > add to site
    - Select the content (rectangle,text etc) and click on hyperlink dropdown > it should show you the added files list
    - Select the file you want to link
    Thanks,
    Sanjit

  • How do you create a new apple id on the iphone

    how do you create a new apple id on the iphone 4?

    Why do you want to do that?

  • How would you create a read/display only applicaiton montior role for SRM

    Hello,
    I was hoping to get some insight on how to create a display/read only SRM Application monitor role.  This role would be used by our Service Desk to perform basic trouble shooting before escalating.  Currently in our system it is tied into a tab named SAP Administration and has the capability of doing more than read.  How do you create a read version of this to only display the application monitoring in read mode? We currently have an SRP role that has the followiing auths below.  Would a EPP portal role need to be created and if so how>  Thank you for any assistance.
       Manually   BBP Component                                                BBP
              Manually   SRM: General Access Authorizations in EBP                    BBP_FUNCT
               Manually   SRM: General Access Authorizations in EBP                    T-SD59003000
                 Function in SRM (for Authoriza MON_ALERTS                                                                  BBP_FUNCT
    - Todd

    Hello,
    I was hoping to get some insight on how to create a display/read only SRM Application monitor role.  This role would be used by our Service Desk to perform basic trouble shooting before escalating.  Currently in our system it is tied into a tab named SAP Administration and has the capability of doing more than read.  How do you create a read version of this to only display the application monitoring in read mode? We currently have an SRP role that has the followiing auths below.  Would a EPP portal role need to be created and if so how>  Thank you for any assistance.
       Manually   BBP Component                                                BBP
              Manually   SRM: General Access Authorizations in EBP                    BBP_FUNCT
               Manually   SRM: General Access Authorizations in EBP                    T-SD59003000
                 Function in SRM (for Authoriza MON_ALERTS                                                                  BBP_FUNCT
    - Todd

  • How do you connect your photoshop elements on your computer to your account online? and how do you create a customized url? how does the gallery work and how do you access it? i have trouble signing in on my program from my computer to connect to the onli

    how do you connect your photoshop elements on your computer to your account online? and how do you create a customized url? how does the gallery work and how do you access it? i have trouble signing in on my program from my computer to connect to the online photoshop, and I really want to create my own customized url and post photos to my gallery and share them with the world, family, and friends, but i need help because i can't figure how to do any of this, would really appreciate feedback and assistance, thanks, - claire conlon

    To add to sig's reply, "calibrating" does not calibrate Lithiu-Ion batteries, it calibrates the charge reporting circuitry.  If you look at the effect of deep discharging Lithium-Ion batteries in the data from the independent test group, Battery University, you will see that doing so shortens the life of the battery significantly. It looks like an optimum balance between use and life is at a discharge level of 50%.

  • HT4191 iPhone Local Storage "My iPhone" - How do you create this folder for use by the Notes app on a iPhone or iPad?  If I want to keep some notes only on my device and not in a cloud environment associated with an e-mail account.

    iPhone Local Storage "My iPhone" - How do you create this folder for use by the Notes app on a iPhone or iPad?  If I want to keep some notes only on my device and not in a cloud environment associated with an e-mail account.  I've seen reference to the  "My iPhone" local storage put no mention on how you create this folder or access this folder within the Notes app.  I realize storing information in a local storage like this provides no syncing between other iDevices but that is exactly what I'm looking for.  I'm running iOS7.0.4 on a iPhone 5S, and a iPad Air.  Any help would be greatly appreciated.

    If you go to Settings > Notes > Default Account you will see "On My iPhone" as the default account and the only choice if you have not enabled syncing Notes in Settings >iCloud or Settings > Mail, Contacts, Calendars. If you have enabled syncing you can still select "On My iPhone" as the default account. When you are in the Notes app you won't see any accounts listed if you have not enabled syncing because they are all in the On My iPhone account and that is the only place possible. It is not a folder that you create.

  • How do you create a new account for a family member?

    My daughter and I both have Ipods, and want to setup SEPARATE accounts. Itunes 7 worked great, but now when we 'upgraded' to 8, it MERGED all our files. So I thought I had a separate account, but it turns out when I load a new song, it goes into HER Itunes files. She deleted all my info, and I REALLY want a separate account (that sticks).
    My songs are still in my directory under "Mikes Itunes", but when I reloaded them into what I thought was a fresh entry, it turns out it went into my daughter's Itunes file too! What is up with Itunes 8? and how can you create a TRUE separate account so I have control over MY songs!?

    First, let's make it easier to swap between accounts. In the Accounts pane of System Preferences click on the Login Options (after unlocking the pane). Enable fast user switching. This will put a new menu in the top right of the screen. You can then swap to the other account without having to log out of the current one.
    Log into the original account. Select the folder you want access from the other account and choose Get Info from the file menu. There is a section called Sharing & Permissions. You will need to click on the padlock to make changes. Click on the + to add permissions for the other user account by selecting the user account from list that appears. Set the permission for that account to read only. Once you have it listed then choose the "Apply to enclosed items" from the gear menu below the list. This should give you access from the other account to that folder and any folders contained in it.
    For iTunes you will want to do this to the Music folder, giving you access to the files below. From within iTunes you can select Add to Library from the file menu, and then select the music from the other account to that account's iTunes library. Once you have set up the new library whoever's library is the original can clean up the library to remove any music they don't want (now that it's in the new account).

  • How do you create an AcrobatXI zip file in windows 8.1?

    How do you create an AcrobatXI zip file in windows 8.1? from acrobat.com docs?  Sorry Not sure what community to ask this in this community?  The email provider I was using didn''t seem to want to accept it through Adobe Send the first time and since Adobe Send ends January 6, I am assuming a zip file is preferable..  I thought I had seen an Adobe Zip file somewhere but haven't been able to locate it. Any help appreciated.
    Thank you.
    Sherrie

    Hi Sherrie L,
    Adobe Send is Adobe's current solution for sending large files. (It's Adobe SendNow that's retiring soon.) Can you tell us what trouble you were running into using Adobe Send?
    There isn't a special version of Zip files for Acrobat, but you could reduce the PDF file size if you have Acrobat. Or, in Windows, you can create a Zip file by choosing File > Send to > Compressed (Zipped) Folder.
    Best,
    Sara

  • How do you stack different photos in the editor layers pallet

    How do you stack different photos in the editor layers pallet? I can get different photos in the editor, but I cannot figure out how to get different photos into the layers pallet at the same time.  Please help!!!!!

    Just to clarify, you can never see the layers panel for more than one photo at a time. The suggestions you got will show all the photos, but because they are now combined as layers in one image.
    If you want to see more photos in the editor at once, go to the preferences>general and turn on Allow Floating Documents, then go to Window>Images>Float all in windows, then Cascade or Tile.
    But you will still only see the layers panel for the image that is active at the moment.

Maybe you are looking for

  • FCP7 with snow leopard - choppy playback in monitor

    Ive been fine running fcp6 with a jvc 1080 hd monitor connect via DVI from my MBP duo intel 2.4 (4 gigs ram) its not the fastest setup but its been fine. ive noticed my playback into my monitor is always choppy now since upgrade to fcp7 and snow lep.

  • How to create a table with a variable

    Hi everyone! I have a procedure which receives a table name as a parameter and need to create a table using that name For example: PROCEDURE REFRESH_REPORTS (table_name varchar2) IS BEGIN table_name_REPORT := table_name; execute immediate 'create tab

  • ORA-32004: obsolete and or deprecated parameter

    Oracle 11.1.7.0: When I startup the db I get ORA-32004. There is no trace of which parameter is obsolete in alert logs. Neither do I see that parameter in v$obsolete_parameter. How can I look at what that parameter is?

  • Computer problem. PC built.

    Alright just to keep this short and simple. I turned on my computer the other day and smelt something burning like dust or what not. Anyways after an hour use my computer just shut off on it own, trying to turn it back on but no success, The power st

  • User Exit to add custom field in Component Screen

    Hi Friends, I searched alot but could find exit to add custom field or tab in material component detail screen for SAP 4.7. Please let me know if there is any exit  or workaround possible. Thanks, Raj