Get the type line height / of a JTextArea in a GridBagLayout

I have a JTextArea declared without default rows/columns, full text of unknown size (assigned during execution). This JTextArea line wrap set to true and wrap the Word style set to true. He is sitting in a JPanel GridBagLayout-ed, with
weightx = 1, heavy = 0.7 gridx = 1, gridy = 2, gridwidth = 2, gridheight = 1, fill = BOTH, anchor = WEST
The JPanel in question a height minimum, maximum and preffered all set at the same amount, because I displayed a bunch of these signs in a vertical scrolling region. The problem is, I don't know how many pixels to set for this height because I do not know how big the panel will be as long as GridBag aligning. I put in a ComponentListener to check resize them and I make one
int desiredHeight = SOME_CONSTANT_FOR_ALL_THE_OTHER_STUFF_IN_THE_JPANEL + jTextAreaObject.getLineCount () * PIXELS_PER_ROW_OF_TEXT;
then, set the dimensions of JPanel accordingly.

Unfortunately, it seems that jTextAreaObject.getLineCount () always returns 1, even though I see that he got at least once rolled up (I see a couple of value of pixels on the top of each letter). I guess it's because I have no return carriage/flow line in my text. OK, so I tried jTextAreaObject.getRows () but that always returns 0. So what appeal will tell me how many lines is displayed onscreen, nevermind carriage returns and other? Thank you!

The 'getWrappedLines' of text utilities method might work for you.

Published by: camickr on September 28, 2010 17:58

Anyone know how to get the link to work? I clicked on the button "click to insert a link.

Published by: camickr on 29 Sep, 2010 01:14

Thank you, Darryl, the link works now.

Tags: Java

