Having Trouble Reading in an Object

im trying to read in a JTabbedPane (called AZTabs) using this method:
public void readContact(){
        in = null;
        try{
            in = new ObjectInputStream(new BufferedInputStream(new FileInputStream("files/contacts")));
            for(index3 = 0; index3 < AZTabs.getTabCount(); index3++){
                AZTabs = (JTabbedPane)in.readObject();
        }catch(ClassNotFoundException e){
            System.out.println("Caught ClassNotFoundException " + e.getMessage());
        }catch(IOException e){
            System.err.println("Caught IOException " + e.getMessage());
        }finally{
            if(in != null){
                try{
                    in.close();
                }catch(IOException e){
                    System.err.println("Caught IOException " + e.getMessage());
    }whenever i run my app it give me this exception: "Exception in thread "main" java.lang.ClassCastException: javax.swing.JPanel cannot be cast to javax.swing.JTabbedPane". any1 know what i can do to solve this problem?
thnx guys

The data you are trying to read is a serialized JPanel.
When it is read in, the object it produces is a JPanel.
You cannot treat a JPanel as a JTabbedPane because it is not a JTabbedPane, it is a JPanel.
I don't see how you're getting confused.
JTabbedPane p = (JTabbedPane) in.readObject();
// throws a ClassCastException at runtime because the readObject() method is returning a JPanel
JTabbedPane p = (JPanel) in.readObject();
// produces a compiler error because you cannot assign a JPanel reference to a JTabbedPane reference
JPanel p = (JPanel) in.readObject();
// should work just fine and dandy

Similar Messages

  • I am having trouble reading some books bought from ITunes and loaded onto my Cocoon ereader which supports  Adobe DRM content.  Any suggestions?

    I am having trouble reading some books bought from ITunes and loaded onto my Cocoon ereader which supports  Adobe DRM content.  Any suggestions?

    matty_234 wrote:
    Will this enable me to plug my iPhone in without any changes or reformatting? ...
    If you follow all the Steps in the Link it should...
    matty_234 wrote:
    .... Also, I guess this will overwrite the purchases already on my mac? ...
    You can redownload them for free...   http://support.apple.com/kb/HT2519
    matty_234 wrote:
    ... One last thing, does this include the iphone backups?...
    Everything that is in iTunes should be there...

  • Having troubles reading usb external drives.

    I have a macbook pro, mid 2010 is when I got it.  The issue I've ran into for about 6 months now is my usb external drives are not currently being recognized.  It's only external drives and thumb drives though.  My mac recognizes my iphone, charges my camera usb, lets me use a usb midi controller.  About six months ago I was having trouble connecting a usb dmx lighting interface.  I called the company and they sent me to a workaround and it worked.  http://groups.google.com/group/dmxis_users/browse_thread/thread/c5746c10c618bf19 ?hl=en_US 
    Ever since then, it's never been the same my external drives don't work.  I even took it to an apple store and replaced the internal boards.  (Sorry for not knowing specifics)  Any suggestions or ideas would be greatly appreciated!

    That would explain your problem!  If you have a backup then see if it's on your backup.  Otherwise, you will need to restore it from your installer DVD using Pacifist:
    How Restore Deleted or Missing OS X Components
    A few of the basic OS X installed applications can be restored from the Optional Installs installer located in the Optional installs folder on your Installer DVD.  However, if what you need is not there then follow the instructions below.
    How to Use Pacifist to Restore Deleted or Missing OS X Components
    Insert the OS X Installer DVD into the optical drive.  Use a simple utility like TinkerTool to toggle invisibility so you can see invisible items.  Alternatively, open the Terminal application in your Utilities folder and at the prompt enter the following:
    defaults write com.apple.finder AppleShowAllFiles Yes Press RETURN.
    To turn off the display of invisible files repeat the above command substituting No for Yes.
    The install packages are located in the /System/Installation/ folder on the DVD.
    Download the shareware utility Pacifist from VersionTracker or MacUpdate. Use it to extract a fresh copy of the missing item(s) from the file archives on your OS X installation DVD. The file archives are in the /System/Installations/ folder (use Go to Folder option in the Go menu of the Finder.)
    Here are Four Basic ways to use Pacifist (courtesy of George Orville.)
    A. Drag a .pkg icon onto the Pacifist window .....proceed to step 7.
    B. Click on “Open Package ....” and navigate to package desired and click “Open” in the open/save window.....proceed to step 7.
    C. Insert Mac OS X installer CD and when it mounts, navigate to .... Menu->Go->Go to Folder. In the path field enter or paste ....
    /Volumes/disc name/System/Installation/Packages (where disc name is the name of the CD/DVD that you inserted.
    • Click on the  "Go" button ..... • Drag a .pkg to Pacifist..... proceed to step 7.
    The package you'll need will have to be discovered by trial and error, but for most applications you should start with the Essentials.pkg and/or Additional Essentials.pkg.
    D. Insert your Mac OS X install disk 1 .... and open Pacifist.
    1. In Pacifist, select "Open Mac OS X Install Packages" ... dialog may appear asking for disk 2, then disk 3 and finally disk 1 again.... {if DVD is not used)...If “Stop Loading” is selected...the procedure will stop!!!
    2a. When loading is complete, a new window appears, click the triangle to display contents of each package...Select item and proceed to step 7.
    2b. or click the “Find” icon in the Pacifist window and type the name of the software you need.
    3. In the list that comes back, click the top most entry for the item that you want. ..... that is the one for the English language.
    4. On the top of the Pacifist window, click “verify” .... you will probably be prompted for your password.
    >5. Enter checks for.... “verify permissions” and “verify file contents.” and click “verify” ....enter password when prompted.... you will get back output which may look like this:
    20 files were scanned. 20 of 20 files were present on the hard disk. 0 of 20 files had file permissions that did not match those specified in the package. 0 of 20 files had checksums that did not match those specified in the package.
    6. Click “close”. Go to step 7.
    Extract or Install........
    7. In the Toolbar (upper left), you now have the option to extract or install. Click a file in the lower list and those two icons will be enabled.
    8. If “Extract to...” is selected.... navigate to the location where the file will be placed, select “choose”, select “extract” in new dialog that appears,authenicate , if prompted, click “OK”.
    9. In the next dialog, click “Extract”.
    10. If “Install” is selected... dialog will appear with the location/path of the installed software. Click “Install”
    11. Type in your password, click “OK”
    Pacifist will begin to extract files.
    12. In steps 8/10ß.... you also have the choice to “cancel”
    Notes.....
    Pacifist may find that a file it is installing already exists on the hard disk. Pacifist will present you with an alert panel....
    Stop Leave original alone Update ..... Default selection Replace .... Replace option should only be used on full install packages

  • Having trouble reading specific lines from a text file and displaying them in a listbox

    I am trying to read specific lines from all of the text files in a folder that are reports. When I run the application I get the information from the first text file and then it returns this error: "A first chance exception of type 'System.ArgumentOutOfRangeException'
    occurred in mscorlib.dll"
    Below is the code from that form. 
    Option Strict On
    Option Infer Off
    Option Explicit On
    Public Class frmInventoryReport
    Public Function ReadLine(ByVal lineNumber As Integer, ByVal lines As List(Of String)) As String
    Dim intTemp As Integer
    intTemp = lineNumber
    Return lines(lineNumber - 1)
    lineNumber = intTemp
    End Function
    Public Function FileMatches(ByVal folderPath As String, ByVal filePattern As String, ByVal phrase As String) As Boolean
    For Each fileName As String In IO.Directory.GetFiles(folderPath, filePattern)
    If fileName.ToLower().Contains(phrase.ToLower()) Then
    Return True
    End If
    Next
    Return False
    End Function
    Private Sub frmInventoryReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim intcase As Integer = 1
    Dim strTemp, strlist, strFile As String
    Dim blnCheck As Boolean = True
    strFile = "Report Q" & intcase.ToString & ".txt"
    Do While blnCheck = True
    strFile = "Report Q" & intcase.ToString & ".txt"
    Dim objReader As New System.IO.StreamReader("E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\" & strFile)
    Dim allLines As List(Of String) = New List(Of String)
    Do While objReader.Peek <> -1
    allLines.Add(objReader.ReadLine())
    Loop
    objReader.Close()
    strlist = ReadLine(1, allLines) & "" & ReadLine(23, allLines)
    lstInventory.Items.Add(strlist)
    intcase += 1
    strTemp = intcase.ToString
    strFile = "Report Q" & intcase.ToString & ".txt"
    blnCheck = FileMatches("E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\", "*.txt", intcase.ToString)
    Loop
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim intcase As Integer = 1
    Dim strTemp, strlist, strFile As String
    Dim blnCheck As Boolean = True
    strFile = "Report Q" & intcase.ToString & ".txt"
    Do While blnCheck = True
    strFile = "Report Q" & intcase.ToString & ".txt"
    Dim objReader As New System.IO.StreamReader("E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\" & strFile)
    Dim allLines As List(Of String) = New List(Of String)
    Do While objReader.Peek <> -1
    allLines.Add(objReader.ReadLine())
    Loop
    objReader.Close()
    strlist = ReadLine(1, allLines) & "" & ReadLine(23, allLines)
    lstInventory.Items.Add(strlist)
    intcase += 1
    strTemp = intcase.ToString
    strFile = "Report Q" & intcase.ToString & ".txt"
    blnCheck = FileMatches("E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\", "*.txt", intcase.ToString)
    Loop
    End Sub
    End Class
    Sorry I'm just beginning coding and I'm still a noob. Any help is appreciated. Thank you!

    Ok, so if I'm following this correctly you should be able to just loop through all of the files in that folder whose file name matches the pattern and then read the first 22 lines, recording only the first and the last.
    Exactly how you store the animal data probably depends on how you are going to display it and what else you are going to do with it.  Is there anything other than name and cage number that should be associated with each animal?
    You might want to make a dataset with a datatable to describe the animal, or you might write a class, or you might just use something generic like a Tuple.  Here's a simple class example:
    Public Class Animal
    Public Property Name As String
    Public Property Cage As String
    Public Overrides Function ToString() As String
    Return String.Format("{0} - {1}", Name, Cage)
    End Function
    End Class
    With that you can use a routine like the following to loop through all of the files and read each one:
    Dim animals As New List(Of Animal)
    Dim folderPath As String = "E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\"
    For Each filePath As String In System.IO.Directory.GetFiles(folderPath, "Report Q?.txt")
    Using reader As New System.IO.StreamReader(filePath)
    Dim lineIndex As Integer = 0
    Dim currentAnimal As New Animal
    While Not reader.EndOfStream
    Dim line As String = reader.ReadLine
    If lineIndex = 0 Then
    currentAnimal.Name = line
    ElseIf lineIndex = 22 Then
    currentAnimal.Cage = line
    Exit While
    End If
    lineIndex += 1
    End While
    animals.Add(currentAnimal)
    End Using
    Next
    'do something to display the animals list
    Then you might bind the animals list to a ListBox, or loop through the list and populate a ListView.  If you decided to fill a datatable instead of making Animal instances, then you might bind the resulting table to a DataGridView.
    There are lots of options depending on what you want and what all you need to do.
    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

  • Having trouble reading a directory

    I'm trying to read all the filenames of a specific web directory for an online photogallery. The reading is done using a custom jsp tag, which creates a js variable with a list of all the picture names. My code works fine when reading from my own PC. For example reading all the names from "C:\Program Files" works perfect. The problem is that I get an error when I try to read from a web directory. Even "http://localhost:8080/test" gives me an error (since I thought it might have something to do with trying to access a directory outside of my domain.) Can anyone help me with the proper way to read a web directory? My code is below:
    if(name != null) {
                   StringTokenizer toker;
                   File f1 = new File(name);
                   File[] list = f1.listFiles(); //Get all files in the directory "name"
                   String files = "", fname;
                   for(int i=0;i<list.length;i++){
                        fname=list.toString(); //Turn filename into a string
                        toker = new StringTokenizer(fname,"\\"); //parse out the path before the filename
                        while(toker.hasMoreTokens())
                             fname=toker.nextToken();
                        files = files + "\"" + fname.substring(0, fname.length()-4) + "\","; //parse out the extension ".jpg"
                   files = files.substring(0,files.length()-1);
                   pc.getOut().write("<script type=\"text/javascript\"> \n var dirlist = new Array("+files+"); \n </script>"); //send the string of filenames to the client

    what is the error you get?
    Even "http://localhost:8080/test" gives me an error
    You are not passing that url to the File object are you?

  • Illus. CS3 Windows: Im having trouble selecting text when objects are beneath it.

    Technically, I CAN select text, its just a pain in the ***. There is a very fine line to click on and I usually end up selecting the obnect that the text is on top of. If someone knows another way to do this I will be most appreciative.
    Cheers,

    Have you perhaps enabled the Type Object Selection by Path Only option (see Illustrator preferences) ?
    If so, disable it.

  • OT: Having trouble reading a PC vista CD on my G5

    CD will not read on G5 or G4.
    Anyone else having problems with this?
    Thanks, Roger

    J_Maloney wrote:
    >
    > Doesn't everyone? Has anyone in this forum _not_ had a problem with mounting/copy from a CD in the last, say, month?
    >
    >
    >
    I haven't had a problem in a long time, but when I do I stick it into my
    pc, and transfer the files over. I had one many moons ago that was
    written using something like udf packet writing, I had to have them send
    a new cd.
    Jay

  • I have an old powerPC G4. dual 867 512 MB. my optical drive is having trouble reading my leopard installer.  I was going to try to use remote install but i don't have a network where I can connect both the mac and the windows laptop.  any suggestions?

    I'm just trying to revive my old PowerPC G4/ dual 867MHz 512MB.  Unfortunately I am unable to install from disc since my optical drive, although still working, is somehow not able to read the leopard installer.  I wanted to try the remote install option but have limited resources and don't have a network where I can have both the Mac desktop and windows laptop communicate.  I read somewhere that I can use a crossover cable to connect the two directly.  I'm still trying to see if I can get an external DVD-ROM as another option.  Any suggestions?

    Your Mac doesn't need a crossover cable, it auto-switches...
    http://support.apple.com/kb/HT2274
    But I have no idea how that will help you install from a Windows computer.
    If you get an external DVD drive it needs to be Firewire & Mac bootable.
    Other solution...
    http://support.apple.com/kb/HT2274

  • Having trouble reading board ID for NI PCI 6143

    VI will not read board ID
    Attachments:
    Boardid.vi ‏29 KB

    bnortham,
    It would appear that you are attempting to use Traditional DAQ's Get DAQ Device Info.vi However the PCI-6143 is supported in DAQmx only. I have attached a VI through which you should be able to get this information using DAQmx.
    I hope this helps,
    Dan
    Attachments:
    Read_Device_ID.vi ‏21 KB

  • Having trouble reading notices

    I can`t get Adobe Reader to read notices sent to me from DWS my case. How canI fix this? It is really frustrating.

    Could you provide more information about what you are trying to do?
    What is the version of your Adobe Reader?
    What is your operating system (Android version)?
    What do you mean by "can't get Adobe Reader to read notices"?  Are "notices" PDF documents?  Are you trying to open or download them?
    Do you see an error message?
    We can troubleshoot your problem one step at a time.

  • Windows user having trouble reading attachments since 10.4.4

    Has anyone else experienced problems sending attachments (specifically Word docs) to Windows users? I have experienced this only since the latest batch of updates. I have checked my settings and 'Windows friendly' is the default for mail. I have also sent the docs I have had trouble with to an old mac and this works fine which leads me to think its 10.4.4 as the cause?
    Help!!!!!!!!!!!

    As I have emailed, in part:
    Well, this Mac friend is not all right! Please tell me the exact method of creating this document, and the version of Word being used. It is not recognized as a valid format by any of my applications that should open it. Also, tell me how you are connected to the internet.
    and
    Placing the cursor over the attachment, reports it to be of the type octet stream. This is most often seen when an exchange server, or some other MS program is involved, and working improperly.
    Also, try switching off windows friendly setting and sending to me again. Does the document open properly when you open the message sent to me in the Sent mailbox?
    Try sending me a JPEG, or other type of attachment -- this might help to check for a transmission error. This does not appear to be simply a Mail problem.
    Ernie

  • Having trouble reading /opening raw files from NIKON 1AW1 camera inn lightroom 5.2

    We have the new Nikon 1AW1 camera and it shoots in raw and jpeg format.  I prefer RAW.  We have opened and processed 1000s of raw images from our other Nikon DSLRs.  With this new camera keep getting the unrecognized  format??   any hints??

    The two pictures provided seem to have different magenta/green (Tint) balance from each other, but without knowing what WB is set in camera or what WB is set in LR that could be what is expected.
    The original problem as described seemed to be that a single picture changed its Color (perhaps WB) and Tone (light/dark/contrast) from when viewed on camera to when viewed in LR.  Slight changes in color and tone would be expected because Adobe doesn't have access to nor is trying to reproduce the raw-conversion only the camera manufacturer knows the specifics of, but WB is something Adobe can read and attempts to make the same as far as neutrals still being neutral.  Seeing two different pictures with an obvious shift in WB isn't an illustration of things looking different between the camera and LR for a specific image, but maybe the WB variance is what you're really wondering about.
    What WB mode were you shooting in with the camera, Auto WB?  And what WB mode do you have set for these two images in LR (As Shot, Auto, Custom, etc), and what specific WB numbers do you see in LR for these two images?  Also, what camera profile do you have set in the camera and what camera profile do you have set in LR?
    If your camera is set to Auto WB then both the camera and LR would show whatever WB the camera determined for each image and that could vary from one image to the next.  The way to fix the WB variance in LR is to figure out what WB to use and then synchronize that across a group of raw images so they all have the same WB. 
    One confusing thing is that if you like the WB on a particular image and synchronize that image to a group of others, but it happens that the image mode of the image you are syncing to is As Shot, then you won't be syncing the specific Temp and Tint values between the images, you'll be syncing the As Shot mode between all the images so nothing will appear to change.  If you are starting with an image WB you like that still says As Shot then tweak the WB slightly up and back, so the same numbers are there in Custom mode, then that Custom mode AND the same numbers will be synced to all the other raws as expected.
    As far as keeping the same toning you see on your camera's review screen (the camera-embedded preview JPG is what you're seeing, here) and what LR shows you by default, is not going to happen, and will be more off if you have the camera doing some exposure optimization like HTP or ALO (if those are still the acronyms Canon uses) because, again, that optimization only affects the camera JPG, except the HTP actually underexposes so LR's version of the images might be darker than what the camera shows because it's digitally boosted the ISO between the time it writes the raw data and produces the in-camera JPG preview.
    Regarding your previous question about using DNGs or CR2s, the particular format of the raw data shouldn't affect how LR works with the images.  Obviously if your DNG conversion includes reducing the size of the images or using lossy compression, then the image dimensions and some aspects of the details, both sharpness and noise-reduction will change compared to the original raw but those sorts of things will be always be different than the in-camera JPGs as well, so it seems unlikely part of what you're seeing.

  • Modbus, having trouble reading more than one register.

    I think my issue may be something simple. I am able to read exactly one modbus register correctly. If I try to increase the registers to any more than one I get a timeout 6101 error at the Modbus read module. So far I've tried a number of different layouts, and even two different Modbus slaves from different vendors with the same results. I'm using a USB-RS485 converter with the FTDI232 chip. Again, a single register read always returns the correct data - so I'm almost there. The register divide routine on the right had side is rudimentary for now until I can get data from multiple registers. Any help is appreciated.
    Attachments:
    Modbus test.vi ‏37 KB

    I have solved the issue. On my RS485 converter (I'm using one from bb-electronics), I had "Echo on" enabled. This caused the written command to re-appear on the read buffer. The modbus read function will accept this configuration - but only when reading one register! So, for anyone with this issue in the future - check your echo setting.
    Someone more familiar with the modbus protocol's working and the internals of the read function could probably explain why this situation would manifest.
    I understand the timed loop is bad practice - I should loop while no error, but I was trying to fix my core issue before making any improvements.
    Thanks for your help.

  • I am having trouble reading a time stamp on a video using OCR

    I am trying to read a time stamp that is overlaid on a video, using OCR software, but it will not read it correctly I've tried the OCR Preproccessing and Recognition Config VI's and neither have been able to correct to problem I would appreciate some help

    In my experience, it is very important that the contrast not only be
    very good but also that the characters can be easily distinguished
    from the background and that the characters are generally repeatable
    and unique. I've had problems with characters "smearing" into the
    background so that the OCR can't tell where the background ends and
    the character begins.
    Beyond the standard NI OCR stuff, you can use a database to map
    incorrect whole words to correct whole ones in OCR but this only works
    when there is a set of unique words that are significantly different
    from each other. It doesn't work on numbers since any number is
    generally as likely as any other.
    It may be worthwhile to invest in higher quality acquisition equipment
    to improve the image quality. If your video source itself is poor
    quality, then it won't matter though.
    Douglas De Clue
    [email protected]
    nestor wrote in message news:<[email protected]>...
    > Ernest,
    >
    > As "labviewguru" mentioned a screenshot will help a lot to determine
    > if the problem is the image quality. However if you can't post this
    > image then please review the following links I'm attaching here. They
    > talk about OCR and most important, about Filtering, which is mostly
    > used in Vision for image enhancement, noise reduction, sharpen an
    > image, etc. Please review the links mentioned below and apply some
    > filtering techniques to your image. This may help a lot, personally
    > I've used OCR software and I have required in most cases to apply
    > filtering before running the OCR functions.
    >
    >
    > href="http://zone.ni.com/devzone/conceptd.nsf/webmain/E69D110920B99E838625685E0081B881?opendocumen...
    >
    > href="http://zone.ni.com/devzone/devzone.nsf/webcategories/605B55C3100D02188625685E0076C928?opendo...
    >
    > href="http://zone.ni.com/devzone/devzone.nsf/webcategories/E28E087D201C1AD48625685E00824E3C?opendo...
    >
    > Here at the Developer Zone, inside the Development Library you will
    > find in the Vision chapter a lot of information that will be helpful
    > for your development. Please review it. In case you require further
    > assistance you can keep posting questions here at the Discussion Forum
    > or give us a call/email (www.ni.com/ask).
    >
    > Good luck!
    >
    > Nestor Sanchez
    > IMAQ/Motion Support
    > National Instruments

  • Flash having trouble reading audio mp3 file

    I am trying to add background music to a website using
    Dreamweaver 8 and followed the embed instructions and it doesn't
    seem to be playing. I tried the file in both wma and mp3 formats.
    My next step was to import it into flash and create a .swf of
    the music file. Flash will not import it due to difficulty reading
    the file. This file will play independently on different computers
    with Windows Media Player. Does anyone have any suggestions as what
    I can do to make this work? I ripped the music from the cd the
    artist provided for me. Could this possibly be the issue?
    To view the website in progress you can visit
    www.fourwindscouncilga.com the sound file is on the splash "Enter
    Here" page.

    Have you received any answers or solutions to this? I also
    came across the same situation and couldn't find support.

Maybe you are looking for

  • "Resetting" a component

    Hi, I have a WD component with two views A and B. The other view B has actually another WD component embedded. I can navigate between these two views. Now I would like to somehow "reset" the other component (in view B) when leaving it (=navigating ba

  • Issue while installing ODI 11.1.1.6 with JDK 7u

    Hi All, I am working on installing ODI on windows 64 bit. I downloaded lastest web logic server files, ODI files and JDK files from oracle site.. I installed Web Logice server with no errors but when I tried to install ODI by running the setup.exe it

  • Insufficient space in Javaheap Error when installing BIEE 10.1.3.4 on linux

    Hi, I am trying to install OBIEE 10.1.3.4 on Linux Enterprise 4 on a VM machine. When the installer reaches 20% it shuts down with the following error. Can someone please tell me how to resolve this as I am not able to install BIEE. I have 4GB of RAM

  • How can i read an COM port ???

    Hi, somebody knows how can i read an COM port from Forms 4.5 ? Thanks in advance. Patricio

  • No scrubber for podcast app on iPhone 4s?

    It looks like the latest update only has a scruber when it is operated on the iPhone 5? Is there no way to scrub or even see the timeline on earlier models? Does anyone know how to fix this?