JTable row background change - based on EXTERNAL event

Greetings folks!
I'm hoping for some help with a JTable issue. Here's the scenario:
The app is a point of sale application. The user scans or manually adds an item to the order, which causes a row to appear in the JTable displaying description, price, quantity, etc. The user can then right click a row on the JTable and select an option from the popup menu. If the user selects one of the options, I want to be able to change the background color on that row.
EVERYTHING I've seen online and researching is based on adding a custom renderer to the jtable which changes the background based on the data in the row. In my case there isn't anything in the row which changes... hence the point of changing the color.
What I'm looking for is a method which will let me change the background of row x. I'm guessing there isn't a way. I'm hoping someone has a suggestion.
Thanks in advance,
John E.
PS: I'm fairly new to java and working with inherited code, so please no 'you need to redesign the world' type answers unless there's an easier way. :)

In my case there isn't anything in the row which changesThen how is the table going to know what color to paint the row? Remember painting the row is a dynamic process. You can't just paint it once. You need the ability to repaint the row if for example the table is scrolled and the row is now longer present. Then when the table scrolls again and the row is present you need to be able to repaint the row in your specified color. This means you need some way to tell the table what color the row should be. Which means you need to keep that information somewhere.
One way to do this is to store the data in the TableModel that indicates that this row should be painted a "different" color. Then your situation is like the examples you have found. You now have some data you can test. This column does not need to be visible in the table since you can remove the TableColumn from the TableColumnModel so the column is not painted.
Here is a simple posting that shows a better approach to painting row backgrounds withouth using a renderer:
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=610474

