NullPointerException when JFrame.setVisible is called

Hi,
We are upgrading our app from JDK 1.2.2 to JDK 1.4.
App used to work fine with JDK 1.2.2. Now it throws a
NullPointerException on one of the calls to JFrame.setVisible
method. Here is the error:
java.lang.NullPointerException
at javax.swing.text.PlainView.getLineWidth(PlainView.java:612)
at javax.swing.text.PlainView.getPreferredSpan(PlainView.java:211)
at javax.swing.plaf.basic.BasicTextUI$RootView.getPreferredSpan(BasicTex
tUI.java:1167)
at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:
737)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1262)
at javax.swing.JTextArea.getPreferredSize(JTextArea.java:606)
at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:76
7)
at java.awt.Container.layout(Container.java:980)
at java.awt.Container.doLayout(Container.java:970)
at java.awt.Container.validateTree(Container.java:1048)
at java.awt.Container.validateTree(Container.java:1055)
at java.awt.Container.validateTree(Container.java:1055)
at java.awt.Container.validateTree(Container.java:1055)
at java.awt.Container.validateTree(Container.java:1055)
at java.awt.Container.validateTree(Container.java:1055)
at java.awt.Container.validateTree(Container.java:1055)
at java.awt.Container.validateTree(Container.java:1055)
at java.awt.Container.validate(Container.java:1023)
at java.awt.Window.show(Window.java:455)
at java.awt.Component.show(Component.java:1128)
at java.awt.Component.setVisible(Component.java:1083)
at com.teoco.events.EventViewerFrame.setVisible(EventViewerFrame.java:29
7)
at com.teoco.events.EventViewerFrame.display(EventViewerFrame.java:185)
at com.teoco.ImportGUI.Desktop.initializeApplication(Desktop.java:654)
at com.teoco.ImportGUI.Desktop.initializeApplication(Desktop.java:639)
at com.teoco.ImportGUI.Desktop.<init>(Desktop.java:310)
at com.teoco.ImportGUI.Desktop.<init>(Desktop.java:337)
at com.teoco.ImportGUI.Desktop.main(Desktop.java:1197)
I cannot figure out what could be causing this problem.
Any help is appreciated.
Thanks
Jitendra

Hi Denis,
Thanks for the bug link you provided. I looked at the bug they were talking about, it looks similar to what is happening to me, but they were talking about Solaris and Linux. Our app runs on Windows and the report says they did not test the fix on Windows.
Jitendra

