Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: JlayeredPane in netbeans Date: Fri, 01 Apr 2011 15:03:28 -0700 Organization: A noiseless patient Spider Lines: 50 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 1 Apr 2011 22:03:34 +0000 (UTC) Injection-Info: mx01.eternal-september.org; posting-host="sJe4u9VRc4chc5yBzxahWw"; logging-data="8482"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/EMUZ5GAVLMyoi1QlXzszYuZElPoQDXNg=" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 In-Reply-To: Cancel-Lock: sha1:mJKaInlCCFhJQ2zSUQzKl5SS1v4= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2699 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". > > private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) > { > // TODO add your handling code here: > jTextArea1.setText(""); > jTextArea1.setOpaque(true); > jLayeredPane1.moveToFront(jEditorPane1); > jEditorPane1.setText("Hello world doing nice"); > } > and when click on button2 then it should show message "Hello world not > doing good". > > private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) > { > // TODO add your handling code here: > jEditorPane1.setText(""); > jEditorPane1.setOpaque(true); > jLayeredPane1.moveToFront(jTextArea1); > jTextArea1.setText("Hello world not doing good"); > } I simplified these methods to remove unnecessary calls. The result is better and the text now displays. However the formatting is still a bit odd, it looks like some of the text is offset slightly from the origin. I'm not sure why that is. Here are the improved event handlers. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: // jTextArea1.setText(""); // jTextArea1.setOpaque(true); // jLayeredPane1.moveToFront(jEditorPane1); jEditorPane1.setText("Hello world doing nice"); } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: // jEditorPane1.setText(""); // jEditorPane1.setOpaque(true); // jLayeredPane1.moveToFront(jTextArea1); jTextArea1.setText("Hello world not doing good"); }