How to make a cell in JTable a different colour?

Hi, i've been playing with JTables with a custom CellRenderer, which I'm trying to make so that in the JTable, when two values down a column are found to be the same, the back ground colour changes to something same (hoping that there is a way to randomize the colour values) the code i have atm is
In the main program :
                    find.addActionListener(new ActionListener() {
                         public void actionPerformed(ActionEvent ae) {
                              datahome = cC.data;
                              TableColumnModel colModel = cC.jtable.getColumnModel();
                              TableColumn column = colModel.getColumn(0);
                              column.setCellRenderer(new RedCellRenderer(new int[] {1,2}));
in the cellrenderer:
package packageSolo;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.*;
import java.awt.*;
public class SetCellColour extends DefaultTableCellRenderer {
     private int arrVerifyColumns[] = null;
     public SetCellColour(int iTestColumns[]) {
          arrVerifyColumns = iTestColumns;
     public Component getTableCellRendererComponent(JTable table, Object value,
               boolean isSelected, boolean hasFocus, int row, int column) {
          this.setBackground(Color.RED); // All columns verified were empty - set
          // our background RED
          return this;
}any my problem is that this cellrenderer will change the column and not just the cell, i've tried to pass where the cell is (the x and y of the cell) to the cellrenderer, but there is no way for me to interpret this value in cellrenderer and set that cell to that colour i'm not sure if there is a cell model instead of column model and be able to pass that onto the cellrenderer

ell after several tries, i have determined that it may be something wrong with that my jtable is part of a JPanel, that is attached to a container with scroll pane that is then added to a JFrame's center... and somewhere here it freezes the display...
my code for the actual JFrame:
package packageSolo;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class ConflictCheckerGUIIntialization extends JFrame {
      * debugger
      * @param x
      *            takes in an int and prints a debug line when enabled to the
      *            console
     private void debug(int x) {
          // System.out.print("Flag: "+ x);
     private static int flag1 = 0;
     private static int flag2 = 0;
     private static int flag3 = 0;
     private static int flag4 = 0;
     private static int flag5 = 0;
     private static int flag6 = 0;
     private static int flag7 = 0;
     private static int flag8 = 0;
     private static int flag9 = 0;
     private Object[][] datahome;
     private JButton cConflict = new JButton("Check Conflict");
     private JButton find = new JButton("Find");
     private JButton quit = new JButton("Exit");
     // private JButton northavg = new JButton("North's Average");
     // private JButton eastavg = new JButton("East's Average");
     // private JButton largest = new JButton("Largest Percepitation");
     // private JButton totalPercepitation = new JButton("Total Percepitation");
     private ConflictCheckerGUI cC = new ConflictCheckerGUI();
     private JFrame jf = new JFrame();
     private JFrame jf1 = new JFrame();
     // Get the size of the default screen
     private static Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
     private int screensizex = (int) (dim.width * 0.8);
     private int screensizey = (int) (dim.height * 0.75);
     private static int gcsizex = (int) (dim.width * 0.625);
     private static int gcsizey = (int) (dim.height * 0.1953125);
     private static GUIConsole gc = new GUIConsole("Output", gcsizex, gcsizey);
     public ConflictCheckerGUIIntialization() {
          boolean RunOnce = false;
          while (RunOnce == false) {
               if (cC.finished == true) {
                    System.out.println("he");
                    Container c1 = jf.getContentPane();
                    c1.setLayout(new FlowLayout());
                    Container c = this.getContentPane();
                    Container c2 = jf1.getContentPane();
                    JPanel jp = new JPanel();
                    jp.add(cC);
                    cConflict.addActionListener(new ActionListener() {
                         public void actionPerformed(ActionEvent ae) {
                              datahome = cC.data;
                              // System.out.print(datahome
                              // [0][0].toString().compareTo(datahome
                              // [1][0].toString()));
                              // System.out.print(datahome
                              // [0][0].toString().equals(datahome
                              // [1][0].toString()));
                              for (int conflictCounter2 = 1; conflictCounter2 < 3; conflictCounter2++) {
                                   int conflictCounter4 = 0;
                                   for (int conflictCounter1 = 0; conflictCounter1 <= cC.Classroomint; conflictCounter1++) {
                                        conflictCounter4++;
                                        for (int conflictCounter3 = 1; conflictCounter3 <= (cC.Classroomint - conflictCounter4); conflictCounter3++) {
                                             if (datahome[conflictCounter2][conflictCounter1]
                                                       .toString()
                                                       .equals(
                                                                 datahome[conflictCounter2][conflictCounter1
                                                                           + conflictCounter3]
                                                                           .toString())) {
                                                  System.out.println("error at "
                                                            + conflictCounter2 + " "
                                                            + conflictCounter1);
                               * for (int counter1 = 0; counter1 < pg.monthint;
                               * counter1++) { for (int counter2 = 0; counter2 < 5;
                               * counter2++) {
                               * System.out.print(datahome[counter1][counter2] +
                               * "\t"); } System.out.println(); }
                    quit.addActionListener(new ActionListener() {
                         public void actionPerformed(ActionEvent ae) {
                              try {
                                   System.exit(0);
                              } catch (SecurityException ea) {
                                   System.out.println("Cannot exit");
                    find.addActionListener(new ActionListener() {
                         public void actionPerformed(ActionEvent ae) {
                              datahome = cC.data;
                              Object value = null;
                              cC.jtable.getCellRenderer(0, 0)
                                        .getTableCellRendererComponent(cC.jtable,
                                                  value, false, true, 0, 0).setFont(new Font(
                                                  "Serif", Font.BOLD, 14));
                              System.out.println(cC.data[0][0].toString());
                              // .setFont(new Font("serif", Font.BOLD, 12));
                    gc
                              .println("There is a known bug with this program that if you enter any information in the table,");
                    gc
                              .println("then not confirming it by not going to another cell, then the data you've entered it not valid and not considered to be input,");
                    gc
                              .println("this will be fixed in future revisions if possible");
                    gc.show();
                    gc.setLocation(0, screensizey);
                                *bold*
                               *bold* c2.add(jp, "Center");
                    *bold*c2.add(new JScrollPane(jp,
                              *bold*ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                              *bold*ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED),
                              *bold*"Center");
                    c1.setLayout(new GridLayout(2, 5));
                    c1.add(cConflict);
                    c1.add(find);
                    c1.add(quit);
                    c1.setVisible(true);
                    c2.setVisible(true);
                    c.add(c1, "South");
                    c.add(c2, "Center");
                    c.setVisible(true);
                    this.pack();
                    this.setTitle("Lancer's Class Conflict Checker");
                    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
                    this.setSize(screensizex, screensizey);
                    RunOnce = true;
                    // ! this.pack(); //this tries to set the size of the thing to a
                    // perferred size, and if used will not alow the dynamic sizing
                    // of
                    // the
                    // main JTable window based on the user's screensize
     public static void main(String[] args) {
          ConflictCheckerGUIIntialization x = new ConflictCheckerGUIIntialization();
          x.setVisible(true);
}here, the JPanel with the jtable is added to c2 and c2 is added to c and c's parent is the JFrame of this whole class
and the code for the jtable JPanel is:
package packageSolo;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
import javax.swing.*;
import javax.swing.table.*;
public class ConflictCheckerGUI extends JPanel {
     private void debug(int x) {
          // System.out.println(x);
     protected static boolean finished = false;
     protected static DefaultTableModel[][] data;
     protected static int Classroomint = 0;
     protected static JTable jtable;
     protected static String[] columnNames = { "Classroom", "Period One",
               "Period Two", "Period Three", "Period Four" };
     protected static int GoAheadFlag = 0;
     SetCellColour renderer;
     public ConflictCheckerGUI() {
          // super(new GridLayout(1, 0));
          JFrame Choose = new JFrame();
          Choose.setDefaultCloseOperation(Choose.EXIT_ON_CLOSE);
          JButton ImportFromFile = new JButton("Impoort From File");
          JButton New = new JButton("New Planner");
          ImportFromFile.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent ae) {
                    String[] North;
                    String[] East;
                    String[] South;
                    String[] West;
                    String[] Month;
                    // JFileChooser fc = new JFileChooser();
                    // fc.show();
                    // int returnVal = fc.showOpenDialog(fc);
                    // File file = null;
                    // if (returnVal == JFileChooser.APPROVE_OPTION) {
                    // file = fc.getSelectedFile();
                    java.util.Scanner parse = null;
                    File file = new File(
                              "E://Documents and Settings//TheHolyLancer//My Documents//java - old//Eclipse workspace//Precipitation//packageSolo//datasave.txt");
                    try {
                         parse = new java.util.Scanner(file);
                    } catch (FileNotFoundException e) {
                         // TODO Auto-generated catch block
                         e.printStackTrace();
                    Classroomint = Integer.parseInt(parse.next());
                    North = new String[Classroomint];
                    East = new String[Classroomint];
                    South = new String[Classroomint];
                    West = new String[Classroomint];
                    Month = new String[Classroomint];
                    for (int counter1 = 0; counter1 < Classroomint; counter1++) {
                         Month[counter1] = "n/a";
                    for (int counter2 = 0; counter2 < Classroomint; counter2++) {
                         North[counter2] = "n/a";
                         East[counter2] = "n/a";
                         South[counter2] = "n/a";
                         West[counter2] = "n/a";
                    data = new DefaultTableModel[Classroomint][5];
                    jtable = new JTable(new DefaultTableModel(Classroomint,5));//columnnames
                    jtable.setPreferredScrollableViewportSize(new Dimension(800,
                              600));
                    finished = true;
          New.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent ae) {
                    String input;
                    String[] North;
                    String[] East;
                    String[] South;
                    String[] West;
                    String[] Month;
                    int flag2 = 0;
                    int flag4 = 0;
                    int flag5 = 0;
                    int flag8 = 0;
                    input = JOptionPane
                              .showInputDialog("How many classromms are there?");
                     * see if the user wantes to quit at this point
                    if (input == null) {
                         debug(4);
                         int exitint = 0;
                         exitint = JOptionPane.showConfirmDialog(null,
                                   "Do you want to exit?", "Exit?",
                                   JOptionPane.OK_CANCEL_OPTION);
                         if (exitint == 0) {
                              try {
                                   System.exit(1);
                              } catch (SecurityException eb) {
                                   System.out.println("exit");
                    while (flag4 == 0) {
                          * this while loop with flag2 is for checking if the thing
                          * is of int class
                         while (flag2 == 0) {
                               * try to get a integer, check for a bad input class
                              try {
                                    * parse, and if success set flag2 to 1 and break
                                    * out this while loop
                                   Classroomint = Integer.parseInt(input);
                                   flag2 = 1;
                                   debug(2);
                              } catch (NumberFormatException ec) {
                                   debug(3);
                                    * ops user input was not a integer class
                                   JOptionPane.showMessageDialog(null,
                                             "Enter a positive integer only",
                                             "Number Format is Wrong",
                                             JOptionPane.ERROR_MESSAGE);
                                   input = JOptionPane
                                             .showInputDialog("How many months are there?");
                                    * see if the user wantes to quit at this point
                                   if (input == null) {
                                        debug(4);
                                        int exitint = 0;
                                        exitint = JOptionPane.showConfirmDialog(null,
                                                  "Do you want to exit?", "Exit?",
                                                  JOptionPane.OK_CANCEL_OPTION);
                                        if (exitint == 0) {
                                             try {
                                                  System.exit(1);
                                             } catch (SecurityException eb) {
                                                  System.out.println("exit");
                          * this while loop sees if the integer is smaller than 0 so
                          * the array cannot be a real one
                         while (flag5 == 0) {
                              // numamountint = Integer.parseInt(numamount);
                              if (Classroomint < 0) {
                                   debug(5);
                                   JOptionPane.showMessageDialog(null,
                                             "Enter a positive integer",
                                             "Number Format/Size is Wrong",
                                             JOptionPane.ERROR_MESSAGE);
                                   input = JOptionPane
                                             .showInputDialog("How many months are there?");
                                   if (input == null) {
                                        int exitint = 0;
                                        exitint = JOptionPane.showConfirmDialog(null,
                                                  "Do you want to exit?", "Exit?",
                                                  JOptionPane.OK_CANCEL_OPTION);
                                        if (exitint == 0) {
                                             try {
                                                  System.exit(1);
                                             } catch (SecurityException eb) {
                                                  System.out.println("exit");
                                    * this while loop check for number format again
                                   while (flag8 == 0) {
                                        try {
                                             debug(6);
                                             Classroomint = Integer.parseInt(input);
                                             flag8 = 1;
                                        } catch (NumberFormatException ec) {
                                             debug(7);
                                             JOptionPane.showMessageDialog(null,
                                                       "Enter a positive integer only",
                                                       "Number Format is Wrong",
                                                       JOptionPane.ERROR_MESSAGE);
                                             input = JOptionPane
                                                       .showInputDialog("How many months are there?");
                                             if (input == null) {
                                                  int exitint = 0;
                                                  exitint = JOptionPane
                                                            .showConfirmDialog(
                                                                      null,
                                                                      "Do you want to exit?",
                                                                      "Exit?",
                                                                      JOptionPane.OK_CANCEL_OPTION);
                                                  if (exitint == 0) {
                                                       try {
                                                            System.exit(1);
                                                       } catch (SecurityException eb) {
                                                            System.out.println("exit");
                              } else {
                                    * here the input is greater than 0 so it sets flag5
                                    * and 4 then break out of the while loops
                                   debug(8);
                                   flag5 = 1;
                                   flag4 = 1;
                    North = new String[Classroomint];
                    East = new String[Classroomint];
                    South = new String[Classroomint];
                    West = new String[Classroomint];
                    Month = new String[Classroomint];
                    for (int counter1 = 0; counter1 < Classroomint; counter1++) {
                         Month[counter1] = "n/a";
                    for (int counter2 = 0; counter2 < Classroomint; counter2++) {
                         North[counter2] = "n/a";
                         East[counter2] = "n/a";
                         South[counter2] = "n/a";
                         West[counter2] = "n/a";
                    DefaultTableModel tableModel = new DefaultTableModel(Classroomint, 0);
                    tableModel.addColumn("Classroom");
                    tableModel.addColumn("Period One");
                    tableModel.addColumn("Period Two");
                    tableModel.addColumn("Period Three");
                    tableModel.addColumn("Period Four");
                    /*protected static String[] columnNames = { "Classroom", "Period One",
                         "Period Two", "Period Three", "Period Four" };*/
                    // /jtable = new JTable(data, columnNames);
                    jtable = new JTable(tableModel) {
                         private static final long serialVersionUID = 1L;
                         public TableCellRenderer getCellRenderer(int row, int col) {
                              return renderer;
                    jtable.setRowSelectionAllowed(true);
                    jtable.setPreferredScrollableViewportSize(new Dimension(800,
                              600));
                    finished = true;
          Container ButtonHolder = new Container();
          ButtonHolder.setLayout(new GridLayout(1, 2));
          ButtonHolder.add(New);
          ButtonHolder.add(ImportFromFile);
          Choose.add(ButtonHolder);
          Choose.setSize(200, 300);
          Choose.setVisible(true);
          boolean RunOnce = false;
          while (RunOnce == false) {
               if (finished == true) {
                    //JScrollPane scrollPane = new JScrollPane(jtable);
                    this.add( jtable, BorderLayout.CENTER );
                    Choose.setEnabled(false);
                    RunOnce = true;
}but upon start, and select start new table, the windows come up, but on where the large JFrame is and where the jtable is, nothing appears, and it acts like a screen cap and the thing just stucks like what is on the background of the computer... i think in all this linking i may have screwed something up, and the examples given were not designed for JPanels, but rather for JFrames... maybe i could implement all this into one class, since the buttons for choosing from load from file and all that can be in the first file as another JFrame, that is first visible, then when user chose one, something becomes visible, or something
but anyone knows how to fix all this?

Similar Messages

  • How to make editing cell to show up caret and taking keyboard event

    Hello everyone:
    I have the following problem with table editing.
    1. using mouse clicking, the editing cell will have cursor and taking keyboard event.(no problem with it)
    2. just type in data, it will show up in the selected cell, but the editing cell do not have cursor visible and also do not fire the keyboard event.
    I have problem with this one. So how to make editing cell to have caret visible and taking keyboard event.
    Thank you very much!
    --tony                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Hi,
    you should subclass JTable and overwrite two methods.
    1. protected boolean processKeyBinding(javax.swing.KeyStroke ks,
    java.awt.event.KeyEvent e,
    int condition,
    boolean pressed)
    to store the current keyboard event,
    2.public boolean editCellAt(int row,int column,java.util.EventObject e)
    to fix the problem with isCellEditable and curret position and direct the event into proper place.

  • How to make table cell have certain width

    Hi
    i have 3 cells when i write text in any cell it effects the
    width of other cells !!!
    how to make every cell have certain? i mean i want to wrap
    the text not to effect the cell width
    thanks in advance.

    Hi Mac,
    Try this
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
    Transitional//EN">
    <HTML><HEAD><TITLE>Home</TITLE>
    <META http-equiv=Content-Type content="text/html;
    charset=iso-8859-1">
    <style>
    .text-content-green {
    FONT-SIZE: 11px;
    COLOR: #a5a834;
    LINE-HEIGHT: 20px;
    FONT-STYLE: normal;
    FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
    TEXT-DECORATION: none;
    .text-content-green:hover {
    FONT-SIZE: 11px;
    COLOR: #AE0B0B;
    LINE-HEIGHT: 20px;
    FONT-STYLE: normal;
    FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
    TEXT-DECORATION:underline;
    .margin {
    margin: 1px 1px 1px 1px;
    border-style: solid;
    border-top-width: 1px;
    border-left-width: 1px;
    border-right-width: 1px;
    border-bottom-width: 1px;
    border-color: gainsboro;
    </style
    </HEAD>
    <BODY topmargin="10px" leftmargin="0" rightmargin="0"
    class="body-style">
    <TABLE width="729" border="0" cellpadding="0"
    cellspacing="0" cellsadding="0" align="center" class="margin">
    <TBODY>
    <TR>
    <TD width="125" valign="top" bgcolor="#f0f0c1">
    <table width="125" border="0" cellspacing="0"
    cellpadding="0">
    <tr>
    <td width="25" height="25" align="middle"></td>
    <td width="108" class="text-content-green"><A
    class="text-content-green" href="default.html">LEFT
    NAV</A></td>
    </tr>
    <tr>
    <td colspan="2" align="middle"></td>
    </tr>
    <tr>
    <td width="25" height="25" align="middle"></td>
    <td width="108" class="text-content-green"></td>
    </tr>
    <tr>
    <td colspan="2"></td>
    </tr>
    </table>
    </TD>
    <TD vAlign=top width=539 bgColor="white" height=471>
    <P class="text-content-green" align=left
    style="padding-left:5px">Lorem ipsum dolor sit amet, consectetur
    adipisicing elit.Duis aute irure dolor in reprehenderit in
    voluptate velit esse cillum .
    </P>
    </TD>
    </TR>
    </TBODY>
    </TABLE>
    </TD>
    </TR>
    </TBODY>
    </TABLE>
    </BODY>
    </HTML>
    HTH
    Shanthi

  • How do I configure my iPhone to show different colours for my two calendars both from separate email accounts, both Exchange.

    How do I configure my iPhone to show different colours for my two calendars both from separate email accounts, both Exchange.

    It does so by default... what's the issue?

  • How to make a cell in a JTable to be uneditable and handle events

    I tried many things but failed,How do you make a cell in a JTable to be uneditable and also be able to handle events>Anyone who knows this please help.Thanx

    Hello Klaas2001
    You can add KeyListener ,MouseListener
    Suppose you have set the value of cell using setValueAt()
    table.addKeyListener(this);
    public void keyTyped(KeyEvent src)
    String val="";
    int r= table.getEditingRow();
    int c= table.getEditingColumn();
    val=table.getValueAt(r,c).toString();
    if (r!=-1 && c!=-1)
    TableCellEditor tableCellEditor = table.getCellEditor(r, c);
    tableCellEditor.stopCellEditing();
    table.clearSelection();
    table.setValueAt(val,r,c);
    public void keyReleased(KeyEvent src)
    public void keyPressed(KeyEvent src)
    table.addMouseListener(this);
    public void mouseClicked(MouseEvent e)
    public void mouseEntered(MouseEvent e)
    public void mouseExited(MouseEvent e)
    public void mousePressed(MouseEvent e)
    public void mouseReleased(MouseEvent e)
    if(e.getClickCount()>=2)//Double Click
    table.clearSelection();
    int r= table.getEditingRow();
    int c= table.getEditingColumn();
    if (r!=-1 && c!=-1)
    TableCellEditor tableCellEditor = table.getCellEditor (
    r,c);
    tableCellEditor.stopCellEditing();
    table.clearSelection();
    table.setValueAt("",r,c);
    }//Mouse Released
    You can remove keyListener and Mouse Listener whenever You want to edit
    then add it later.
    Regarding handling events implement javax.swing.event.TableModelListener
    table.getModel().addTableModelListener(this);
    public void tableChanged(javax.swing.event.TableModelEvent source)
    TableModel tabMod = (TableModel)source.getSource();
         switch (source.getType())
    case TableModelEvent.UPDATE:
         break;
         }//Table Changed Method
    //This method gets fired after table cell value is changed.

  • How to make crosstab cell value become hot link which can link to other?

    Dear Gurus:
    I am using Bi beans in a project, i create a crosstab in one .jsp file,the crosstable can display data correctly,but i want to make every cell value become hot link which point to a url,this url contains measure info and all dimension info,how can i do? Thanks a lot!

    Hi Tomsong,
    We will post a BI Beans Sample that does that to OTN next week.
    In the mean time, look at the following BI Beans Help topic (under Jdeveloper BI Beans Help)
    Handling Drill-Out Events in HTML-Client Applications
    Hope this helps
    Katia

  • How to make ALV cell editable

    Hi ,
    I am using cl_gui_alv_grid .
    please let me know how to make a particular cell is editable
    eg:  cell corresponding to first row second column should be editabel but remaining all are non editable

    Hi,
    Loop at your internal table.
    Eg: i have total 5 fields in my internal table itab_zqmeinz. in that 3 fields are editable as below.
    declare DATA: lt_celltab TYPE lvc_t_styl.
    internal table with celltab as one of the column
    DATA: BEGIN OF itab_zqmeinz OCCURS 0. "TYPE STANDARD TABLE OF zqmseqkopf
            INCLUDE STRUCTURE zqmseqeinz.
    DATA: celltab TYPE lvc_t_styl.
    DATA: END OF itab_zqmeinz.
    LOOP AT itab_zqmeinz INTO wa_zqmeinz.
          l_index = sy-tabix.
          REFRESH lt_celltab.
          CLEAR wa_zqmeinz-celltab.
          PERFORM fill_celltab1 USING 'RW'
                                  CHANGING lt_celltab.
          INSERT LINES OF lt_celltab INTO TABLE wa_zqmeinz-celltab.
          MODIFY  itab_zqmeinz FROM wa_zqmeinz INDEX l_index.
        ENDLOOP.
    FORM fill_celltab1 USING value(p_mode)
                      CHANGING pt_celltab TYPE lvc_t_styl.
    Refresh pt_celltab.
      clear ls_celltab.
      IF p_mode EQ 'RW'.
        l_mode = cl_gui_alv_grid=>mc_style_enabled.    "to enable the required fields
      ELSE.                                "p_mode eq 'RO'
        l_mode = cl_gui_alv_grid=>mc_style_disabled.
      ENDIF.
      ls_celltab-fieldname = 'NEBENSEQUEN'.   " field1
      ls_celltab-style = l_mode.
      INSERT ls_celltab INTO TABLE pt_celltab.
      ls_celltab-fieldname = 'BEZEICHNUNG'.     "field2
      ls_celltab-style = l_mode.
      INSERT ls_celltab INTO TABLE pt_celltab.
      ls_celltab-fieldname = 'SORTIERUNG'.         "field3
      ls_celltab-style = l_mode.
      INSERT ls_celltab INTO TABLE pt_celltab.
    Endform.
    It works. I have done it in my program.
    Thanks,

  • How to make a cell/column read only

    HI All,
    Is there any way to make a specific cell read only with in a specific data form?
    Similarly is there any way to make whole column read only inside a specific data form?
    I don't want to make changes in my dimension member (e.g Dynamic Calc), i want to make these changes at data form level because, these cell/column are read only at one form but on some other data form they are editable/enterable

    If you want to make a column read only then have a look at asymettric columns in the planning admin doc, if you use them then you can make one of the columns read only.
    If you want a make one cell read only then one method could be to use javascript, you could add an extra member which is dynamic calc and point to the original member with a formula but it doesn't sound like you want to do that.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • How to make editable cell in ALV TREE?

    Hi all,
    I have a problem to make the cell in item row (I mean not  the cell in hierarchy columns and not in the node row) in ALV tree editable.
    I know to make it in "normal" ALV, but my ALV is type class: cl_gui_alv_tree and the nodes are calculated in a sum.Can anyone help me to set the cell editable in ALV tree?
    Thank you a lot!
    Best regards,
    Danijela Zivanovic
    Message was edited by: Danijela Zivanovic

    HI,
    To make a column editable, it will be sufficient to set the field “<b>EDIT</b>” in the field catalog. The ALV Grid perceives if there are some editable fields and adds buttons for editing purposes. If you do not need these new buttons
    <u><i>if you want it in the Classes</i></u>
    For this procedure; add the name of the field to the field “FIELDNAME”, and pass “cl_gui_alv_grid=>mc_style_enabled” to make a field editable and “cl_gui_alv_grid=>mc_style_disabled” to make a field non-editable,
    <b>Example:</b>
    FORM adjust_editables USING pt_list LIKE gt_list[] .
    DATA ls_listrow LIKE LINE OF pt_list .
    DATA ls_stylerow TYPE lvc_s_styl .
    DATA lt_styletab TYPE lvc_t_styl .
    LOOP AT pt_list INTO ls_listrow .
    IF ls_listrow-carrid = 'XY' .
    ls_stylerow-fieldname = 'SEATSMAX' .
    ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled . APPEND ls_stylerow TO lt_styletab .
    ENDIF .
    IF ls_listrow-connid = '02' .
    ls_stylerow-fieldname = 'PLANETYPE' .
    ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled . APPEND ls_stylerow TO lt_styletab .
    ENDIF .
    INSERT LINES OF lt_styletab INTO ls_listrow-cellstyles . MODIFY pt_list FROM ls_listrow .
    ENDLOOP .
    ENDFORM
    Thanks
    Sudheer

  • How to make a cell populate the same as other cells mac numbers

    does anyone know if theres a command where I can make a cell be the same value as another cell? so i change one cell and it populates the same in others. Thanks!

    Hi appleryan,
    =A1
    in any cell will bring the value of A1 into that cell.
    quinn

  • WPF: How to make Tab Header to show three different icons?

    Our WPF application needs Tab header to show three different icons and Foreground.
    If tab is not selected, show one icon and black foreground. If tab is selected, show another icon and white foreground. If tab is selected and also require show Chromestyle, show third icon and red foreground.
    we have tried the following code. However, MultiDataTrigger section does not work.
    <TabItem x:Name="tabItemSetup" Header="Setup">
    <TabItem.HeaderTemplate>
    <DataTemplate>
    <StackPanel Orientation="Vertical">
    <Image x:Name="imgSetup" Height="50" Width="65" Source="Resources/Images/UNSELECTED_Setup Icon.png" DockPanel.Dock="Top" />
    <TextBlock x:Name="txtSetup" Text="{Binding}" Foreground="Black" Style="{StaticResource TabTextStyle}" DockPanel.Dock="Bottom" FontFamily="Eras ITC" FontSize="13.333"/>
    </StackPanel>
    <DataTemplate.Triggers>
    <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type TabItem}}}" Value="True">
    <Setter TargetName="txtSetup" Property="Foreground" Value="White"/>
    <Setter TargetName="imgSetup" Property="Source" Value="Resources/Images/SELECTED_Setup Icon.png"/>
    </DataTrigger>
    <MultiDataTrigger>
    <MultiDataTrigger.Conditions>
    <Condition Binding="{Binding IsChromeStyle}" Value="True"/>
    <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type TabItem}}}" Value="True"/>
    </MultiDataTrigger.Conditions>
    <MultiDataTrigger.Setters>
    <Setter TargetName="txtSetup" Property="Foreground" Value="Red"/>
    <Setter TargetName="imgSetup" Property="Source" Value="Resources/Images/Chrome SELECTED_Setup Icon.png"/>
    </MultiDataTrigger.Setters>
    </MultiDataTrigger>
    </DataTemplate.Triggers>
    </DataTemplate>
    </TabItem.HeaderTemplate>
    </TabItem>
    Does anyone know how to make it work? Thx!
    JaneC

    Where is the IsChromeStyle property defined? It is the Header, i.e. the string "Setup" that is the DataContext of the HeaderTemplate and the a string has no property called IsChromeStyle so you must specify a source for the binding.
    If for example the DataContext object of the TabControl, or the parent of the TabControl (for example the window or whatever) has a property called IsChromeStyle you could bind to this one using a RelativeSource:
    <MultiDataTrigger.Conditions>
    <Condition Binding="{Binding DataContext.IsChromeStyle, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="True"/>
    <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type TabItem}}}" Value="True"/>
    </MultiDataTrigger.Conditions>
    Then it should work. It is the binding that fails.
    Please remember to close your threads by marking helpful posts as answer.

  • : How to make a cell editable and uneditable in a JTable

    i have created a table and want to make some modifications in the cells and also make it uneditable...i hace used abstract table model . kindly guide me

    You have got to implement the 'isCellEditable' method within your abstract table model. If you want to allow the user to only edit cells in the first column you would add the following:
    public boolean isCellEditable (int row, int col) {
      if ( col == 0 ) {
        return true
      } else {
        return false;
    }That should be sufficent to base your own needs off.
    Jon

  • How to make a cell or column in JTable non focusable.

    I have created a table which contains 2 rows and 2 columns. My requirement is that 2nd column should be non editable and non focusable. Making any cell non editable is very easy but how should i avoid focus on particular cell.i.e., suppose focus is on first cell and now if u press right arrow button on the keyboard 2nd cell should not get highlighted and focus should remain on first cell.
    Thanks in advance

    Override the default Tab Action. Here is an example:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=657819

  • How to make more cells in one table by DataGridView

    Hello,
    I have a question, Firstly I'm using VB
    How can I make invoice by datagridview I'm trying to type customer information in the Textbox and Inventory Items in datagridview but the problem is datagrid give me one cell and I can type one inventory item only,  I want to put a lot of items for
    one customer. And I bind the datagridview to access db table.
    For more explain , How can I make Invoice and use datagridview for put items into it and save to access database table?
    For example " create invoice in Quick books " something like that Every customer have a gridview and it's have item he taken it.

    The problem with the datagridview is that it can only show one table.
    For more tables 3th party datagrid's are better. 
    Although you can start with using the old datagrid. Despite what is written on MSDN is it a complete different control then the datagridview. You can add in to your toolbox by right clicking on it and then add it.
    The datasource of a DataGrid can be a complete dataset which is showed with all its relations.
    Success
    Cor

  • How to make SMOOTH scrolling with Jtable in Swing automatically ?

    Hi All,
    I'm coding for a price board program, with all records I designed a table for them. So now I want to scroll automatically for all records on that table for customers viewing them. The problem that I can make it scroll smoothly ! Currently I use this block code :
    Thread scollTable;
    int scrollCount = 38;
    public void scrollTable(final int records) {
    if (scollTable == null) {
    scollTable = new Thread() {
    @Override
    public void run() {
    try {
    while (true) {
    if (scrollCount == 38) {
    jTable1.setRowSelectionInterval(scrollCount, scrollCount);
    scrollRowToVisible(scrollCount, jTable1);
    Thread.sleep(4000);
    jTable1.setRowSelectionInterval(scrollCount, scrollCount);
    scrollRowToVisible(scrollCount, jTable1);
    Thread.sleep(1000);
    scrollCount++;
    if (scrollCount == records) {
    scrollCount = 0;
    Thread.sleep(4000);
    jTable1.setRowSelectionInterval(scrollCount, scrollCount);
    scrollRowToVisible(scrollCount, jTable1);
    scrollCount = 38;
    continue;
    } catch(Exception ex) {
    if (!scollTable.isAlive()) {
    //scollTable.setPriority(7);
    scollTable.start();
    public void scrollRowToVisible(int row, JTable table) {
    Rectangle cellRect = table.getCellRect(row, 0, true);
    Rectangle visibleRect = table.getVisibleRect();
    cellRect.x = visibleRect.x;
    cellRect.width = visibleRect.width;
    table.scrollRectToVisible(cellRect);
    The problem I think the progam can not run smoothly with scroll :
    scrollRowToVisible(scrollCount, jTable1);
    Thread.sleep(1000);
    scrollCount++;
    Any helps,
    Thanks.
    Edited by: onlysang2004 on Aug 4, 2009 2:22 AM

    Could you please tell me more detail ? I studied about Swing recently ! I found a link for that javax.swing.Timer : http://forums.sun.com/thread.jspa?threadID=5366085&messageID=10603235#10603235 but how can I use ? In my price board screem doesn't have ActionListener object or button to listen to submit. Can I create an ActionListener object ? Please help me more, how to run smooth scrolling automatically !
    public class ViewElectricHaSTC extends JFrame {
    Thread scollTable;
    public ViewElectricHaSTC(Options options) throws Exception {
    scrollTable(options.getRecord());
    int scrollCount = 38;
    public void scrollTable(final int records) {
    if (scollTable == null) {
    scollTable = new Thread() {
    @Override
    public void run() {
    try {
    while (true) {
    if (scrollCount == 38) {
    //jTable1 created with initComponents method
    jTable1.setRowSelectionInterval(scrollCount, scrollCount);
    scrollRowToVisible(scrollCount, jTable1);
    Thread.sleep(4000);
    jTable1.setRowSelectionInterval(scrollCount, scrollCount);
    scrollRowToVisible(scrollCount, jTable1);
    Thread.sleep(1000);
    scrollCount++;
    if (scrollCount == records) {
    scrollCount = 0;
    Thread.sleep(4000);
    jTable1.setRowSelectionInterval(scrollCount, scrollCount);
    scrollRowToVisible(scrollCount, jTable1);
    scrollCount = 38;
    continue;
    } catch(Exception ex) {
    if (!scollTable.isAlive()) {
    //scollTable.setPriority(7);
    scollTable.start();
    public void scrollRowToVisible(int row, JTable table) {
    Rectangle cellRect = table.getCellRect(row, 0, true);
    Rectangle visibleRect = table.getVisibleRect();
    cellRect.x = visibleRect.x;
    cellRect.width = visibleRect.width;
    table.scrollRectToVisible(cellRect);
    Edited by: onlysang2004 on Aug 4, 2009 7:23 PM

Maybe you are looking for

  • How can I display an analog input to PXI-5105 out on LabVIEW?

    Hi ALL, I am very very new to LabVIEW and I just started to fiddle around with it. I am running LabVIEW 2010 SP1 version on Windows 7 OS. I also have NI PXIe-1073 chassis with PXIe-6361 and PXI-5105 modules and the chassis is connected to my PC via P

  • Play two different sounds at same time  from Split Keyboard?

    Is it possible to configure the Logic Environment so that one can play or record, from a split keyboard, two different EX24/Audio Instrument sounds on two different tracks AT THE SAME TIME... (and/or: combinations of Audioinstrument + Midi) EG: From

  • Problem with uploading pictures

    i just got my ipod classic 160gigs and i tried to upload pictures with my laptop (hp windows vista), it loads a while but then it suddenly shut off my laptop, i tried it many times but still the same problem...what will i do??im afraid my laptop migh

  • Re :Table: AR_RECEIVABLE_APPLICATIONS  -- Column Name : DISPLAY

    Hi Team, Can you please let me know the significance of the following column : DISPLAY in the table : AR_RECEIVABLE_APPLICATIONS The following is displayed in eTRM--> Y or N flag to indicate whether this is the latest application -Sridhar Edited by:

  • Naming the bubbles in Bubble chart of Jfreechart

    Hi, I am using Jfreechart to create a bubble chart. I am unable to name the bubbles but in the legend the bubble names are coming. Please help me to generate the bubble names with the names which are present in the legends.