JScrollPane + Component sizes before display

I was recently presented with a minor quandry.
I have a JPanel which needs to occupy a minimum fixed amount of real estate on my application's GUI, call it 'checkbox_jpanel'. The problem is that as the user operates the application, more and more checkboxes will be added to it. This works fine until I reach the size limit of the JPanel.
The obvious solution seemed to be to use a JScrollPane, and simply tuck the checkbox_jpanel inside of it. That way, I could dynamically resize the JPanel, and the JScrollPane could take care of displaying it.
Simple, until I realized that there's no good way to ask a layout manager how much space it had planned to let a given component take up, including buffer pixels. I can't even ask the component itself because, having not yet been drawn, it doesn't know how big it is either.
Currently, I'm able to get this strategy to work by guessing - eyeballing the number of pixels + space - each new checkbox takes up for the height * the number of items, and the width is based on the largest constant + (constant-intended-to-represent-average-character-width*letters in text portion of checkbox) among the set of checkboxes. I use that width and height to set the preferredSize of the JPanel i'm actually adding to.
I wince when I look at that code.
The comment above it says "This really needs to be done correctly."
How could I do this 'correctly' ?
The only thing I've been able to come up with is almost as ugly; make the checkbox_jpanel some insanely large size that will always encompass EVERYTHING, insuring that the checkboxes will be drawn, force/wait for the redraw, and then recalculate the width/height, and reset the panel to the desired (correct) width and height. I don't know if I could get this done without a bit of flickering, and really, everything about it screams 'non-optimal solution'.
Any thoughts?

Just an idea: the sizes become calculated when the components become visible OR when the application frame is packed... perhaps you could use a call to pack(), then do your job, then finally show your frame ?

