Buttons become the same size as my image?? PLEASE HELP

Hi guys,
this is the second posting of this topic, as in the first one i didn't post my code properly (sorry!!!)
My problem is that the buttons i have in the code come up as the same size as the 'Goldsmiths' Image. How can i alter the provided code to make the image stay the same size and the buttons to have the default button size?
Thanks
//SSPanesar
//copyright 2005 all rights reserved
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.URL;
public class SwingApplication implements ActionListener {
private static String labelPrefix = "Number of button clicks: ";
private int numClicks = 0;
final JLabel label = new JLabel(labelPrefix + "0 ");
//Specify the look and feel to use. Valid values:
//null (use the default), "Metal", "System", "Motif", "GTK+"
final static String LOOKANDFEEL = "System";
public Component createComponents() {
JButton button = new JButton("I'm a Swing button!");
button.setMnemonic(KeyEvent.VK_I);
button.addActionListener(this);
label.setLabelFor(button);
JButton button1 = new JButton("I'm a Swing button!");
     button1.setMnemonic(KeyEvent.VK_I);
     button1.addActionListener(this);
label.setLabelFor(button1);
JButton button2 = new JButton("I'm a Swing button!");
     button2.setMnemonic(KeyEvent.VK_I);
     button2.addActionListener(this);
label.setLabelFor(button2);
JButton button3 = new JButton("I'm a Swing button!");
     button3.setMnemonic(KeyEvent.VK_I);
     button3.addActionListener(this);
label.setLabelFor(button3);
JButton button4 = new JButton("I'm a Swing button!");
     button4.setMnemonic(KeyEvent.VK_I);
     button4.addActionListener(this);
label.setLabelFor(button4);
JLabel label = new JLabel();
     URL loc = getClass().getResource("smalllogo2.gif");
     Icon icon = new ImageIcon(loc);
     label.setSize(icon.getIconWidth(), icon.getIconHeight());
label.setIcon(icon);
JLabel label2 = new JLabel();
     URL loc2 = getClass().getResource("SheeraAutoRepair2.jpg");
     Icon icon2 = new ImageIcon(loc2);
     label2.setSize(icon.getIconWidth(), icon.getIconHeight());
label2.setIcon(icon2);
* An easy way to put space between a top-level container
* and its contents is to put the contents in a JPanel
* that has an "empty" border.
JPanel pane = new JPanel(new GridLayout(0, 1));
//pane.setLayout(new FlowLayout(FlowLayout.RIGHT));
pane.add(label);
pane.add(button);
pane.add(button1);
pane.add(button2);
pane.add(button3);
pane.add(button4);
pane.setBorder(BorderFactory.createEmptyBorder(
30, //top
30, //left
10, //bottom
30) //right
pane.setBackground(Color.white);
return pane;
public void actionPerformed(ActionEvent e) {
numClicks++;
label.setText(labelPrefix + numClicks);
private static void initLookAndFeel() {
String lookAndFeel = null;
if (LOOKANDFEEL != null) {
if (LOOKANDFEEL.equals("Metal")) {
lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
} else if (LOOKANDFEEL.equals("System")) {
lookAndFeel = UIManager.getSystemLookAndFeelClassName();
} else if (LOOKANDFEEL.equals("Motif")) {
lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
} else if (LOOKANDFEEL.equals("GTK+")) { //new in 1.4.2
lookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
} else {
System.err.println("Unexpected value of LOOKANDFEEL specified: "
+ LOOKANDFEEL);
lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
try {
UIManager.setLookAndFeel(lookAndFeel);
} catch (ClassNotFoundException e) {
System.err.println("Couldn't find class for specified look and feel:"
+ lookAndFeel);
System.err.println("Did you include the L&F library in the class path?");
System.err.println("Using the default look and feel.");
} catch (UnsupportedLookAndFeelException e) {
System.err.println("Can't use the specified look and feel ("
+ lookAndFeel
+ ") on this platform.");
System.err.println("Using the default look and feel.");
} catch (Exception e) {
System.err.println("Couldn't get specified look and feel ("
+ lookAndFeel
+ "), for some reason.");
System.err.println("Using the default look and feel.");
e.printStackTrace();
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
private static void createAndShowGUI() {
//Set the look and feel.
initLookAndFeel();
//Make sure we have nice window decorations.
// JFrame.setDefaultLookAndFeelDecorated(true);
//Create and set up the window.
JFrame frame = new JFrame("SwingApplication");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//final int width=300;
//final int height=400;
frame.setSize(600,900);
SwingApplication app = new SwingApplication();
Component contents = app.createComponents();
frame.getContentPane().add(contents, BorderLayout.CENTER);
//Display the window.
frame.pack();
frame.setVisible(true);
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}

You still aren't using the "code" formatting tags as was suggested in your first posting in the forum.
when i add the picture and the buttons go vertically down from the image,Well, this doesn't make sense since you are using a FlowLayout which means components will be displayed horizontally on a line, not vertically.
If you need further help then you need to create a [url http://www.physci.org/codes/sscce.jsp]Short, Self Contained, Compilable and Executable, Example Program that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided. (ie. the code doesn't compile so we can't test it).

Similar Messages

  • Buttons become the same size as my iamge??? PLEASE HELP!!

    Hi guys,
    I I'm trying to setup a JFrame where i have an image above some buttons. They don't necessarily have to be in the same column but for soe reason, when i add the picture and the buttons go vertically down from the image, the become the same size as the image? The following code describes my contentPane. Please help!
    public Component createComponents() {
    JButton button = new JButton("I'm a Swing button!");
    button.setMnemonic(KeyEvent.VK_I);
    button.addActionListener(this);
    label.setLabelFor(button);
    JButton button1 = new JButton("I'm a Swing button!");
         button1.setMnemonic(KeyEvent.VK_I);
         button1.addActionListener(this);
    label.setLabelFor(button1);
    JButton button2 = new JButton("I'm a Swing button!");
         button2.setMnemonic(KeyEvent.VK_I);
         button2.addActionListener(this);
    label.setLabelFor(button2);
    JButton button3 = new JButton("I'm a Swing button!");
         button3.setMnemonic(KeyEvent.VK_I);
         button3.addActionListener(this);
    label.setLabelFor(button3);
    JButton button4 = new JButton("I'm a Swing button!");
         button4.setMnemonic(KeyEvent.VK_I);
         button4.addActionListener(this);
    label.setLabelFor(button4);
    JLabel label = new JLabel();
         URL loc = getClass().getResource("smalllogo2.gif");
         Icon icon = new ImageIcon(loc);
         label.setSize(icon.getIconWidth(), icon.getIconHeight());
    label.setIcon(icon);
    JLabel label2 = new JLabel();
         URL loc2 = getClass().getResource("SheeraAutoRepair2.jpg");
         Icon icon2 = new ImageIcon(loc2);
         label2.setSize(icon.getIconWidth(), icon.getIconHeight());
    label2.setIcon(icon2);
    * An easy way to put space between a top-level container
    * and its contents is to put the contents in a JPanel
    * that has an "empty" border.
    JPanel pane = new JPanel(new GridLayout(0, 1));
    pane.setLayout(new FlowLayout(FlowLayout.RIGHT));
    pane.add(label);
    pane.add(button);
    pane.add(button1);
    pane.add(button2);
    pane.add(button3);
    pane.add(button4);
    pane.setBorder(BorderFactory.createEmptyBorder(
    30, //top
    30, //left
    10, //bottom
    30) //right
    pane.setBackground(Color.white);
    return pane;
    }

    multi-post. Please answer in this posting:
    http://forum.java.sun.com/thread.jspa?threadID=694396

  • TS1538 I have tried everything but I can't connect my iphone to my laptop. It says that apple mobile device failed to be installed. I have read everything on the internet and did everything but still am facing the same problem. Can you please help me.

    I have tried everything but I can't connect my iphone to my laptop. It says that apple mobile device failed to be installed. I have read everything on the internet and did everything but still am facing the same problem. Can you please help me.

    Again without stating the trouble shooting steps you have taken, its hard to direct you with any information.
    Try a different port on the computer.
    Does the iphone beep when u plug it up. ?
    Plug iphone into computer and give it 3 to 4 minutes to see if it connects and is running slow.,
    Delete the apple mobile device from your computer.
    Upgrade itunes to newest version.
    Is you USB cord defective ?
    Any USB 3.0 on your system ? .
    Delete or Disable  any antivirus program on your computer ?
    I will tell u the problem is your computer not the phone.
    We could do this for hours.

  • HT1349 WHEN I TURN MY IPHONE 3S ON IT ASKS ME TO CONNECT TO ITUNES AND RESTORE. I HAVE DONE THIS 10 TIMES AND STILL GET THE SAME SCREEN. CAN ANYONE PLEASE HELP??

    WHEN I TURN MY IPHONE 3S ON IT ASKS ME TO CONNECT TO ITUNES AND RESTORE. I HAVE DONE THIS 10 TIMES AND STILL GET THE SAME SCREEN. CAN ANYONE PLEASE HELP??

    Has your phone been jailbroken?  If so, you will likely never get it to work again.
    You can try placing your phone in DFU mode (search google) and restoring.

  • I am not able to sync some videos and apps onto my iphone 3gs. it shows a sync error: 0xe8008001.i updated it but still i am getting the same sync error problem..please help.

    i am not able to sync some videos and apps onto my iphone 3gs. it shows a sync error: 0xe8008001.i updated it but still i am getting the same sync error problem..please help.
    aman

    Are you using Windows...?

  • When we using overflow-x and overflow-y in tbody its not working properly. In the previous version i.e. 3.7.1 its working fine the same coding....Please help me.

    ''Duplicate post, continue here - [https://support.mozilla.com/en-US/questions/828024]''
    when we using overflow-x and overflow-y in tbody its not working properly. In the previous version i.e. 3.7.1 its working fine the same coding....Please help me.

    See:
    *https://developer.mozilla.org/en/Firefox_4_for_developers#Miscellaneous_DOM_changes
    *http://www.cssplay.co.uk/menu/tablescroll.html
    A good place to ask questions and advice about web development is at the mozillaZine Web Development/Standards Evangelism forum.<br />
    The helpers at that forum are more knowledgeable about web development issues.<br />
    You need to register at the mozillaZine forum site in order to post at that forum.<br />
    See http://forums.mozillazine.org/viewforum.php?f=25

  • Windows thinks my itouch is a camera and itunes says this ipod can't be used because the software isn't installed - reinstall itunes.  i've done that and continue to get the same error.  can someone please help?

    windows thinks my itouch is a camera and itunes says this ipod can't be used because the software isn't installed - reinstall itunes.  i've done that and continue to get the same error.  can someone please help?

    (apologies for barging in, lllass.)
    Let's try a standalone Apple Mobile Device Support install. It still might not install, but fingers crossed any error messages will give us a better idea of the underlying cause of why it's not installing under normal conditions.
    Download and save a copy of the iTunesSetup.exe (or iTunes64setup.exe) installer file to your hard drive:
    http://www.apple.com/itunes/download/
    Download and install the free trial version of WinRAR:
    http://www.rarlab.com/download.htm
    Right-click the iTunesSetup.exe (or iTunes64setup.exe), and select "Extract to iTunesSetup" (or "Extract to iTunes64Setup"). WinRAR will expand the contents of the file into a folder called "iTunesSetup" (or "iTunes64Setup").
    Go into the folder and doubleclick the AppleMobileDeviceSupport.msi (or AppleMobileDeviceSupport64.msi) to do a standalone AMDS install.
    (If it offers you the choice to remove or repair, choose "Remove", and if the uninstall goes through successfully, see if you can reinstall by doubleclicking the AppleMobileDeviceSupport.msi again.)
    Does it install (or uninstall and then reinstall) properly for you? If so, does your device connect without that message now?

  • HT1420 I get en error message 42408. I have tried several times to activate my account but the same message keeps reappearing. Please help. I cant even sink my iPad or iPhone. Thanks

    I get en error message 42408. I have tried several times to activate my account but the same message keeps reappearing. Please help. I cant even sink my iPad or iPhone. Thanks

    After searching, found a few answers and tried one last thing-- allowing Safari to accept Cookies. I never use Safari so never changed any settings in it ever. However, I guess an update along the way turned off cookies in it and that was the blockage. Once I allowed Safari to use cookies I was able to redeem the gift card. SO, glad this board is here for these types of questions!!!!

  • Started downloading IOS8 24 hrs ago, still down loading now! Tried switching off/on with 2 button still the same. Can anyone advise please. Cheers

    I Want to stop download of iOS 8 and start again

    sorry, thought my question had been posted. I started downloading iOS 8 24 hrs ago, it is still downloading now, have tried off/on with 2 buttons but still the same can anyone advise please cheers

  • My ipad is saying ipad disabled connect to itunes. so I connected to itunes. i have already done the recovery and am still getting the same message before. Someone please help me!

    I have already tried to recover my ipad but it still keeps coming up that it is disabled and to connect to itunes. When i go to itunes it says that I require to put my passcode in on my ipad but i cant because its still disabled. Please help, I have no clue where to go from here. I though by recovering it that it would work but it didn't. Help! Thanks in advance.

    Did you do this?
    Recovery Mode:
    1. Turn off iPad. Press and hold the Sleep/Wake button for a few seconds until the red slider appears, slide to turn off.
    2. Connect USB cable to computer; leave the other end alone
    3. Press and hold the Home button down and connect the docking end of cable to iPad
    4. Continue holding the Home button until you see the "Connect To iTune" screen
    5. Release the Home button
    6. Open iTune (make sure you have the newest version of iTune)
    7. You should see "iTunes has detected an iPad in recovery mode"
    8. Use iTune to restore iPad
    Note: You need to be patient and repeat the above many times to recover your iPad

  • My MacBook Pro crashes when I go into Powerpoint slideshow mode and I get an error message to resave and give it another name.  I updated the powerpoint based on using the help update but get the same problem....please help!

    I updated to Mavericks and since then my powerpoint no longer works when I want to start the slideshow mode.  Help!

    http://answers.microsoft.com/en-us/mac/forum/macpowerpoint?tab=Threads

  • Multiple photos trying to crop at the same size... Advice please....

    Hello out there...
    I am working on a web page... We have multiple images that need to be cropped at the same size ( resolution and image) ... Is there an easy way to do this?  Please Advise...
    all the best,
    Robinpress..

    Use File->Scripts->Image Processor and don't bother about ppi resolution, that's only for print

  • How to resize watermark to be the same size for vertical/horizontal images?

    I am using File -> Place menu to place my watermark onto the images. 
    No matter what I try so far, the absolute size of the watermark comes out different Portrait/Landscape images.
    Watermark is smaller on Portrait and larger on Landscape images.  I tried resizing writing in the number of pixels during the File->place command, but no luck.  Photoshop resizes the watermark based on the percentages, and I don't know why image orientation matters. 
    ideally I want my watermark to be the same size, and I can use absolute pixel dimensions if needed.  How do I do this?

    Hi Doug - What exactly are you trying to do? Is the third
    child being added dynamically, and you want it added above the
    first child? If so, you can use the addChildAt() method when adding
    the child to the container. addChildAt() takes an index and the
    child object is added at that index and all other children are
    reshuffled to maintain the ordering. IE:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="vertical">
    <mx:TitleWindow layout="vertical" id="tw">
    <mx:Button id="a" />
    <mx:Button id="b" click="go();"/>
    </mx:TitleWindow>
    <mx:Script>
    <![CDATA[
    private function go():void
    var c:Button = new Button();
    c.label="new";
    tw.addChildAt(c, 0);
    ]]>
    </mx:Script>
    </mx:Application>
    Does that help, or am I misinterpreting what you're trying to
    do?

  • Is Retina Display Algorithm Changing the Images at the Same Size?

    Hi. If the Retina Display has a denser pixerl per inch count, shouldn't it be making images smaller as you would in an iMac i7 display or any non Retina display for example? Is the Retina display and the iOS themselves are changing the images themselves so that they don't become smaller? Would that mean, photos for example are not in their original state when you view it on the Retina Display with it's added details coz' it's the photos remain the same size only sharper? If you saved that on your iMac, does it mean it retains the changes the Retina Display made to it when it's on your desktop Mac or does it revert it to the original? Thanks in advance. Gbu.

    Kiarazza
    No you are not wrong to be upset.  Should Apple have given you the heads up, yes.  Like you experience with Dell I had a similar experience with a phone a few years back, the store exchanged the one I purchased a short time later with the newly released device. The store employees are there to sell and we do live in a buyer be ware world for the most part.  Truthfully the store employees might not have even known when the new model would be released.  In general electronics are evolving extremely rapidly.  Any "new" phone, tablet, computer type device today will be an "old model" tomorrow.  While you feel you may have been mislead this is just a fact at this time.  With that said...
    While I have had iPods for years my first experience, and last, with an Apple store subsequent Apple's customer service was about 11-12 months ago when I got an iPad &amp; iPhone. I have found them both to be substandard.
    But look at what you have and take it for what is, a pretty sophisticated devise.  the iPad you purchased is still a fine machine.  By no means is it out dated. Use it enjoy it and don't look back. You'll drive yourself mad otherwise because there will always be a newer model tomorrow.  
    These forums a full of some very helpful people for the most part. 
    Best of luck.

  • Resizing images on two layers to the same size?

    OK, it's kind of difficult to explain but what I am trying to do is create posters in pages and I am pasting photographs in there from different layers of the same photo and then resizing them. But the trouble is getting both to the same size, is there an autosnap feature for this or something?
    I find it kind of irksome when I create an image and resize it to a specific dimension in preview then copy+paste it into a Pages document of the same dimensions and it resizes it smaller.
    How do I get it to the same size without manually dragging the corners with my mouse?
    Does that question make sense? Can anyone help?

    Actually I just found a neat way to do it in GIMP (great peice of software BTW) the question remains of how to resize it in Pages...

Maybe you are looking for

  • IPhone / iCal /itunes calendar issue

    Hi all, since updating to the latest iTunes / iPhone OS I have an issue synching the phone. It takes hours(!) when it comes to sync the calendar (I have 6 or 7, all local on my macbook pro). Contacts work fine, same with apps and music, just the cale

  • Error while Migo

    Hi while doing MIGO for material type finished goods the system is working fine and changing the movement type in the background on the other hand same process is not working in case of raw material and while doing migo system is giving following err

  • [solved] Build of php package with mssql support - checking my process

    Since the straight 'php' package doesn't support mssql, I'm in the process of trying to build and install an updated copy that has that switch turned on. The information I've seen out there seems pretty straight forward, but my results are odd, so I'

  • How to delete a web gallery

    I was trying out the Web section of Lightroom and after choosing a template went to add some images just for a trial, and found I added the whole 243 images I had in my Library. Now, I want to delete that effort and explore other templates (this time

  • Iphoto library gone on my side

    My wife and I each have an account on my 1.8 duel G5. When I opened my iphoto 6 tonight my library was completely gone. All my photo books and every roll. Our iphoto folder lives in our shared file. When I go to my wife's side, she still has everthin