Similar Messages

  • BACKGROUND  SCHEDULING  based on a event

    Hi,
        I need to execute my program in background ..  based on an event..for example.. here i want to execute   RBDMIDOC program  based on  when ever i change the master data ..
      i created a varient in SE38.. and i enetred into SM37  and  here  what i need to select .. for based on  an event..
    thanks
    Babu

    You can use worfklows to achieve this.
    For more infor check the faq in the Workflow forum, or ask your local workflow expert.
    basically you must first find out which event is triggered, you can find this out with the event trace (SWELS and SWEL) then you must create a workflowtemplate which is triggered by that event and which will schedule the backgournd job. Next you must link the event to the workflowtemplate, either in pftc , tab event, or transaction SWE2.
    ALternatively you can use transaction SWEINST to place a check function module on the event Business object instance. In that FM you can also schedule the job. This is a bit easier than creating a worklfow.
    Kind regards, Rob Dielemans

  • Report row color change based on condition

    I have follow this forum steps Re: Color Row In Report
    Column Template 1
    <td #ALIGNMENT# class="t1data" style="background-color:#ADD8E6;">#COLUMN_VALUE#</td>
    PL/SQL expression condition
    '#2#' = 'BOOKED'
    Column Template 2
    <td #ALIGNMENT# class="t2data" style="background-color:#FFE87C;">#COLUMN_VALUE#</td>
    PL/SQL expression condition
    '#2#' = 'ENTERED'
    http://img29.imageshack.us/img29/2792/apexcolor.png
    This does color change but for some rows the colors are highlighted wrong and when i mouse over the rows , it changes to wrong color.

    Hi,
    t1Data and t2Data sound like standard theme css class names.
    In my example, the colouring is done by the style attribute on the TD tag. For "normal" rows:
    &lt;td #ALIGNMENT# headers="#COLUMN_HEADER#" class="t18data"&gt;#COLUMN_VALUE#&lt;/td&gt;for highlighted rows:
    &lt;td #ALIGNMENT# headers="#COLUMN_HEADER#" class="t18data" style="background-color:red;"&gt;#COLUMN_VALUE#&lt;/td&gt;Have you defined "t1Data" and "t2Data" in STYLE tags on your page?
    Andy

  • A Listener For JTable Row Selection Changed?

    Never mind... Thought of a couple other things after I posted and found ListSelectionListener. This looks like it fulfills my requirement nicely. - cimmerian76
    >>>
    TableModelListener isn't what I am looking for here. Basically, I'm looking for something that behaves in a way that is analogous to
    TreeSelectionListener's valueChanged(...). Perhaps I'm looking in the wrong places, but the only things I've found were RowSet listener (not even close)
    and TableModelListener (not exactly what I'm looking for - I'm not concerned about data in the table changing).
    The tool I'm writing displays additional information about the object in the row selected in an adjacent panel.
    This display should change every time a user selects a different row.
    I can mimic the behavior I want using a mouse listener on the table, so this isn't an emergency.
    It's more about curiosity. If I can find something that produces this functionality directly, I would prefer to use that.
    <<<
    Message was edited by:
    cimmerian76

    Hi,
    you can use this to handle selection events for the table:
    yourTable.getSelectionModel().addListSelectionListener(... );
    Now e.g. the class containing your main can implement interface ListSelectionListener.

  • How to set JTable row background color

    Hello,
    I have seen JTable with rows having alternate background color (mostly white and light blue). How can i set the same.
    Thanks,
    Deepak

    Well, i am new user to forum and so have no idea if this question has been asked previously "countless" times.Which is why you "search first" and "ask later". How to you expect to find out what valuable information is in the forum without learning how to do a simple search. This goes for any forum on the web you might use, so don't use the "I'm a new user" excuse.

  • Schedule Brio/IR Reports to Trigger Based on External Events

    Hi all, we have a new request to trigger reports to run when a) the database refresh is completed or b) other reports have completed. We have both Brio V8 and Hyperion 9 BI+ platforms.
    I've thoroughly investigate 'external trigger' but it appears these are not completely automated (require user intervention).
    Can anyone share solutions / workarounds ? Appreciate your expertise and help in brainstorming!
    Thanks.

    Hi,
    The file base event looks for the specific file on specific location, if the file already exist it will not trigger. You must remove the file before the event server start looking for the file. BO event server does not look at the time/date when the files created it only check for the file name. You can create a program in BO which can trigger after the successful running of the report and delete the event file.
    In Business Objects the only components do not have fail over capability is the Event server, if you have distributed environment, the events will not fail over to another server.
    I Hope this helps.
    Thanks,
    Muhammad

  • Af:table: defining row background color based on a condition

    I want to display log objects (priority, name, detail) in a tab.
    The background color must be green for priority "DEBUG" and red for priority "WARN".
    It seems that in the table component, we can only control the column aspect and the output text inside...
    I'have read some posts (Franck N.) and it seems not possible to have an action of the row (all columns) background color...
    What can be the workarround ? other <af:?> component ???
    Is it now possible with the new JDEV11 components ?
    <af:table partialTriggers="pollRefresh" emptyText="No items were found"
    value="#{backing_logviewer.logViewerList}" var="log"
    rows="50">
    <f:facet name="detailStamp"/>
    <af:column sortable="true" headerText="Prio" formatType="text"
    sortProperty="prio">
    <af:outputText value="#{log.prio}"/>
    </af:column>
    <af:column sortable="true" headerText="Cat" formatType="text"
    sortProperty="cat">
    <af:outputText value="#{log.cat}"/>
    </af:column>
    <af:column sortable="false" headerText="Msg" formatType="text">
    <af:outputText value="#{log.msg}"/>
    </af:column>
    <af:column sortable="false" headerText="Thread" formatType="text">
    <af:outputText value="#{log.thread}"/>
    </af:column>
    <af:column sortable="false" headerText="Info" formatType="text">
    <af:outputText value="#{log.info}"/>
    </af:column>
    <af:column sortable="false" headerText="Log Date" formatType="text">
    <af:outputText value="#{log.logDate}" converter="dateConverter"/>
    </af:column>
    <af:column sortable="false" headerText="Throwable"
    formatType="text">
    <af:outputText value="#{log.throwable}"/>
    </af:column>
    </af:table>

    Thanks for your answer.
    Your solution is not working but if i put the styleclass instruction in the outputText element, it is working...
    Is there any other solution ???... because in this solution, we are obliged to put this EL in each outputText element of the tab.
    <af:column sortable="true" headerText="Cat" formatType="text"
    sortProperty="cat">
    <af:outputText value="#{log.cat}" styleClass="#{(log.prio == 'DEBUG') ? 'bgDebug' : (log.prio == 'WARN' ? 'bgWarn' : '')}"/> </af:column>

  • Row background color in dataTable control based on criteria

    It is relatively straightforward to give a pattern of color to rows in a dataTable control, for instance to alternate colors from white to gray.
    However, I have not yet figured how the row background color could be decided based on data fields associated with each row. For instance, I would like to set the row background color based on the value of a boolean attribute associated with the row, e.g. white if value is false and gray if it is true.
    Is there an easy way to do this?
    Martin

    of the text, but not the whole cell. I need to find a
    way to change the span at the row level (on the <tr>
    tag). ANy ways to do this?
    MartinThis is a question of how to let the renderer adjust its behaviour depending on the current state of the model. My renderer changes the background for the selected row by changing the style class:
            writer.startElement("tr", table);
              if (table.getRowSelector())
                   if (table.isAtSelectedRow())
                        writer.writeAttribute("class", "selectedRow", null);
    etc.(of course, to be able to do this you must write your own renderer)
    erik

  • Process flow for the Mid-year Status Changes based upon the Qualifying Even

    Hi Experts,
    I'm looking some information for the process flow for the Mid-year Status Changes based upon the Qualifying Events. Basically, I need to know, what would be the impact of these changes on various info types (Via IT0014 - Deduction changes & so forth) and the things that needs to be considered during it's Configuration and the things that needs to be checked due to the occurrence of the change. I would greatly appreciate any kind of help/document.
    Thanks a bunch in advance,
    Thanks,
    Exertive.

    Hello guys,
    Can anyone has any kind of input on this? Basically, I need to know the procees for Mid-year status changes based upon Qualified events. Any kind of help is greatly appreciated.
    Thanks,
    Exertive.

  • Class Changing Based on Spry:if Complex Dates

    I know this can be done in concept, because I've done it
    before, I just don't know how to approach in Spry.
    I have a dynamic table that shows is sorted by date. I am
    trying to have the class of each row dynamically change based on
    the difference in days between the date and today.
    For instance:
    If the date is more than 10 in the past, the rows style is
    "redFlag"
    If the date is more than 6 days but less than 10, the rows
    style is "YellowFlag"
    I can do this in PHP, but how would i do this using spry?
    Thanks

    I have found what I was looking to do.
    http://labs.adobe.com/technologies/spry/samples/data_region/Function_colon.html
    This allows the externalization of logic - EXACTLY what I
    need. This is a huge breakthrough for me, as this will help
    tremendously

  • Change Column Header / Column Background color based on a value in a specific row in the same column

    SSRS 2012
    Dataset (40 columns) including the first 3 rows for Report layout configuration (eg: the <second> row specifies the column background color).
    Starting from the 4th row, the dataset contains data to be displayed.
    I would like to change the background color of the ColumnHeader/Column based on the value in the same column in the <second> row.
    How can I accomplish the this requirement? (this must be applied for all the columns)
    Thanks

    Hi Fasttrck2,
    Per my understanding that you want to specify the background color of all the columns/column header based on the value in one special column of the special row, right?
    I have tested on my local environment and you can add expression to condition show the background color in the columns properties or the column header properties.
    Details information below for your reference:
    Specify the background color in the Column header: you can select the entire column header row and in the properties add expression in the Background color :
    If you want to specify the background color for the entire column, you can select the entire column and add the expression, repeat to add background color for other columns.
    If you want to specify the background color based on the value in the specific columns and row, you can create an hidden parameter to get the list of values from the  specific column, specify the Available values and default values by select "Get
    values from a query", finally using the expression as below to get the specific value you want:
    Expression(Backgroud Color):
    =IIF(Parameters!Para.Value(1)="1221","red","yellow")
    If your problem still exists, please try to provide some smaple data of the report and also the snapshot of the report structure to help us more effective to provide an solution.
    Any problem, please feel free to ask.
    Regards
    Vicky Liu
    If you have any feedback on our support, please click
    here.
    Vicky Liu
    TechNet Community Support

  • How to schedule a background Job based on events

    Hi,
    We are on 4.6 C.
    We have a background job that has two ABAP programs.
    We need to start the 2nd ABAP program only after the first one has run successfully.
    If the second ABAP program does not run, the the job should have a status "FINISHED".
    Help appreciated.
    Thanks
    Mala

    Hi,
    How to schedule a background Job based on events,please refer to the follow SAP help:
    You can use events that have already been defined, or you can create new events for scheduling background jobs.
    If you wish to use new events, do the following to implement the event scheduling:
    Define and transport the event as a user event with transaction SM62.
    You must define only event IDs; event arguments are not defined in the R/3 System. Instead, you specify event arguments when you schedule a job to wait for an event and when you trigger the event.
    If you define a new event, you must also transport it to your production systems. The event transaction does not have a connection to the transport system. Instead, you must create a transport request for the event yourself.
    Do this to transport an event:
    Create a transport request.
    Start the editor in the transport request and enter the following:
    R3TR TABU <table name> where table name is BTCSEV for a system event ID, BTCUEV for a user event ID.
    Press F2 with the cursor on the table name to call up the screen for specifying the table entries to transport. In this screen, enter the event ID’s that you have created.
    Save and release the transport request. Ensure that it is imported into your production system(s).
    To trigger an event, add:
    – the function module BP_EVENT_RAISE to your ABAP program, or
    – the program SAPEVT to your external script, batch file, or program.
    When your programs execute these keywords, an event will be triggered in the R/3 background processing system. The event-based scheduler is started immediately. It in turn starts all jobs that were waiting upon the event, subject to normal background processing restrictions, such as the requirement that the job has been released to start.
    Schedule the jobs that are to run when your events are triggered.
    You can schedule jobs for one-time start or to be started whenever an event is triggered.
    Regards,
    collysun

  • ADF Table row background color change ???

    Hi All
    i got below sql view object
    SELECT DEPARTMENT_ID,JOB_ID,COUNT(*) FROM EMPLOYEES GROUP BY DEPARTMENT_ID,ROLLUP(JOB_ID)
    By using this i will get each department_id, jobid's and total employes count in each department
    and i will get rollup for each departments ie i will get total employees.
    So i want to change the back ground of the total row.
    DepartmentId     JobId     Count1
    SA_REP 1
    1
    10     AD_ASST     1
    10     1 < this row in RED back ground in JSF page
    20     MK_MAN     1
    20     MK_REP     1
    20     2 < this row in RED back ground in JSF page
    30     PU_MAN     1
    30     PU_CLERK     5
    30     6< this row in RED back ground in JSF page
    40     HR_REP     1
    40     1< this row in RED back ground in JSF page
    50     ST_MAN     5
    50     SH_CLERK     20
    50     ST_CLERK     20
    50     45< this row in RED back ground in JSF page
    any kind of help is welcome...
    thanks
    Ravi

    Hi,
    you can do this by setting the background color of the outputText component that is the cell component e.g. in a read only table. Use the inlineStyle property to set the background-color but get the string from a managed bean. For each row you get a call to the managed bean and you can use JSF value binding
    FacesContext.getCurrentInstance().getApplication().createValueBinding()
    to access #{row} so that you can determine the value of a row column. Based on this you return a color
    Frank

  • Jtable on cell changed event

    How can i treat an Jtable on cell changed event, not on value changed

    Do you mean cell selection changed? One way is to add a ListSelectionListener to both the table's and the table's ColumnModel's ListSelectionModels. Something likeListSelectionListener lsl = new ListSelectionListener() {
       public void valueChanged(ListSelectionEvent e) {
          System.out.println(e.getSource());
          ListSelectionModel lsm = (ListSelectionModel) e.getSource();
          if (!lsm.getValueIsAdjusting()) {
             System.out.println("Selection changed");
    table.getSelectionModel().addListSelectionListener(lsl);
    table.getColumnModel().getSelectionModel().addListSelectionListener(lsl);Note that simultaneous change of both row and column will generate two valueChanged events.
    If that's not what you wanted to know, ask a better question.
    [http://catb.org/~esr/faqs/smart-questions.html]
    db

  • Is it possible to have the background colour of a field change based on the entry?

    I previously obtained help from a user here to create a script that autopopulates a field based on options selected in two sets of radio buttons:
    var consequence = this.getField("Consequence").valueAsString; 
    var likelihood = this.getField("Likelihood").valueAsString; 
    if (consequence=="Insignificant" && likelihood=="Rare") event.value = "Low"; 
    else if (consequence=="Insignificant" && likelihood=="Unlikely") event.value = "Low";
    else if (consequence=="Insignificant" && likelihood=="Moderate") event.value = "Low";
    else if (consequence=="Insignificant" && likelihood=="Likely") event.value = "Low";
    else if (consequence=="Insignificant" && likelihood=="Almost Certain") event.value = "Moderate"; 
    else if (consequence=="Minor" && likelihood=="Rare") event.value = "Low"; 
    else if (consequence=="Minor" && likelihood=="Unlikely") event.value = "Low";
    else if (consequence=="Minor" && likelihood=="Moderate") event.value = "Moderate";
    else if (consequence=="Minor" && likelihood=="Likely") event.value = "Moderate";
    else if (consequence=="Minor" && likelihood=="Almost Certain") event.value = "High"; 
    else if (consequence=="Moderate" && likelihood=="Rare") event.value = "Low"; 
    else if (consequence=="Moderate" && likelihood=="Unlikely") event.value = "Moderate";
    else if (consequence=="Moderate" && likelihood=="Moderate") event.value = "High";
    else if (consequence=="Moderate" && likelihood=="Likely") event.value = "High";
    else if (consequence=="Moderate" && likelihood=="Almost Certain") event.value = "Critical"; 
    else if (consequence=="Major" && likelihood=="Rare") event.value = "Low"; 
    else if (consequence=="Major" && likelihood=="Unlikely") event.value = "Moderate";
    else if (consequence=="Major" && likelihood=="Moderate") event.value = "High";
    else if (consequence=="Major" && likelihood=="Likely") event.value = "Critical";
    else if (consequence=="Major" && likelihood=="Almost Certain") event.value = "Extreme"; 
    else if (consequence=="Catastrophic" && likelihood=="Rare") event.value = "Moderate"; 
    else if (consequence=="Catastrophic" && likelihood=="Unlikely") event.value = "High";
    else if (consequence=="Catastrophic" && likelihood=="Moderate") event.value = "Critical";
    else if (consequence=="Catastrophic" && likelihood=="Likely") event.value = "Extreme";
    else if (consequence=="Catastrophic" && likelihood=="Almost Certain") event.value = "Extreme";
    // etc. 
    else event.value = ""; 
    I'm wondering if its possible to have the colour of the field that uses the above script, change based on the entry. E.g. If the answer is Low; make the background colour Green; if its Moderate, make it orange etc.?
    I know its a big ask but thought I would check.
    Thanks in advance.

    One approach would be to have access to a Mac that can run the classic environment or has a pre OS X native installation. These should be able to read the files for dates of creation/modification. There is also SheepShaver that runs on OS X machines.
    https://www.macupdate.com/app/mac/20615/sheepshaver
    http://en.wikipedia.org/wiki/Classic_Environment
    http://www.everymac.com/systems/by_capability/macs-that-support-macos-9-classic. html
    https://discussions.apple.com/message/22597899#22597899

Maybe you are looking for