JTextPane & JTextArea Control Handling

Hello...
I have created chat application. At client side i take applet in that The chat is dispalyed in JTextPane in different colors. Also i have taken JTextArea & button to send message to other end. But the problem is that when chat message is receives from remote end it is shown in JTextPane & if at same time user is typing message in JTextArea then focus is lost from JTextArea to JTextPane. This action prevents user from writing he has to set focus on JTextArea again & again.
The code is
StyledDocument doc = (StyledDocument)jtp.getDocument();                 
               doc.insertString(doc.getLength(), "\n"+oprName+": "+matter, style2); Help plz.....

This is a bit of a guess but you may well find that my suggestion in this thread (apply it to your display component rather than the input component) fixes it,
http://forum.java.sun.com/thread.jspa?threadID=5114287
If not then you should be able to follow the source code from setText() to see what's grabbing the focus.

Similar Messages

  • Redirecting System.out() output to a JTextArea control

    I want to be able to redirect System.out() and System.err() messages to a JTextArea control:
    I know how to redirect output to a file as follows:
    FileOutputStream fos =
    new FileOutputStream(filename, true);
    PrintStream ps = new PrintStream(fos, true);
    System.setOut(ps);
    System.setErr(ps);
    How can I set it up so that I can recognise when messages have been to System.out() with a view to displaying the message within the JTextArea?
    I guess I need to set it up so that the JTextArea control acts as an Observer. The bit I'm having difficulty with is figuring out how I can automatically determine when information has been written to System.out()?
    Hopefully I'm explaining my issue in enough detail and clarity.
    thanks
    - Garry

    I would suggest you set up a separate thread to monitor System.out. Use a PipedOutputStream and redirect System.out to that, then connect that to a PipedInputStream that your other thread is continually waiting to read. Each time that thread reads a line, it should append the line to the JTextArea, using SwingUtilities.invokeLater.
    This is just a rough outline of something that might work. Hope it helps.

  • Is point in custom object with only one control handle possible?

    I notice with a rounded rectangle if you make it editable and click on any of the points, they all seem to have only one "control handle". Normally there are always two. Is there really only one control handle on those points, or does it just look that way? Assuming there is indeed only one control handle, how can I do that too?

    Chris Miner wrote:
    I notice with a rounded rectangle if you make it editable and click on any of the points, they all seem to have only one "control handle". Normally there are always two. Is there really only one control handle on those points, or does it just look that way?
    Hi Chris,
    Yes, there really is only one control handle for these points. And a look at the 'ordinary' rectangle shows that the control points at its vertices have zero control handles.
    The rectangles appear to be set to retain the property of the rounded corner attaching to a line segment (for the rounded rectangle) or the vertex being formed by the intersection of two lines (for the 'ordinary' rectangle).
    "Normal" control points (your term) treat the point at which they are inserted as a point on a curve, even it that curve has infinite radius (and appears as a line segment), and provide for revision of the curve on both sides of the control.
    If you insert one of these (option-click) anywhere on the shape, it will appear as an unfilled red circle, and will have two control handles.
    Assuming there is indeed only one control handle, how can I do that too?
    For a start, you could explain what you mean by "do that too."
    Regards,
    Barry

  • CS6 Lighting Effects-Missing Control Handles / Crashing

    I have read several other threads on this issue where the control overlays are missing when you go to Filter>Render>Lighting Effects. The "answer" from Adobe always seems to be, "updated your video card drivers."
    I have a ATI Mobility Radeon™ HD 560v for my Dell laptop running Windows 7 64bit. I have checked both through Dell and the ATI page and I have the latest drivers but Lighting Effects don't work properly. So now what?
    I tried messing with the Preferences for Performance based on other posts. No luck. When I go to View>Extras>Show All I do then see the controls, however, the program freezes then crashes every time.
    So is there a fix for this or do I have to go back to CS4 to do all my lighting effects?
    Thanks.

    Chris,
    99% SOLVED! I think the problem here is that Photoshop users don't know the tech speak surrounding driver technology.
    For instance when you started talking about AMD I was thinking, "I have an ATI driver, who is AMD?"
    Also, quite frankly the AMD/ATI site is a very poor unser experience. I searched for my Dell Studio 1747 Laptop driver (ATI Mobility Radeon™ HD 560v) several times and it found no drivers to update even though there is a whole page dedicated to that processor.
    I never did find what you called a "driver cleaner" on the AMD site, however I stumbled (yes, stumbled after looking at tons of pages on AMD) on this AMD Driver Autodetect. I installed that and it recommended I replace my driver with AtI Mobility Radeon HD 4650. The process went smooth other than everything on my screen getting tiny for a bit. After the forced restart everything looked right.
    I opened a Photoshop doc and tried Filter>Lighting Effects and still NO CONTROLS / HANDLES, however this time when I went to View>Extras>View All the handles showed like before BUT PHOTOSHOP NO LONGER CRASHES. I can now manipulate those controls/handles and use lighting effects.
    I know this is not all of Adobe responsiblity, but I'm writing this post hoping anyone wlse who is frustrated will taked your advice, go to the AMD Driver Autodetect link and get it sorted out.
    Thanks.

  • Path with anchor points and bezier control handles

    I have a text, not converted to outline. Live text.
    I am using IllCS4.
    That is cool thing about hovering the cursor above the text and see hidden path and anchor points only when you hovering exactly above them. But I want them be visible permannently, while I am applying some envelop distort  changes. Then I want to turn visibility off. And how to get permanent visiblity of bazier control handles at  the same time?
    I am lost.
    Tx

    Yes, thank you,
    that is great thing, but when I use it, I see outlines (like a wireframe) of image  only.
    Is there any way to see still image as it is and switch on visibility of object' path with all control points?

  • Why are the gradient control handles invisible in isolation mode?

    Whenever I have an object grouped, and double click to edit it, I can't get the gradient control handles to show up inside of it.
    How can I get them to show up and why did they disappear in the first place?

    Are you referring to the control handles in the gradient panel (A) or on the object (B) itself?
    A)
    B)

  • How to manually enter delta/angle for control handles?

    I have a smooth point of a path with two control handles.  When I use the white arrow to select a handle, the Info panel shows the X, Y position of the point as well as the D (delta) and angle of the control handle relative to that point.  I can move the handle around with my mouse pointer, but if I have two independent handles, I may want to manually enter the delta and angle.  This would allow me to work more quickly.  Is this possible?

    I would think that a repetitive need to numerically position anchorPoint handles would not be in the same location. Actions are just dumb recordings of steps. They have no way of, for example, drawing lines of a given length/angle at the locations of multiple selected anchorPoints. That kind of functionality would be germane to scripting, not Actions (macros). And a script dedicated to this purpose would not have to draw temporary lines.
    If the intent is to effectively "copy" handles from one anchorPoint and "paste" them to multiple others, I already have a pair of scripts for that. But that doesn't sound like what is being described.
    JET

  • Control handles or points and warping text

    The transform controls in Photoshop CS6 disappear as soon as I click on the warp mode icon, preventing me from manually warping the layer on which I am working. Oh sure, I can click on Show Transform Controls and, voila, there they are. But as soon as I click on the icon that switches me between warp and free transform, the handles disappear (no mesh either) and without them there is no way to manually warp text or images. Because this used to work perfectly in CS5, I am just a tad frustrated. None of the prebuilt warp modes involve perspective (although I understand this option is maybe, perhaps, it's possible, coming at some point in the future) I can't even get the look I'm after with any prebuilt mode.
    3D doesn't offer a simple perspective tool either. Yes, it does a lot, but not what I want.
    So, why do the handles disappear and how can I get them to stick when I need them?
    And, yes, I do have View > Extras active. Or at least the option is checked as active.
    Thank you for any help.

    PECourtejoie, That was a lot of text! I did not include most of it, but I did include anything related to the video card. I hope I included what you need. If not, I can copy the whole shebang. Thank you for all your help.
    Adobe Photoshop Version: 13.1.2 (13.1.2 20130105.r.224 2013/01/05:23:00:00) x64
    Operating System: Windows 8 64-bit
    Version: 6.2
    System architecture: Intel CPU Family:6, Model:10, Stepping:7 with MMX, SSE Integer, SSE FP, SSE2, SSE3, SSE4.1, SSE4.2
    Physical processor count: 4
    Processor speed: 3293 MHz
    Built-in memory: 8045 MB
    Free memory: 4931 MB
    Memory available to Photoshop: 7046 MB
    Memory used by Photoshop: 60 %
    Image tile size: 1024K
    Image cache levels: 4
    The GPU Sniffer crashed on 2/6/2013 at 3:19:27 PM
    OpenGL Drawing: Enabled.
    OpenGL Drawing Mode: Advanced
    OpenGL Allow Normal Mode: True.
    OpenGL Allow Advanced Mode: True.
    OpenGL Allow Old GPUs: Not Detected.
    OpenCL Version: 1.1 CUDA 4.2.1
    OpenGL Version: 3.0
    Video Rect Texture Size: 16384
    OpenGL Memory: 1024 MB
    Video Card Vendor: NVIDIA Corporation
    Video Card Renderer: GeForce GTX 650 Ti/PCIe/SSE2
    Display: 2
    Display Bounds: top=-30, left=1680, bottom=1020, right=3360
    Display: 1
    Display Bounds: top=0, left=0, bottom=1050, right=1680
    Video Card Number: 2
    Video Card: NVIDIA GeForce GTX 650 Ti
    Driver Version: 9.18.13.1106
    Driver Date: 20130118000000.000000-000
    Video Card Driver: nvd3dumx.dll,nvwgf2umx.dll,nvwgf2umx.dll,nvd3dum,nvwgf2um,nvwgf2um
    Video Mode: 1680 x 1050 x 4294967296 colors
    Video Card Caption: NVIDIA GeForce GTX 650 Ti
    Video Card Memory: 1024 MB
    Video Card Number: 1
    Video Card: Intel(R) HD Graphics 3000
    Driver Version: 9.17.10.2932
    Driver Date: 20121212000000.000000-000
    Video Card Driver: igdumd64.dll,igd10umd64.dll,igd10umd64.dll,igdumd32,igd10umd32,igd10umd32
    Video Mode:
    Video Card Caption: Intel(R) HD Graphics 3000
    Video Card Memory: 2172 MB
    Serial number: 90970570205633490069
    Application folder: C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\
    Temporary file path: C:\Users\Sheryl\AppData\Local\Temp\
    Photoshop scratch has async I/O enabled
    Scratch volume(s):
      C:\, 1.82T, 1.74T free
    Required Plug-ins folder: C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\Required\
    Primary Plug-ins folder: C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\Plug-ins\
    Additional Plug-ins folder: not set

  • Regarding table control handling in BDC

    Hi,
    how to Handle table control in BDC ,how to handle resolution of table control in BDC?
    Pls send urgently

    Hi,
    chk this excellent link.
    http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
    Regards
    Anver
    if helped pls mark points

  • Table control Handling

    hi all,
    Can any one send material related to table control...
    points will be rewarded......
    Regards,
    Bhagya
    [email protected]

    hi Bhagya,
        There are many documents available for Table controls in SDN , please do a good  search and you will get it . Else see the simple code provided below for assistance .
    Creation of table controls in mpools
    Here you go with the  complete steps  for creating module pool programs  using table control:
    open se51, choose the icon like a table for table control . drag it and then place it in your screen . click on F6 and you will get a screen where youi need to provide the table name / field name that ( fields ) you are going to use in the screen and table control. after giving the ztable name click on get it from dictionary . you will get the list of available fields in a table. next choose the fields you wish to place in the table control , and if you want to place all fields in your table control then select every fields . after this you will get a structure which you should drag place inside the table control area .
    double click on the table control , set the proper attributes, tickmark the horizontal and vertical scroll bars to appear in your TC in the screen . save , check and activate ..
    following are the sample code you should follow to display datas in your table control ..
    write the following code in the flow logic of the screen ............
    process before output.
    module tc_01_init.
    loop at g_tc_01_itab
    into g_tc_01_wa
    with control tc_01
    cursor tc_01-current_line.
    module tc_01_move.
    module tc_01_get_lines.
    endloop.
    module status_0001.
    process after input.
    loop at g_tc_01_itab.
    chain.
    field sflight-carrid.
    field sflight-connid.
    field sflight-fldate.
    module tc_01_modify on chain-request.
    endchain.
    endloop.
    module tc_01_user_command.
    Write the following code in your Zmodulepool program !!
    program z_tst_mpool_tc_01.
    data: begin of l_tab_sflight occurs 10,
    carrid like sflight-carrid,
    connid like sflight-connid,
    fldate like sflight-fldate,
    end of l_tab_sflight.
    tables: sflight.
    types: begin of t_tc_01,
    carrid like sflight-carrid,
    connid like sflight-connid,
    fldate like sflight-fldate,
    end of t_tc_01.
    data: g_tc_01_itab type t_tc_01 occurs 0,
    g_tc_01_wa type t_tc_01. "work area
    data: g_tc_01_copied. "copy flag
    controls: tc_01 type tableview using screen 0001.
    data: g_tc_01_lines like sy-loopc.
    data: ok_code like sy-ucomm.
    include z_tst_mpool_tc_01_pbo .
    include z_tst_mpool_tc_01_pai .
    include z_tst_mpool_tc_01_incl01 .
    include z_tst_mpool_tc_01_status_0001.
    include Z_TST_MPOOL_TC_01_PBO .
    inside include
    module tc_01_init output.
    if g_tc_01_copied is initial.
    select * from sflight
    into corresponding fields
    of table g_tc_01_itab.
    g_tc_01_copied = 'X'.
    refresh control 'TC_01' from screen '0001'.
    endif.
    endmodule.
    module tc_01_move output.
    move-corresponding g_tc_01_wa to sflight.
    endmodule.
    module tc_01_get_lines output.
    g_tc_01_lines = sy-loopc.
    endmodule.
    Else check for the sample programs in Txn ABAPDOCU
    or search for prgrams in SE38 , you will get many more .
    PS: Anytime you need a document do not post it as a thread until you dont get it in the SDN forum .
    Regards,
    Ranjita

  • Control handles do not remain showing

    I have show handles for multiple selected anchor points turned on, and all of the handles are showing, but as soon as I drag out a guideline the handles disappear. I was watching a tutorial video where the handles remained showing as the guidelines were dragged and snapped to points. Is this a difference between Windows and Mac versions of Illustrator?

    Lock guides in the View menu. Guides are objects, so remain selected after they are created unless locked.

  • JTextArea mouse handling related question

    Hey All,
    I've been beating my head off a wall for this for too long, I'm one bug away from shipping here, and this bug has been there through the whole development cycle.
    I have a JTextArea which is to be a member of a class which fits into a hierarchy of manipulatives (objects you can place on screen and manipulate). Default properties of these manipulatives that must not change are that they can be grouped (working fine), clicked on with mouse to manipulate (working fine), and clicked on with mouse to move around the screen (herein lies the problem).
    I currently have a mouselistener listening to the "drawing area" (a JComponent that all manipulatives get placed onto to be interacted with). When a mouselistener is added to the JTextArea giving the drawing area's listener as the cather of events, the e.getPoint method returns varied results. Sometimes it is the point relative to the origin of the drawing area, sometimes it is the point relative to the origin of the JTextArea (it's upper left corner). I suspect I have errors with Listener overloading, but I could be completely offbase as well.
    What I'm intersted in, is having it setup so that e.getPoint() returns the JTextArea's location relative to my drawing area so that I can move it around the drawing area easily enough. I've tried treating the JTextArea specially, checking to see if it is the source, but e.getSource returns an anonymous instance of the JTextArea so I can't actually get that JTextArea's location on the screen.
    If anyone can offer any suggestions, I would really appreciate it. If I've worded this so that it is too confusing to understand, feel free to contact me directly and we can arrange something.

    But event.getSource is returning an anonymous instance of a JTextArea. And I want to go to a JComponent I have implemented coordinate space.
    I haven't had a chance to completely attempt this. I have to restructure some other aspects of that code yet. But I thought I'd ask if the anonymous class returned by event.getSource would cause a problem

  • SQLOD32W do not release its control handler.

    Hello,
    I have a windows service, this windows service use MAXDB database and release the environment. When I shutdown the computer I have a GPF.
    The address is <SQLOD32W BASE ADDRESS> + 0x86510.
    I think this is a ControlHandler installed by SQLOD32W. This handler is not release when DLL_PROCESS_DETACH is called.
    I can workaround the issue by installing my own ControlHandler, but do you know this is a known bug ?
    Yann.

    Hello Yann,
    there are some restrictions with the ODBC driver including 7.6, which probably will not be changed in the future.
    Starting with SAP MaxDB 7.7 a new ODBC driver is available which was completely new written (basing on SQLDBC, our main low level interface). At the momen 7.7 is not available as download edition, but I can provide you with the [new ODBC driver|https://sapmats-de.sap-ag.de/download/download.cgi?id=NFPSS6QZGWYKYJIYNFOTBO71ED9H0RWZG1OM4VUVOSOOO8E9ES].
    Please use it as evaluation copy of the current MaxDB ODBC driver. If there are problems, please let me know.
    The archive contains the ASCII and Unicode version and the trace tool of the new driver. For registration please use the odbcreg-tool of 7.6
      odbcreg -i newMaxDB -p c:\MaxDB_ODBC77 -d sdbodbc.dll
    Regards  Thomas

  • JTextPane editor large file & performance

    Hi,
    I'm using a JTextPane to edit XML files. A jflex parser split xml file in tokens and using a custom document (extends
    DefaultStyledDocument) i color syntax:
    doc.setCharacterAttributes(token.getCharBegin() + change,
         token.getCharEnd()     - token.getCharBegin(),
            Token_Styles_Define.getStyle(token.getDescription()),  true);My problem is to load and edit large xml file, for exemple a 400kb xml file takes 30 seconds and for 700kb 1Mb i get java heap space.
    I google it and i found :
    " Define a limit that JTextPane/JEditorPane can handle well (like 500KB or 1MB). You'll only need to load a chunk of the file into the control with this size.
    Start by loading the 1st partition of the file.
    Then you need to interact with the scroll container and see if it has reached the end/beginning of the current chunk of the file. If so, show a nice waiting cursor and load the previous/next chunk to memory and into the text control.
    The loading chunk is calculated from your current cursor position in the file (offset).
    loading chunk = offset - limit/2 to offset + limit/2
    The text on the JTextPane/JEditorPane must not change when loading chunks or else the user feels like is in another position of the file.
    This is not a trivial solution but if you don't find any other 3rd party control to do this I would go this way. " (bruno conde)
    Is this a good solution and can anybody give me an exemple (link tutorial project) ? or are any other solution?
    How can we improve jtextpane performance?
    Thx

    Yes, i allready done that (using SwingUtilities.invokeLater and updates are only performed on document objects that are not attached to text components at the time that the updates are made)
    The slow speed of insertion in a JTextPane has at least two culprits. The first is simply an effect of the Model-View-Controller architecture: If the document into which strings are being inserted is serving as the model for a visible text pane, each insertion will trigger a re-rendering of the display, which may in turn trigger other user interface updates. For interactive editing, this is exactly the behavior that one would want, since the results of user input should be immediately visible when editing text pane content. For initializing a text pane with a large amount of content, or, in general, making large “batch” edits, the overhead of repeated UI updates is signficant.
    The second source of sluggishness is an implementation detail of DefaultStyledDocument. Unlike most Swing classes, which should only be modified in the AWT thread, DefaultStyledDocument is designed to be thread-safe. This requires DefaultStyledDocument to implement locking, so that multiple threads do not try to update the document contents at the same time. This locking imposes a small amount of overhead on each insertion or other document modification, which can add up to a long delay for large and complex text insertions.
    [Faster JTextPane Text Insertion|http://javatechniques.com/public/java/docs/gui/jtextpane-speed-part1.html]
    but is still slow (reading file)...and the other problem is with memory usage.
    I found this subject on many other forums but not with a satisfactory answer ......must be a solution
    Thx for your answers guys!

  • JTextArea horizontal alignment

    I want to control the alignment of text in a JTextArea control (alignment left, center or right). I assume that I need to make a custom renderer of some description to be able to draw the text in the appropriate alignment,
    but if this is the case, I cannot work out how to setup the components.
    I appreciate that the JTextPane provides for setting of paragraph alignment attributes, but in my situation I need to use the JTextArea (the user needs to be able to turn line wrap on and off at run time so I need to make use of the JTextArea lineWrap facility).
    Is there any way that I can get the JTextArea to support the horizontal alignment??
    Any assistance would be greatly appreciated,
    regards, Sean

    I just realised that using a JTextPane would be acceptable as long as I could allow the user to turn on and off the line wrapping behaviour of the JTextPane. Does anybody know how to achieve that?
    Thanks, Sean

Maybe you are looking for

  • Skype doesn't save files where it suppose to!

    Same here - my friend sent me pictures, they came with strange long numbers names and all are downloaded to C/user name/AppData/Roaming/Skype/skype user name/media_messaging/media_cache Thou the auto.download are disabled and another folder are set f

  • Takes hours to install windows 8 on 5k Imac

    The first thing i did when i got my maxed out 5k retina Imac with 1 TB fusion drive is i installed windows 8.1 on it using bootcamp. That was 5 months ago. a few weeks back i was experiencing crashes and generally a very laggy windows so i decided to

  • Time Function in Oracle

    Note that there is no specific time function in Oracle. What is the most efficient way to change the time segment of a Date or Timestamp field (column)? I need to pick up the date from the system but the time requires manual entry. Thanks

  • What is the maximum number of characters in a FrameMaker 11 variable? in a FrameMaker 11 marker?

    Thx to anyone who can answer today's FM trivia question!! -Matt

  • Recover after zpool add -f ? Is it possible?

    Hello. Recently I've upgraded one of my machines to OpenSolaris 2009.06; the box has a few HDD: 1) main with OS, etc and 2) archive and ... After installing I created users, environment, etc on HDD(1), and then wanted to mount the existing ZFS for th