Swing---JTextPane(a boring trouble---looking forward to answer)

In the following program the JLabel inherited can'nt be seen when it inserted into the JTextPane, I wander why?
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
import java.awt.event.*;
public class AdvancedJTextPane extends JFrame
JTextPane jtp;
public AdvancedJTextPane(){
     jtp=new JTextPane();
     this.getContentPane().setLayout(new BorderLayout());
     JScrollPane js = new JScrollPane();
     js.getViewport().add(jtp);
     this.getContentPane().add(js);
     this.pack();
     this.setSize(350, 250);
     this.setVisible(true);
     jtp.insertComponent(new DrawLabel(""));
     this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
public static void main(String[] args) {
new AdvancedJTextPane();
class DrawLabel extends JLabel {
public DrawLabel(String label) {
super(label);
Dimension size = getPreferredSize();
size.width = size.height = Math.max(size.width,
size.height);
setPreferredSize(size);
protected void paintComponent(Graphics g) {
g.setColor(Color.lightGray);
g.drawOval(0, 0, getSize().width-3, getSize().height-3);
super.paintComponent(g);
protected void paintBorder(Graphics g) {
g.setColor(getForeground());
g.drawOval(0, 0, getSize().width-1, getSize().height-1);
}

Here's your culprit:
jtp.insertComponent(new DrawLabel(""));You need to use something other than an empty string (spaces will work):
jtp.insertComponent(new DrawLabel("     "));

Similar Messages

  • Javax.swing.JTextPane - COLOR Problem

    Hi
    I am using javax.swing.JTextPane object to display text recieved from two servers.
    How can I make messages recieved from Server 1 to be in RED and while from Server 2
    to be in Green? i.e. the window should look...
    (red) Server 1 says ta ta
    (green) Server 2 says Hello
    My code looks....
    javax.swing.JTextPane WINDOW;
    String message1 = connection1.getMessage();
    ..........// What code should I put here??? to make this message look RED??
    ..........// Color of previous text should remain as it is...
    WINDOW.setText(WINDOW.getText() + message1);An Example would be highly appreciated.
    Regards
    Fahad

    Hi,
    that is the wrong way - try this method in your JTextPane subclass
    public void appendText(String s,Color col) {
    StyledDocument sd = getStyledDocument();
    SimpleAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setForground(attr,col);
    try { sd.insertString(sd.getLength(),s,attr); }
    catch (BadLocationException e) {}
    } // end of methodand use it in your code like that
    WINDOW.appendText(message1,Color.red);
    hope that helps
    greetings Marsian

  • What games are you looking forward to?

    I might have to give this a go tonight when I get home.
    Just seeing the video took me back to the old Amiga days.

    Hello, I'm really looking forward to Zelda Skyward Sword buy I'm going to wait for a price drop and buy used. Anyway, here's my lists of recently played PS3 Action/Adventure games: Infamous - Loved it, loved it, loved it!  Excellent game! (now playing Infamous 2)5 out of 5 stars Castlevania: Lords of Shadow - Loved it, loved it loved it!  A total deviation from the previous Castlevania storylines but much improved and sets the series up for a bunch of sequels as well.5 out of 5 stars Batman Arkum City - OK but I really liked the first one better and I did not like the abrupt and unexpected ending either.31/2 out of 5 stars Uncharted 3: Drake's Deception - Sort of a letdown because I've waited so long for it. 31/2 out of 5 stars Red Dead Redemption - An OK game with too many side quests. Leader board shows one guy assisting almost 5,000 civilians... I completed the game with less than 15 assists (and the assists really don't get you anything)31/2 out orf 5 stars Prince of Persia (not Forgotten Sands) - Started slow but then I got into it..3 out of 5 stars Silent Hill: Homecoming - Slow, boring and weird overall; however, some parts of the game were really fun!21/2 out of 5 stars The Watchman - Funny, goofy, and easy at the same time. The game was so cheap, I had to try it. 21/2 out of 5 stars  Have fun, norepli

  • I am getting old and looking forward to use I Pad as a Phone if possible through WIFI! I this possible? The screen is to small for me! If possible, with new I Watch taking calls, other uses through I Pad!

    Like I wrote on title, I am getting old and it is not easy to see E-mails, news etc. on a I phone! New I phone will not help me for the size.
    If possible, everything without calls, I would like to use I Pad as direct unit, and for calls through I Pad over WIFI all calls. If a call as Skype, I would like
    to use the I Pad as a monitor. Is this possible?
    I found on a side that there is a product for people for better hearing, which can be put into the ears, using WIFI with I Phone.
    If this product could be used also for I Pad as a Phone for hearing, and the I watch or I Pad as Microphone, it will be great for old Mac users.
    Is this possible with our system know?
    I am using Mac since Classic II! Would like to continue with the newest items with the possibility for old person with bad Eyes or Ears.
    Looking forward for a kind answer
    with regards
    Christian an old Mac user!

    Definitely No

  • How can I use a SCH-LC11 device in CHINA which bought from ebay. I am not Verizon customer but I prefer to using your 4G LTE Router . How can I get the unlock code? The device may have a bad ESN but I only use it in CHINA. Kindly looking forward your repl

    How can I use a SCH-LC11 device in CHINA which bought from ebay. I am not Verizon customer but I prefer to using your 4G LTE Router . How can I get the unlock code? The device may have a bad ESN but I only use it in CHINA. Kindly looking forward your reply. Thanks!

    It's good to read Antoniad's post.  It reassures me that I can use my new iPad as an international communication device which is the reason I purchased the thing.  However, I called Verizon today (my provider of cellular data) who told me that I can't just pop in a SIM card as you suggested.  He also said that he was from the "Pre-Pay" division of Verizon and he was certain that I couldn't do what I planned to do.  I was extremely disappointed as I had called Apple prior to buying the iPad and I read the algorhythm on the website for choosing an iPad before purchasing.  Those sources were quite specific and the information seemed clear.  I would be able to use my iPad to communicate through cellular connections while traveling on the road, literally, abroad.  I was told that I could pop in a data card wherever I was, just as you indicated in your message above, and voila I was good to go.  The Verizon rep definitively rained on that parade, but said that I might be able to do this if I have a "Post-Pay" account, a different area of Verizon.  I haven't had the chance to talk to this division yet, so I looked to Apple's Support for answers.  Maybe I will find out that I can use my iPad as an international communication device while traveling on the road afterall, however, it appears I may need a different type of account (Post-Pay), something I was never warned about. Can I switch to this kind of account?  I don't know.  I have to find out.  If you have any information about this issue, it would be good to share since I strongly suspect there are others who bought the iPad for the same purpose that I have.

  • Next upcoming expert day Looking forward to the next Expert Day any estimated date of the event

    next upcoming expert day Looking forward to the next Expert Day any estimated date of the event
    it‘s great to be able to post in the forum and obtain help
    my gratitude and appreciation is certainly provided; may I inquire
    as to any estimate Is there another
    Upcoming Expert Day Event
    Since the designated Expert Day is stated as the event has now concluded for
    Expert Day in English (Consumer) - April 18-19, 2012
    Hopefully before September
    Thanks  
    Respectfully

    However if it is Sep I’ll gladly wait and that is still excellent the designated Expert Day’s are great
    my gratitude and appreciation is certainly provided..

  • I am having trouble looking at video podcasts on my ipod touch. they are all greyed out. I have tried removing them and resyncing. this did not work. any ides?

    I am having trouble looking at video podcasts on my ipod touch. they are all greyed out. I have tried removing them and resyncing. this did not work. any ideas?

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Unsync all media and resync
    - Reset all settings
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up           
    - Restore to factory settings/new iOS device.

  • BPM and ALEAUD Response - Looking forward for help

    Hi ,
    I tried the using the concepts from the blog (/people/mitesh.parekh/blog/2008/12/01/receiving-aleaud-as-acknowledgment-in-ccbpm)where i have the Message ID which entered into BPM
    but not the message Id which triggered the IDoc send . I think i m missing some small detail where i need to capture the send step MSG Id
    i'm aware that its not possible to get the Msg id in BPM . How is that ABAP Mapping in the above blog captures the message id ?
    TRY.
    l_msgid_ref = param->get(
    IF_MAPPING_PARAM=>MESSAGE_ID ).
    catch CX_SY_REF_IS_INITIAL into oref.
    endtry.
    Alternatively one more thread has some info
    if someone can let me know where you can get this SourceDocNum would be great in this RFC Look up . in the thread Re: Idoc Acknowledgements and BPM.
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:RFC_READ_TABLE xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><DELIMITER/><NO_DATA/><QUERY_TABLE>IDXRCVPOR</QUERY_TABLE><ROWCOUNT/><ROWSKIPS/><DATA><item><WA/></item></DATA><FIELDS><item><FIELDNAME>SNDLAD</FIELDNAME><OFFSET/><LENGTH/><TYPE/><FIELDTEXT/></item></FIELDS><OPTIONS><item><TEXT>IDOCNUMBER EQ &apos;"
    + SourceDocNum
    + "&apos;</TEXT></item></OPTIONS></ns0:RFC_READ_TABLE>";
    Since i do not have the Message ID it just creates the below payload from my mapping
    This is the request being sent out using the ABAP Mapping as the Messgae ID is null .
    <?xml version="1.0" ?>
    - <ns0:ZALEAUDIT4XI xmlns:ns0="urn:sap-com:document:sap:rfc:functions">
    <S_DOCNUM>0000000000000000</S_DOCNUM>
    <S_MESTYP />
    <S_SNDSYS />
    <S_UPDDAT>00000000</S_UPDDAT>
    </ns0:ZALEAUDIT4XI>
    Looking forward for Help .
    Edited by: Priyalakshmi Bhuvanendran on Aug 8, 2009 2:28 AM

    Can someone help one the ALEAUD Response - IDOC Capturing Problem . I would appreciate your help . Thanks

  • New ACR RC released... Looking forward to seeing new features in LR

    Adobe just announced ACR 8.5 RC: Camera Raw 8.5 RC and DNG Converter 8.5 RC Now Available
    Some very useful new features are included along with the usual support for new camera models, such as the ability to modify gradients with a new brush tool and being able to display a mask overlay for gradients... Nice! Looking forward to seeing LR 5.5 (or perhaps even 6?). No news on a release candidate for LR; perhaps there won't be one as per 5.4.
    M

    I note this paragraph heading in the notes for the release's new features:
    "Camera Raw 8.5 introduces the following new features for Photoshop CC customers"
    Could this mean that although the Beta update is stated to be for both CS6 and CC that the new features (outside the camera additions) would not be implemented with a CS6 install?

  • HT4009 Purchasing gems on the clash of clans game.  It tells me to contact customer support   This happens a lot  and support takes the block off my account  and everything works fine. Looking forward to y'all resolving my issue   Ryan Hinger

    Purchasing gems on the clash of clans game.  It tells me to contact customer support   This happens a lot  and support takes the block off my account  and everything works fine. Looking forward to y'all resolving my issue   Ryan Hinger

    If you are getting a message to contact iTunes support then only they can help you (these are user-to-user forums, we won't know why you are getting the message) : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page

  • Looking forward to download Adobe After Effects CC from Creative Cloud Desktop Application. But why most of the apps appear to be in CS6?

    I installed the new copy of Adobe Creative Cloud Desktop Application, and looking forward to download Adobe After Effects CC. But why most of the apps appear to be in CS6? - Including AE. Only few appears to be CC.
    Thank you.

    A chat session where an agent may remotely look inside your computer may help
    Creative Cloud chat support (all Creative Cloud customer service issues)
    http://helpx.adobe.com/x-productkb/global/service-ccm.html

  • Looking forward to next rows

    hello everybody, i have a particular scenario that i want to solve with a query
    here is some sample data. note dates are not sorted in table. i put it here for readabaility reason
    WITH table1 AS
      SELECT 111 cid,  To_Date('1/31/2010','mm/dd/yyyy') dt, 'line' line,  345 pid   FROM dual UNION ALL
      SELECT 111 cid,  To_Date('2/1/2010','mm/dd/yyyy') dt,  'line2' line, 346 pid  FROM dual UNION all
      SELECT 111 cid,  To_Date('2/2/2010','mm/dd/yyyy') dt,  'line3' line, 347 pid  FROM dual UNION ALL
      SELECT 111 cid,  To_Date('2/3/2010','mm/dd/yyyy') dt,  'line4' line, 348 pid  FROM dual UNION ALL
      SELECT 111 cid,  To_Date('2/4/2010','mm/dd/yyyy') dt,   null   line, 349 pid FROM dual UNION ALL
      SELECT 111 cid,  To_Date('2/5/2010','mm/dd/yyyy') dt,  'line6' line, 340 pid  FROM dual UNION all
      SELECT 999 cid,  To_Date('2/28/2010','mm/dd/yyyy') dt, 'line7' line, 341 pid  FROM dual UNION ALL
      SELECT 999 cid,  To_Date('3/1/2010','mm/dd/yyyy') dt,  'line8' line, 342 pid  FROM dual UNION ALL
      SELECT 999 cid,  To_Date('3/2/2010','mm/dd/yyyy') dt,  'line9' line, 343 pid  FROM dual UNION ALL
      SELECT 999 cid,  To_Date('3/3/2010','mm/dd/yyyy') dt,  'line0' line, 344 pid FROM dual UNION ALL
      SELECT 999 cid,  To_Date('3/4/2010','mm/dd/yyyy') dt,  'line3' line, 345 pid  FROM dual UNION ALL
      SELECT 999 cid,  To_Date('3/5/2010','mm/dd/yyyy') dt,  'line2' line, 345 pid  FROM dual UNION ALL
      SELECT 444 cid,  To_Date('3/31/2010','mm/dd/yyyy') dt,  'line111' line, 346 pid  FROM dual UNION ALL
      SELECT 444 cid,  To_Date('4/1/2010','mm/dd/yyyy') dt,  'line112' line, 347 pid  FROM dual
    SELECT 555 cid,  To_Date('4/2/2010','mm/dd/yyyy') dt,  'line12' line, 247 pid  FROM duali want the following output.
    CID     DT            LINE     PID
    111     1/31/2010     null     345   --copy line column value from 4th day
    111     2/1/2010     line2     346
    111     2/2/2010     line3     347
    111     2/3/2010     line4     348
    111     2/4/2010     null     349
    111     2/5/2010     line6     340
    999     2/28/2010     line3     341    --copy line column value from 4th day
    999     3/1/2010     line8     342
    999     3/2/2010     line9     343
    999     3/3/2010     line0     344
    999     3/4/2010     line3     345
    999     3/5/2010     line2     345
    444     3/31/2010     line111     346
    444     4/1/2010     line112     347
    555     4/2/2010     line12     247here is how i get to this output. i want to get all month end dates for a particular id. then i want to look forward and get the values from the 4th day following
    the month end date. so for 1/31/2010, the 4th day is 2/4/2010. then i want to get the value from line column in the 4th row and copy that in the current row,
    in this case 1/31/2010 line column becomes null since 2/4/2010 has null value
    in the case of 444, 3/31 is month end but there is no 4th day to move forward, in this case just display the data.
    in the case of 555, there is no month end date so just display the rows for 555 and no need to move forward
    i try using last value analytic function but this function will skips row that are null which proceduce invalid result.
    if the 4th row we trying to copy from has null values then i want those null values as display in output above.
    also i am using oracle 9i 9.2 version and ignore null is not supported.
    can someone help me write a query that give above output? thanks alot

    Hi,
    You're right: repeating basically the same CASE expression 8 (or is it 2 + 8 = 10) times is not a very good idea.
    On each row of output, you want 8 columns from some row of the table: possibly the same row, possibly the 4th subsequent row. That sounds like a self-join. Think of joining a "base" row (containing the dt) to a "detail" row of the same table. When dt is the last day of the month, and there are at least 4 later rows, then the detail row will be the 4th later row. In all other cases, the detail row will be the same as the base row.
    How can we find the detail row for a given base row? The same way we found the appropriate line value before; only instead of getting tyhe value of line, we need something that will uniquely identify the detail row. If your table has a one-column primary key, you could return that, and use it in the join condition. In the query below, I assume that the combination (cid, dt) uniquely identifies each row.
    WITH     got_detail_dt     AS
         SELECT     cid, dt, line, pid
         ,     CASE
                  WHEN  dt = LAST_DAY (dt)
                  THEN  LEAD ( dt
                              , 4
                          , dt
                          ) OVER ( PARTITION BY  cid
                                          ORDER BY      dt
                  ELSE  dt
              END          AS detail_dt
         FROM    table1
    SELECT       b.cid
    ,       b.dt
    ,       d.line
    ,       d.pid
    FROM       got_detail_dt       b
    JOIN       got_detail_dt       d     ON     d.cid     = b.cid
                            AND      d.dt     = b.detail_dt
    ORDER BY  cid
    ,            dt
    ;Adding more columns to the report is now just a matter of adding more columns to both SELECT clauses. (Depending on what output you will accept, you might make that just the SELECT clause of the sub-query, and use d.* in the main SELECT clause.) At any rate, the addition columns will just be simple column names, not complicated CASE expressions.

  • How can I fix error code 131:4? Licensing for this product stopped working. I have windows vista home edition and CS4 Design Premium. I downloaded licensing zip file for windows but I can't seem to get it to launch. Look forward to help from anyone

    How can I fix error code 131:4? Licensing for this product stopped working. I have windows vista home edition and CS4 Design Premium. I downloaded licensing zip file for windows but I can't seem to get it to launch. Look forward to help from anyone

    Steve,
    I appreciate your answer.  While it might work, I'm a bit hesitant to remove the other programs as a possible solution since they are all currently working.
    With Acrobat 9 Pro failing with the OS 10.7 upgrade, I'm hoping that there is a less severe solution.
    Since the trigger appears to be 10.7 and may have something to do with the discontinued support of Rosetta, I could be spending a few hours working on a reinstall without a change.  Yes, it might work.  The "might" is the part that makes me hesitate.
    Is anyone else out there on OS 10.7 and running Acrobat 9 Pro?  Any issues with anyone else?
    Thanks Steve.  I do appreciate your offering a solution.  I may end up trying it if nothing else comes together.
    Mark

  • Working with objects \ beans inside a Swing.JTextPane

    javax.swing.text.html
    specifically
    javax.swing.text.html.ObjectVeiw Class
    Is it possible to set the size of on object, which is an instance of type Component
    Example
    Although these beans work fine, I can not set the width and height properties while they are embedded in the JTextPane. Attempts to give initial values of height & width within the object tag also fail.
    <HTML><BODY bgcolor="#00A0A0">
    Test This <P>page
    <p>This next object is a Simple Bean that extends Canvas
    <object classid="SimpleBean" width="150" height="150">
    <param name="width" value="10">               <! Does not work in JTextPane>
    <param name="height" value="200">     
    <param name="underText" value="Text for the Canvas">
    </object>
    <p>This next object is a JTextPane
    <object classid="javax.swing.JTextPane">
    <param name="text" value="Embeded JTextPane">
    <param name="size" value"150,150">
    </object>
    </BODY></HTML>
    Also could you show me more HTML examples of use

    if there is
    a LayoutManager in use, it will overwrite the size you
    attempt to set. Only if the layout manager is null
    will doing a setSize() work properly.true

  • Fiscal date DD-MON and year end looking forward

    Trying to figure out the best way to look forward to the new year and back to the old year when comparing sysdate to a table column fiscal that is formatted DD-MON. The process works perfectly during the year, since is uses current year when comparing data. But at the end of the year, we do not see anything past 12/31 or before 1/1 in a new year. Any ideas? I was thinking of declaring a couple of values and based on sysdate Sep, Oct, Nov, Dec to add 1 year to Fiscal months Jan, Feb, Mar, Apr so they appear as the next year and vice versa for the first months of a new year, subtract one year from the fiscals to indicate previous year. Has anyone worked on something like this in the past?

    Look in to this, i am substituting values for the year, so you will get idea.
    The fisccal date you have is month end all the time or it is all the dates?
    SQL> ed
    Wrote file afiedt.buf
      1  WITH T AS
      2    (SELECT '01-DEC' dt  FROM dual
      3     UNION ALL
      4    SELECT  '05-JUL'   FROM dual
      5     UNION ALL
      6    SELECT  '10-JAN'     FROM dual
      7     UNION ALL
      8    SELECT  '30-MAR'    FROM dual
      9     )
    10  --ens of data
    11  SELECT TO_DATE(dt||'-'||&y,'DD-MON-YYYY') fisc_date,
    12         TO_DATE(dt||'-'||&y,'DD-MON-YYYY')+180 NEW_DATE,
    13      ADD_MONTHS(TO_DATE(dt||'-'||&y,'DD-MON-YYYY'),6)
    14* FROM T
    SQL> /
    Enter value for y: 2008
    old  11: SELECT TO_DATE(dt||'-'||&y,'DD-MON-YYYY') fisc_date,
    new  11: SELECT TO_DATE(dt||'-'||2008,'DD-MON-YYYY') fisc_date,
    Enter value for y: 2008
    old  12:        TO_DATE(dt||'-'||&y,'DD-MON-YYYY')+180 NEW_DATE,
    new  12:        TO_DATE(dt||'-'||2008,'DD-MON-YYYY')+180 NEW_DATE,
    Enter value for y: 2008
    old  13:     ADD_MONTHS(TO_DATE(dt||'-'||&y,'DD-MON-YYYY'),6)
    new  13:     ADD_MONTHS(TO_DATE(dt||'-'||2008,'DD-MON-YYYY'),6)
    FISC_DATE NEW_DATE  ADD_MONTH
    01-DEC-08 30-MAY-09 01-JUN-09
    05-JUL-08 01-JAN-09 05-JAN-09
    10-JAN-08 08-JUL-08 10-JUL-08
    30-MAR-08 26-SEP-08 30-SEP-08

Maybe you are looking for

  • Other problems with loading Captivate files into Flash AS3 project

    I have a Captivate file done with Captivate 3, published to Flash player 9 that is being loaded into Flash AS3. The captivate is a simple recording of some mouse clicks in a browser. I am displaying the playbar along the bottom, and its buttons all w

  • In OS 10.6.8 how do I turn on printer sharing from terminal?

    I have a Mac Pro and I need to share a printer, however every time I go to sharing and try to select printer sharing preferences crashes. Is there a way to turn on printer sharing from termina?

  • Mac slow down

    My late 2009 duel core Imac after upgrading to Lion has become slow and sluggish. The hard drive works over time and i really am fearful that it will cause it to prematurely fail. I have search over these forums and see that this has been addressed m

  • Unexpected ends of rule "Check Connection" (id= CIR 01200)

    Hi, I'm new with Business Objects and I'm facing lots of error messages into some Universes .unx built in our BO system that I don't know how to solve them. For example this one, in a .unx universe, when I check integrity in the .dfx part, I receive

  • Com.mysql.jdbc.MysqlDataTruncation: Data truncation

    Hi, i have these error com.mysql.jdbc.MysqlDataTruncation: Data truncation: Out of range value adjusted for column 'longtitude' at row 1 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2932) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java: