No space between buttons

Hi,
Here i put three buttons on panel one under one but there is no space between them although i determine the space ..
my code :
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class MainFram extends JFrame {
    private JPanel mainPanel;
    private JButton[] buttons;
//    private JLabel[] labels;
    private String[] labelNames = {"Levels", "Help", "About"};
    private static final int BUTTON_DISTANCE_Y = 20;
    private static final int BUTTON_WIDTH = 50, BUTTON_HEIGHT = 50;
    public MainFram() {
        intializingPanel();
        intializingButtons();
      //  intializingLabel();
        getContentPane().add(mainPanel);
    public static void main(String[] args) {
        MainFram mainFram = new MainFram();
        mainFram.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        mainFram.setSize(new Dimension(600, 300));
        mainFram.setLocationRelativeTo(null);
        mainFram.setVisible(true);
        mainFram.setExtendedState(MAXIMIZED_BOTH);
    private void intializingPanel() {
        mainPanel = new JPanel(null);
        mainPanel.setBounds(100, 10, 600, 300);
        mainPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 5));
        mainPanel.setBackground(Color.GREEN);
    private void intializingButtons() {
        buttons = new JButton[labelNames.length];
        for (int i = 0; i < labelNames.length; ++i) {
            buttons[i] = new JButton();
            buttons.setBounds(50, (BUTTON_DISTANCE_Y * i) + 50, BUTTON_WIDTH, BUTTON_HEIGHT);
mainPanel.add(buttons[i]);
// private void intializingLabel() {
Why this ???
thanks in advance                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

beshoyatefw wrote:
Why this ???Because you have the equation wrong!
   buttons.setBounds(50, ((BUTTON_DISTANCE_Y + BUTTON_WIDTH) * i) + 50, BUTTON_WIDTH, BUTTON_HEIGHT);

Similar Messages

  • How can I set some space between buttons on the buttonbar

    I want to set some empty spaces between buttons on the button control bar?
    Thank you.
    Scott

    If you mean a JToolBar try addSeparator();
    If you mean a JMenuBar... I don't know!

  • Menu widget (horizontal) space between buttons

    How do I get spaces between navigation buttons on the horizontal menu widget?
    In the basic Katie video, she does this as a "pre-set". Then in the advanced video it shows up in the images with no discussion. Thanks for helping.

    Hello,
    You can either choose to use manual menus for this and place the menu as per your requirement, or you can use the "uniform spacing" option in the item size section of menu options for some spacing between the menu items.
    Cheers
    Parikshit

  • Newbie How to put spaces between buttons

    I have a CANCEL and a SAVE button in a REGION.
    I tried putting    &nbsp:
    I would like to put about 4 spaces between them.
    Suggestions?
    Thanks.
    Steve

    You can try putting &ampnbsp;&ampnbsp;&ampnbsp;&ampnbsp; (that's a semi-colon, not a colon) in the Post Element Text of the first button.
    Regards,
    John

  • Eliminate Default Space Between Buttons

    This seems like a very simple problem - however, I cannot seem to find the solution for it.
    I have a VBox container and a Panel with vertical layout.  Each of them contain several buttons that are about 40 pixels high and extend to fill the width of the container.  The buttons are displayed vertically, but it seems as if Flex automatically asigns about 3 pixels worth of space between each button.  How do I eliminate this space?  There isn't a "Margin" property associated with the button.
    Here is an example..
    <mx:Panel x="83.5" y="186"
    width="250"
    height="435"
    layout="vertical"
    backgroundColor="#FFFFFF"
    borderColor="#B59D9D">
              <mx:Button width="100%" height="40" cornerRadius="0" label="Clothing" fontSize="18" color="#363535" fontWeight="normal" fontFamily="Verdana" borderColor="#FCFAFA"/>
              <mx:Button width="100%" height="40" cornerRadius="0" label="E-Books" fontSize="18" color="#363535" fontWeight="normal" fontFamily="Verdana"/>
              <mx:Button width="100%" height="40" cornerRadius="0" label="Laptops" fontSize="18" color="#363535" fontWeight="normal" fontFamily="Verdana"/>
              <mx:Button width="100%" height="40" cornerRadius="0" label="Movies" fontSize="18" color="#363535" fontWeight="normal" fontFamily="Verdana"/>
              <mx:Button width="100%" height="40" cornerRadius="0" label="Music" fontSize="18" color="#363535" fontWeight="normal" fontFamily="Verdana"/>
              <mx:Button width="100%" height="40" cornerRadius="0" label="Phones" fontSize="18" color="#363535" fontWeight="normal" fontFamily="Verdana"/>
              <mx:Button width="100%" height="40" cornerRadius="0" label="Software" fontSize="18" color="#363535" fontWeight="normal" fontFamily="Verdana"/>
    </mx:Panel>

    Thanks Prashant - it works!
    I didn't realize that it had to be added to the container for the buttons - I had been trying to apply it to each button instance.

  • Adding space between a buttons in a navigation list

    Hello,
    I am currently using apex 3.2.1 with a 10g backend. All of my forms are using a button list navigation. On one of my forms, I want to add more space between two buttons. Is this possible?
    Thanks,
    Mary

    That doesn't work for a button list navigation. It just makes the button bigger. I need space between two of the list entries in the navigation.
    Thanks,
    Mary

  • Space between htmlb radio buttons

    Hello all,
    I'm working with a jsp as part of a par file, and I'm trying to put a little bit of space between two radio buttons in a radioButtonGroup hbj tag. I've not had any success in doing so. Here's my code:
    <hbj:radioButtonGroup
      id="rbgSuppressZeros"
      columnCount="2"
      selection="N">
      <% rbgSuppressZeros.setOnClick("suppressZeros"); %>
      <hbj:radioButton
        id="doNotSuppress"
        text="Dont Suppress Zero Quantities"
        key="N"
        />
      <hbj:radioButton
        id="doSuppress"
        text="Suppress Zero Quantities"
        key="Y"
        />
      <% rbgSuppressZeros.setSelection(SearchBean.getSuppressZeros());%>
    </hbj:radioButtonGroup>
    I've tried adding spaces in the text attribute without success. I've also tried including   in the text attribute, but the page just displayed ' ' instead of translating it into a space. I tried adding   several times between the hbj:radioButton tags without success.
    Does anyone know how to do this?
    Thanks!
    Stephen Spalding
    Web Developer
    Graybar

    Hi Stephen,
    Try this code:
    <hbj:radioButtonGroup
    id="rbgSuppressZeros"
    columnCount="2"
    selection="N">
    <% rbgSuppressZeros.setOnClick("suppressZeros"); %>
    <hbj:radioButton
    id="doNotSuppress"
    text="Dont Suppress Zero Quantities"
    key="N"
    />
    <br>
    <hbj:radioButton
    id="doSuppress"
    text="Suppress Zero Quantities"
    key="Y"
    />
    <% rbgSuppressZeros.setSelection(SearchBean.getSuppressZeros());%>
    </hbj:radioButtonGroup>
    by adding the <br> tag it gives a space between your radio buttons. You can add as many <br> tag according to your requirement.
    Hope this solves your problem. If any problem then let me know.
    Regards
    Pravesh
    PS: Please award points if helpful.

  • How can i set the space between two button?

    Hello,
    I have
    <mx:HBox>
    <mx:Button label="one" />
    <mx:Button label="two" />
    </mx:HBox>
    how can i set the distance between this two compotents?
    Thanks

    quote:
    Originally posted by:
    robinbouc77
    Hi,
    you can use horizontalGap property on HBox to change the
    space between your buttons. I think the default value is 6. You can
    also use <mx:Spacer/>, but changing the gap on HBox is
    probably the cleanest way ;)
    C U
    perfect!!! works fine

  • How in the heck did the spaces between the buttons get in there?

    Hello,
    Go to this link:  http://www.peterdanko.com/peterdanko.com/gb_installation2.html#  Note the white spaces between the buttons.  They are not supposed to be there.  All margins/borders are set to zero.  Then, because of this white space, the last button gets tossed into the great cyber void.
    What am I doing wrong? and how come when I used this same structure on other pages it worked perfectly?
    Thanks,

    Hi Peter,
    about hotspots: you only need to build an image with your buttons (I made it at the moment with 5 so that I can send it here), like this:
    Then you have to insert this image in your DW file, a menu opens, which looks like this (German DW):
    Now you can do 10 overlays with these green (rectangle) areas and assign each aerea with a link.
    Hans-G.

  • Have more space between images used as buttons

    Hi again,
    Would like to see if there's some html properties to have more space beetwen buttons based on image:
    i've used: save.gif and del.gif instead of the standard template buttons.
    Would be nice to have the 2 images not so near.
    thanx a lot

    Hi,
    You could go to Edit Button Item and insert some HTML white spaces as Post Element Text. For example, if you have 2 buttons, do it at left button.
    Roger

  • White space between images

    I have 5 rollover images lined up beside each other in a
    table cell. I have reduced their borders to 0, the cell padding and
    cell spacing to 0 also. I even tried reducing the images padding
    and margin to 0. However, there is still a really thin line between
    each of the images that i want to get rid of (it's as if the images
    all have a small white border around them, but I've reduced their
    borders to 0).
    Here is what the code looks like:
    <table border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="53">
    <div id="box">
    <p align="right"><img src="banner.jpg"
    name="banner" width="536" height="101" border="0" id="banner" />
    <a href="#" onmouseout="MM_swapImgRestore()"
    onmouseover="MM_swapImage('home','','Buttons/homebtnover.jpg',1)"><img
    src="Buttons/homebtnup.jpg" name="home" width="107" height="36"
    border="0" id="home" /></a><a href="#"
    onmouseout="MM_swapImgRestore()"
    onmouseover="MM_swapImage('theteam','','Buttons/theteambtnover.jpg',1)"><img
    src="Buttons/theteambtnup.jpg" name="theteam" width="107"
    height="36" border="0" id="theteam" /></a><a href="#"
    onmouseout="MM_swapImgRestore()"
    onmouseover="MM_swapImage('schedule','','Buttons/schedulebtnover.jpg',1)"><img
    src="Buttons/schedulebtnup.jpg" name="schedule" width="107"
    height="36" border="0" id="schedule" /></a><a href="#"
    onmouseout="MM_swapImgRestore()"
    onmouseover="MM_swapImage('gallery','','Buttons/gallerybtnover.jpg',1)"><img
    src="Buttons/gallerybtnup.jpg" name="gallery" width="107"
    height="36" border="0" id="gallery" /></a><a href="#"
    onmouseout="MM_swapImgRestore()"
    onmouseover="MM_swapImage('contact','','Buttons/contactbtnover.jpg',1)"><img
    src="Buttons/contactbtnup.jpg" name="contact" width="108"
    height="36" border="0" id="contact" /></a></p>
    </div> </td>

    .oO(Twinbird24)
    >It still doesn't work. I've even tried to just make a new
    document and just
    >place the rollover images beside each other in a row
    (horizontally). However,
    >even with the image's borders, padding, and margin set to
    0, there still seems
    >to be a really small space between the images.
    >
    > Here is a link to the rollover images, as you can see,
    there is that small
    >white space between the images:
    >
    http://www.arkdesigns.ca/untitled.html
    The gap I see is in the images themselves - the outermost
    right and
    bottom pixels are faded. There's no other gap between the
    images in
    Opera and IE 6.
    Micha

  • Spaces between images on header - please help!

    I’m having an issue with a layout that I can’t seem to figure out. Here’s the website where the layout looks fine: www.sincityknitshop.com   All I did was add an additional navigation link (testimonials) and it started leaving a space between each image on the header ONLY when I added the rollover navigation buttons.  It was fine if I just inserted the navigation buttons as an image and not a rollover.    http://www.sincityknitshop.com/test2.htm  If I just insert the “off” button as a regular image (no rollover) it looks fine: http://www.sincityknitshop.com/test3.htm  In case it looks fine on your pc, here is a snippet image: http://www.sincityknitshop.com/images/mess.jpg   Does anyone know why it’s doing this??? I’m not doing anything different than what I did on the original layout that is now on her website www.sincityknitshop.com that looks fine.   What's weird is it looks fine on my ipad.   Thanks!!  Any help would be greatly appreciated.

    Nancy O. wrote:
    I think you would be so much better off using CSS styled text links for your rollover menus.  Plus, you could get rid of that awful MM rollover code which clearly isn't working correctly when you mouse over test2.
    I agree with that 100%. In my experience, I've twice been forced to use images in place of text for navigation menus, simply to keep the original design of the site intact. I made my own way around it, and it was "bulky" from a CSS standpoint, but it did have the advantage of the menu still looking like text to search engine crawlers.
    First thing I did was apply a text-indent property of -10000px to my navigation menu list items (#navmenu ul li a{ text-indent:-10000px;}). This keeps the text links off the page when viewed in a browser. Next, I applied a different ID to each <li> in my nav menu list, and applied a normal state (#navmenu ul li a#home) and a hover state (#navmenu ul li a#home:hover) using the image link as a background image with an "on" and an "off" version of each image for each state. Then I built my navigation menu in a <ul> just as I normally would with the proper ID for each <a> list item. It reads just like a regular text menu in the HTML. If you have a lot of items in your menu it can get a little long in the CSS, but it works without "that awful MM rollover code" as Nancy so accurately puts it.

  • I have a big difference of free space between my 32GB iPod and 32GB iPad when sync'd with iTunes.

    Why is there such a difference in my free space between my iPod Touch and my iPad (3) as indicated below:
                            iPod               iPad
    Songs               1,107               774
    Videos                   18                30
    Photos               6,230           4,720
    Apps                    111               113
    Capacity           28.4GB          28.0GB
    Avail (Free)       15.6GB            3.2GB
    Is there anyway of recapturing free space on my iPad without removing songs, pictures, applications, etc. ??

    How much space is Other using? You may be able to reduce.
    How Do I Get Rid Of The “Other” Data Stored On My iPad Or iPhone?
    http://tinyurl.com/85w6xwn
    With an iOS device, the “Other” space in iTunes is used to store things like documents, settings, caches, and a few other important items. If you sync lots of documents to apps like GoodReader, DropCopy, or anything else that reads external files, your storage use can skyrocket. With iOS 5/6, you can see exactly which applications are taking up the most space. Just head to Settings > General > Usage, and tap the button labeled Show All Apps. The storage section will show you the app and how much storage space it is taking up. Tap on the app name to get a description of the additional storage space being used by the app’s documents and data. You can remove the storage-hogging application and all of its data directly from this screen, or manually remove the data by opening the app. Some applications, especially those designed by Apple, will allow you to remove stored data by swiping from left to right on the item to reveal a Delete button.
     Cheers, Tom

  • How can I change the space between a checkbox and text all at one time? I have a lot of checkboxes in my form.

    How can I change the space between a checkbox and text all at one time? I have a lot of checkboxes in my form.

    Okay, I haven't found a way to add an extra space using Find/replace, but you might be able to add some text wrap to the check boxes that will push the text away from them.
    Open Find/Replace and click the Object tab.
    Click the Specify attributes to find button to the right of the Find Object Format: field.
    Under Basic Attributes, choose Stroke and then the Black swatch (assuming the black swatch is applied to the strokes of your check boxes). If there are no other stand-alone objects in your form with a Black stroke, this should be all you need. (If there are Black strokes on your table cells, they will be ignored.)
    Click OK
    Click the Specify attributes to change button to the right of the Change Object Format: field.
    Under Basic Attributes, choose Text Wrap & Other > Text Wrap > Type: > Wrap around bounding box (2nd button from left)
    Under Offset, set a Right offset at the distance you'd like to add (I don't know what units you use, but the 3-5 points might work for your purposes...might take some trial-and-error to get it where you want)
    Click OK
    Click Change All

  • How do I get images to sit side by side without space between?

    No matter what I try, my social media buttons are spacing themselves out more than I would like!
    Here is my reference page http://www.gogographics.ca/hh
    See top right and I have used a span class with 0 margin on them as a last try to stop them spreading.
    I would like to get rid of the few pixels in between to snug them up - I have a background on my .gifs of a very small width but these are not butting up against each other.
    If anyone can help, I would be very grateful!
    Thanks!

    If you remove the spaces in your HTML, they move closer together as expected. You can have them on different lines, but you seem to have added in a space between the <a></a> tags.
    <span class="mediabuttons">   
    <a href="http://www.facebook.com/pages/Hearts-Hands-Foundation/153171264740088"><img src="images/facebook.gif" alt="hearts &amp; hands on facebook" width="49" height="56" style="padding-bottom:30px; padding-left:25px; "/></a>
    remove space
    <a href="http://www.twitter.com/Heartsand_Hands">remove space
    <img src="images/twitter.gif" width="47" height="57" alt="Hearts &amp; Hands on Twitter" style="padding-bottom:30px; margin:0;" /></a>
    remove space
    <a href="http://canmorehearts.wordpress.com/"><img src="images/blogger.gif" alt="" width="46" height="57" style="padding-bottom:30px; margin:0;" /></a>
    remove space
    <img src="images/youtube.gif" alt="" width="46" height="58" style="padding-bottom:30px; margin:0;" />
    remove space
    <img src="images/flickr.gif" alt="" width="45" height="58" style="padding-bottom:30px; margin:0;" />
    </span>

Maybe you are looking for

  • How can i fix my wifi and bluetooth issues in yosemite?

    Hi, after upgrading to Yosemite I've noticed that my bluetooth trackpad (Logitech t651) and wifi connection are having serious conflicts which result in sluggish trackpad response or occasional wifi connection drops. I would have some occasional slug

  • How do I delete large files

    How do I delete large files, so they don't take 12 to 16 hours to delete?

  • Defective Apple TV 2?

    So I finally upgraded to Apple TV 2, because I wanted my mlb.com on my apple tv (still don't undertand why this couldn't be on the apple tv 1 .. sigh). So I get it home and I plug it into the same hdmi cable that my apple tv 1 was using. The problem

  • Allow log on through Remote Desktop Services Group Policy for Domain Controllers

    Hello, We want to allow our Helpdesk Operators to be able to connect to Domain Controllers with the Remote Desktop Services. This is by default not allowed but according to many sites, it should be able to configure by using a Group Policy. We made a

  • New iPad crashes constantly, it *****

    Hey people, I just want to let you know my story: A few weeks ago I bought the new iPad. its screen, its sound, everything is incredible, but its stability... there havent been any day without a problem. I know what you would say: why dont you try to