About select() in JTextArea?

i wrote the following codes,but the select() didnt work, :( why?
could you help me?please....
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
public class TrySelect {
     * @param args
     public static void main(String[] args) {
          // TODO Auto-generated method stub
          JFrame frame = new JFrame("TrySelect");
          Container c = frame.getContentPane();
          final JTextArea t= new JTextArea();
          c.add(t);
          JButton b = new JButton("Select");
          c.add(b,BorderLayout.SOUTH);
          b.addActionListener(new ActionListener(){
               public void actionPerformed(ActionEvent e){
                    t.select(5, 10);
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     frame.setBounds(120, 200,400,500);
     frame.setVisible(true);
thanks a lot!

If the problem exactly is to get the data from the TextArea you have to use "getText()".
Also mention number of rows and columns that the TextArea should contain while defining Text Area.
JTextArea t = new JTextArea(5,10);
This statement creates the TextArea with 5 rows and 10 cols.
In order to get the data entered in the TextArea when the button pressed, use the following statement in "actionPerformed()".
String str = t.getText();

Similar Messages

  • Problem about selecting waveform in waveform graph

    Hi all:
    I am developing a project by Labview. Now I meet a problem about selecting the waveform in the waveform graph.
    I am not sure whether it is possible about my idea.
    for example:
    In the waveform graph,  the different waveforms from a couple of channels are displayed. and then I want to select one waveform of them, and corresponding data about this waveform are shown. 
    Thanks so lot
    regards

    hanwei wrote:
    1.  can I zoom in and out in that "waveform graph"??
    You can do this using the graph palette. Just make it visible. The middle control allows you to zoom.
    2.  can I display the plot array or plot index that I select in the waveform graph?
    You can connect the same wire that goes to the ActivePlot property node to an indicator.
    3.  I build a sample codes for my project, in which , I used a random number generater to simulate a DAQmx data collection, and generate a overlapping waveform in the waveform graph.
         but it seems the program is not stable, when i first run the codes, it is ok, and I can select the plot what I want. but after I stop and restart the program, there is error message about "Property Node".
         it seems something wrong about the "waveform graph properties"
    I attached my codes here, anybody know what wrong about it?
    For some strange reason the property node is "messed up". I've seen this happen sometimes with graphs. I don't know what causes it, and the only way I've found to fix the problem is to delete the graph, put a new one on the front panel, and recreate the property nodes. I've typically seen this happen when copying code from another VI that has a graph with property nodes, as I suspect you did. If you delete the graph, put a new one on there, and recreate the property node you should be OK.
    That said, a few comments regarding the code:
    The architecture seems to be a mish-mash of operations, and I'm thinking that you probably want to look at using a producer-consumer architecture. Your producer loop responds to events, and the consumer loop does your DAQ collection.
    You have a race condition with your use of the "size(s) 2" local variable.
    Avoid right-to-left wires.
    The method of creating your arrays seems convoluted. However, since you said you will actually be getting the data from a DAQ system, the actual project code will likely be considerably different.

  • Question about selecting vector paths in Photoshop

    Hi, I have a question about selecting path points in photoshop.
    This is the setup. I have a vector shape layer (the redi circle). but that's placed inside a group with a vector mask (the black pentagon). What I want to do is select parts of the red circle using click and drag) so I can modify portions of the circle).
    This is Photoshop's behavior as I've noticed it. Photoshop likes to select the shapes for you, and will target layers on its own when you use the Path Selection Tool. It tends to want to select the top most shape. If I target the shape layer first, I can use the Direct Selection tool to select individual points. I can add selected points bu shift+clicking.This is all well and good.
    If I try to select multiple points using click+drag though, it gets a bit weird.
    If I try to click+drag to select multiple points from within the vector mask (from the black), it will fail and select the vector mask. If i try to click+drag to select multiple points from outside the vector mask (from the white), then it will allow me to select points from my vector shape like i intended.
    I could also shift click to hide the vector mask, and it will work the way i want.
    Is there an easy way to tell photoshop not to auto target vector shapes? or a better way to select paths inside vector masks?
    Thanx for any input

    canvai wrote:
    Is there an easy way to tell photoshop not to auto target vector shapes? or a better way to select paths inside vector masks?
    Sure.
    Simply click once on the vector mask for the shape layer (red circle) to highlight that vector mask in the Layers Panel. Then when you click-drag the anchors of that path will be selected, not the group's path.
    If you have no mask highlighted, Photoshop assumes it should select the first path it comes in contact with.

  • Doubt about Select statement.

    Hi folks!!
                 I have a few doubts about the select statements, it may be a silly things but its useful for me.
    what is   difference between below statment.
    1)SELECT * FROM TABLE.
    2)SELECT SINGLE * FROM TABLE
    3)SELECT SINGLE FROM TABLE.
    Hope i will get answer,thanks in advance.
    Regards
    Richie..

    Hi,
    try this and if possible use sap help.i mean place the cursor on select and press F1.
                 Types of select statements:
    1.     select * from ztxlfa1 into table it.
                 This is simple select statement to fetch all the data of db table into internal table it.
       2.   select * from ztxlfa1 into table it where lifnr between 'V2' and 'V5'.
            Thisis using where condition between v2 and v5.
      4. select * from ztxlfa1 where land1 = 'DE'. "row goes into default table work Area
      5. select lifnr land1 from ztxlfa1
            into corresponding fields of it   "notice 'table' is omitted
             where land1 = 'DE'.
              append it.
               endselect.
         Now data will go into work area. and then u will add it to internal table by     
            append statement.
      6.   Table 13.2 contains a list of the various forms of select as it is used with internal tables and their relative efficiency. They are in descending order of most-to-least efficient.
    Table 13.2  Various Forms of SELECT when Filling an Internal Table
    Statement(s)                                   Writes To
    select into table it                                    Body
    select into corresponding fields of table it   Body
    select into it                                    Header line
    select into corresponding fields of it           Header line
    7. SELECT VBRK~VBELN
           VBRK~VKORG
           VBRK~FKDAT
           VBRK~NETWR
           VBRK~WAERK
           TVKOT~VTEXT
           T001~BUKRS
           T001~BUTXT
        INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
        FROM VBRK
        INNER JOIN TVKOT ON VBRKVKORG = TVKOTVKORG
        INNER JOIN T001 ON VBRKBUKRS = T001BUKRS
        WHERE VBELN IN DOCNUM AND VBRK~FKSTO = ''
       AND VBRK~FKDAT in date.
    Select statement using inner joins for vbrk and t001 and tvkot table for this case based on the conditions
    8. SELECT T001W~NAME1 INTO  TABLE IT1_T001W
    FROM T001W INNER JOIN EKPO ON T001WWERKS = EKPOWERKS
    WHERE EKPO~EBELN = PURORD.
    here selecting a single field into table it1_t001winner join on ekpo.
    9. SELECT BUKRS LIFNR EBELN FROM EKKO INTO CORRESPONDING FIELDS OF IT_EKKO WHERE     EBELN IN P_O_NO.
    ENDSELECT.
    SELECT BUTXT   FROM T001 INTO  IT_T001 FOR ALL ENTRIES IN IT_EKKO WHERE BUKRS = IT_EKKO-BUKRS.
    ENDSELECT.
    APPEND IT_T001.
    here I am using for all entries statement with select statement. Both joins and for all entries used to fetch the data on condition but for all entries is the best one.
    10. SELECT AVBELN BVTEXT AFKDAT CBUTXT ANETWR AWAERK INTO TABLE ITAB
                 FROM  VBRK AS A
                 INNER JOIN TVKOT AS B ON
                 AVKORG EQ BVKORG
                 INNER JOIN T001 AS C ON
                 ABUKRS EQ CBUKRS
                 WHERE  AVBELN IN BDOCU AND AFKSTO EQ ' ' AND B~SPRAS EQ
                 SY-LANGU
                 AND AFKDAT IN BDATE AND AVBELN EQ ANY ( SELECT VBELN FROM
                VBRP WHERE VBRP~MATNR EQ ITEMS ).
        Here we are using sub query in inner join specified in brackets.
    Thanks,
    chandu.

  • Info about select

    Hello
    if possible, i need a info about a select in a table of 165.000.000 with the following fields:
    Name Null? Type
    MANDT NOT NULL VARCHAR2(3)
    DOCNUM NOT NULL VARCHAR2(16)
    COUNTER NOT NULL VARCHAR2(3)
    PAGENO NOT NULL NUMBER(5)
    TIMESTMP NOT NULL VARCHAR2(14)
    PAGELG NOT NULL NUMBER(5)
    VARDATA LONG RAW
    I've seen that there are many records with blank in vardata field. So I did a select 'where vardata is null' but i didn't find records. This is not possible so i think that field has all blank characters and i should find a select that show me how many records have vardata with blank. I know that this select goes in table access full but is not important at the moment. Can you help me?
    Thanks
    Nick

    SQL> create table a(c1 varchar2(10));
    Table created.
    SQL> insert into a values('   ');
    1 row created.
    SQL> select * from a where c1 is null;
    no rows selected
    SQL> select * from a where trim(c1) is null;
    C1
    SQL>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • One question about Selection screen

    Hi experts,
    I am writing a report, on the selection screen, I need to input the file path and then do the file upload.
    My question is about how to check the file path I put is correct or not? If it is incorrect, I want to get a message and the cursor still in the field and don't jump to the next page.
    How can I do like that?
    Any one has any suggestion, please help me.
    Thanks in advance.
    Regards,
    Chris Gu

    Hi Chris,
        do it this way: check my code after calling gui_upload what condition i am using.
    parameters:
      p_file type rlgrap-filename.          " File name
    *           AT SELECTION-SCREEN ON VALUE-REQUEST EVENT               
    at selection-screen on value-request for p_file.
      perform get_file_name.
    *                       AT SELECTION-SCREEN EVENT                    
    at selection-screen on p_file.
      perform validate_upload_file.
    *  Form  GET_FILE_NAME                                               
    form get_file_name.
      call function 'F4_FILENAME'
       exporting
         program_name        = syst-cprog
         dynpro_number       = syst-dynnr
         field_name          = ' '
       importing
         file_name           = p_file.
    endform.                               " GET_FILE_NAME
    *  Form  VALIDATE_UPLOAD_FILE                                        
    form validate_upload_file.
      data:
        lw_file  type string.              " File Path
      lw_file = p_file.
      call function 'GUI_UPLOAD'
        exporting
          filename                    = lw_file
          filetype                    = 'ASC'
          has_field_separator         = 'X'
          dat_mode                    = 'X'
        tables
          data_tab                    = t_final_data.
      IF sy-subrc ne 0 and t_final_data is initial. " here message if file path is wrong
        Message 'File not found' type 'E'.
      ELSEIF sy-subrc eq 0 and t_final_data is initial.
        Message 'File empty' type 'E'.
      ENDIF.                              
    endform.                               " VALIDATE_UPLOAD_FILE
    With luck,
    Pritam.
    Edited by: Pritam Ghosh on May 8, 2009 8:57 AM

  • Block selection in JTextArea

    Hi,
    I was wondering if there is anything built-in to Swing to implement a block selection in a text area.
    I understand that the concept of block selection is really only applicable when a fixed-width font is used. and since the text is represented as a flow of characters, the concept of block selection might not be readily available.
    If anyone know of any ways this can be done that will be great. Thank for your help in advance.
    Kit
    PS. In case it is not clear what block selection is, think of the selection behavior in Excel.

    You can implement KeyListener where use similar approach.
    best regards
    Stas
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.text.*;
    public class TestPopup
    JFrame frame;
    public static void main(String args[])
    new TestPopup();
    public TestPopup()
    frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JTextArea ta=new JTextArea("test11111\ntest22222\ntest33333\ntest44444\ntest55555\n");
    try {
    ta.getHighlighter().addHighlight(14,17,((DefaultHighlighter)ta.getHighlighter()).DefaultPainter);
    ta.getHighlighter().addHighlight(24,27,((DefaultHighlighter)ta.getHighlighter()).DefaultPainter);
    ta.getHighlighter().addHighlight(34,37,((DefaultHighlighter)ta.getHighlighter()).DefaultPainter);
    catch (Exception ex) {
    ex.printStackTrace();
    JScrollPane scroll=new JScrollPane(ta);
    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(scroll,BorderLayout.CENTER);
    frame.setSize(300,200);
    frame.setVisible(true);

  • Re: Vertical Selection in JTextArea

    How do I get a vertical selection (i.e. by columns) in a JTextArea? I'm trying to recreate the behaviour of the old DOS 'e' editor or Kate from KDE on Linux.
    I would also like to be able to cut copy and paste as colums, rather than rows.
    Thanks in Advance.

    textComponent.setSelectionStart(int);
    textComponent.setSelectionEnd(int);

  • Error in BAPI_ROUTING_CREATE about Selected Set of Inspection Characteristics

    hi,all
         When I use  'BAPI_ROUTING_CREATE' to batch import Routings , I come across a problem that the Selected Set of Inspection Characteristics can not be imported,and it's  not updateable.
         Here are the parameters I imported to the BAPI about the Inspection Characteristics.
    activity
    operation_id
    cha_master_import_modus = 'N'
    mstr_char
    inspchar = '0010'..
    valid_from = sy-datum.
    valid_to_date = '99991231'.
    char_descr
    pmethod
    smpl_unit
    smpl_quant
    quantitative_ind
    smpl_procedure
    SAMPLING_PROCEDURE_IND
    pmstr_char
    SEL_SET1
    PSEL_SET1
    CAT_TYPE2
    Can anybody help,thanks in advance.

    Its nice to Ask question & then close it saying you find the answer, will you please take some time to Explain what was the solustion of your problem ? Thanks.
    This is a trend i see in SDN, Moderator please request the members to put solustion in before closing the question as answered This will save lot time of others who are searching answare to same questions.

  • About select data performance

    hi experts:
       about performance when select data from table
        if i use index to slect data,it can run fast,but costomer tell me can't use index,
    for exmple: internel table itab_01[] has 2000 data, ztable has 1,000,000 data
    then  select vbeln from ztable into table itab_02
    for all entriesin itab_01
    where vbeln = itab_01-vbeln.
    it runs very slowly....
    i try to use select vbeln from ztable into table itab_02.then use loop read ...
    it runs ok. can i use this method?
    does it increase memory???
    chen xinrong

    Hi,
    You can see a report performance in SE30(Runtime analysis)and
    SQLtrace(ST05).
    ST05 tells you the list of selected statements.
    You should remember some points when you tuning the code
    - Use the GET RUN TIME command to help evaluate performance. It's
    hard to know whether that optimization technique REALLY helps unless you
    test it out. Using this tool can help you know what is effective, under what
    kinds of conditions. The GET RUN TIME has problems under multiple CPUs, so
    you should use it to test small pieces of your program, rather than the
    whole program.
    - *Generally, try to reduce I/O first, then memory, then CPU activity.
    *I/O operations that read/write to hard disk are always the most
    expensive operations. Memory, if not controlled, may have to be written to
    swap space on the hard disk, which therefore increases your I/O read/writes
    to disk. CPU activity can be reduced by careful program design, and by using
    commands such as SUM (SQL) and COLLECT (ABAP/4).
    - Avoid 'SELECT *', especially in tables that have a lot of fields.
    Use SELECT A B C INTO instead, so that fields are only read if they are
    used. This can make a very big difference.
    - Field-groups can be useful for multi-level sorting and displaying.
    However, they write their data to the system's paging space, rather than to
    memory (internal tables use memory). For this reason, field-groups are only
    appropriate for processing large lists (e.g. over 50,000 records). If
    you have large lists, you should work with the systems administrator to
    decide the maximum amount of RAM your program should use, and from that,
    calculate how much space your lists will use. Then you can decide whether to
    write the data to memory or swap space.
    - Use as many table keys as possible in the WHERE part of your select
    statements.
    - Whenever possible, design the program to access a relatively
    constant number of records (for instance, if you only access the
    transactions for one month, then there probably will be a reasonable range,
    like 1200-1800, for the number of transactions inputted within that month).
    Then use a SELECT A B C INTO TABLE ITAB statement.
    - Get a good idea of how many records you will be accessing. Log into
    your productive system, and use SE80 -> Dictionary Objects (press Edit),
    enter the table name you want to see, and press Display. Go To Utilities ->
    Table Contents to query the table contents and see the number of records.
    This is extremely useful in optimizing a program's memory allocation.
    - Try to make the user interface such that the program gradually
    unfolds more information to the user, rather than giving a huge list of
    information all at once to the user.
    - Declare your internal tables using OCCURS NUM_RECS, where NUM_RECS
    is the number of records you expect to be accessing. If the number of
    records exceeds NUM_RECS, the data will be kept in swap space (not memory).
    - Use SELECT A B C INTO TABLE ITAB whenever possible. This will read
    all of the records into the itab in one operation, rather than repeated
    operations that result from a SELECT A B C INTO ITAB... ENDSELECT statement.
    Make sure that ITAB is declared with OCCURS NUM_RECS, where NUM_RECS is the
    number of records you expect to access.
    - If the number of records you are reading is constantly growing, you
    may be able to break it into chunks of relatively constant size. For
    instance, if you have to read all records from 1991 to present, you can
    break it into quarters, and read all records one quarter at a time. This
    will reduce I/O operations. Test extensively with GET RUN TIME when using
    this method.
    - Know how to use the 'collect' command. It can be very efficient.
    - Use the SELECT SINGLE command whenever possible.
    - Many tables contain totals fields (such as monthly expense totals).
    Use these avoid wasting resources by calculatin
    Rgds,
    P.Naganjana Reddy

  • About SELECT VALUE FROM NLS_INSTANCE_PARAMETERS WHERE PARAMETER =""

    I am developing a web application based on Oacle 10g .But after the DBServe was startedup for about 5~6 hours, the max connection process exceeded. From the DB Administration Tool it shows that there were many INACTIVE Connections which executed
    SELECT VALUE FROM NLS_INSTANCE_PARAMETERS WHERE PARAMETER ='NLS_DATE_FORMAT'
    But it seems that this is called by the JDBC driver, not my application. How to avoid this, or release the inactive connection?
    By the way,who and when call that sql?
    Thanks a lot.

    By the way,who and when call that sql?Also for this you can take an 10046 level 8 sql trace and format the output with sys=yes option of tkprof - http://tonguc.wordpress.com/2006/12/30/introduction-to-oracle-trace-utulity-and-understanding-the-fundamental-performance-equation/
    Since we are talking about a web application you may use a database logon trigger to start sql trace for your application user, or if possible you may set sql_trace database parameter to true at instance level for a while and since you are at 10g you can use new package dbms_monitor and trcsess utility - http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/sqltrace.htm#sthref2001
    Best regards.

  • Selection in JTextArea

    Hi all,
    I want to select a part of the words in my JTextArea. But not with the mouse, my programm has to select. I use the method select(int, int) from javax.swing.text.JTextComponent. It works, becouse if I make cut selection the part will be cut. But I also want to SEE what is selected, like it looks like when i select something with the mouse.
    What can I do?
    THX
    foxy

    textComponent.setSelectionStart(int);
    textComponent.setSelectionEnd(int);

  • About selecting Scheduling Agreement and Forecast delivery schedule

    Hi Experts,
    i want to write a Report, with 2 parameters for the selection : Sold-to-party and Period
    For this Sold-to-party/Period, I want to list all scheduling agreement + Forecast delivery schedule.
    I already found the Function SD_VBEP_READ_WITH_VBELN to read all Forecast delivery schedule lines using Sales Doc.No. , but how can I select all Scheduling Agreement for the Period ?
    Regards,
    David

    Solution:
    by selecting data from table VEPVG (Delivery Due Index) and using function SD_VBEP_READ_WITH_VBELN for each SD Document.
    Regards,
    David

  • About select option

    Hi experts,
    In my alv report there is one field SERNR serial number, for this i have to put select option. My problem is this field doesn't exist in the table(Zmanifest) from where i'm fetching data. So i'm not able to mention this select option in my select query for that particular table. This field is existing in EQUI table and have no relation defined between zmanifest table & EQUI.
    In my internal table i have all fields of zmanifest & this sernr; to fulfill this field logic is
    Serial Number is combination of P_PREFIX-(dash)P_SERIAL fields in zmanifest. I have fetch all data including SERNR by above logic at my grid; but facing problem in defining SELECT-OPTIONS for Sernr.
    Please help.
    Points Sure.
    Anshuman

    Hi,
    do like this.
    take the lenght of P_PREFIX
    take the lenght of P_SERIAL
    add the length.
    for exmaple :
    P_PREFIX size is 4.
    P_SERIAL size is 10
    now declare the variable like this.
    data : v_selop(15).
    Note : 4101 = 15, so i declared the variable with lenght of 15.
    select-options : so_field for v_selop.
    now use off-set in your select query like this:
    where PREFIX = v_selop+0(4)
       and SERIAL = v_selop+5(10)
    it will work if you are using variable v_selop as a parameter else if you are using select option you have to break v_selop into two different select option like this:
    s_prefix type prefix,
    s_serial type serial.
    loop at v_selop.
    s_prefix-* = v_selop-. "      (  = sign, option)
    s_serial-* = v_selop-*.
    s_prefix-low = v_selop-low+0(4).
    s_serial-low = v_selop-low+5(10).
    s_prefix-high = v_selop-high+0(4).
    s_serial-high = v_selop-high+5(10).
    endloop.
    now use following select query
    where PREFIX in s_prefix
       and SERIAL in s_serial.
    it will surely wrok.
    Regards-
    Gagan Kumar
    Plz Reward if need full. also close the question.
    Edited by: Gagan Kumar on May 18, 2008 7:30 PM

  • About selecting single column in a alv table.........

    Hi Experts,
    I need single column to be selected from a ALV table...selected in da sense to be highlighted....as it happens..by default for a row.....
    I hope u understood my query...
    Please help me out in this..
    I know u all will surely help me...
    Thks and Regards,
    Runali.

    Hi Runali,
    Get the reference to the column settings of your ALV Model. Then you can get the reference of each column by passing the column ID. There is a method set_selected_state in the column class, but that does not highlight the column as it does for a row. So what you can use is a cell design for a column that will highlight the column with a color or whatever.
    lr_column = lr_column_settings->get_column( ID = id ).
    lr_column->set_cell_design( preferred design ).
    Hope this helps. Please award points if it solves your purpose.
    Regards,
    Nithya

Maybe you are looking for