My .class files work...but when I jar it, the swing goes crazy!!

5 dukes, if anyone can get this :) :) ....
Hi, I have an application which is working perfectly when I view it using the java viewer. But when I put the whole thing into a jar.....the layout, and the swing stuff is messed up, terribly. Like Its foxused on nothing, and you have to click on where you think the button is...to make it appear, sooo strange. Here's what I have.
I put 2 panels onto desktopPane() using a GridBagLayout layout.
on panel 1, I have a whole bunch of g2d objects,
on panel 2, I have a whole bunch of Components (JButton's, JTextField's, etc..), but panel2 isn't really the problem, since when I removed panel 1, the jar ran without problems.
So It could be panel 1, or something in the main() class which sets up the panels, here is the appropriate code...
Panel 1
static class MyComponent extends JComponent {
          JScrollBar scroll;
          //          ~~~~~~~~~~~~~~Graphics Stuff~~~~~~~~~~~~~~~
          public void paintComponent(Graphics g){
          // a whole bunch of g2d things
          // ~~~~~~~~~~~~~~Component Stuff~~~~~~~~~~~~~~~
          MyComponent() {
                    setBackground(Color.pink);
                    setBounds(0,0,500,500);
                    setBorder(BorderFactory.createLineBorder(Color.pink,10));
                    scroll = new JScrollBar(JScrollBar.VERTICAL,0,20,0,100);
                    scroll.setBounds(484,0,16,500);
                    scroll.setVisible(true);
                    add(scroll);
                    System.out.println(scroll.isEnabled() + "" + scroll.isVisible() + scroll.getBounds());
                    setVisible(true);
And the main code...
     public static void main(String[] args) {
          //This section converts to windows look
          try {
          UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
          catch (Exception ex) {
          ex.printStackTrace();
          SwingUtilities.updateComponentTreeUI(frame);
          frame.pack();
          //~~~~
          componentPanel = new JPanel(); //initialize panel to place the component with buttons and stuff
          mc = new MyComponent(); // initialize the component with the g2d stuff
          mc.setSize(500,500);
          buttonComponent = new MySwingSwing(); // initialize the buttons and stuff
          componentPanel.setBorder(BorderFactory.createLineBorder(Color.GREEN));
          componentPanel.add(buttonComponent);
          JScrollPane scrollPane = new JScrollPane(mc);
          //~~~~~~~~~~~~~~~~~~~~~~~~~~~~Layout Stuff~~~~~~~~~~~~~~
          GridBagLayout grid = new GridBagLayout();
          constraints = new GridBagConstraints();
          frame.getContentPane().setLayout(grid);
          frame.getContentPane().setLayout(grid);
          constraints.weightx = constraints.weighty = 10.0;
          constraints.fill = 1;
          grid.setConstraints(componentPanel, constraints);
          grid.setConstraints(scrollPane, constraints);
          System.out.println("constraints are " + constraints.BOTH);
          scrollPane.setBackground(Color.green);
          frame.getContentPane().setBackground(Color.RED);
          buttonComponent.setBackground(Color.BLUE);
          frame.getContentPane().add(scrollPane);
          //frame.getContentPane().add(buttonComponent);
          frame.getContentPane().setVisible(true);
          scrollPane.setVisible(true);
          buttonComponent.setVisible(true);
          frame.getContentPane().requestFocus();
I dont know what I did wrong, but If you can find it Ill give u 5 dukes!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Here is how it looks when its run as a .class file,
http://www.members.lycos.co.uk/markrules/morestuff/1.jpg
And it is just completely distorted when its not...
thanks, MArk

Dude, throw GridBagLayout out! Go get TableLayout or FormLayout! Seriously. Unless you are restricted to use only JDK layouts, TableLayout has been a huge time saver and life saver for me. Google it, you'll thank me a million times over, and toss me them 5 dukes. ;)

Similar Messages

  • I have a new iMac with osx 10.8.3 i can not get my hp laserjet m1522nf scanner to work. The printer works but when in scanner mode the scanner does not show up

    I have a new iMac with osx 10.8.3 i can not get my hp laserjet m1522nf scanner to work. The printer works but when in scanner mode the scanner does not show up.I tried to install the newest hp driver for the printer but when I install the computer ca not find the printer.

    Repair permissions and restart your computer.
    Make sure you have the updated scanner drivers installed. 
    Install the gimp drivers:  http://gimp-print.sourceforge.net/MacOSX.php 
    http://support.apple.com/kb/PH11070 OS X Mountain Lion: Troubleshoot a network printer 
    http://support.apple.com/kb/PH11143 OS X Mountain Lion: Reset the printing system
    http://support.apple.com/kb/HT3669 Printer and scanner software available for download
    What to do when you can't print

  • Windows 7 Install failed - Boot camp partition to NTFS during formatting worked but when i clicked onto the 'next' button, it won't allow me to proceed any further. Help!

    Hi there,
    I used the following manual (http://manuals.info.apple.com/MANUALS/1000/MA1583/en_US/boot_camp_install-setup_ 10.7.pdf) in attempt to install windows 7 onto my mac but I get an error at Step 3 - windows installation process
    I selected the BOOTCAMP partitioned drive as mentioned, clicked the advance options, and then reformatted that drive. What happens next is the drive changes name from BOOTCAMP to 'untitled'. I then tried to click 'next' button but it won't let me proceed any further and didn't state clearly why it couldn't go through (instead says to check the log file for reason why - but then I have not clue where this log file is located in as well!). 
    I had a look at that partitioned drive after to find that it is NTFS format (when I went back to OS x) so it appears that I am doing the right thing so that shouldn't be the issue..
    Does anyone know what could be wrong? or what I should try to do next?
    Could it be a format error because when i click onto the 'untitled' drive, there is nothing in there.

    Hi Steve1904,
    So you have use the backup and Restore to restore your files from Windows XP to Windows 7 directly?
    This should be considered not work.
    If you would like to transfer files between Windows XP and Windows 7, you need another tool called Windows Easy Transfer.
    See the article below if you would like to upgrade from Windows XP to Windows 7:
    Upgrading from Windows XP to Windows 7
    If possible, follow the steps there, then things should be OK.
    Best regards
    Michael Shao
    TechNet Community Support

  • Hard drive works, but when plugged in hangs the system

    First of all, since this is not a Linux-specific problem I'm not sure this is the right place for this post.
    Anyway, for the past few years I've been using a 250GB IDE hard drive mostly to store backups on.  For quite a while it worked fine, but when  plugged in again after being removed so I could clean out the dust in my PC it didn't work quite right anymore.  It caused the system to hang and gave error messages remniscent of those detailed on this page.  After some fiddling it worked OK for a while, and then one day it randomly did this again.  I took the ribbon cable out, then the hard drive, and realized one of the pins was pushed in (at the time I thought it was broken).  After some reading I decided to sacrifice a ribbon cable.  What I did was yank a pin off of an old DVD drive that doesn't work and shoved it in the cable where the short pin was.  I made sure it was seated well, plugged in in, and hoped for the best.  To my delight it worked without a hitch for maybe a year or more.
    And then a little more than a month ago we had lightning strike a power line outside of our house and it fried my motherboard.  I now have a replacement board, but after all of the taking apart and moving around and stuff, the hard drive is back to its old antics.  The pin-in-the-cable trick wasn't working anymore.  After I realized that the pin wasn't broken half-way but rather pushed in, I grabbed some needlenose pliers and pulled it out.  It now will plug into any ribbon cable just fine and the computer recognizes it, but it's slow at POST and hangs the system when booting the OS, whether it be Linux or Windows.  Knoppix CDs boot just fine, although slower.  S.M.A.R.T. sees no problems.
    Basically I'm wondering 2 things.  First of all, is there anything I can do to get around the hangs?  And second, I'm considering buying an external hard drive enclosure for regular 3.5 inch hard drives and using it as an external USB drive.  Since the drive does still work and I can add/remove stuff while booted in Knoppix, and the main issue seems to be my system hanging, I figure, maybe, I can just plug in the drive when I need it after the computer is already booted up and it will work fine.  Does this sound like a reasonable expectation?

    What you hear may sound like it's the hard drive, but it's really an electronic type of noise. Same with my PB. Try what BGreg said, and wait for the drive to spin down - you'll still hear the noise.
    There was a thread about this issue several months ago, and IIRC the conclusion was that it's a normal noise, and that you should just ignore it if possible.
    If you must make it quieter, set processor performance to the lowest setting in Energy Saver preferences. But it's not going away completely.

  • Router works but when security is on the laptop says that the password is not correct

    I just hooked up a WRT54G v8.0 router. My home computer uses XP and the set up went fine. I have a Mac laptop. When I go unsecured the laptop can use the network. When I set the security on, the laptop login says that the password is incorrect. I have changed the password once and nothing changed. I have triple checked the password, so I know it is correct.
    What can be causing this problem?
    THANKS
    bej

    I tried wep security and it was on the 128 setting and it did not work.
    Any other suggestions as I looked over the security settings and everything looked ok.
    I saw some old problems like this that mention maybe putting a certain sign like a $before the password on the mac. Have you ever heard of anything like that??

  • I can get thumbnail photos but when I tap them the screen goes blank

    Brand new iphone4 - photos taken appear as thumbnails and when tapped to enlarge are shown OK. But after the phone is powered down and restarted the thumbnails appear but when tapped do not appear. Help please.

    Hello linslaf,
    It may help to force close the Messages app, then restart the device.
    iOS: Understanding multitasking
    http://support.apple.com/kb/HT4211
    iPhone, iPad, iPod touch: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/HT1430
    If the issue persists, the next step would be to restore your iiPhone.
    iOS: Back up and restore your iOS device with iCloud or iTunes
    http://support.apple.com/kb/HT1766
    Cheers,
    Allen

  • I tried to use borders, I pick out the cell(s) and the border shows but when i change cells, the border goes away????

    Bordersdo not stay when I goon to another cell

    To set the border for one, or more, cell(s) you have to:
    - make the selection (of cells)
    - the make a selection from each of the border selection tools
      + The borders to highligh
      + the border style
      + the weight
      + the color (default is gray so you have to select black if you want the dark)

  • I have an imac running with 10.6.8 to be able to use facetime. I downloaded everything but when I click on the facetime icon i have the following message " An internal error facetime has occured. Any help to make facetime work? Thanks

    I have an imac running with OS X 10.6.8
    Then I downloaded Facetime to make it work but when I click on the icon a message error pops up
    "An internal error facetime has occured. There was a problem with Facetime - you need to quit Facetime and Open Facetime again"
    Is anyone can help to fix the problem - Thank you

    Did you figure this out? I have the same issue!!

  • Hi am trying to save Data into a write to measurement file vi using a NI PXI 1042Q with a real time mode but it is not working but when i run it with uploading it into the PXI it save in to the file

    Hi am trying to save Data into a write to measurement file vi using a NI PXI 1042Q and DAQ NI PXI-6229 with a real time mode but it is not working but when i run it without uploading it into the PXI it save in to the file please find attached my vi
    Attachments:
    PWMs.vi ‏130 KB

     other problem is that the channel DAQmx only works at real time mode not on stand alone vi using Labview 8.2 and Real time 8.2

  • TS3989 My Photo Stream works and I have iCloud control panel installed. The photo stream sync is selected, but when I go to the my photo stream folder on my windows PC there are no photos in the file.

    My Photo Stream works and I have iCloud control panel installed. The photo stream sync is selected, but when I go to the my photo stream folder on my windows PC there are no photos in the file.

    mlvov,
    I did as you said and went to the icloud control panel on my Windows 8 Laptop to be sure I was looking at the correct folder for my photo stream.  All my "shared" albulms pushed to my Laptop and are up-to-date with the exception of the "photostream" album. If I create a "shared stream album" and place photo's in it on the phone; I can see the photos on my laptop. I dont get it. I had a iphone 4s and had zero isues and now with my new nifty iPhone 5s it doesent work.
    What am I not doing correctly.
    Thanks,
    iPhone, 5s, iOS 7.0.2

  • TS3212 i downloaded itunes on my windows 7 computer, but when i try running the setup file, it says it's not a valid win32 file. how do i fix this?

    i just bought a brand new HP computer with the windows 7 and i'm trying to download itunes on my computer. I've used the email and a new one for the download. it'll go through the process of downloading the itunes setup, but when i go to the downloads folder in my computer and click on the file, it says it's not a valid Win32 file and won't open.  I've tried downloading the 64 bit version to se if that was the problem, but even that won't work.  please help!

    Perhaps try downloading and saving a copy of the installer to a different PC. (If you're on a 32-bit Windows system, try to download on a different 32-bit Windows system.) Copy the iTunesSetup.exe installer to an external hard-drive, or a large-enough thumb drive or burn it to a CD-R. Carry the installer back to your PC, copy the installer to your hard drive. (Don't run the install from the ExHD, thumb or CD-R.) Start the install by doubleclicking the iTunesSetup.exe file.

  • I had this video file and I was trying to flip it to a format that would work with iMovie.  It used to have the Quicktime image with it.  So, I assume it was a QT file.  But, somehow I've changed the file from a video to a folder.

    I had a video file and I was trying to flip it to a format that would work with iMovie.  It used to have the Quicktime image with it.  So, I assume it was a QT file.  But, somehow I've changed the file from a video to a folder.  I've tried to undo the action.  No luck.  I wasn't running my Time Machine.  So, I can't go back.  Help.  It's the only copy of this video.

    I've tried to undo the action.
    How?
    Please detail ALL you have done so far in the way of troubleshooting?   Need this info to avoid the been there done that scenarios.
    it's the only copy of this video.
    Where did you get the video from?
    From the pic I noticed that the folder is 841.9mb.  What's inside?  Or what happens when you click on it?

  • I am new at Captivate 8 and I have created a learning project using an existing power point presentation.  I have added a button that will allow my students to view a video on the subject.  When I run the project in Preview the button works but when I pub

    I am new at Captivate 8 and I have created a learning project using an existing power point presentation.  I have added a button that will allow my students to view a video on the subject.  When I run the project in Preview the button works but when I publish it, it stops working.

    I added an Interactions button and in the Actions on Success I open an URL or file. I have placed the video on our web server.   In the URL I point to our web server "http://www.wmabhs.org/Media/Add Client 3rd Party Coverage.mp4".  If I run this from any browser it works.  So what do you think I have done wrong?

  • My Outlook/iCloud calendar invites to others appear to work on my end and sync with my PC and mobile, but when other people "accept" the invite, it will not populate/add in to their calendar. How can i fix this without turning off iCloud?

    My Outlook/iCloud calendar invites to others appear to work on my end and sync with my PC and mobile, but when other people "accept" the invite, it will not populate/add in to their calendar. How can I fix this without turning off iCloud?
    I am at a new office that uses Outlook (not Outlook Exchange) which does not sync with my mobile... I just got iCloud set up on my PC to sync my contacts, calendar, reminders, etc... The sync worked (not without flaws, but the other issues seem solvable... I think), so that i can now see all my appointments on both my phone and on my PC. The problem I am having is that iCloud moved all of my calendar items from Outlook into iCloud calendar and now when I send out meeting/calendar invites the recipients may accept them, but the meeting does not get added to their calendar. This is a huge problem and may mean that i need to turn off iCloud.
    Does anyone know how to fix this?
    Thanks!

    I am replying to my own post here as I seem to have fixed the problem.
    I do have some calendars that are shared. Some of those are shared with users who have time zone support turned on. So i activated time zone support on my iphone, then deleted my icloud subscription. I then signed in to icloud again and voila... problem solved.
    It is a weird one as the other calendar views were always fine and when you opened an event that appeared in the wrong day (on list view), the correct date of the event was shown in the information...
    one more bug in a complicated system I guess

  • I just order 8 calendars from iPhoto and they came to me fine. Now I need to order two more but when I go thru the process I get a message  saying:unable to assemble calendar. There is a probleme with the photo with the file name"(Null)"   more........ .

    Would someone be able to explain to me the following issue with Iphoto?
    I ordered 8 same calendars for my soccer team and received them fine. Although a couple of pictures on it are a little off (out of focus). I need to order two more of the same calendars but when I go thru the process ireceive an error message saying:
    "Unable to to assemble  calendar" There is a problem with the photo with the file name "(Null)" The full resolution version of this photo either cannot be located or is corrupt. Please replace this photo or delete it from your calendar.
    How can  I fine this "corrupt" photo? How did it go thru with the first batch of calendars but won't go thru now?
    Thank you for your help.   

    Apply the two fixes below in order as needed:
    Fix #1
    Launch iPhoto with the Command+Option keys held down and rebuild the library.
    Since only one option can be run at a time start
    with Option #4 and then #1 as needed.
    Fix #2
    Using iPhoto Library Manager  to Rebuild Your iPhoto Library
    1 - download iPhoto Library Manager and launch.
    2 - click on the Add Library button, navigate to your Home/Pictures folder and select your iPhoto Library folder.
    3 - Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File ➙ Rebuild Library menu option.
    4 - In the next  window name the new library and select the location you want it to be placed.
    5 - Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments.  However, books, calendars, cards and slideshows will be lost. The original library will be left untouched for further attempts at fixing the problem or in case the rebuilt library is not satisfactory.
    OT

Maybe you are looking for

  • No message tone or icon after software update

    I did a software update yesterday to the 10.2.1.2102 and now when i receive a text my phone doesnt notify me of this. No tone goes off and no icon appears. HELP!

  • Vendor Master: Contact Person View

    Hi Gurus, Can you move some fields in contact person's detail page to initial screen in ECC6.0?  ECC 6.0 provides multiple contacts for vendor master.  When you click on the contact person, it brings a more detail page.  However, there are only five

  • SRM 7.0 Box - BW Reports

    Gurus , not sure if any one has worked on the SRM 7.0 box.If you go to SPRO -->Supplier Relationship Management->Analytics they have lots of BW reporting templates available there. On the help it says that we can configure the BW templates from SRM 7

  • In Design not starting up.

    Hi; I installed the complete CS6 on a Win 7 x64 Acer M5 laptop. Everything works except In Design. I re-installed In Design and it made no difference. The program closes before fully starting and Windows just says the program closed and has a problem

  • Rman - "report unrecoverable" concept

    Hi I am readin g a book on rman (rman recipes 11g from APress). I m not able to understand what is the purpose of "report unrecoverable" command. Book says: > Ref: Section 8.3 - page# 229: You want to identify which datafiles have been affected by un