Similar Messages

  • Hyperlinks in table component? Data processing before display?

    Hi all!
    I have following problem to solve - I have some database tables I need to show on a page. Creating a DataProvider and using it works really fine even with parameters in my query.
    But I have some columns with data that needs processing after fetching from data base (e.g. one colum has a value 20060925 with should be shown as date). Who can I do this - implementing my own data provider is the only thing I can think of.
    Second, I need one column in my table to be a hyperlink, changing column type will do, but sometimes I would like a simple text (when there are no details to link to). Any ideas for this one?
    Thanks in advance,
    Jan

    You can use the date time converter to display date. or then you can also use the sql function to format the date field before displaying...
    for example, If you are using an Oracle database, use the SQL Timestamp converter instead.

  • Implementing a graph scrolling using JScrollPane component

    I would like to ask a question apropos using of JScrollPane component. A part of the default behaviour of this component is adjusting the component's state when the size of the client changes. But, I need to achieve an opposite effect - I need to adjust a size of my client when the size of JScrollPane (and its viewport) changes (for instance, when the user resizes the frame).
    I implement a graph component which will show the graph of a time function. This component should always show nnn seconds without connection to the size of the scroll pane's viewport. So, if the the scroll pane component is resized I need to adjust the size of my client in order to keep the displayed time period unchanged.
    Now the question: how may I check the size of the viewport when the size of the JScrollPane changes? And whether I can do it even if the JScrollPane component has no client?
    If you know any other method of achieving the same effect, plese let me know.
    Thanks.

    I still find getExten\tSize (and getViewRect) work for me. Here's another demo.
    In my component, there's a big oval thats bounded by my component and a smaller
    oval that should track with the viewport's bounds.
    import java.awt.*;
    import javax.swing.*;
    public class ViewportLemonJuice extends JPanel {
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawOval(0, 0, getWidth(), getHeight());
            Container parent = (Container) getParent();
            if (parent instanceof JViewport) {
                Rectangle rect = ((JViewport) parent).getViewRect();
                g.drawOval(rect.x, rect.y, rect.width, rect.height);
        public static void main(String[] args) {
            JComponent comp = new ViewportLemonJuice();
            comp.setPreferredSize(new Dimension(800,800));
            JScrollPane sp = new JScrollPane(comp);
            sp.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
            JFrame f = new JFrame("ViewportLemonJuice");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(sp);
            f.setSize(500,300);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • How to check the file size before loading it to the context

    Hello,
    I have an application to upload a file and write it to the server using the FileUpload UI and IWDResource Interface.
    I would like to limit the size of the file the user is uploading to, say, 2MB.
    The problem is that the current API doesn't allow me to check the file size before I store it in IWDResource. The API available for IWDResource:
    IWDResource resource = ...
    InputStream stream = resource.read(false);
    size = stream.available();
    Is working on the file only AFTER storing it in the context and the server's memory. This way, if a user decides to upload 1GB file for example, he can easily crash the server.
    I am already familiar with <a href="https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a4d71">this</a> arcticle but it doesn't answer this question as well, all it does is calculating the file size only after storing it in the context.
    Any ideas...?
    Roy

    Hi Ram,
    Have you activated your Objects ?
    You need to activate your objects in order to see them in RWB.
    Thanks & Regards,
    Varun Joshi

  • How to Fill value in Input fields before displaying ADOBE FORM

    Hi to all,
    Please can anyone tell me how to fill the entry in ADOBE FORM before displaying?
    I have written a program to generate ADOBE FORM, but I need while displaying ADOBE FROM some input field should already be filled by value and can not be changed.
    Please can anyone tell me how to do that in program?
    Below is the program.
    DATA: fm_name           TYPE rs38l_fnam,
            fp_docparams      TYPE sfpdocparams,
            fp_outputparams   TYPE sfpoutputparams.
    Parameters: p_pdf_form_name type fname.
      fp_docparams-langu   = 'E'.
      fp_docparams-country = 'IN'.
      fp_outputparams-preview = 'X'.
      CALL FUNCTION 'FP_JOB_OPEN'
        CHANGING
          ie_outputparams = fp_outputparams
        EXCEPTIONS
          cancel          = 1
          usage_error     = 2
          system_error    = 3
          internal_error  = 4.
      CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
        EXPORTING
          i_name     = p_pdf_form_name
        IMPORTING
          e_funcname = fm_name.
      E_INTERFACE_TYPE           = E_INTERFACE_TYPE
      CALL FUNCTION fm_name
        EXPORTING
          /1bcdwb/docparams        = fp_docparams
      IMPORTING
        /1BCDWB/FORMOUTPUT       = fp_outputparams
        EXCEPTIONS
          usage_error           = 1
          system_error          = 2
          internal_error           = 3.
      CALL FUNCTION 'FP_JOB_CLOSE'
       IMPORTING
        E_RESULT             =
        EXCEPTIONS
          usage_error           = 1
          system_error          = 2
          internal_error        = 3
          OTHERS               = 4.
    I shall be thankful to you for this.
    Regards
    Pavneet Rana
    Edited by: pavneet rana on Jul 25, 2011 2:57 PM

    Hello,
    you need to provide the information via the interface, which you create for the Adobe form.
    And then pass this values via the following function module inside your generation report.
    CALL FUNCTION fm_name
    check standard report : FP_EXAMPLE_01 as an example!

  • RegionRenderer encodeAll The region component with id: pt1:r1 has detected a page fragment with multiple root components. Fragments with more than one root component may not display correctly in a region and may have a negative impact on performance.

    Hi,
    I am using JDEV 11.1.2.1.0
    I am getting the following error :-
    <RegionRenderer> <encodeAll> The region component with id: pt1:r1 has detected a page fragment with multiple root components. Fragments with more than one root component may not display correctly in a region and may have a negative impact on performance. It is recommended that you restructure the page fragment to have a single root component.
    Piece of code is for region is:-
       <f:facet name="second">
                                                <af:panelStretchLayout id="pa1"
                                                                       binding="#{backingBeanScope.Assign.pa1}">
                                                    <f:facet name="center">
                                                        <af:region value="#{bindings.tfdAssignGraph1.regionModel}" id="r1"
                                                                   binding="#{backingBeanScope.Assign.r1}"/>
                                                    </f:facet>
                                                </af:panelStretchLayout>
                                            </f:facet>
    How do I resolve it ?
    Thanks,

    Hi,
    I see at least 3 errors
    1. <RegionRenderer> <encodeAll> The region component with id: pt1:r1 has detected a page fragment with multiple root components.
    the page fragment should only have a single component under the jsp:root tag. If you see more than one, wrap them in e.g. an af:panelGroupLayout or af:group component
    2. SAPFunction.jspx/.xml" has an invalid character ".".
    check the document (you can open it in JDeveloper if the customization was a seeded one. Seems that editing this file smething has gone bad
    3. The expression "#{bindings..regionModel}" (that was specified for the RegionModel "value" attribute of the region component with id "pePanel") evaluated to null.
    "pageeditorpanel" does seem to be missing in the PageDef file of the page holding the region
    Frank

  • How do I change the size of display on my desktop?

    How do I change the size of display on my desktop?

    Where the apple sign  and than safsir  file  view history bookmards window help etc to make smaller

  • Get original component size in componentResized()

    Does anyone know how to get the original component size (i.e. the size prior to resizing) of a JComponent after the componentResized() method has been called. I need access to the original and the new component size in the componentResized() method. I am trying to avoid keeping and maintaining lots of arrays of component sizes on the basis I might need a component's size if it changes.

    This JPanel is managed by GroupLayout and all components in it have preferred sizes. All the layout for this JPanel is managed by the layout. I need the original component size (and new size) in the event handler method componentResized() because any component can be resized and the change in size affects other JPanels.
    Does anyone know if it is possible to get the original component's size from the componentResized() method and if so, how.

  • I have finished my iBook but want to change the size before ordering. Is it possible

    Finished book.  Can the size be changed before placing order?

    Sure - what version of iPhoto? Ad is OS X 10.4.8 as you state correct?
    Assuming it is not and you have iPhoto '11 then you simple select the book and duplicate it (Command D), open the copy and click on "change theme" and select the same theme and the new size -
    Before ordering your book preview it using this method - http://support.apple.com/kb/HT1040 - and save the resulting PDF for reference - the delivered book will match it.
    the preview is critical since with a new size text may reflow
    LN

  • MWA: Issue while capturing the values entered, before displaying the LOV

    I have created a LOV in Mobile Web Application using PL/SQL procedure.
    I'm not able to get the values entered by the user before displaying the List of values.
    I need the values entered to pass it to the query.
    There might be a seeded event or method to capture these values.
    Any help would be appreciated.
    Thanks,

    Before invoking Input task, I have created a transformation to initailize the payload elements, so that in the UI these field elements will be become editable.
    I have an ADF table which is used to insert account details elements which is initialized in the transformation with namespace.You can simple use a ADF form to do this. Create ADF editable input fields in a panelFormLayout and wehn user enters values and clicks ona button .. pass those values to BPM payload.
    See - http://andrejusb.blogspot.com/2010/10/initializing-oracle-bpm-11g-process.html

  • "Filter Before Display" Erroring out in ARXRWRCT.fmb

    Hi All,
    We had a performance issue with the Reciepts screen in AR Superuser responsibility and according to the metalink note 418873.1, we made changes to the form ARXRWRCT.fmd. The change is given below:
    ON-SITE Fix instructions: ARXRWRCT.fmb
    1.Open the form.
    2.Navigate to LOV's.
    3.Select the LOV "RGW_BILLING_NUMBER". Open up the property palette. Change the property "filter before
    display" from "NO" to "YES".
    4.Save the changes, compile the form ARXRWRCT.fmb and ARXRWMAI.fmb to pickup these changes. Test the issue.
    Now, when we compile the above mentioned forms after making changes, we are encountering the below errors.
    For Form ARXRWRCT
    FRM-30048: Unable to find record group .
    LOV RGW_EXCHANGE_RATE_TYPE
    Form: ARXRWRCT
    FRM-30085: Unable to adjust form for output.
    For Form ARXRWMAI
    FRM-30048: Unable to find record group .
    LOV RGW_EXCHANGE_RATE_TYPE
    Form: ARXRWMAI
    FRM-30085: Unable to adjust form for output.
    I have tried copying all the standard libraries and referencing them, but it did not help.
    Any help in this regard is appreciated.
    Jithin

    We never figured this out and are waiting for the EBS upgrade to fix this. hence closing this thread.
    Thanks,
    Jithin

  • How can read BOM component date before save the production order??

    Hi Experts,
    In our company, we need to develop a program to read the BOM component data of the production order
    before we save the production order.
    That for example ,when we create and release a production order , before we save the production
    order,we want a porgram to read the BOM component data. If some component data can meet our
    requriement (may be if there is material requirement quantity>100 EA),then the system will pop up a
    small dialog box to remind us.
    There is user exit PPCO0007 and PPCO0007.But it seems they only can read the head data of the
    production order before we save the production order. And the BOM component data of the production
    order are saved in the RESB(Reservation Table).So if we do not save the production order,all the BOM
    component data are not saved in the RESB table.
    So how can slove the problem??
    How can read component date before save the production order??
    Are there any other user exit we can use???

    Hi Just wanted to check am I right that you are trying to check if you have enough Materials Available before you release or Save the order right ? if this is your business objective then when you create order you have material availability tab which checks and gives error if shortage is there. Please let me know if is this wht you asking for ?

  • Hiding few columns before displaying alv grid output

    Hi All,
    I struck up at hiding few columns before displaying alv output. I have used used FM: REUSE_ALV_GRID_DISPLAY. By using this i am displaying 29 fields to the output. But before displaying the output i want to hide few columns among them, and also those fields have to be avialable for further selection by the user by using layout.
    Kindly help me in this,
    Regards
    Srinivas K

    Hi,
    In field catalog set NO_OUT='X' for all the columns you want to hide. They will be available when changing layout for ALV, so you can show them at any time.
    Regards
    Marcin

  • Auto Query in Before Display Page Section

    The following code is querying master and detail blocks automatically in before display page section. It was working fine. But now I don't know why it doesn't work any more. Does any one know what's the problem?
    declare
    l_fs varchar2(4000);
    l_s varchar2(4000);
    L_user varchar2(4000);
    begin
    l_fs := p_session.get_value_as_varchar2(p_block_name => 'MASTER_BLOCK',
    p_attribute_name => '_FORM_STATE');
    l_s := p_session.get_value_as_varchar2(p_block_name => 'MASTER_BLOCK',
    p_attribute_name => '_STATUS');
    L_user := portal30.wwctx_api.get_user;
    if l_fs = 'QUERY_AND_SAVE' and l_s is null then
    p_session.set_shadow_value(p_block_name => 'MASTER_BLOCK',
    p_attribute_name => 'A_E_MAIL_ID',
    p_value => L_user,
    p_language => portal30.wwctx_api.get_nls_language
    WWV_MASTER_GENSYS_1(p_block_name => p_block_name,
    p_object_name => p_object_name,
    p_instance => p_instance,
    p_event_type => p_event_type,
    p_user_args => p_user_args,
    p_session => p_session);
    p_session.save_session;
    htp.p('<script>window.location.reload();</script>');
    end if;
    end;

    Hi,
    To query records before displaying and to refresh the page, you can call the same form (by using the code given below)with necessary parameters from ..before displaying page..section of your form.
    declare
    l_fs varchar2(4000);
    l_s varchar2(4000);
    L_user varchar2(4000);
    begin
    l_fs := p_session.get_value_as_varchar2(p_block_name => 'MASTER_BLOCK',
    p_attribute_name => '_FORM_STATE');
    l_s := p_session.get_value_as_varchar2(p_block_name => 'MASTER_BLOCK',
    p_attribute_name => '_STATUS');
    L_user := 'PPP';
    if l_fs = 'QUERY_AND_SAVE' and l_s is null then
    htp.p('<SCRIPT LANGUAGE="JavaScript">
    window.location.href = "PORTAL30.wwa_app_module.link?p_arg_names=_moduleid&p_arg_values=<MODULE ID>&p_arg_names=_show_header&p_arg_values=YES&p_arg_names=E_MAIL_ID&p_arg_values='||l_user||'&p_arg_names=_E_MAIL_ID_COND&p_arg_values=%3D";
    </script>');
    end if;
    end;
    Replace <MODULE ID< with the module id of your master detail form.
    Hope this helps!..
    -Krishnamurthy

  • ADF/Swing: changing iterator in runtime before displaying panel

    Is it possible ,before displaying panel, to change iterator name that was specified in design time and is placed in panel.pageDef xml file and this way display panel with different iterator than is in panel.pageDef file? If yes, is it posible display this way many panels in the same time?

    Hi,
    the iterator is referenced by the attribute binding. If you look at the Swing code then you see that the Swing widgets reference a named attribute binding in their model binding. To change the iterator you would need to access the ADF binding layer and change it there. which I haven't tried.
    The attribute binding references an iterator as a named reference, which means that changing the physical implementation - in theory - works if the same set of attributes are available.
    Frank

Maybe you are looking for

  • Inserting JAPANESE characters in a database

    Can somebody please let me know how to insert the JAPANESE (Kanji) Characters into the Database. Database Version: Oracle 9.2.0.1.0 Paremeters Setting: NLS_CHARACTERSET - UTF8 NLS_NCHAR_CHARACTERSET - UTF8 Server OS: Win2K Client OS: Win2K

  • Is there 1 Glossary file with all terms & def's?

    I have created a complete glossary list in RH7 for my project. One of my teammates would like to use the same glossary terms because the RH project he is working on is very similar to mine. Is there a way to grab a copy of the glossary terms and defi

  • Windows can compile phonegap iOS apps in dw cs6

    ONCE I DOWNLOAD IN MY ANDROID PHONE AN APP FROM DW CS6-PHONEGAP VIA QR SCANNER, where saved the App downloaded? 2.3.6 Android... windows can compile phonegap iOS apps in dw cs6 on WINDOWS? to make win phone 7 or 8 Apps can I from dw cs6 or needed pho

  • SAPscript Prgram/Form Example

    Hi I'm new to sapscript. so please bear with me. When using SAPscript one has a program that gets all the data, then a form is created on top of it. I would like to know the following on the program. 1) The ABAP program will retrieve the data, is the

  • Creating A/R Reserve Invoice through DI API

    Hello everyone, I am trying to create a A/R Reserve invoice through DI API, for that i have to set invoice documnet property is: oInvoice.WareHouseUpdateType = SAPbobsCOM.BoDocWhsUpdateTypes.dwh_CustomerOrders; but it throws a exception - The object