Similar Questions

  • Satellite L510 - PC Health Monitor - could not get the Type of Bios

    Hi guys,.

    I m appeal for some help and hope that some of you experts out there may be able to help me!

    My laptop is a Satellite L510 bought November 2009
    Windows 7 Home Premium SP1 32-bit
    The version of the BIOS/Date: INSYDE, 1.30, 08/05/2009

    Problems:
    1 ReelTime (worm: 1.0.04.0) TC00210100H stopped working about 6 months ago, so I uninstalled it.
    2 PC Health Monitor (worm: 1.4.0.0) TC00148300O

    Value Added Package: Worm: 1.2.25 (TC00214700E)

    For a couple of weeks stop would take a little longer than before and last weekend he just stopped even if the battery is fully charged.

    I had a bit of a job to resume but I finally did, I came to the conclusion even if the hard drive was not.

    I then tried to open the PC Health Monitor, but this error appeared impossible to get the type of bios and obviously wouldn t open. I uninstalled PCHM programs and features and then ran TC00148300O.exe of
    C:/Program Files / Toshiba / TOSAPINS / COMPS1 / TOSHIBA PC Health Monitor - 1.4.0.0, it seemed something was going on but ultimately nothing has.

    I dropped while I needed to sort first on the hard drive. Long story short, the hard drive has been replaced by a SSD 840 EVO 250 GB by a friend of TI at work.

    I prefer like to get ReelTime and PCHM working again correctly troubleshooting (with your help) that I put t really want to restore back provided that the factory, but if I have to...

    If I have explicit instructions on how to do that would be a big help (if necessary I can also get my friend to help me).

    If I n t give any other specific information that you need please ask. I apologize for this long post, but thanks to anyone who responds.

    Hello

    If you replaced the HARD drive I recommend you to install original recovery image and start using your machine with the factory settings. After that it all will again be OK. Install important Windows updates current, your important software and I think that everything will be OK again.

    Software related questions can sometimes be very complicated. All you can try to do is remove pre-installed application, restart the computer and try to install it again.

    On BIOS I can just say that you shouldn't change anything.

    One last thing: I don t know how important ReelTime and PC Health Monitor are for you, but I removed the two applications on my system. In my opinion there is no much help from both of them, but they CPU utilization for the unnecessary process.

  • Get the Type (U8, U16... I64) controls within a Cluster

    Hello

    I have a cluster with multiple controls.

    I would get the type of each control inside. To get the class is ok. It's simple and they are all digital. But I need to know if they are U8, U16, U32... I64.

    No idea how to do this?

    Paul

    I got it.

    I had to convert the Refernce element to digital, and then use the BitAccurateDataSize property.

    I lost several hours to find the solution and in 5 minutes after I had posted my problem on the forum I solved it .

  • How to get the type of network in Blackberry 10 Webworks 1.0

    Hello

    I am developing web applications and using connection plugin to get the type of network used.

    I've added the id of the required functionality in the file config.xml as follows:

    function id = "blackberry.connection".

    Now when you click on buuton, I call the function below:

    function currentConnectionType(){
        alert("1111111111");
        var connection = blackberry.connection;
        alert("222222"+blackberry.connection.CELL_3G);
    
        var connType = blackberry.connection.currentConnectionType();
    
        alert("Current con Type : "+connType);
    }
    

    In the code above curretCoonectionType is not called.

    Please help me correct where I am doing wrong. Or please let me know is there another way or sample code for the Type of network being used

    Thanks in advance

    It seems that the type property, you should get the current connection type:
    BlackBerry.Connection.type

    https://developer.BlackBerry.com/HTML5/APIs/gold/BlackBerry.connection.html#.type

    You can also save to connectionchange headphones to monitor changes in the type.

  • in windows 7 when you right click on how do you get the little line under the letter of the you can click on to make it open Windows 7

    in windows 7 when you right click on how do you get the little line under the letter of the you can click on to make it open Windows 7

    Example when you right click on a program, you can see Open if you click o the file opens, it was in XP, but not in 7

    That's what you want.

    1 - Open "Control Panel" and go to accessibility.

    2 - click make the keyboard easier to use.

    3. the title of 'Make it easier to use keyboard shortcuts' tick the box 'Underline access keys and keyboard shortcuts' and click 'Ok '.

    Oh sure, it could be useful.

  • How can I get the type of coverage to work

    type of coverage

    How can I get the type of coverage to work

    Hi Ted,

    Once you take the type of coverage, it's ready to go!

    You are in a place to type in information?

    Once it is aligned, it works like a regular keyboard.

    B Eddie

  • Get the types of columns in a select statement

    Hello

    Is there a way to get the types of columns that results in a select statement?

    For example to force an analysis on this topic and then look for the types of columns resulting in the view v$?

    Best regards

    Klaus Mogensen

    declare
      c       number;
      d       number;
      col_cnt integer;
      rec_tab dbms_sql.desc_tab;
      col_num number;
    begin
      c := dbms_sql.open_cursor;
      dbms_sql.parse(c, 'select dummy, 33 x, sysdate now from dual', dbms_sql.native);
      dbms_sql.describe_columns(c, col_cnt, rec_tab);
      col_num := rec_tab.first;
      while col_num is not null
      loop
        dbms_output.put_line( rec_tab(col_num).col_name || ' ' ||
                              case rec_tab(col_num).col_type
                                when 1 then 'varchar2'
                                when 2 then 'number'
                                when 12 then 'date'
                                else '???? ' || rec_tab(col_num).col_type
                              end
                            );
        col_num := rec_tab.next(col_num);
      end loop;
      dbms_sql.close_cursor(c);
    end;
    /
    DUMMY varchar2
    X number
    NOW date
    
  • How to get the responsible line line is SOA Composite for Workflow OIMR2

    Hello

    I have a requirement to get the 2nd line in SOA Composite. For example a user (Jon) creates an application available to users on the target system. First approver's manager Jon user line and first line manager this gathering for payload Task.payload.beneficiaryDetails.managerLogin. Now the problem is Second line manager which Jon line manager Manager.

    How can we get this second hierarchy in Composite SOA? Can someone help me? is there an API for it?


    Thank you

    Tamim Khan

    Hello

    I have this problem as below, without using the API. I do this ruin sql in the database of the IOM.

    1. Add the variable ManagerLogin2 in the RequestDetails.xsd file in source modefing.

    2. drag the expression to the node ManagerLogin2 in the entitlement operation.

    3 Add the following query using QUERY-DATABASE in the EXPRESSION.

    oraext:query - database (concat ("Select DISTINCT LINE_MANAGER2 from USR_LINE_MANAGER_VW where the USR_LOGIN =', concat ("'", bpws:getVariableData('inputVariable','payload','/ns3:process/ns4:BeneficiaryDetails/ns4:Login'),)"'"")), false (), false (),'jdbc:oracle:thin:DEV_OIM / @localhost Password: 1521:idmdevdb')

    4. to make the simple SQL I use a view of database USR_LINE_MANAGER_VW in the scheme of the IOM as below:

    CREATE OR REPLACE VIEW "DEV_OIM" OF THE FORCE. "" USR_LINE_MANAGER_VW ".

    ('USR_LOGIN', 'LINE_MANAGER1', 'USR_KEY', 'LINE_MANAGER2')

    AS

    SELECT U1. USR_KEY,

    U1. USR_LOGIN,

    V2M USR_LOGIN AS LINE_MANAGER1,

    U3. USR_LOGIN AS LINE_MANAGER2

    USR U1,

    USR U2,

    USR U3

    WHERE U1. USR_MANAGER_KEY = U2.usr_KEY

    AND U2. USR_MANAGER_KEY = U3.usr_KEY;

    5. Select insertMessingToData in the operation of the legal successor.

    6. Add the line below in ApprovalProcess.bpel

    xmlns:oraext =http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc

    7. now, we can use Task.payload.beneficiaryDetails.managerLogin2 approvalTaskRules.

  • Anyone had any chance to get the 'Chat line' to answer a question, not to mention that the declarant is unavailable...

    Anyone had any chance to get the 'Chat line' to answer a question, not to mention that the declarant that it is not available at this time?

    Nevermind, I got a refund.

  • How can I get the type of device in ESXi5?

    In ESX or ESXi4, use dmicode | grep 'product name'-i to get the type of device. But this command is not found in ESXi5. So, how can I get the type of device in ESXi5? Thank you.

    The dmicode | grep 'product name'-i train ESX4.1 as follows:

    [root@host22 ~]# dmidecode | grep -i "product name"
     Product Name: CN21UPSA  
     Product Name: CN21UPSA

    Try the simple way: "esxcli hardware platform get."

    / Rubeck

  • How to get the selected line in af:inputComboBoxListOfValues

    Hello

    Am on jdev 11.1.1.2.1.

    Uses af:inputComboBoxListOfValues component, I've done the component based on the id of 'service' and the display value is "name of the Department.

    In the value change listener I want to get the id of the selected service, but now I get only the name of the service. (using valueChangeEvent.getNewValue m:System.NET.SocketAddress.ToString (()))

    So is it possible to get the whole line and get the "department id" using that?

    Help, please.


    Thank you
    Hari

    Sorry for the confusion, necessary to check it out:
    This code should work:

        public void nameValueCangeListener(ValueChangeEvent valueChangeEvent) {
            FacesContext contxt = FacesContext.getCurrentInstance();
            valueChangeEvent.getComponent().processUpdates(contxt); // after this the new row is selected!
            BindingContext lBindingContext = BindingContext.getCurrent();
            BindingContainer lBindingContainer = lBindingContext.getCurrentBindingsEntry();
            JUCtrlListBinding list = (JUCtrlListBinding) lBindingContainer.get("YOUR_LIST_BINDING_NAME");
            Row lFromList = (Row)list.getCurrentRow();
            Object lAttribute = lFromList.getAttribute("YOUR_ATTRIBUTE_YUO_WANT_TO_GET");
        }
    

    Timo

  • How to get the Type of a Collection class

    Hi all
    I just want to ask if there is a simple way to get the type of a Collection class.

    For example, for an ArrayList < String > or items of list < number > integer, dynamically how 'String' or 'Integer' class object (expecially with generic types) without any sequences of strange reflections?

    Thank you!

    Java generics follow one main erasure called which essentially States that any generic info is maintained during execution. If you can not, even if you can get information about variables and fields of reflection.

  • How to get the width and height of Flex Mobile view?

    Hello

    The following instructions can get the width and height of the current Flex app:

    var request: UIComponent = FlexGlobals.topLevelApplication as UIComponent;

    trace (application. Width);

    trace (application. Height);

    But I don't know how to get the width and height of mobile display Flex current (i.e. the content size excludes bar action and the Navigation bar). Why the "this.width" always returns 0?

    Thank you!

    Looks like you're running in this bug: https://bugs.adobe.com/jira/browse/SDK-30070

  • Get the width and height of the image

    Hi scripters

    I try to get the width and height of my image file. Here is my code

    myPicFile = File("c:\\ar.eps");

    h = myPicFile.height;

    w = myPicFile.width;

    Alert (h)

    Copy the following code generates error

    ---------------------------
    Script alert
    ---------------------------
    undefined
    ---------------------------
    Ok
    ---------------------------

    How can I get the height and the width of my image? is there another method?

    Thanks in advance

    concerning

    a you are the

    Dear Arul,

    Here, my code is in InDesign. I don't know that we get the size of the Image directly. ?

    Throught InDesign [you using the InDesign Script then] Script here I pasted the code below...

    = Image height / width =.

    myDoc var = app.activeDocument;

    myPicFile = file ("E:\\HariharaSudhan\\Blue hills.jpg");

    App.place (file (myPicFile);

    = Then u please select the Image file in InDesign and then you run the script = / /.

    mySel var = app.selection [0];

    var limit = mySel.geometricBounds;

    var height = related [2] - bound [0];
    var width = Bound [3] - bound [1];

    Alert ("Image Height:" + height + ""+"Image width:" + width);

    = End: getting the Image height / width =.

    Please let me know if you have any questions.

    Thank you & best regards

    Thierry T.R.Harihara

  • get the current line by a treetable

    Hello
    How to get the selected line in a treetable. (in support)

    Thanks in advance

    Hello

    call the getSelectedRowKeys. In a single-selection model, this returns a set with a single entry, which is a list of paintings representing the rowKey.

    RowKeySet selectedRows = treeTable.getSelectedRowKeys();
    //use EL to access binding (note that you can do this in Java as well)
    JUCtrlHierBinding treeTableBinding = (JUCtrlHierBinding) executeValueExpression("#{bindings.}");
    //get first entry of selected rows (single selection case)
    JUCtrlHierNodeBinding node =  treeTableBinding .findNodeByKeyPath((List)selectedRows .iterator().next());
    ... do the work with the node here ...
    
    private Object executeValueExpression(String valueExpression){
          FacesContext fctx = FacesContext.getCurrentInstance();
          ELContext elctx = fctx.getELContext();
          Application app = fctx.getApplication();
          ExpressionFactory exprFactory = app.getExpressionFactory();
          ValueExpression valueExpr = exprFactory.createValueExpression(
                                    elctx,
                                    valueExpression,
                                    Object.class);
           return valueExpr.getValue(elctx);
          }
    

    Frank

Maybe you are looking for

  • can watch it identify the user?

    Hey,. I'm curious to know if the Apple Watch is able to identify the user who wears. I try to explain what I mean Scenario would be: I bought and use the watch, everything is set up and works great. Then for example my sister puts the watch. The devi

  • When I start my pc the monitor reads "mode not supported".

    unplugged my pc & MONITOR. When I plugged it back in & has tried to start it, it keeps reading 'mode not supported '.

  • 2nd hard drive install on pavilion dv7-3060us 17.3 inches with Quad core processor

    Pavilion dv7-3060us computer has a 2nd hard drive Bay.  On 2 flags of 17.3 inches previous, I installed a 2nd HDD.  This quad core Pavilion is much thinner than the previous pavilions;  the underside of the computer has also a centre piece in the for

  • Windows shut down Hello.

    Given that I have installed Explorer 9 Windows was Hello stop. Windows Firewall is enabled and Hello is allowed. I can restart Hello, but Windows will usually close within a period of 12 hours.

  • Positioning of moving image

    I have a field that extends BitmapField (called AnimatedGIFField) and an AnimatorThread (which extends from Thread) who does the work of a loop through the images GIF, image current and crippling incrementing field, which calls the method object to d