Similar Messages

  • NullPointerException: when call "drawImage" function?

    hello all:
    I met a java.lang.NullPointerException when I try to call drawImage in
    my program.
    My program structure:
    1>JFrame / JPanel / ImagePane(which extends JComponent)
    a object of class ImagePane stays on top of a object of JPanel which stays on JFrame.
    2>code of class ImagePane
    <pre>
    public class ImagePane extends JComponent {
    Image pic = null;
    Image canvas = null;
    int width = -1;
    int height = -1;
    public ImagePane() {
    ImageIcon bird = ZoomUtil.createImageIcon("birdView.jpg");
    width = bird.getIconWidth(); // ImageIcon width
    height = bird.getIconHeight(); // ImageIcon height
    // the image birdView.jpg is successfully loaded by java
    // b/c I can get correct width and height
    pic = bird.getImage();
    canvas = createImage(width, height);
    canvas.getGraphics().drawImage(pic, width, height, null);
    // the above line get nullPointerException, when I ran program.
    public void paint(Graphics g) {
    g.drawImage(pic, 5, 5, 200, 250, null);
    </pre>
    Main program looks like:
    JPanel jPanel1 = new JPanel();
    ImagePane imagePaneA = new ImagePane();
    jPanel1.add(imagePaneA, BorderLayout.CENTER);
    thank you for any suggestion!
    -Daniel

    hello all:
    I had made my code without NullPointerException, but I still cannot
    get any image drawed?!
    any helps are welcome!
    public class ImagePane extends JComponent {
    Image pic = null;
    Image canvas = null;
    int width = -1;
    int height = -1;
    public ImagePane() {
    ImageIcon bird = ZoomUtil.createImageIcon("birdView.jpg");
    width = bird.getIconWidth(); // ImageIcon width
    height = bird.getIconHeight(); // ImageIcon height
    pic = bird.getImage();
    public void paint(Graphics g) {
    setVisible(true);
    canvas = createImage(width, height);
    if (canvas == null) {
    System.err.println("canvas is null"); // correct
    return;
    if (g.drawImage(canvas, 0, 0, this)) {
    System.err.println("drawImage true"); // correct
    else {
    System.err.println("drawImage false");
    }

  • Bug in Oracle JDBC Driver: NullPointerException when calling clearParameters

    There is a bug in the latest version of the JDBC driver that throws a NPE when calling PreparedStatement.clearParameters(). I don't need a response to this, since I have a workaround (just catching and ignoring the exception), but it should probably be fixed. I speculate that the problem only occurs when you try to call clearParameters() more than once on the same PS, but I haven't confirmed it.
    It is probably an easy fix. Following is the stack trace:
    java.lang.NullPointerException
    at oracle.jdbc.dbaccess.DBData.clearItem(DBData.java:431)
    at oracle.jdbc.dbaccess.DBDataSetImpl.clearItem(DBDataSetImpl.java:3528)
    at oracle.jdbc.driver.OraclePreparedStatement.clearParameters(OraclePreparedStatement.java:3401)
    at com.solarmetric.datasource.PreparedStatementCache$CachePreparedStatement.close(PreparedStatementCache.java:293)
    at com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executePreparedStatementBatch(SQLExecutionManagerImpl.java:666)
    at com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executePreparedStatement(SQLExecutionManagerImpl.java:514)
    at com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executeInternal(SQLExecutionManagerImpl.java:406)
    at com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.flush(SQLExecutionManagerImpl.java:273)
    at com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManager.java:421)
    at com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:549)
    at com.solarmetric.kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:412)
    at com.sun.jdotck.api.persistencemanager.MakePersistentAssignsObjectId.testMakePersistentAssignsObjectId2(Unknown Source)
    at com.sun.jdotck.api.persistencemanager.MakePersistentAssignsObjectId.testMakePersistentAssignsObjectId(Unknown Source)
    at com.sun.jdotck.api.persistencemanager.MakePersistentAssignsObjectId.runTest(Unknown Source)
    at com.sun.jdotck.api.persistencemanager.PersistenceManagerTest.run(Unknown Source)
    at com.solarmetric.kodo.compatibility.JDOCompatabilityTestSuite$1.runTest(JDOCompatabilityTestSuite.java:493)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:325)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:524)
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

    Take a look at the method that is causing the NullPointerException:
    public void clearItem(int i)
    if (!m_dynamic && m_vector == null && i < m_vector.size())
    m_vector.removeElementAt(i);
    if (m_items != null && i >= m_items.length)
    return;
    m_items[i] = null;
    return;
    A NullPointerException will be thrown whenever clearParameters() is called when no parameters have yet been bound.
    The first IF statement should read:
    if (!m_dynamic && m_vector != null && i < m_vector.size())
    A simple workaround would be to make sure that your parameter list is never empty before calling clearParameters(). Is there a patch for this anywhere?

  • NullPointerException when mouselistener calls method

    Good Evening,
    I get a java.lang.NullPointerException when a mouselistener calls a method "populatethedatafields()" contained within the class. The populatethedatafields method tries to set the values of text fields and it is at this point the exception occurs. I have tried being more explict in identifying the fields using myclassname.this.textfieldname and this.textfieldname without success. When I moved the settext to within the mouselistener scope, I was able to make the changes.
    Why does this occur?
    I know that I can fix it by putting the settext into the listeners, but that does not seem to be good coding practice. Any suggestions for a good coding practice to solve this type of issue?
    Many thanks for your time.
    Some code removed for clarity and brevity.......
    package EMSBeta1;
    public class ContactInfoViewTEST2 extends JPanel {
    private JTextField textFieldFirstName, textFieldLastName;
    private JPanel custDetails;
    /** Creates new ContactInfoView */
    public ContactInfoViewTEST2(PowerSourceRacingModel model) {
    mod = model;
    cqm = mod.getContactQuery();
    cdt = mod.getContactDetails();
    initComponents();
    public void initComponents() {
    JPanel panel1 = new JPanel();
    JPanel panel2 = new JPanel();
    JPanel detailsPanel = new JPanel();
    double size[][] =
    {{10, -1.0, -1.0, -1.0, -1.0, TableLayout.PREFERRED, 10}, // Columns
    {10, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 10}}; // Rows
    panel1.setBorder(BorderFactory.createTitledBorder("This is a title"));
    BoxLayout layout = new BoxLayout(panel1, BoxLayout.Y_AXIS);
    panel1.setLayout(layout);
    // panel2.setBorder(BorderFactory.createTitledBorder("This is a title"));
    BoxLayout layout2 = new BoxLayout(panel2, BoxLayout.X_AXIS);
    panel2.setLayout(layout2);
    detailsPanel.setBorder(BorderFactory.createTitledBorder("This is a title"));
    detailsPanel.setLayout(new TableLayout(size));
    JLabel labelLastName = new JLabel("Last Name") ;
    final JTextField textFieldLastName = new JTextField("Enter LastName",10);
    JLabel labelFirstName = new JLabel("First Name") ;
    final JTextField textFieldFirstName = new JTextField("FirstName",5);
    textFieldLastName.setNextFocusableComponent(textFieldMembershipNum);
    textFieldMembershipNum.setNextFocusableComponent(textFieldAddress);
    textFieldAddress.setNextFocusableComponent(textFieldEmerContactPhone);
    detailsPanel.add(labelLastName, "1, 1, L, C");
    detailsPanel.add(textFieldLastName, "1, 2, L, T");
    detailsPanel.add(labelFirstName, "3, 1, L, C");
    detailsPanel.add(textFieldFirstName, "3, 2, L, T");
    panel1.add(contactListPane);
    this.setLayout(new BorderLayout());
    add(panel1,BorderLayout.WEST);
    add(panel2,BorderLayout.SOUTH);
    add(detailsPanel,BorderLayout.CENTER);
    MouseListener listMouseListener = new MouseListener() {
    public void mouseClicked(MouseEvent e) {
    public void mouseEntered(MouseEvent e) {
    public void mouseExited(MouseEvent e) {
    public void mousePressed(MouseEvent e) {
    public void mouseReleased(MouseEvent e) {
    createNewContact.setEnabled(true);
    updateButton.setEnabled(true);
    insertNewDataButton.setEnabled(false);
    clearButton.setEnabled(false);
    JList theList = (JList)e.getSource();
    int indexValue = theList.getSelectedIndex();
    System.out.println("This is the selected index from the JList: " + indexValue);
    ContactIdName selectedItem = (ContactIdName)list.getSelectedValue();
    int selectedKey = selectedItem.getKey();
    contactInfo = cdt.getContactDetails(selectedKey);
    populateTheDataFields();
    list.addKeyListener(listKeyListener);
    list.addMouseListener(listMouseListener);
    public void clearFields() {
    textFieldFirstName.setText(null);
    textFieldLastName.setText(null);
    public void populateTheDataFields() {
    String first = (String)contactInfo.get("FIRSTNAME");
    String last = (String)contactInfo.get("LASTNAME");
    this.textFieldFirstName.setText(first);
    this.textFieldLastName.setText(last);
    }

    Ah Ha, Discovered the solution/problem.
    Note that I declared textFieldFirstName and textFieldLastName as class objects with private scope. Then in the initComponents METHOD, I created NEW textFieldFirstName and textFieldLastName objects whose scope is limited only to the method. By prefixing the objects with type, I was creating new instances of the objects rather than "re-using" the class objects. Class objects with appropriate scope are accessible by methods and inner classes. Objects created within a method are not unless the method returns the object.
    Subtle, but basic OO stuff that was a painful lesson. Whew!

  • Which event will be fired when I after set JFrame.setVisible(false)

    Experts.
    I want to know which event will be fired when I after set JFrame.setVisible(false)?
    Because I need to check a thread is finished it job or not.
    I have checked windowClosing event, but it doesn't work.
    Thanks
    Francis

    Oh....
    Sorry, I find it will fired on componentHidden event.
    Very sorry.

  • NullPointerException when using setBindingContext

    Hello,
    I'm having some trouble instantiating a JFrame that has data binding.
    When i instantiate the JFrame in an other class in the same project as the JFrame it works.
    But when i try to instantiate it in a class in an other project (still in the same workspace) it doens't work.
    I get a NullPointerException where ever setBindingContext is called, because panelBinding.getBindingContext() returns null from some reason.
    Can someone explain me why this is?
    Thanks in advance
    Johan Smolders

    Hi Jan,
    First off all thanks for responding.
    The bootstrap code is called before the other elements do there method calls to setBindingContext.
    So the context of panelBinding shouldn't be empty.
    All calls are preformed in the same order as they would be called when you start the JFrame itself.
    Now your second remark made me think.
    When i instantiate my JFrame in the other projects class does it use the wrong Databinding.cpx?
    So the best solution would be: Join all the file's in one project?
    Or can i explicitly tell the JFrame which Databindings it should use?
    Edit:
    As a test i copied my Databindings.cpx file in the project containing the JFrame and named it Databindings2.cpx
    I then edited the JFrame class to use this Databindings2.cpx (so i was sure is wasn't using the Databindings.cpx file of the other project)
    but the same error accured.
    Thx again
    Johan
    Message was edited by:
    Johan Smolders

  • Java.lang.NullPointerException when trying to compile

    Hi everybody!
    I'm trying to compile a file using javax.tools.JavaCompiler but I get a java.lang.NullPointerException when running the program.
    Here is my code:
    public boolean CompExecFile(File filename){
              boolean compRes = false;
              try {
                   System.out.println(filename.getAbsolutePath());
                   JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
                   StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); //line where I get the error
                   Iterable<? extends JavaFileObject> compilationUnits2 = fileManager.getJavaFileObjects(filename);
                   compRes = compiler.getTask(null, fileManager, null, null, null, compilationUnits2).call();
                   fileManager.close();
                 if (compRes) {
                     System.out.println ("Compilation was successful");
                 } else {
                     System.out.println ("Compilation failed");
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              return compRes;
         }There error on the line "StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);":
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException+
    I've seen several examples using the parameters "null,null,null" but I don't know if it's good :(
    Many thanks for your help.

    I've found something which could maybe be what I need to do but I'm not sure:
    // Build a new ClassLoader using the given URLs, replace current Classloader
    ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
    ClassLoader newCL = new URLClassLoader(myClasspathURLs, oldCL);
    Thread.currentThread().setContextClassLoader(newCL);
    System.out.println("Successfully replaced ClassLoader");
    Class fooClass = newCL.loadClass(appClass); //which replaces the line "Class<?> tempFileClass = Class.forName("TempFile");" ?!Is that what I need to do?
    EDIT: I've tried that but I still have the same problem:
                      File classFile = new File ("TempFile.class");
                      ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
                      ClassLoader newCL = new URLClassLoader(new URL[] {classFile.toURL()}, oldCL);
                      Thread.currentThread().setContextClassLoader(newCL);
                      System.out.println("Successfully replaced ClassLoader");
                      Class tempFileClass = newCL.loadClass("TempFile");
                      Method main = tempFileClass.getMethod("main", String[].class);
                      main.invoke(null,new String[0]); Edited by: Foobrother on Jul 28, 2008 8:18 AM

  • Weblogic throws NullPointerException when using ServiceControl.setTimeout

    We are invoking a SOAP service via a com.bea.control.ServiceControl that was generated from a WSDL (right click WSDL, Generate Service Control) using Weblogic 8.1.6.
    SOAP service execution is successful using an http and https endpoint. However, when setting a timeout via ServiceControl.setTimeout(int millisecods) method, the Weblogic API is throwing a NullPointerException when using an https endpoint. When using an http endpoint with the setTimeout method execution is successful.
    DEBUG com.bea.wlw.runtime.jws.call.SoapHttpCall [ExecuteThread: '10' for queue: 'weblogic.kernel.Default']: opening connection to https://[... edit removed ...]
    DEBUG com.bea.wlw.runtime.jws.call.SoapHttpCall [ExecuteThread: '10' for queue: 'weblogic.kernel.Default']: Response generation exception
    Throwable: java.lang.NullPointerException
    Stack Trace:
    java.lang.NullPointerException
         at weblogic.net.http.HttpsClient.openWrappedSSLSocket(HttpsClient.java:455)
         at weblogic.net.http.HttpsClient.openServer(HttpsClient.java:235)
         at weblogic.net.http.HttpsClient.openServer(HttpsClient.java:389)
         at weblogic.net.http.HttpsClient.<init>(HttpsClient.java:209)
         at weblogic.net.http.HttpClient.New(HttpClient.java:228)
         at weblogic.net.http.HttpsURLConnection.getHttpClient(HttpsURLConnection.java:246)
         at weblogic.net.http.HttpsURLConnection.connect(HttpsURLConnection.java:217)
         at weblogic.net.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:189)
         at com.bea.wlw.runtime.jws.call.SoapHttpCall.invoke(SoapHttpCall.java:179)
         at com.bea.wlw.runtime.jws.call.SoapHttpCall.invoke(SoapHttpCall.java:80)
         at com.bea.wlw.runtime.core.control.ServiceControlImpl.invoke(ServiceControlImpl.jcs:1288)
         at com.bea.wlw.runtime.core.control.ServiceControlImpl.invoke(ServiceControlImpl.jcs:1155)
         at com.bea.wlw.runtime.core.dispatcher.DispMethod.invoke(DispMethod.java:377)
         at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:433)
         at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:406)
         at com.bea.wlw.runtime.jcs.container.JcsProxy.invoke(JcsProxy.java:388)
    DEBUG com.bea.wlw.runtime.jws.call.SoapFault [ExecuteThread: '10' for queue: 'weblogic.kernel.Default']: SoapFault exception throwable e
    DEBUG com.bea.wlw.runtime.jws.call.SoapHttpCall [ExecuteThread: '10' for queue: 'weblogic.kernel.Default']: response code=0, responseMsg=null
    DEBUG com.bea.wlw.runtime.jws.call.SoapHttpCall [ExecuteThread: '10' for queue: 'weblogic.kernel.Default']: closed connection to https://[... edit removed ...]
    WARN WLW.INVOKE.[... edit removed ...] [ExecuteThread: '10' for queue: 'weblogic.kernel.Default']: Id=[... edit removed id ...] Method=[... edit removed method ...]; Failure=com.bea.control.ServiceControlException: SERVICE FAULT:
    Code:java.lang.NullPointerException
    String:null
    Detail:
    END SERVICE FAULT
    ERROR [... edit removed ...]
    [ExecuteThread: '10' for queue: 'weblogic.kernel.Default']: ServiceControlException
    com.bea.control.ServiceControlException: SERVICE FAULT:
    Code:java.lang.NullPointerException
    String:null
    Detail:
    END SERVICE FAULT
         at com.bea.wlw.runtime.core.control.ServiceControlImpl.invoke(ServiceControlImpl.jcs:1268)
         at com.bea.wlw.runtime.core.dispatcher.DispMethod.invoke(DispMethod.java:377)
         at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:433)
         at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:406)
         at com.bea.wlw.runtime.jcs.container.JcsProxy.invoke(JcsProxy.java:388)

    Thanks for the suggestion. But with -DUseSunHttpHandler=true the Weblogic API is throwing a ClassCastException with or without the timeout value set.
    Failure=com.bea.control.ServiceControlException: SERVICE FAULT:
    Code:java.lang.ClassCastException
    String:null
    Detail:
    END SERVICE FAULT
    ERROR: ServiceControlException
    com.bea.control.ServiceControlException: SERVICE FAULT:
    Code:java.lang.ClassCastException
    String:null
    Detail:
    END SERVICE FAULT
         at com.bea.wlw.runtime.core.control.ServiceControlImpl.invoke(ServiceControlImpl.jcs:1268)
         at com.bea.wlw.runtime.core.dispatcher.DispMethod.invoke(DispMethod.java:377)
         at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:433)
         at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:406)
         at com.bea.wlw.runtime.jcs.container.JcsProxy.invoke(JcsProxy.java:388)

  • NullPointerException when adding an object into a Vector Class

    So here is the code:
    package Image;
    import java.io.Serializable;
    import java.util.Vector;
    public class Album implements Serializable{
    private String name;
    private String password;
    Vector<ImageClass> allImages;
    public Album( String name, String password, Vector<ImageClass> allImages) {
    this.name = name;
    this.password = password;
    this.allImages = allImages;
    public Album() {
    public Vector<ImageClass> getAllImages() {
    return allImages;
    public void setAllImages(Vector<ImageClass> allImages) {
    this.allImages = allImages;
    public String getName() {
    return name;
    public void setName(String name) {
    this.name = name;
    public String getPassword() {
    return password;
    public void setPassword(String password) {
    this.password = password;
    public void addIC(ImageClass ic){
    allImages.add(ic);
    public ImageClass getIC(int pos){
    ImageClass ic = allImages.get(pos);
    return ic;
    Now I got an NullPointerException when I call the getIC Method from another class of another package
    Here is the part of code of that class.
    private void SaveMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                            
    ImageClass ic = new ImageClass();
    ic.setTitle(ImageTextField.getText());
    ic.setDescription(DescriptionTextArea.getText());
    try {
    ic.setReferenceNumber(Integer.parseInt(ReferenceTextField.getText()));
    } catch (NumberFormatException nfe) {
    JOptionPane.showMessageDialog(null, "Reference Number is not in a correct format");
    try {
    ic.setDate(new SimpleDateFormat("dd/MM/yyyy").parse(DateTextField.getText(), new ParsePosition(0)));
    } catch (IllegalArgumentException iae) {
    JOptionPane.showMessageDialog(null, "Date is not in correct format");
    ic.setImageData(imageData);
    if(a==null){
    JOptionPane.showMessageDialog(this,"Please, create or open an Album");
    }else{
    a.addIC(ic);
    try{
    ObjectOutputStream oos;
    FileOutputStream fos = new FileOutputStream(album, true);
    oos = new ObjectOutputStream(fos);
    oos.writeObject(a);
    oos.flush();
    oos.close();
    }catch(FileNotFoundException fnfe){
    fnfe.printStackTrace();
    }catch(IOException ioe){
    ioe.printStackTrace();
    }

    h1. The Ubiquitous Newbie Tips
    * DON'T SHOUT!!!
    * Homework dumps will be flamed mercilessly. [Feelin' lucky, punk? Well, do ya'?|http://www.youtube.com/watch?v=1-0BVT4cqGY]
    * Have a quick scan through the [Forum FAQ's|http://wikis.sun.com/display/SunForums/Forums.sun.com+FAQ].
    h5. Ask a good question
    * Don't forget to actually ask a question. No, The subject line doesn't count.
    * Don't even talk to me until you've:
        (a) [googled it|http://www.google.com.au/] and
        (b) had a squizzy at the [Java Cheat Sheet|http://mindprod.com/jgloss/jcheat.html] and
        (c) looked it up in [Sun's Java Tutorials|http://java.sun.com/docs/books/tutorial/] and
        (d) read the relevant section of the [API Docs|http://java.sun.com/javase/6/docs/api/index-files/index-1.html] and maybe even
        (e) referred to the JLS for "advanced" questions.
    * [Good questions|http://www.catb.org/~esr/faqs/smart-questions.html#intro] get better Answers. It's a fact. Trust me on this one.
        - Lots of regulars on these forums simply don't read badly written questions. It's just too frustrating.
          - FFS spare us the SMS and L33t speak! Pull your pants up, and get a hair cut!
        - Often you discover your own mistake whilst forming a "Good question".
        - Often you discover that you where trying to answer "[the wrong question|http://blog.aisleten.com/2008/11/20/youre-asking-the-wrong-question/]".
        - Many of the regulars on these forums will bend over backwards to help with a "Good question",
          especially to a nuggetty problem, because they're interested in the answer.
    * Improve your chances of getting laid tonight by writing an SSCCE
        - For you normal people, That's a: Short Self-Contained Compilable (Correct) Example.
        - Short is sweet: No-one wants to wade through 5000 lines to find your syntax errors!
        - Often you discover your own mistake whilst writing an SSCCE.
        - Often you solve your own problem whilst preparing the SSCCE.
        - Solving your own problem yields a sense of accomplishment, which makes you smarter ;-)
    h5. Formatting Matters
    * Post your code between a pair of &#123;code} tags
        - That is: &#123;code} ... your code goes here ... &#123;code}
        - This makes your code easier to read by preserving whitespace and highlighting java syntax.
        - Copy&paste your source code directly from your editor. The forum editor basically sucks.
        - The forums tabwidth is 8, as per [the java coding conventions|http://java.sun.com/docs/codeconv/].
          - Indents will go jagged if your tabwidth!=8 and you've mixed tabs and spaces.
          - Indentation is essential to following program code.
          - Long lines (say > 132 chars) should be wrapped.
    * Post your error messages between a pair of &#123;code} tags:
        - That is: &#123;code} ... errors here ... &#123;code}
        - OR: &#91;pre]&#123;noformat} ... errors here ... &#123;noformat}&#91;/pre]
        - To make it easier for us to find, Mark the erroneous line(s) in your source-code. For example:
            System.out.println("Your momma!); // <<<< ERROR 1
        - Note that error messages are rendered basically useless if the code has been
          modified AT ALL since the error message was produced.
        - Here's [How to read a stacktrace|http://www.0xcafefeed.com/2004/06/of-thread-dumps-and-stack-traces/].
    * The forum editor has a "Preview" pane. Use it.
        - If you're new around here you'll probably find the "Rich Text" view is easier to use.
        - WARNING: Swapping from "Plain Text" view to "Rich Text" scrambles the markup!
        - To see how a posted "special effect" is done, click reply then click the quote button.
    If you (the newbie) have covered these bases *you deserve, and can therefore expect, GOOD answers!*
    h1. The pledge!
    We the New To Java regulars do hereby pledge to refrain from flaming anybody, no matter how gumbyish the question, if the OP has demonstrably tried to cover these bases. The rest are fair game.

  • Auto-scrolling doesn't work when JFrame is not visible

    Hi, I have auto-scrolling implemented for my JTextPane that sits in JScrollPane - which lives in JInternalFrame. It works as excepted - as long as my application's JFrame is visible. When the JFrame becomes invisible, auto-scrolling simply doesn't work anymore.
    I've overcame this by scrolling down in "windowShown", but it's ugly because the user can visually see the scroll down when using this workaround (it jumps).
    I guess this is Swing's optimization, but I would really like to overcome it in someway. But it seems I'm not enough a swing hacker to do it.
    One thing to note is thtat, the auto-scrolling works fine when the JInternalFrame is NOT visible, but frame is.
    I've tried to override the isShowing-method of JInternalFrame, with no luck.
    Here's my scrolling method:
    public static void scrollDown(JScrollPane scroll) {
              JViewport port = scroll.getViewport();
              Rectangle rect = new Rectangle(0, port.getViewSize().height, 1, 1);
              port.scrollRectToVisible(rect);
              JScrollBar bar = scroll.getVerticalScrollBar();
              bar.setValue(bar.getMaximum() - bar.getModel().getExtent());
         }Anyone have ideas?

    At some point I had really hard time getting the auto-scrolling to work, as I got these weird little bumps after scrolling down.
    Adding scrollBar.setValue() seemed to 'just fix it'. It actually seems to be superfluous now.
    The scrolling is already wrapped in SwingUtilities.invokeLater() - in conjuction with printing text into the JTextPane and it works OK.
    I had some wrong info in the first post, the viewport actually does get scrolled down even when the JFrame is not visible. And by visible I mean JFrame.setVisible(false) - my application has a minimize-to-tray feature, which hides the JFrame.
    So I think the problem is 'just' a repainting problem. When the frame is shown, the previous scroll location is first displayed, and then a repaint is triggered that causes the 'jump down'.
    I'm not still sure how to fix it though.

  • Why my iphone 5 restart itself when I make a call on facetime?

    When I make a call on facetime, sometime my iphone 5 was hang, then black screen and restart itself.
    At the first, I think it's because my ios is 6.0 so I update to 6.0.1 but it still restart itself. What should I solve this problem?

    Thank you

  • How do I use my Mac's mic and speaker when answering a phone call?

    Whenever I receive a phone call on my iPhone and answer it on my Mac, the speaker and mic on the iPhone are used for the call rather than the Mac. On an older Mac I was using, when I answered a call from my iPhone, it used the Mac's speaker and mic for the call. Is there a setting somewhere to fix this on the new Mac? When I make calls from the Mac, it uses the speaker and mic, but it doesn't when I answer them. Any help is appreciated. Thanks.
    2015 MacBook Pro 13" 10.10.2
    iPhone 5S iOS 8.2

    Howdy Robb,
    The article linked below details a number of troubleshooting steps that can help resolve issues with Continuity between your Mac and your iPhone.
    Get help using Continuity with iOS 8 and OS X Yosemite
    https://support.apple.com/en-us/TS5458
    Cheers,
    Allen

  • When bluetooth headset is connected to iphone,I can't hear iphone ringing aloud when I have a call or a text. Do i really have to wear the bluetooth headset all the time in my ear to know when I have a call or a message? Why it doesnt ring through iphone?

    when bluetooth headset is connected to iphone,I can't hear iphone ringing aloud when I have a call or a text. Do i really have to wear the bluetooth headset all the time in my ear to know when I have a call or a message? Why it doesnt ring through iphone but it rings through the bluetooth headsets?
    In other phones, you can hear the phone ringing and if it was connected to bluetooth, you could pick up the call from the bluetooth headset.
    Here with iphone, if its connected to bluetooth headset, it only rings through the headset, which means that if you dont have the headset in the ear all the time, you cannot know that you have an incoming call or message.
    Any ideas - solutions - comments please?

    I'm having the same problem. I had a plantronics 975 (which I lost, sadly). When connected, the ringer would always be routed through the bluetooth and the iPhone's external speaker. When in silent mode, the iPhone would only vibrate, but I could still hear the ringer in the bluetooth.
    I just bought a new Plantronics Voyager+. Now when it's connected, all sounds are routed to the earpiece - including the taps, etc. The iPhone's speaker doesn't ring at all, unless the bluetooth is disconnected or powered off. I'd really like to be able to hear both, like I was before. This is an iPhone 3G running iOS 4 (latest version, not sure what it is exactly). Haven't updated software/firmware in between bluetooths, just changed the earpiece.

  • I have 1 apple id, 2 5S iPhones with separates numbers and both ring when I get a call on one of the numbers. How do I switch that of ?

    I have 1 Apple ID, 2 5S iPhones (1 private/1 work) with separates numbers and both phones ring when I get a call on one of the numbers. How do I switch that of ?

    I realize that my wife could make her own iTunes account; however, she's been using mine for about 2 years now and this hasn't been an issue.  I guess with the Family Sharing she can have access to all of our music and apps now with her own account. 
    I'll have to see if unchecking our emails resolves this issue.

  • What is a sure way to use FaceTime when cannot use phone call to do it?

    There are situations where one person is in USA, and one person is in Asia, and both iPhone 4 have WiFi, but one of them cannot make or receive phone calls.
    If using iPod touch, then there is a Facetime app to log in and other people using iPhone 4 or iPod touch can try to use that Apple ID to connect to you.
    But what if both are iPhone 4? There is no FaceTime app (unlike on the iPod touch), so what is a sure way to make FaceTime connection? One person has Apple ID of [email protected] but when using the email app, the email is [email protected] Must another account be added for the email app for [email protected] or somehow add the appropriate App ID to that iPhone 4 -- how would that be done? Thanks!
    Message was edited by: winterheat

    When selecting a contact with the Contacts app on the iPhone, the following selections are available below each contact's info.
    Text Message
    FaceTime
    Share Contact
    Add to Favorites
    When wanting a FaceTime call with another iPhone 4 user without making a regular call first, select FaceTime for the contact to initiate a FaceTime call with the contact's iPhone.

Maybe you are looking for