How can I specify that a border should have a certain length on a side?

how to customize a border so that length can be specified?
(I know that you can use createMatteBorder() to specify which sides should have a border. But this is different - how do you specify the length on a side).
for example, here is one side: --- is the side and ==== is the border
===========
how do I implement it?
I am stumped.
thanks,
Anil

BorderFactory does dispense some static instances depending on the type of
border being created. But you'll need to subclass MatteBorder to customize it;
I don't think you'll be able to do it via BorderFactory. You can either override
the paintBorder method to not paint the entire top part of the border or paint
over it; the latter approach is taken below:
import java.awt.*;
import javax.swing.border.MatteBorder;
import javax.swing.*;
public class PartiallyPaintedBorder extends MatteBorder {
     private final static int MARGIN = 15;
     public PartiallyPaintedBorder( int top, int left, int bottom, int right, Icon tileIcon ) {
          super( top, left, bottom, right, tileIcon );
     * Paints the matte border.
    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
         super.paintBorder( c, g, x, y, width, height );
        Insets insets = getBorderInsets(c);
        Color oldColor = g.getColor();
        g.translate(x, y);
        color = c.getBackground();
        if ( color == null )
             color = Color.gray;
        // Erase part of top matte edge
        g.setColor(color);
        g.fillRect( width / 2, 0, width, insets.top);
        g.translate(-x, -y);
        g.setColor(oldColor);
     // Example use on a JPanel containing a JButton.
     public static void main( String[] args ) {
          JPanel p = new JPanel();
          p.setBorder( new PartiallyPaintedBorder( MARGIN, MARGIN, MARGIN, MARGIN, UIManager.getIcon( "FileView.computerIcon" ) ) );
          p.add( new javax.swing.JButton( "Press me" ) );
          JFrame f = new JFrame( "Tester" );
          f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
          f.getContentPane().add( p );
          f.pack();
          f.setVisible( true );
}

Similar Messages

  • How can i indicate that the table columns have different size?

    How can i indicate that the table columns have different size?
    It is because i have a table that has several columns....but i would like to have the possibility to indicate the size for every column....could somebody help me please?
    Thanks,
    Mary

    Hi,
    don't know as much as I should about JTable, but it seems that using yourTable.getDefaultRenderer() could help you: if I clearly understood the javadoc notes, it returns an object inheriting from JLabel, so you should be able to use setHorizontalAlignment(int align) on it... no time to verify this, but I'd be thankfull if you tell me the results !!!
    Regards

  • My boyfriend and I have each an IPhone with two different Apple IDs. Since the recent software his contacts appears in my Iphone. How can I switch that off? I have be looking at both Iphones and Iclouds.

    My boyfriend and I have each an IPhone with two different Apple IDs. Since the recent software his contacts appears in my Iphone. How can I switch that off? I have be looking at both Iphones and Iclouds.

    All apps and purchases are linked to your apple ID, so you can't share them across 2 devices that are using different apple id's, it won't work. the purchases that are on your mac at the moment will only work with the apple id they were brought with.
    the only thing thats possible to share is purchased music. you have to first covert it to mp3 within itunes, then your bf can import it into his own itunes library and sync with his phone.

  • How can one specify that multiple windows open (each with its own web page(s) ) when Firefox starts?

    I am on Firefox 15.0. I would prefer not to open multiple tabs to get multiple web sites up when Firefox is started. Instead, I prefer multiple windows. Some might have one tab, some might have several. For example, one window might have Gmail, another might have several different web pages related to weather, and another might simply have Google, and another Yahoo, and another, Orbitz. Since there may be five or six of these windows, with multiple web pages, perhaps 20 in toal, tabs get cluttered, and I don't prefer them anyway. I have plenty of memory and processing power.
    Interestingly enough, if Firefox crashes, it allows you to restart with the pages it thinks you would want. It would be great to have a Start Firefox option similar to that!

    You can reopen the windows and tabs from the previous session.
    You can also use command line switches with a bash script or a modified Firefox desktop shortcut ant use -new-window -url <URL> to open a page in a new window.
    <pre><nowiki><path to firefox>/firefox -new-window -url <URL1> -new-window -url <URL2>
    </nowiki></pre>
    *https://developer.mozilla.org/en/Command_Line_Options

  • How do I specify that an image should be in the shared images folder?

    I created a simple 4 page website, and my background, title and subtitle are the same on all four pages. In iWeb, it saves the same image to all pages, basically because there is no ability to duplicate an existing page.
    Yes I know I can modify the HTML in the published version, but this is annoying if I need to go back in and change something.
    Having a background image load slowly because its a PNG is one problem, but having the same image reload slowly in a second page is unacceptable.
    Is there an option I'm missing???

    That's what iWeb does. It's all part of making it easy to use for novices. Those that aren't novices will notice it can be inefficient, but you can't have it all ways.

  • I have an iPod touch and wife has a new ipad2. We share one computer. Now, when she downloads an app to her ipad the app also downloads on my iPod touch. How can we stop that?

    I have an iPod touch and wife has a new ipad2. We share one computer. Now, when she downloads an app to her ipad the app also downloads on my iPod touch. How can we stop that?

    you should have two separate account

  • I know how to convert wma files into aac but the itunes program messed all my album how can i fix that

    When i convert my wma files and put them into my itunes program it converts them automaticly but it mess up all my albums it split albums and it put lonely song here and there and i cannot put them back were they bellong...why it does that ? How can i fix that because i do have a lot of albums and i would like to convert them all and make sure that all song are in the album were it should belong ?
    Thank in Advance.
    Yan.

    Filling in the Album Artist will fix things most of the time, though if you also have an older iPod then you might find the album splits up again on your device. For more information see my article on Grouping tracks into albums.
    tt2

  • Hi my version of P-shop cc is in swedish and I wish to change that to english. How can I do that?

    Hi my version of P-shop cc is in swedish and I wish to change that to english. How can I do that?

    You would have to add the language pack from the CC Desktop Panel.  But first, let's be sure if it is an option in Photoshop Preferences.  If it is change to English and Restart Photoshop.
    If not, exit Photoshop and install English.
    Here is a screenshot guide to adding language packs via the Creative Cloud Desktop app:
    In this example, Simplified Chinese is chosen, but no matter the language, you will see an Install button underneath Find New Apps. When the Install is finished,
    open Photoshop and it should be in the UI language list you see in the first screenshot.

  • When I send an Imessage to other's who have iMessage my e-mail adress pop's up instead of my name.. How can I fix that?

    when I send an iMessage to other's who have iMessage my e-mail adress pop's up instead of my name when they recieve my text.. How can I fix that?

    They would have to have your name in their contacts and then assign your email address to your contact. It's similar to receiving a regular text message from a phone number you do not have saved in your contacts; their phone number will show up instead of their name, but once you add them to your contacts their name will show up.

  • I want know that when ever i open a new tab, i should get all the websites visited in small tabs. How can i get that ?

    On opening a new tab, i should get all the previously visited websites in small or medium tab format. How can i get that ?
    Please help me with that.

    Is this a Thunderbird question?

  • I have a Macbook Pro early 2011. i don't have AirPlay on my computer. How can I get it. I have read that early 2011 should have the AirPlay option. Any ideas please.

    I have a Macbook Pro early 2011. i don't have AirPlay on my computer. How can I get it. I have read that early 2011 should have the AirPlay option. Any ideas please.

    Hi All,
    I need your expert advice to proceed. I bought apple TV and it works fine with my iPad and iPhones also fine with itune of my Mac Book Pro BUT I am not seeing setting which says "Airplay Mirroring" in system preference -> Display at all.
    I checked my mac serial number and it shows the model as below. As far as I understood this feature should be there from 2011 onwards.
    MacBook Pro (13-inch, Late 2011)
    Software  Mac OS X Lion 10.7.5 (11G63b)
    Please suggest!!
    Thanks and Regards

  • How can I specify an SFTP directory path that has spaces in it?

    The directory (path) on my SFTP server has spaces in some of the folder names: e.g. /data/Cisco Products/UC Applications/
    How can I specify this path in the directory field of a remote server definition if I want to upload files from my SFTP server to the CUCM?
    I've tried surrounding the whole path in quotes, %, *, backslash space, point, hash...running out of things to try. Must be possible...surely?!#
    Thank-you
    -Rob.

    I haven't tried this but when i hit tab to auto complete on a linux machine i notice a space and backslash between two words. I can see you tried backslash space. Try space backspace - <word><space><backslash><word>

  • How Can i specify multiple server names in rwservlet.properties  file?

    How Can i specify multiple server names in rwservlet.properties file without clustering?
    I am using oracle 10g Application server. we have 3 servers Repsvr1, RepSvr2 and RepSvr3. Now i need to configure rwservlet.properties file to point to these servers based on any running report. i got 3 keymap files with reports info.
    Sample entry in the key map file is:
    key1: server=Repsvr1 userid=xxx/yyy@dbname report=D:\Web\path1\path2\reports\Report1.rdf destype=cache desformat=PDF %*
    key2: server=Repsvr2 userid=xxx/yyy@dbname report=D:\Web\path1\path3\reports\Report2.rdf destype=cache desformat=PDF %*
    rwservlet.properties file letting me to enter only one servername. Even though i merged all 3 keymap files into 1, still i have the server name issue. If i leave the server to the default name still i am getting the below error.
    REP-51002: Bind to Reports Server Repsvr1 failed. However, i know the default rep_<servername> would be used incase we dont have SERVER=<value> parameter in the rwservlet.properties file.
    If i specify the servername in the rwservlet.properties file then only Repsvr1 reports are working fine and other 2 server reports are giving the same error like
    REP-51002: Bind to Reports Server <<Server Name>> failed.
    how can i configure the info which will work all 3 reports. 2 Port servers are invoking using oracle forms and report server is invoking using ASP pages.
    If i specify Server name & Key map file in rwservlet.properties one at a time, all the reports are working without any error, whenever i am trying to integrate all 3 to workable i am getting binding error. if i exclude the server from rwservlet.properties still i am getting the same error.

    My RELOAD_KEYMAP setting is YES only.As i said If i specify Server name & Key map file in rwservlet.properties one at a time, all the reports are working without any error.
    keymap file entries
    key1: server=Repsvr1 userid=xxx/yyy@dbname report=D:\Web\path1\path2\reports\Report1.rdf destype=cache desformat=PDF %*
    key2: server=Repsvr2 userid=xxx/yyy@dbname report=D:\Web\path1\path3\reports\Report2.rdf destype=cache desformat=PDF %*
    If i use http://server.domain:port/reports/rwservlet? cmdkey = key1 should bring the report from Repsvr1 and http://server.domain:port/reports/rwservlet? cmdkey = key2 should bring the report from Repsvr2, but i am getting an error from Repsvr2 saying that REP-51002: Bind to Reports Server repsvr2 failed.
    Only Servername Repsvr1 is in rwservlet.properties file. Now what is the best option to by pass the server from rwservlet.properties file and should be from keymap file. if i comment server name in rwservlet.properties file still i am getting REP-51002: Bind to Reports Server <<Server Name>> failed error for both keys.

  • How can I specify the default tab in a CHM Output?

    My company uses CHM-based help for some of its products. We build the CHM files from RoboHelp 9, and while these CHM files don't really have a full Index attached to them, the Index tab shows up in the output anyway. Unfortunately, we are suddenly seeing that when the CHM file is launched from our program, the Index tab is displayed by default. We'd rather have the Contents tab be the default look, especially considering that the Index does not exist.
    I have poked around into how you can specify a default tab for a CHM file, and the only information I have found suggests that using a CHM file creates a file (HH.dat) that specifies which tab should be displayed on a user-by-user basis, and that the last tab displayed when you close the CHM should be the first one displayed when you re-open it. While this is true if you open the CHM independent from the product, when you launch it from our program, it's all Index, all the time.
    So, my question is: How can I specify the default tab for a CHM file? Or, failing that, how can I excise the Index tab from my CHM output.

    Hi there
    This will be something up to your application developer to resolve. When s/he issues the call to open the CHM, there are parameters that may be used to always open with the desired tab "in front".
    Point your developer to the link below and advise that s/he is most likely interested in the section titled: Programming Tips.
    Click here to view
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7, 8 or 9 within the day!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • How can I specify the path in Form Builder 9.0

    Hi, everyone,
    could anybody tell me how can I specify the path in Form Buidler 9.0? there is problems when I want to attach library in form builder. thanks to Kuldeep RAwat and Natalia Vidal, I know I should specify the path, but I still don't know how to specify, how can I do?
    besides, when I run a form, sometime there will be a warnig:
    Please acknowledge message
    what's that meaning?
    thank you very much for your great help

    Shay Shmeltzer thank you very much for your so quickly response. I have modified the file and my form can run now!
    but, when I open my form, it always suggest me:
    FRM-10102: Cannot attach PL/SQL library TalbotStandard. This library attachment will be lost if the module is saved.
    so everytime I open my form, I must attach the library manully. I don't know the reason. do you know that or anybody else knows that? thank you very much!
    have a good weekend :-)

Maybe you are looking for

  • Not able to update the project using 'BAPI_PROJECT_MAINTAIN'.

    I  want to create a project , with reference to an already existing project. I am using 'BAPI_PROJECT_GETINFO' to get the data of the existing project.   The bapi gives the following: 1)     e_project_definition. 2)     e_wbs_element_table. 3)     e_

  • Wondering how to create a text box with variables...

    Hi everyone, I was wondering how to create a text box, that at the beginning of the presentation, the audience fills in regarding what they think constitutes the role they have been chosen for. I would like that same box to then appear at the end of

  • Main Viewer is blank

    I have just started to use Aperture and somewhere along the way the main viewer has gone blank . If I look at the images in full screen they appear and can be edited . But once I switch back , only the photos in the browser are visible with the main

  • DB Connect Procedure

    hi collegues, Some one Please give me the complete procedure of DB connect(Oracle Database)  with all details like, 1. Where should the DB client should exist 2. advantages of DB connect Please send me the Details at   [email protected] Thanks in adv

  • Droid Pro- corporate contact access

    I just got the Droid Pro and so far so good.  I changed over from the Droid Eris because I needed a global phone and wanted a hard keyboard.  I really like it but I seem to have an issue...I don't think I can search for a contact that is in my compan