Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!198.186.194.249.MISMATCH!transit3.readnews.com!news-out.readnews.com!news-xxxfer.readnews.com!postnews.google.com!b13g2000prf.googlegroups.com!not-for-mail From: mukesh tiwari Newsgroups: comp.lang.java.programmer Subject: Re: JlayeredPane in netbeans Date: Fri, 1 Apr 2011 23:26:51 -0700 (PDT) Organization: http://groups.google.com Lines: 75 Message-ID: References: NNTP-Posting-Host: 117.194.231.142 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1301725673 23707 127.0.0.1 (2 Apr 2011 06:27:53 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 2 Apr 2011 06:27:53 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: b13g2000prf.googlegroups.com; posting-host=117.194.231.142; posting-account=utVMDgoAAACBclB38JUYjL1LjVN2Gha6 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.43 Safari/532.5,gzip(gfe) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2721 On Apr 2, 3:03=A0am, markspace <-@.> wrote: > On 4/1/2011 12:23 PM, mukesh tiwari wrote: > > > > > > > Hello all, I am trying to put two components Jeditorpane and Jtextarea > > in Jlayeredpane. I am using Netbeans. I added jeditorpane and > > jtextarea in jlayeredpane and two buttons. When i click on button1 > > then it should show message "Hello world doing nice". > > > =A0 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt= ) > > { > > =A0 =A0 =A0// TODO add your handling code here: > > =A0 =A0 =A0jTextArea1.setText(""); > > =A0 =A0 =A0jTextArea1.setOpaque(true); > > =A0 =A0 =A0jLayeredPane1.moveToFront(jEditorPane1); > > =A0 =A0 =A0jEditorPane1.setText("Hello world doing nice"); > > } > > and when click on button2 then it should show message "Hello world not > > doing good". > > > =A0 private void jButton2ActionPerformed(java.awt.event.ActionEvent evt= ) > > { > > =A0 =A0 =A0// TODO add your handling code here: > > =A0 =A0 =A0jEditorPane1.setText(""); > > =A0 =A0 =A0jEditorPane1.setOpaque(true); > > =A0 =A0 =A0jLayeredPane1.moveToFront(jTextArea1); > > =A0 =A0 =A0jTextArea1.setText("Hello world not doing good"); > > } > > I simplified these methods to remove unnecessary calls. =A0The result is > better and the text now displays. =A0However the formatting is still a bi= t > odd, it looks like some of the text is offset slightly from the origin. > =A0 I'm not sure why that is. > > Here are the improved event handlers. > > private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { > =A0 =A0 =A0// TODO add your handling code here: > // =A0 =A0jTextArea1.setText(""); > // =A0 =A0jTextArea1.setOpaque(true); > // =A0 =A0jLayeredPane1.moveToFront(jEditorPane1); > =A0 =A0 =A0jEditorPane1.setText("Hello world doing nice"); > > } > > private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { > =A0 =A0 =A0// TODO add your handling code here: > // =A0 =A0jEditorPane1.setText(""); > // =A0 =A0jEditorPane1.setOpaque(true); > // =A0 =A0jLayeredPane1.moveToFront(jTextArea1); > =A0 =A0 =A0jTextArea1.setText("Hello world not doing good"); > > > > } Hi markspace Thank you for your reply but this is not fulfilling the purpose because texts are deformed in second case. I don't know if i understand the JlayeredPane fully but what in my mind is , i added two components [ jeditorpane and jtextarea ] in jLayeredpane in same Default_Layer and use the function moveTofront and moveToback to move these components in same layer.When jeditorpane will be in front position then it will hide all the contents of jtextarea and vice- versa. Its like dynamically changing the components position in layer but i don't think this is happening. Thanks again for your valuable insights. Regards Mukesh Tiwari