How to prevent scrolling if you have two Jpanels in a JScrollPane

I have a JScrollPane with a JPanel for Linenumbers and one for a JTextArea,
each time you have a new line in the JTextarea the propertyListenerEvent call a Method that sets the LineNumbers in the JPanel for Linenumbers, but then you get an unwanted behaviour of the scrollbar: The Scrollbar scrolls down to the last Line. (e.g. if youre writing in the first Line - LineNumber update after pressing return, set's the view to the last Line e.g. 200 - the caret/cursor is on the second) I tried to set the Linenumber Panel not focusable, but it doesn't work. Does anyone got a hint for me?

Thanks for the answers.
@itchyscratchy: didn't get it working with that workarround. but thanks a lot :)
camickr: Since we can't see your code, we can't suggest what you might be doing wrong.I better kick my idea... thought it could be possible like: when
LnNums=false after setLineNum Call in jTPaneCaretUpdate!?
* LineNumberTest.java
* Created on 12. Dezember 2006, 23:40
public class LineNumberTest extends javax.swing.JFrame
    /** Creates new form LineNumberTest */
    public LineNumberTest()
        initComponents();
   // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents()
    jScrollPane1 = new javax.swing.JScrollPane();
        jPanel1 = new javax.swing.JPanel();
        jTxtArea1 = new javax.swing.JTextArea();
        jTLineNums = new javax.swing.JTextArea();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
       jPanel1.setLayout(new java.awt.BorderLayout());
        jTxtArea1.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) 
                jTxtArea1CaretUpdate(evt);
        jPanel1.add(jTxtArea1, java.awt.BorderLayout.CENTER);
        jTLineNums.setBackground(javax.swing.UIManager.getDefaults().getColor("TextField.disabledBackground"));
        jTLineNums.setEditable(false);
        jPanel1.add(jTLineNums, java.awt.BorderLayout.WEST);
        jScrollPane1.setViewportView(jPanel1);
        getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-400)/2, (screenSize.height-300)/2, 400, 300);
    // </editor-fold>
    private void jTxtArea1CaretUpdate(javax.swing.event.CaretEvent evt)
        //Caret
        ci = jTxtArea1.getCaretPosition();
        String sc;
        sc = Integer.toString(ci);
        String s = "0";
        sli=jTxtArea1.getLineCount();
        s = Integer.toString(sli);
        if(LnNums) {
            setLineNums();
           //LnNums =false;
         private void setLineNums()
        jTLineNums.setText("");
        //jTLNums.setFont (new Font (fName, Font.PLAIN, fSize));
        for (int i = 1; i <= sli; i++) {
            jTLineNums.append(i+" \r\n");
        //setFoc ();
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new LineNumberTest().setVisible(true);
    public javax.swing.JPanel jPanel1;
    public javax.swing.JScrollPane jScrollPane1;
    public javax.swing.JTextArea jTLineNums;
    public javax.swing.JTextArea jTxtArea1;
    boolean LnNums = true;
    int iLnNums, iSymBar, iCodeBar, iInv, sli, ci;
}

Similar Messages

  • Can you have two seperate acounts on one MAC and if so how do you do it?

    Can you have two seperate acounts on one MAC and if so how do you do it?

    Look at Method One in this document:  How to use multiple iPods, iPads, or iPhones with one computer, http://support.apple.com/kb/HT1495

  • You know how you download apps, well let's say you have two devices and get an app on one and it goes to the other, how do you remove it from doing that?

    You know how you download apps, well let's say you have two devices and get an app on one and it goes to the other, how do you remove it from doing that?

    Click here and use the instructions to turn off the automatic downloads.
    (120206)

  • HT1296 How do you sync iphone and PC when you have two different iphones/users?

    How do you sync iphone and PC when you have two different iphones/users in house? I just tried to sync my iphone and cancelled sync becauase I saw it was updating my phone with my husband's apps! How do I make it so that sync can distinguish between my and my husband's phone?

    I sync two iPhones and an iPad with one iTunes library on the same computer and each device has different content. Each device has its own sync preferences with iTunes. You can transfer the same music and apps to each device or different music and apps.
    Are you sharing the same Apple ID or iTunes account?

  • Can you have two Apple IDs on one IPAD? One for school and one for home?

    Can you have two Apple IDs on one IPAD? One for school and one for home?
    If so do you know how to do it?

    It depends on what you want to do.
    You could, for example, have one AppleID for iCloud backup [and therefore message syncing, notes syncing, etc] and a second one for iTunes [music, iBooks, etc].
    But if you are looking for a way to flip everything between different appleIDs, then no.

  • Can you have two itunes accounts on the same computer?

    Can you have two itunes accounts on the same computer and if so how do you access them without syncing each others music?

    Yes. Use separate iTunes libraries(launch iTunes with the Shift(Windows) or Option(Mac OS X) key held down as needed), or different user accounts on the computer.
    (100648)

  • Can you have two slides shows on the one interactive page?

    I'm just new at learning interactive pdfs in indesign so sorry if this is common knowledge. I know how to create a slide show on a page, but can you have two slide shows on the one page or more for that matter? (Ideally I need 3.) Each slide show has its own set of images and buttons.

    Just :http://www.youtube.com/watch?v=Dm0aeMUPZ4U
    But I'm happy to create them a different way if needed be.

  • How many ADFS farms can you have in a single forest/single domain?

    Hi
    I may have some terminology incorrect...please let me know if I do. :)
    My question is, how many ADFS farms can you have in a single forest/single domain? If you want to know why I am asking...please read on.
    We have 1 ADFS Farm and we are looking adding services to it. However not every cloud vendor provides a "Identity Broker" with there services.
    We have a consultant that is advising that we need to enable a SAML-based IdP-initiated single sign-on (SSO) ie using "IdpInitiatedSignOnPage"
    However to do this we need to modify the ADFS website to have "drop down" list so the user can select the "Relying Party" and then authentication with them.
    This means we are exposing a list of every company/party we have federated with. The exposure of this information, is deemed a security concern by our company....which I agree with.
    So the consultant advises that we need a separate ADFS farm. I have searched online, but haven't found any information that confirms multiple ADFS farms can be implemented in a single forest/single domain.
    Thanks for reading and if you have any other suggestions...I'd appreciate it.
    Nyobi

    This is not exactly FIM related question - there is ADFS forum available on Technet. However - technically there is no limit of ADFS farms in a forest \ domain. It is just a service which uses AD and is not altering it in any way or storing some forest-wide
    information like Exchange. So you can setup two ADFS services in single forest - no problem. 
    If it is a best solution to your problem? I can't say with that limited information but maybe just customization of pages on ADFS side would be enough? 
    Tomek Onyszko, memberOf Predica FIM Team (http://www.predica.pl), IdAM knowledge provider @ http://blog.predica.pl

  • Can you have two nicknames for game center for two kids linked to one Apple ID?

    Can you have two nicknames in game center (for each child) linked to one email/apple ID?

    On each of the phones you're gonna use a new Apple ID for iCloud: turn off Contacts, Calendars, etc. for iCloud. You'll be prompted to keep the data or delete it from the phone, then turn off iMessage, FaceTime & delete the iCloud account...Settings>iCloud...scroll down...delete account. Then, setup iCloud using the new Apple ID, turn on iMessage & Facetime.
    This will have no affect on the ID you share for iTunes content, & you can continue to do so.

  • My husband does not have an itunes account and wants to set one up and we only have the one computer. can you have two separate accounts? We want to set up separate iphones.

    My husband does not have an itunes account and wants to set one up and we only have the one computer. can you have two separate accounts? We want to set up separate iphones.

    How to use multiple iPods, iPads, or iPhones with one computer

  • How many message filters do you have ?

    I don't know if that question has been asked before?
    How many message filters do you have set up on your Ironport?
    Thanks
    Arnaud

    Hi "Community", (or are we still a "Nation"?) :-)
    Since one of the "conflating responses" was mine, I like to complete my answer:
    Besides the content filters mentioned in my first post, we have 3 message filters.
    Two are quite simple X-header adding filters (to indicate a message is actually received from the internet and an other to give insight into the SRB scores), The last one is some more sophisticated, it detects messages that need to be forwarded to our internal policy systems, regardless of the used destination domain.
    Steven.

  • If you have two public class in a java file what will be the error ?

    Q:If you have two public class in a java file what will be the error and how will you remove that.?

    Kannan_S wrote:
    I dont want you to be on that list . Here goes my explanation..
    A class is well defined with members and functions
    An abstract class is not defined well as compared to a full fledged class (talking more generically)
    An interface is more abstract.
    I was asking the author who has posted this question to be like a class(very clear)
    and not either as an abstract class or an interface
    Hope i have made it clear..Not in the slightest. This has absolutely no bearing whatsoever on the question asked. Not to mention that classes are classes, and all equal in the eyes of the compiler, be they abstract, concrete or interfaces. It's difficult to see what your point is, to be honest, but I suspect it wouldn't be worth seeing anyway

  • Can you have two detail lists from the basic list at the same time?

    Hi
    Can you have two detail lists from the basic list at the same time?
    If yes how and if no why?
    Thanks
    Venkat

    No   ... it is not   possible   of   2 detail  list at   one time   from the basic  list ...
    you can  increament   the SY-LSIND  .... But you can not   display  both the windows   at single time  ...
    it is  possible  to  display  2 Detail list  in ALV   ......  from one  basic  list   using  the  Blocked  list  concept    .
    Sample Program on BLOCK LISTS
    Report   zblock_list
    * Declarations for BLOCK ALV DISPLAY
    *--type pools
    TYPE-POOLS:slis.
    DATA:x_layout TYPE slis_layout_alv,
    t_field TYPE slis_t_fieldcat_alv,
    *--field catalog
    x_fldcat LIKE LINE OF t_field,
    *--to hold all the events
    t_events TYPE slis_t_event,
    x_events TYPE slis_alv_event,
    t_sort TYPE slis_t_sortinfo_alv,
    x_sort LIKE LINE OF t_sort ,
    *--Print Layout
    x_print_layout TYPE slis_print_alv.
    *----Macro to add field catalog.
    *field "text "length "tech "COL_POS "DATATYPE "DDIC_OUTPUTLEN
    DEFINE add_catalog.
    clear x_fldcat.
    x_fldcat-fieldname = &1.
    x_fldcat-seltext_m = &2.
    x_fldcat-outputlen = &3.
    x_fldcat-tech = &4.
    x_fldcat-col_pos = &5.
    x_fldcat-no_zero = 'X'.
    x_fldcat-ddictxt = 'M'.
    x_fldcat-datatype = &6.
    x_fldcat-ddic_outputlen = &7.
    if &6 = 'N'.
    x_fldcat-lzero = 'X'.
    endif.
    *--build field catalog
    append x_fldcat to t_field.
    END-OF-DEFINITION.
    *----- data declerations.
    data: v_repid like sy-repid.
    data: begin of itab occurs 0,
    matnr like mara-matnr,
    ernam like mara-ernam,
    meins like mara-meins,
    end of itab.
    data: begin of jtab occurs 0,
    matnr like makt-matnr,
    maktx like makt-maktx,
    end of jtab.
    select matnr ernam meins
    up to 20 rows
    from mara
    into table itab.
    select matnr maktx
    up to 20 rows
    from makt
    into table jtab.
    v_repid = sy-repid.
    *DISPLAY alv
    * Initialize Block
    call function 'REUSE_ALV_BLOCK_LIST_INIT'
    exporting
    i_callback_program = v_repid.
    *Block 1:
    *INITIALIZE
    refresh t_field. clear t_field.
    refresh t_events.
    *field "text "length "tech "COL_POS "DATATYPE "DDIC_OUTPUTLEN
    add_catalog:
    'MATNR' 'Material' '18' '' '1' 'C' '18',
    'ERNAM' 'Created By' '12' '' '2' 'C' '12',
    'MEINS' 'Unit' '5' '' '3' 'C' '3'.
    *--build table for events.
    x_events-form = 'TOP_OF_LIST1'.
    x_events-name = slis_ev_top_of_list.
    append x_events to t_events.
    call function 'REUSE_ALV_BLOCK_LIST_APPEND'
    exporting
    is_layout = x_layout
    it_fieldcat = t_field
    i_tabname = 'ITAB'
    it_events = t_events
    it_sort = t_sort
    tables
    t_outtab = itab
    exceptions
    program_error = 1
    maximum_of_appends_reached = 2
    others = 3.
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    *--BLOCK 2(SUMMARY REPORT)
    *INITIALIZE
    refresh t_field. clear t_field.
    refresh t_events.
    *field "text "length "tech "COL_POS "DATATYPE "DDIC_OUTPUTLEN
    add_catalog:
    'MATNR' 'Material' '20' '' '1' 'C' '18',
    'MAKTX' 'Description' '40' '' '2' 'C' '40'.
    *--build table for events.
    x_events-form = 'TOP_OF_LIST2'.
    x_events-name = slis_ev_top_of_list.
    append x_events to t_events.
    * Append table block.
    call function 'REUSE_ALV_BLOCK_LIST_APPEND'
    exporting
    is_layout = x_layout
    it_fieldcat = t_field
    i_tabname = 'JTAB'
    it_events = t_events
    tables
    t_outtab = jtab
    exceptions
    program_error = 1
    maximum_of_appends_reached = 2
    others = 3.
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    *--CALL FM TO DISPLAY THE BLOCK REPORT.
    call function 'REUSE_ALV_BLOCK_LIST_DISPLAY'
    * exporting
    * is_print = x_print_layout
    exceptions
    program_error = 1
    others = 2.
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    form top_of_list1.
    skip 1.
    write: 10 'List 1',
    /5 '--------------------'.
    skip 1.
    format reset.
    endform.
    form top_of_list2.
    skip 1.
    write: 10 'List 2',
    /5 '--------------------'.
    skip 1.
    format reset.
    endform.
    reward  points if it is  usefull ....
    Girish

  • Can you have two different iTunes accounts on same computer?

    Can you have two different iTunes accounts on same computer?

    J2217 wrote:
    I'm going to give my old iPad to my granddaughter, I want to create an account for her, but I want to do it on my computer so there are no worries about who is spending credits for that account. Don't know how this will work, or if its possible to two iTunes libraries.
    Okay.
    She's going to use your computer to sync with iTunes.
    Create an new computer login on your computer for her. This will keep her stuff separate and she won't be able to mess with any of your info.
    Log into her computer account.
    Launch iTunes.
    Create a new iTunes account for her. See this -> http://support.apple.com/kb/HT2731
    You can enter a credit card to create the account then delete the CC info. Or you can use an iTunes gift card and she can fund the account with gift cards instead of using a CC to make purchases. This is an easy way to control spending.
    on the iPad, go to Settings > iMessage > Off.
    Then Settings > General > Reset > Erase all content & settings.
    Once it finishes, plug in the iPad, select it in iTunes and this will set it up as a new device. Enter all your granddaughter's info.
    When she wants to sync her iPad or use iTunes, she needs to log into your computer with her account.
    Then the iTunes library she uses will be only hers.

  • Can you have two apple ids on one mac?

    Can you have two apple ids on one mac? We each have iPhones and want to utilize iCloud.  Is this possible?

    No, in this case the 2 user accounts with its own Apple IDs would be completely seperated.
    If you want to share this things like music and app purchases you will have to to something else.
    1. Create two user accounts on your Mac (user A and user B).
    2. Create two iCloud accounts just for Mail, Contacts, Calendars, Photos, etc. (one for user A and one for user B):
    On your Mac (with Mac OS X Lion or Mountan Lion):
    Settings > Mail, Contacts, Calendars > iCloud > Create an Apple ID (button in left corner)
    On your iPhone, iPad or iPod touch (iOS 5 or later):
    Settings > Mail, Contacts, Calendars > Add Account > iCloud > Get a free @me.com address and create a new Apple ID
    3. It is not recommended because you shouldn't share your Apple ID account information with other people but you could set up your old Apple ID as an account just for store purchases (Apps, Music, ...) so that everyone of you can manage the purchases in their own library (Access is limited to 10 devices). Therefore you have to setup this "old" ID in Settings of your iOS devices (Settings > iTunes & App Store) and in iTunes on your Mac.

Maybe you are looking for