JTEXTAREA COLUMNS RESTRICTIONS

Hello,
I'd like to block a jTextArea and avoid users to introduce more than 5 characters .. how can i do it?
thanks

Hello,
Funny. I answered to a similar question today.
public class TestTextArea {
     public static void main(String[] args) {
          final JFrame frame = new JFrame("Test");
          frame.addWindowListener(new WindowAdapter() {
               public void windowClosing(WindowEvent e) {
                    System.exit(0);
          JTextArea textArea = new JTextArea(new SmallDocument());
          frame.setContentPane(textArea);
          frame.setSize(300, 300);
          SwingUtilities.invokeLater(new Runnable() {
               public void run() {
                    frame.show();
     private static class SmallDocument extends PlainDocument {
          public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
               if (offs >= 5) return;
               super.insertString(offs, str, a);
}There may be a much simplier solution but at least it does the trick.

Similar Messages

  • Summary column restricted by a condition

    I have a table that returns, lets say, 20 rows. I have created a summary item that gives a total for these 20 rows. Is there a way of creating a Summary item that would give me a total across these 20 rows based upon a certain condition?
    As its an amount, I could create a hidden formula column and create a summary column on this new column, but it 'seems' like a simple requirement to want to create conditional summary columns.
    Any ideas?
    Richard

    I have a table that returns, lets say, 20 rows. I have created a summary item that gives a total for these 20 rows. Is there a way of creating a Summary item that would give me a total across these 20 rows based upon a certain condition?
    As its an amount, I could create a hidden formula column and create a summary column on this new column, but it 'seems' like a simple requirement to want to create conditional summary columns.
    Any ideas?
    Richard

  • JTextField columns restrictions

    Hello,
    I'd like to block a jTextField and avoid users to introduce more than 5 characters .. how can i do it?
    I've used column attribute but it doesn't work.
    thanks

    Try this code
    import java.awt.Toolkit;
    import javax.swing.JTextField;
    import javax.swing.text.AttributeSet;
    import javax.swing.text.BadLocationException;
    import javax.swing.text.Document;
    import javax.swing.text.PlainDocument;
    * Limits the Number of Characters in the JTextField.
    public class MaxLengthTextField
        extends JTextField {
      private int maxLen;
       * Simple Constructor
       * @param maxLen Number of Charactes to Limit
      public MaxLengthTextField(int maxLen) {
        super();
        this.maxLen = maxLen;
      protected Document createDefaultModel() {
        return new MaxLenDocument();
      class MaxLenDocument
          extends PlainDocument {
        public void insertString(int offs, String str, AttributeSet a) throws
            BadLocationException {
          if (str == null) {
            return;
          if ( (getLength() + str.length()) <= maxLen) {
            super.insertString(offs, str, a);
          else {
            Toolkit.getDefaultToolkit().beep();
    }

  • OWB Number of Column level restriction

    Hi All,
    I'm Pradeep....beginner in OWB 9i. I have one to one direct mapping with source and target table(delinquency mapping with buckets) same.The table is having 836 columns. I am trying to execute that but its running endlessly...
    so my question to all..is
    1) Do we have any "number of column restriction" ?
    2) Are there any configuration apart for ROW based for performance tuning?
    Thanks in advance!
    Regds
    Pradeep:))

    Kindly reply....Desperately need the solution
    thanks in advance
    Pradeep

  • How do I can use more than 3 columns in Column Break in a report of APEX

    Hi,
    I have 2 tables which have linkage based on a PK and FK (1:N relationship). I want to create a report which will have 5 columns from Table1 and 2 columns from Table2. APEX only allow max 3 columns for break, but I want to hide duplicate values of all the 5 columns of Table1.
    Does someone has an idea "How can I do this?".
    Thanks
    Varinder

    Hi
    As a workaround, can you concatenate together some of the columns from Table1? For instance, instead of:
    select first_name, last_name, ...
    you could use:
    select first_name||' '||last_name full_name, ...
    to have fewer columns in order to fit into the 3-column restriction.
    Luis

  • Dynamic  Lead Columns / Data Columns

    Hi
    I want to use dyanmic data columns restricted by a characteristic relationship of another variable.
    When I use the characteristic as a lead column, it works perfect, I only see the rows for valid lines.
    When I use the characteristic as a data column, I see all possible characteristic values of that characteristics. The ones that are not valid are not ready for input, the ones that are valid are ready for input.
    I would like to use dynamic data columns but only display the columns with a valid characteristic relationships (just the way it works when I put the characteristic in the lead column)
    Should that work?
    Thanks

    Enable Zero-Suppression on your column structure. Then in your Query properties, enable zero-suppresion for columns. That way only characteristic values with data will be shown and not all possible characteristic values present in the master data tables. I should note that there should be some data in the fact table which links the keyfigure to the characteristic value, otherwise it will be suppressed.

  • BEx variables restricted value not shown

    Hello,
    I have 2 variables defined and used in a query. I put both these characteristics as global filters.
    When the query is run, a popup screen allows user to input these 2 variable values.
    The navigation block in the worksheet shows only 1 of the 2 variables values entered by the user. That is, only the restricted value for one variable is shown. The other is not shown. The result is, however, correct.
    Not sure why is it so. Hope to get some clues.
    Thanks.
    Regards,
    Mirella Russo

    Dear AVR,
    Thanks for the reply.
    I placed the period and year infoobjects restricted by their respective variables in the free characteristics area but still the filtered values are not showing, although the period and year characteristics for filtering are shown as normal in the navigation block.
    I have several other reports also using the same period and year variables in free char or global filter section without such 'anomaly'.
    I noted that this problem report has columns restricted also by period and year variables. In fact, the year variable is an offset of -1. Is the problem caused by this restriction?
    I tried creating a new query of the same design. The problem is replicated.
    I hope you can throw me some more clues.
    Appreciate it very much.
    Thank you.
    Best regards,
    Mirella Russo

  • Bex Query Multiprovider: restrict same characteristic for different Infoproviders

    HI SAP Guru's
    I have scenario here where the multiprovider is made up of 3 DSO .....i have a infoobject 0CRM_OBJ_ID(transaction Number) in two DSO and i want to display both values in separate rows as AMC Number and Service order Number in the query
    1.AMC Number(restricted to AMC infoprovider)
    2.Service Order Number(restricted to Service infoprovider)
    if it was a key figure i could have created a restriction in the kefigure structure by making a selection. but it characteristic and if  i create a structure in rows its throwing error infoobject 0NFOPROV is used in both structures of the query
    Please Suggest how to do it thanks

    You can go ahead with the workaround Arun has suggested.
    Create a new CKF--Under that formula variable--Create a new formula variable--Processing by replacement path--Reference char--0crm_obj_id.
    Hit the replacement path--Replace variable with--infoobject--replace with key--Hit the currency/unit tab--Choose number under dimensions.
    Now drag this ckf in columns--restrict with infoprovider.
    Hope this helps.
    Regards,
    AL

  • Customize "Tab" key for JTextArea to focus next component.

    Hi,
    I am trying to change the "TAB" key behaviour for JTextArea, by using CustomAction configured via InputMap() and ActionMap(). When the user presses the Tab key, the focus should go the next component instead of tabbing in the same JTextArea component. Here is the code for the CustomAction().
        public static class CustomTabAction extends AbstractAction {
            private JComponent comp;
            public CustomTabAction (JComponent comp) {
                this.comp = comp;
                this.comp.getInputMap().put(KeyStroke.getKeyStroke("TAB"), "TABPressed");
                this.comp.getActionMap().put("TABPressed", this);
            public void actionPerformed(ActionEvent evt) {
                Object source = evt.getSource();
                if (source instanceof Component) {
                    FocusManager.getCurrentKeyboardFocusManager().
                            focusNextComponent((Component) source);
        }This works for most of the cases in my applicaiton. The problem is that it doesn't work with JTable which has a custom cell editor (JTextArea). In JTextArea field of JTable, if the Tab is pressed, nothing happens and the cursor remains in the custom JTextArea exactly at the same place, without even tabbing spaces. Here is the CustomCellEditor code.
        public class DescColCellEditor extends AbstractCellEditor implements TableCellEditor {
    //prepare the component.
            JComponent comp = new JTextArea();
            public Component getTableCellEditorComponent(JTable table, Object value,
                    boolean isSelected, int rowIndex, int vColIndex) {
                // Configure Tab key to focus to next component
                CustomActions.setCustomAction("CustomTabAction", comp);
                // Configure the component with the specified value
                ((JTextArea)comp).setText((String)value);
                // Return the configured component
                return comp;
            // This method is called when editing is completed.
            // It must return the new value to be stored in the cell.
            public Object getCellEditorValue() {
                return ((JTextArea)comp).getText();
        }regards,
    nirvan

    >
    textArea.getInputMap().remove(....);but that won't work because the binding is actually defined in the parent InputMap. So I think you need to use code like:
    textArea.getInputMap().getParent().remove(...);But I'm not sure about this as I've never tried it.I tried removing the VK_TAB key from both the input map and parent input map as shown below. But I still have to press "TAB" twice in order to get out of the JTextArea column in JTable.
                comp.getInputMap().getParent().remove(
                            KeyStroke.getKeyStroke(KeyEvent.VK_TAB,0));
                comp.getInputMap().remove(
                            KeyStroke.getKeyStroke(KeyEvent.VK_TAB,0));after coding this, I am using the setFocusTraversalKeys for adding only "TAB" key as ForwardTraversalKey as given below.
            Set newForwardKeys = new HashSet();
            newForwardKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
            comp.setFocusTraversalKeys(
                        KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,newForwardKeys);
            Set newBackwardKeys = new HashSet();
            newBackwardKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_DOWN_MASK));
            comp.setFocusTraversalKeys(
                        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,newBackwardKeys);The only problem that remains now is that I have to press the "TAB" twice in order to get out of the JTextArea column
    regards,
    nirvan.

  • VPD Update policy at column level

    Hi,
    I have a table abc and I have applied a policy for update. Now the user who has no access is unable to update the table abc. Can I just restrict the user from updating a specific column ( user_id column in the table abc), rather than restricting the user from updating all columns?
    Thanks.

    hi,
    You can use sec_relevant_cols parameter of the DBMS_RLS.ADD_POLICY procedure
    begin
    dbms_rls.add_policy (
    object_schema => 'SCOTT',
    object_name => 'EMP',
    policy_name => 'VPD_TEST_POLICY',
    function_schema => 'SCOTT',
    policy_function => 'TEST_VPD',
    statement_types => 'select, insert, update, delete',
    sec_relevant_cols => 'sal,comm');
    end;
    you can see this doc
    http://www.in-oracle.com/Oracle-DBA/DBA-I/vpd-virtual-private-database.php
    or
    You can also use views to enforce column-level security, showing only which columns in a table may be updated. For example, assume that you must design roles based a table where only managers may view or update the salary column of the employee table (column restriction).
    1 - You can grant the end-user access to only those columns you wish to update:
    grant update (col1, col2) on mytab to fred;
    2 - You might create a view with only those columns that you want to allow updates, the table appears to the end-user as-if it contains only those columns. By granting access only to that view (and not the base table), you can effectively implement column-level security and restrict which columns in a table may be changed.
    regards,
    Edited by: dataseven on 04.Eki.2012 23:22

  • Characteristic in key column BPS

    Hi all,
    In my BW-BPS I created a layout with 0CALMONTH in key column restricted with variable and key figure 0SALES in data column.
    If for variable of 0CALMONTH I choose range from 01.2007 to 12.2007 in my layout I see only until 08.2007 that corresponding to actual data.
    I need to see also 09.2007 10.2007 11.2007 and 12.2007  beacause I must to plan in corrispondence of this month.
    How can I do for to see this month?
    Thanks a lot
    Gianmarco

    <FONT FACE = "Tahoma", Font Color = "Blue">
    Hi<br>
    Go to Change Mode of your Planning Layout. Expand the button for Additional Settings. If you have selected the Radiobutton <b>From Transaction Data</b> then change it to <b>All Possible Characteristic Combinations</b>. Save the layout and see if it works for you.
    <br><br>
    Hope it helps.<br>
    Cheers Abhijit</FONT><FONT FACE = "Verdana", Font Color = "Red">
    REMOVED
    </FONT>

  • JTextArea in JTable as cellrenderer

    Does anyone know how to use JTextArea to display/edit data in the JTable?
    Many thanks,
    Pippen

    I have just solved the problem by writting a cellerenderer and a celleditor on the JTextArea column of the JTable, disabling the "Enter" keystroke event on the table and enabling the "Enter/CR" event on the column alone to insert the break action. Good For you!
    The code is not so pretty but it works. A wise man who frequently posts in JDC forums once said something like this:
    any solution that works is a good solution
    BTW, if you have other workaround, pls also let me know.Thanks but no thanks...... I have written my own editors and renderers a long time ago. For a picture of my cell spanning editor, see link shown below:
    http://www.aokabc.com/help/TextPane.png
    ;o)
    V.V.

  • Reading Data From a Different Planning Package in a Exit Function

    Hi,
    Is it possible to read data from a planning level / package other than the package that the exit function was executed with?  I want to read data into an internal table from another package and use that data in combination with the data in the current package to create new records.  If this is possible sample code for how to read data from a different package would be appreciated.
    Thanks!
    Mel Waldner

    Hi,
    As an example lets say you have restricted 0calmonth in your package to 6.2007. In the planning layout to fetch values for 5.2007 (read only), you can take 0calmonth in data columns, and for this column restrict it as 5.2007.
    Similarly in Planning functions, you can mark 0calmonth as field to be changed and fetch data for 5.2007.
    Hope this helps.

  • Need help with this scenario....

    Hi, here I want the out amount to be calculated with the variable ranges..
    I attached the report output.
    I took doc.no and doc.date in column,
    restricted doc.date with current day ( date changed to  05.05.2006)
    2 variables as manual entry, 2 variables as customer exit.
    with those manual entry variables i calculated different dates for 2 customer exit variables using ABAP
    everything is going fine till here.
    when i drag amount in a selection n restrict it with range of customer exit variables in doc.date
    the output does not shows the value for the range
    its just show the output  for the particular date 
    dates
    05.05.2006
    05.04.2006
    i want the output to show the total sum of amount for 30 days (or the no. which user enters)

    Hi Praveen,
    i hope this is what your requirement(sample output as below):-
    Customer
    Amount(01.05.2006 - 05.05.2006)
    Amount(06.05.2006 - 10.05.2006)
    C1
    $100
    $500
    C2
    $200
    $700
    if so, can we do this way: on KF1, restrict the document date with user input variable 1
    and KF2 with user input variable 2.
    if user enters first user input variable as  01.05.2006 - 05.05.2006
    and the same way for the second one. in that case, no  need of further logic to determine the variable ranges.
    Let us know if this works?
    Regards,
    Sakthi.

  • Misalignement in Excel sheet,while downloading reports with huge data

    Hi,
    While downloading reports in excel with huge volume of data ,we are getting misalignments in the excel sheet(some data comes in wrong rows). Can you please suggest what could be the reason and how to correct it.
    Regards,
    Roopak

    Hi,
    If you are using Office 2003, then you cannot download morethan 65000+. However if you use Office 2007, I think it gives you somewhere around 400000 records. (I didnt scroll below that!!!). Also the columns are morethan IV.
    However assuming that, even that version can have limitation, you can always download your data in a wordpad/notepad/textpad etc which are basically text editing tools. They dont have any such row or column restrictions.
    Once downloaded, you can randomly split them into some x number of files, based on the number of records and then open the same documents using xls sheet using tab value as delimiter. Now the alignment will be perfect in the excel sheet.

Maybe you are looking for