JTextArea with freeze pane functionality

Greetings. I am trying to implement a plain text viewer that has some sort of "freeze pane" functionality (like that found in MS Excel)
I took the approach of using 4 JTextArea and put them into a JScrollPane, its row header, column header and upper-left corner. All these text areas share the same document.
Everything works as expected. When I scroll the lower-right pane, the row and column headers scroll correspondingly. The problem I have is that the document in the lower-right pane now shows duplicate portion of the document that is already showing in the row and column headers.
Knowing that this should merely be a matter of shifting the Viewport on the document, I went through the documentation and java source, and just couldn't find a way to translate the view. SetViewPosition() works to a certain extent, but the scrollbars allow users to scroll back to the origin and reveal the duplicate data, which is undesirable.
Your help with find out a way to relocate the view to the desired location is much appreciated.
khsu

some sample code attached (with a quick hack in attempt to making it work, at least presentation-wise)
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
import javax.swing.text.*;
public class SplitViewFrame extends JFrame {
    int splitX = 100;
    int splitY = 100;
    public static void main(String[] args) {
        // Create application frame.
        SplitViewFrame frame = new SplitViewFrame();
        // Show frame
        frame.setVisible(true);
     * The constructor.
     public SplitViewFrame() {
        JMenuBar menuBar = new JMenuBar();
        JMenu menuFile = new JMenu();
        JMenuItem menuFileExit = new JMenuItem();
        menuFile.setLabel("File");
        menuFileExit.setLabel("Exit");
        // Add action listener.for the menu button
        menuFileExit.addActionListener
            new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    SplitViewFrame.this.windowClosed();
        menuFile.add(menuFileExit);
        menuBar.add(menuFile);
        setTitle("SplitView");
        setJMenuBar(menuBar);
        setSize(new Dimension(640, 480));
        // Add window listener.
        this.addWindowListener
            new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    SplitViewFrame.this.windowClosed();
        makeFreezePane();
    void makeFreezePane() {
        Container cp = getContentPane();
        Font font = new Font("monospaced", Font.PLAIN, 14);
        OffsetTextArea ta = new OffsetTextArea();
        ta.setSplit(splitX, splitY);
        ta.setOpaque(false);
        ta.setFont(font);
        // read doc
        readDocIntoTextArea(ta, "..\\afscheck.txt");
        JScrollPane jsp = new JScrollPane(ta);
        jsp.getViewport().setBackground(Color.white);
        Document doc = ta.getDocument();
        // dump doc
        //dumpDocument(doc);
        JViewport ulVP = makeViewport(doc, font, 0, 0, splitX, splitY);
        JViewport urVP = makeViewport(doc, font, splitX, 0, 20, splitY);
        JViewport llVP = makeViewport(doc, font, 0, splitY, splitX, 20);
        jsp.setRowHeader(llVP);
        jsp.setColumnHeader(urVP);
        jsp.setCorner(JScrollPane.UPPER_LEFT_CORNER, ulVP);
        jsp.setCorner(JScrollPane.UPPER_RIGHT_CORNER, new Corner());
        jsp.setCorner(JScrollPane.LOWER_LEFT_CORNER, new Corner());
        jsp.setCorner(JScrollPane.LOWER_RIGHT_CORNER, new Corner());
        cp.setLayout(new BorderLayout());
        cp.add(jsp, BorderLayout.CENTER);
    void readDocIntoTextArea(JTextArea ta, String filename) {
        try {
            File f = new File(filename);
            FileInputStream fis = new FileInputStream(f);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            int br = 0;
            byte[] buf = new byte[1024000];
            while ((br = fis.read(buf, 0, buf.length)) != -1) {
                baos.write(buf, 0, br);
            fis.close();
            ta.setText(baos.toString());
        } catch (Exception e) {
            e.printStackTrace();
            ta.setText("Failed to load text.");
    protected void windowClosed() {
        System.exit(0);
    JViewport makeViewport(Document doc, Font f, int splitX, int splitY, int width, int height) {
        JViewport vp = new JViewport();
        OffsetTextArea ta = new OffsetTextArea();
        ta.setSplit(splitX, splitY);
        ta.setDocument(doc);
        ta.setFont(f);
        ta.setBackground(Color.gray);
        vp.setView(ta);
        vp.setBackground(Color.gray);
        vp.setPreferredSize(new Dimension(width, height));
        return vp;
    static void dumpDocument(Document doc) {
        Element[] elms = doc.getRootElements();
        for (int i = 0; i < elms.length; i++) {
            dumpElement(elms, 0);
static void dumpElement(Element elm, int level) {
for (int i = 0; i < level; i++) System.out.print(" ");
System.out.print(elm.getName());
if ( elm.isLeaf() && elm.getName().equals("content")) {
try {
int s = elm.getStartOffset();
int e = elm.getEndOffset();
System.out.println(elm.getDocument().getText(
s, e-s));
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
return;
System.out.println();
for (int i = 0; i < elm.getElementCount(); i++) {
dumpElement(elm.getElement(i), level+1);
class OffsetTextArea extends JTextArea {
int splitX = 0;
int splitY = 0;
public void setSplit(int x, int y) {
splitX = x;
splitY = y;
public void paint(Graphics g) {
g.translate(-splitX, -splitY);
super.paint(g);
g.translate( splitX, splitY);
/* Corner.java is used by ScrollDemo.java. */
class Corner extends JComponent {
protected void paintComponent(Graphics g) {
// Fill me with dirty brown/orange.
g.setColor(new Color(230, 163, 4));
g.fillRect(0, 0, getWidth(), getHeight());

Similar Messages

  • Freeze Panes functionality for Web

    Hello,
    In Microsoft XL, we have freeze Panes functionality with which, columns and rows can be freezed. This is important in the situation where we have too many columns and when want to view last column, rows disappear and difficult to know which rows it is referring to.
    Now coming to question, I have BW reports which I am displaying on web browser. Can we freeze the panes on Web browser? Is there some standard functionality to do the same? Do we have some standard script for the same.
    Please do suggest.
    Regards
    Pank

    In BW 3.5 it is standard functionality using the properties of the TABLE Web Item namely...
    <b>Number of data columns displayed at one time (BLOCK_SIZE_COLUMNS)
    Columns scrolled per step (BLOCK_STEP_SIZE_COLUMNS)</b>
    Additionally the same is possible for setting the table size in rows...
    <b>Number of data rows displayed at one time (BLOCK_SIZE)
    Rows scrolled per step (BLOCK_STEP_SIZE)</b>
    for releases lower that BW 3.5
    lookup the how to document
    <b>How to… Change Page Scrolling in a Web Table Item</b>
    Hope that helps!
    Rishi

  • Freeze Panes Functionality

    I am required to develop a report that has a large number of columns. For readability the first 3 columns must remain frozen during horizontal scrolling (much like excel freeze panes).
    So far I have achieved this with two regions with different column sets from the same report displayed next to each other, This way I can make the right hand report region scroll (<div> tags in the Header & Footer of this region)while leaving the left hand report static.
    This leaves me with a problem where I need to link the pagination of both report regions. I am trying to change the SQL on the right hand report to only return the records displayed in the right hand region, my SQL for the right region Looks something like this but does not work:
    Select * from TABLE_NAME WHERE ID IN (:P3_LEFT_REGION)
    I believe it is because I am trying to reference a region as a list which I cannot do or am doing wrong.
    So my question is "Is there a better way to do this and how?"

    wow, it would cost your company so much less if your users can just download into Excel and do the fancy stuff there.
    Next they are going to ask you for more Excel-like functionality.

  • Freeze panes in OBIEE

    Hi Experts,
    I have a very big report (pivot table) and the column names for that report goes off the screen while scrolling down to see the bellow reports. Now the business requirement is can we freeze the column names similar to Excel?? Is there any work arrond and please suggest me some idea to try.
    Thanks,
    DK

    user,
    Refer :FREEZE PANE functionality in OBIEE  is it possible ???
    or http://blog.somerlott.net/2009/12/15/obiee-freeze-pane-headers/
    thanks,
    Saichand.v

  • Excel freeze panes on WEB APPLICATIONS

    Hi Experts,
    Does anybody know how to implement something like the "excel freeze panes functionality" (freeze columns headers on top of the pages) for web applications?
    We are using BW 7.0 (SAP Netweaver 2004s BI).
    Thanks in advance.
    Best regards,
    Raphael

    Hi Raphael,
       Did you check the Analysis Item Properties, you should be able to define how many Data Columns to be displayed, I dont have my system now but i think you can set a Web Property for this, or you can simply write javascript function for this
    thanks,
    Deepak
    SAP BI Consultant
    DNTech

  • Office Web Apps Server June 2013 Cumulative Update Excel Freeze Pane and Hide/Un-hide Feature Missing

    Hi,
    I have recently updated the Office Web Apps Server to the June 2013 Cumulative Update (KB2817350) which was published with the new features that allow rendering of freeze pane, hide/un-hide the excel worksheet and row/columns, Header
    Row Snapping, Sorting, Data Validation and Autocomplete. i have followed the TechNet article (http://technet.microsoft.com/en-us/library/jj966220.aspx)
    to update the office web apps server. Current setup is a SharePoint 2013, SQL 2012 and Office Web Apps server. All server are installed on Windows server 2012.
    3vild3vil

    Hi,
    Sorry to inform you that these new features are specific to cloud Excel Web App in both SkyDrive and Office365. There is no update available for on-premise Excel Web Apps installed locally
    yet. Thank you for your understanding.
    http://blogs.office.com/b/microsoft-excel/archive/2013/06/26/we-ve-updated-excel-web-app-what-s-new-as-of-june-2013.aspx
    Miles LI TechNet Community Support

  • Excel's Freeze Pane Property  in RTF template for XML Publisher Report

    Hi all,
    I have created RTF template and it's output type is Excel.
    I want to apply Freeze Pane Property of Excel in rtf template so that it can be applied to Excel Output.
    Please let me know any information regarding this.
    ta,
    P

    I am looking for the same functionality. Did you ever got answer for this?

  • Freeze panes in OBIEE 11g

    Hi All,
    Glad to post regarding Freezing panes in OBIEE 11g.
    Since this has got most hits in the search.
    I searched a quite few websites like replies from BI Joe and few others. But couldnt resolve this.
    Would be great help for all those who are looking for workaround regarding the same.
    Also - another feature likely in 11.1.1.6 - freeze panes for rows and columns :-). But need it in 11.1.5
    Regards
    MuRam
    http://obiee10grevisited.blogspot.in/
    Edited by: MuRam on Feb 29, 2012 10:23 AM

    check with oracle support. they might released patches for 11.1.5

  • Can pp col headings act like freeze pane in excel

    Hi.  We run 2012 enterprise.  Can co headings on my pivot table scroll as freeze pane does in regular excel?  How?

    Hi, your Situation is as follow?:
    You have a powerpivot model, and a pivot-table based on this PP data, created with Excel 2013
    Now you want the Pivot-table columns to freeze if you scroll down the Excel sheet?
    IMHO you can't do this because Excel has no Feature to freeze Pivot-table column, but can freeze columns of Excel table objects
    You can get PP data into a Excel table object by creating a DAX Query, see:
    http://www.sqlbi.com/articles/linkback-tables-in-powerpivot-for-excel-2013

  • How can I work out about Pan function?

    Hi,
    Can anybody help? my point is I don´t want my XY graph to have pan function.
    I mean the XY graph cannot pan neither running VI nor not running. If it´s impossible to do that two ways, just only when running VI that cannot pan the graph.
    Thanks in advance
    Mannie

    What you can do is edit the graph palette to hide the panning tool.
    Click on the graph
    LabVIEW menu >> Edit >> Customize Control
    In the new window, click on the left button in the tool menu (Change to Customize Mode). Sorry but my mothertongue is not English and I ignore the name of the illustrated tool.
    Select the panning tool in the graph palette
    Press Ctrl + Shift + J to move the panning tool to back (or click on the square with two arrows (Reorder) and select Move to Back)
    Move the panning tool under the zooming tool
    Resize the graph palette decoration
    Switch back to Edit Mode
    Menu >> File >> Apply Changes
    Close the customizing window
    You have now a graph with a customized graph palette. See the LabVIEW help for more details about customizing controls.
    Attachments:
    Graph without panning tool.ctl ‏9 KB

  • Review comments completely hidden by freeze panes in VBA Excel

    Hello
    I have a worksheet with review comments attached to the cell during run time. I use these
    review comments like tool tips to explain the user that the field is a mandatory field and it must be entered .
    I also used the Freeze Panes feature to keep the left side columns say (4 columns)  visible
    as the worksheet is scrolled horizontally. However, the review comments are visible when it is not scrolled but they are hidden under the frozen pane when the worksheet is scrolled horizontally.
    The review comment that overlaps the boundary is no longer visible when scrolled completely.
    Is there any way to prevent this from happening? Please suggest
    Thanks and Regards
    Kamal
    Kamal

    Hello Zhang
    Thanks very much for your response and suggestions
    I have tried increasing the width of the column D but still the review comments are getting hidden under the frozen panes. Dragging of comment window is not possible as these review comments are attached to the cell at run time. 
    Trying the data validation technique will not be a better choice. The reason is i am validating all the fields present in all the rows at once in a single button click  . Correct me if i am wrong...The reason is if the user doesn't enter the
    value for this column for at least (say 10 rows) then it might fire the validation pop up ten times.This will make the user to clear the validation pop ups first and then enter the values for all the left rows. If i add review comments then it will just add
    a red mark at the top right corner of the cell along with the review comments which will help the user to understand that it is a mandatory field.
    So, Please suggest a solution regarding how to handle the case related to the review comments that overlaps the boundary is not longer visible when scrolled completely.
    Thanks and Regards
    Kamal

  • What's equivalent to "Freeze Panes" in Excel?

    I've used Excel for years at work. Now I've not Numbers at home. I can't figure out how to "freeze panes" so, as I scroll down a page, the header row stays visible. Help?

    While Freeze Panes does not exist, Jason over on www.numberstemplates.com
    came up with this solution:
    http://www.numberstemplates.com/forums/showthread.php?t=20
    His demonstration consists of 3 tables. The third table is where the full spreadsheet exists. The second table is a "window" onto the third table. The first table is just two slider bars. As you slide the sliders, the second table adjusts what it is showing in the second table from the data in the third. This makes more sense once you try his example.
    If you are just looking at data, his solution works very well. If you need the freeze panes so that you know what column to input the data into, well, keep hitting that "Provide Numbers Feedback" button. until it appears.

  • Excel freeze panes

    Hi
    I'm using ActiveX to create an excel spreadsheet and fill it with data. Is it possible to use the excel freeze panes command from Labview and if so how ? I want to keep the column/row headings in sight so I was hoping to use freeze panes which I could setup straight after the wroksheet is created. Anyone got any ideas?
    Cheers
    Dave

    Dear Eli,
         You are posting a followup to discussions almost a decade old!  Consider starting a New Message and asking your own questions.  Among other changes since LabVIEW 7 is the Report Generation Toolkit has been vastly improved (it now uses Report Objects, very cool), making it possible to do a lot of things with Excel Workbooks without ever needing to use ActiveX (and it is pretty fast, as well).
    Bob Schor

  • Split Pane? Freeze Pane?

    Is there a Numbers equivalent to Excel's Split Pane and Freeze Pane commands? ... so, for example, the header row is always visible and scrolling happens to the rows below the header.

    rowster,
    Would you like to try the following? It's quicker to do than to write it all out, so don't be put off by my lengthy step-by-step instructions.
    In Numbers, deselect Show or Hide Print View at the extreme bottom of the window, to hide the Print View page boundaries. Create your blank spreadsheet Table either from scratch or using a Template, and after clicking on the Table to expose the Row and Column Reference Numbers and Letters, drag to the right the 'Handle' at the right hand end of the row of Column Reference Letters which lie along the top of the Table; drag to the right as far as you need to go to add sufficient columns for your needs; the table will scroll to the left if you go off the right hand edge of the window. Do the same to increase the number of Rows by dragging downwards the Handle below the bottom of the column of Row Reference Numbers which are shown down the left hand edge of the Table.
    Enter your data into the Table with any Formatting you require, and make sure you specify a Header and Footer Row and Column in the Table Inspector pane. To do this, select the Table by clicking on it, then click on the Inspector Icon on the Toolbar to open the Inspector pane, and select the Table Icon at the top of the pane. If you want to minimise the size of the Table, auto-adjust the width of the columns and the height of the rows to 'fit' these to the space required by each data. You can also consider reducing the View magnification if this doesn't reduce readability too much.
    With the Table selected, select your paper sheet size and orienatation (Portrait or Landscape) in the Document Inspector and Sheet Inspector panes respectively and also set whether you want successive pages to lie horizontally or vertically adjacent to each other, then click on the Table Icon in the Inspector pane. At the very bottom of the Table Inspector pane, make sure that 'Repeat header cells on each page' is checked.
    Now re-select Show or Hide Print View at the extreme bottom of the window; this will break up the window contents into individual pages corresponding to what you would get if you were to print them. Using the scroll bars at the side and bottom of the window, you can now scroll around the spreadsheet and as you move from one page to another, the Header and Footer Row and Column will always be visible on each page, allowing you to relate data in any cell to these.
    To me, this is the next best thing to Excel's Freeze Panes feature, and in some situations, I think it's preferable.
    The only feature omission is that whilst the row of Column Reference Letters is always visible on every page if the Table is 'selected' by clicking on it, the column of Row Reference Numbers is only visible on the left-most pages; I've used the 'Provide Numbers feedback' feature to request Apple to repeat the column of Row Reference numbers on every page alongside the left-hand Header column.
    Hope this helps,
    Ian Mathieson.
    U.K.

  • Freeze Pane in Oracle Apex3.2

    Hi,
    Please help me out to implement Freeze Pane in Oracle Apex 3.2
    Thanks,
    Dhanalakshmi.

    Hi,
    Just to be clear for you, create a new Report Template using the following settings:
    Before Rows:
    &lt;style type="text/css"&gt;
    #table1 th {white-space: nowrap}
    #table1 td {white-space: nowrap}
    #table2 th {white-space: nowrap}
    #table2 td {white-space: nowrap}
    &lt;/style&gt;
    &lt;table cellpadding="0" cellspacing="0" summary="" style="padding:0px; border-collapse:collapse;"&gt;#TOP_PAGINATION#
    &lt;tr&gt;&lt;td&gt;
      &lt;tr&gt;
        &lt;td style="vertical-align:top; background-color:#EFEFEF; padding:0px; border:1px solid darkgray;"&gt;
          &lt;div id="d1" style="background-color:white; margin:0px; border:0px; padding:0px;"&gt;
          &lt;/div&gt;
        &lt;/td&gt;
        &lt;td style="vertical-align:top; padding:0px; border:1px solid darkgray;"&gt;
          &lt;div id="d2" style="overflow-X:scroll; margin:0px; border:0px; padding:0px; border-right:1px solid darkgray;"&gt;
    &lt;table cellpadding="0" border="0" cellspacing="0" summary="" class="t18Standard" id="table2"&gt;Column Heading Template:
    &lt;th class="t18ReportHeader"#ALIGNMENT# id="#COLUMN_HEADER_NAME#"&gt;#COLUMN_HEADER#&lt;/th&gt;Before Each Row:
    &lt;tr #HIGHLIGHT_ROW#&gt;Column Template 1:
    &lt;td #ALIGNMENT# headers="#COLUMN_HEADER#" class="t18data"&gt;#COLUMN_VALUE#&lt;/td&gt;After Each Row:
    &lt;/tr&gt;After Rows:
          &lt;/div&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;&lt;div class="t18CVS"&gt;#EXTERNAL_LINK##CSV_LINK#&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;#PAGINATION#&lt;/table&gt;
    &lt;script type="text/javascript"&gt;
    var d1 = document.getElementById("d1");
    var t2 = document.getElementById("table2");
    var t1 = t2.cloneNode(false);
    t1.style.width = "100%";
    t1.id = "table1";
    d1.appendChild(t1);
    var t2Rows = t2.rows;
    var k;
    var r;
    var c;
    for (k = 0; k &lt; t2Rows.length; k++)
    r = document.createElement("TR");
    t1.appendChild(r);
    c = t2Rows[k].cells[0].cloneNode(true);
    r.appendChild(c);
    t2Rows[k].deleteCell(0);
    d1.innerHTML += "";
    &lt;/script&gt;Next Page Template:
    &lt;a href="#LINK#" class="t18pagination"&gt;#PAGINATION_NEXT# &gt;&lt;/a&gt;Previous Page Template:
    &lt;a href="#LINK#" class="t18pagination"&gt;&lt;#PAGINATION_PREVIOUS#&lt;/a&gt;Next Set Template:
    &lt;a href="#LINK#" class="t18pagination"&gt;#PAGINATION_NEXT_SET#&gt;&gt;&lt;/a&gt;Previous Set Template:
    &lt;a href="#LINK#" class="t18pagination"&gt;&lt;&lt;#PAGINATION_PREVIOUS_SET#&lt;/a&gt;Then update your report to include the following in the Region Header setting:
    &lt;style type="text/css"&gt;
    #d1 {width:175px;}
    #d2 {width:400px;}
    &lt;/style&gt;That is what is running on: http://apex.oracle.com/pls/otn/f?p=267:47
    Note that the above template is using Theme 18 - all "class" names are prefixed with "t18" - change this to your own theme (eg, if you are using Theme 12, change this to "t12" - or check with the Standard Report template for the "class" names you need)
    Andy

Maybe you are looking for

  • Add child to root (PL/SQL PARSER) Oracle 8.1.7

    Hi all, i have two dom documents, i need to add to the root of the first one a subtree of the second one. Could someone give me an example of how to do that ? Thanks.

  • AppleTV (6-11) and Macbook Pro. Will it work?- Airplay

    I just got an Apple TV. Can I play stuff on my MacBook Pro through the Apple TV? (Airplay) Or just via iTunes? I didn't see any quick way to do it, but say some third party application to do it? Do I need to buy something else? thanks mark

  • Copy data pages from one workspace to another in JDev 10.1.2

    Hi: I have a workspace-1 that has a model and viewcontroller projects. No, I created another wrokspace-2. I created the same model. When I tried to copy the data pages from workspace-1 to workspace-2, it didn't allow me. Can't this be done? Have I to

  • Search results displays title from the document and not from its metadata

    Hi All, I have an issue with SharePoint 2010 Search results. While searching for any content in SharePoint, it displays the title value from the keyword in the document and not from the metedata. Scenario:- I have a document library and a document na

  • Send for Review gives wrong folder permissions

    As per my last post , it looks like when a page is "Sent for Review" that the folder created by Contribute is not getting the proper permissions on my server. I have all of my folders set to be 775 and to inherit permissions from the parent folder, b