How to automatically highlight / bold words in a JTable cell?

how do i do it?
i have an Object called Data (where toString() is the same as getDataName()).
and i want the JTable to either highlight or bold specific words (using the bold HTML tags) that are present in a SortedSet.
i do not want the dataName to be changed by directly manipulating the Object because the Data Objects were taken from the DB and i need the Objects and the records to be synchronised, and because the words in the SortedSet itself are subject to changes (add/edit/remove).
thanks.

Edit: removed
db
Cross posted
http://www.java-forums.org/awt-swing/47138-how-automatically-highlight-bold-words-jtable-cell.html
Edited by: Darryl Burke

Similar Messages

  • How do you highlight typed words for a calendar event

    how do you highlight typed words for a calendar event on ical?

    See this plugin in for APEX 4.x applications..:http://www.apex-plugin.com/oracle-apex-plugins/dynamic-action-plugin/clarifit-report-instant-search_98.html
    Next time please help us help you.. Post the following information:
    APEX Version
    Database Version
    Browser Version
    Thank you,
    Tony Miller
    Webster, TX
    On the road of life...There are 'windshields', and there are 'bugs'
    (splat!)
    "Squeegees Wanted"
    If this question is answered, please mark the thread as closed and assign points where earned..

  • In e-mail, how can I highlight certain words or sentences?

    How would I highlight certain words or sentences in e-mail?

    Hi Bee
    Thanks for yoUr reply.  All you recommended I know how to do, what I am looking for is a like a yellow highlighter, to be able to highlight a word, paragraph,etc.  I thought there was one in an older v.OSX.

  • When composing an email, how do I highlight a word in yellow (NOT change the font color, just highlight)?

    On Windows when composing an email,  I would often highlight a word or sentence in yellow. I don't seem to have this option on my Mac Book Air toolbar as I did when I had on my laptop. How can I add this feature to my toolbar? I don't want to change the font color, just want to highlight a word within the email.
    Thank you,

    Browder-41 wrote:
    How to I copy a Word document into an email without losing the design and colors in the document.  When I copy and paste I only get the typed words.  No design or color.
    You may or may not be able to do this based on which e-mail client or webmail platform you're using.  In your email options, you'll want to have the option to paste it as rich-text or HTML.  If you only have the option for plain text then you're out of luck.

  • How can I highlight multiple words in Pages?

    I would like to highlight multiple words in my Pages document so as to make changes to them all at once instead of each separately.  My mac came with this new pages so I cannot just go back to Pages '09.
    Thanks.

    Why not?
    Didn't you migrate from your old Mac to the new? In which case Pages '08/'09 should be in your Applications/iWork folder.
    Don't you have the original installers for Pages '09?
    Pages 5 is mostly useless and unproductive. This is only one of the over 110 missing features.
    Peter

  • How to display cusomized custom tooltip(jwindow)  in jtable cell position

    Hi,
    i am trying to display custom tooltip for jtable cell. i created custom tooltip(jwindow) and on mouseover of jtable cell i am trying to display the custom tooltip.
    But it is not display the position of jtable cell. How to display the exact position of jtable cell
    please help me on this.

    Did you read the posting directly below yours which was also about a custom tool tip?
    JScrollableToolTip is buggy
    The code presented there shows the tool tip in the proper location.
    For more help create a [url http://sscce.org]SSCCE, that demonstrates the incorrect behaviour.
    Don't forget to read the "Welcome to the new home" posting at the start of the forum to learn how to use the "code tags" so posted code is formatted and readable.

  • How to Automatically convert a word Document as a webpage in a document library

    Hi
    i have a document library with some word documents and i have activated the word automation service which will converts the word documents to a webpage. now this has to be done manually instead i need to automate this using a WF is there any method to automatically
    run this once a document is added to the library.
    Alen Austin

    Hi Alen, 
    If you want to covert word to web page automatically, you can create a workflow activity using SharePoint Designer.
    Here are some detailed articles for your reference:
    http://blogs.msdn.com/b/chandru/archive/2010/09/04/using-word-automation-services-as-a-workflow-custom-activity-in-sp-designer.aspx
    http://blog.petergerritsen.nl/2010/01/13/codeplex-project-for-word-automation-services/
    Best Regards
    Zhengyu Guo
    TechNet Community Support

  • How to stop highlighting misspelled words?

    I have Word for Mac 2011. How do I stop it from underlining mispelled words? I want to do spell check only when I want.

    I am sorry but have you actually looked in the Word preferences?
    It's Right THERE under Spelling & Grammer, TOP listing. Check Spelling As YOU TYPE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    If you want to change it for all document you'll need to open Normal.dot and make the change there and save it as Normal.dot

  • How to automatically add colons to number in a cell

    Hello
    I'm working on a video script. I have 2 columns with Time Code that I have to enter. The format is 8 numbers. (00:00:00:00).
    Is there a way to have the colon automatically inserted so I don't have to keep manually inserting it? If it's a sript, the script would have to follow when I export to XLS format.
    Thanks for any help
    Allen

    In the Inspector, go to the Cell Inspector (the "42" tab).
    Choose Custom for the cell format.
    Click on the arrow on the format that is there (the #,###).
    Make it two digits with no separator and show zeros for unused digits.
    Copy that format (highlight it if it isn't already highlighted then Command-C)
    Type a colon then do a paste (command V).
    Repeat until you have 00:00:00:00
    Give it a name and click OK
    12345678 will display 12:34:56:78
    123456789 will display as 123:45:67:89
    0 will display as 00:00:00:00
    I tested an export to Excel and the format came through okay for me.

  • Word wrap in jtable cell?

    Can there be some sort of "word wrap" whithin the individual cells
    of a jtable

    If you use something like a JTextArea for a cell renderer then it will be able to wrap the text for you.
    You can also use a JTextArea in a JScrollPane but will need to implement a corresponding editor to get it to respond to scroll gestures.
    If you want to get the table to choose a sensible height for the row then it will get a bit trickier!
    Let me know if you'd like to know more about how to go about doing some of this.
    Hope this helps.

  • How to catch the mouse event from the JTable cell of  the DefaultCellEditor

    Hi, my problem is:
    I have a JTable with the cells of DefaultCellEditor(JComboBox) and added the mouse listener to JTable. I can catch the mouse event from any editor cell when this cell didn't be focused. However, when I click the editor to select one JComboBox element, all the mouse events were intercepted by the editor.
    So, how can I catch the mouse event in this case? In other word, even if I do the operation over the editor, I also need to catch the cursor position.
    Any idea will be highly appreciated!
    Thanks in advance!

    Hi, bbritta,
    Thanks very much for your help. Really, your code could run well, but my case is to catch the JComboBox event. So, when I change the JTextField as JComboBox, it still fail to catch the event. The following is my code. Could you give me any other suggestion?
    Also, any one has a good idea for my problem? I look forward to the right solution to this problem.
    Thanks.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test3
    extends JFrame {
    // JTextField jtf = new JTextField();
    Object[] as = {"aa","bb","cc","dd"};
    JComboBox box = new JComboBox(as);
    public Test3() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = getContentPane();
    String[] head = {
    "One", "Two", "Three"};
    String[][] data = {
    "R1-C1", "R1-C2", "R1-C3"}
    "R2-C1", "R2-C2", "R2-C3"}
    JTable jt = new JTable(data, head);
    box.addMouseListener(new MouseAdapter() {
    // jtf.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e)
    System.out.println("-------------------JComboBox mouseclick....");
    jt.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e)
    System.out.println("-------------------JTable mouseclick....");
    // jt.setDefaultEditor(Object.class, new DefaultCellEditor(jtf));
    jt.setDefaultEditor(Object.class, new DefaultCellEditor(box));
    content.add(new JScrollPane(jt), BorderLayout.CENTER);
    setSize(300, 300);
    public static void main(String[] args) {
    new Test3().setVisible(true);
    }

  • How to create 2 checkboxs in 2 different JTable cells within 1 buttonGroup?

    Hi,
    I have a JTable with dynamic number of rows and 5 columns. What I mean by dynamic is that new rows can be added and existing rows can be deleted so the number of rows may change. As I said before there are 5 columns. The first 3 columns will always contains Strings. The fourth and fifth column will have checkboxs. I'm creating the checkboxes be specifying that the forth and fifth columns will have boolean in them. As you all know JTable converts boolean values to checkboxes.
    Here is my problem:
    I want to add these 2 checkboxes in column 4 and column 5 to a buttonGroup, s� that if I check the checkbox in column 4 the checkbox in column 5 will be unchecked and vice versa. An importent thing is that every row has its own buttonGroup for its checkboxes.
    To use buttonGroup I have to have 2 checkboxes to add them to the group for example
    buttonGroupForRow1.add(checkBox1);
    buttonGroupForRow2.add(checkBox2);
    But in my case there are no specific checkBoxes to add, I only have boolean values in 2 different cells in the JTable.
    How can I solve the problem?
    Here is a part of the code to help you undersand my problem:
    JTableToggle getPrgMemberPopupTable() {
              if (prgMemberPopupTable == null) {
                   DefaultTableModel model = new MyTableModel(10,5);
                   prgMemberPopupTable = new JTableToggle(model) {
                        public boolean isCellEditable(int rowIndex, int vColIndex) {
                             if (vColIndex == 3 || vColIndex == 4)
                             return true;
                             else return false;
                   prgMemberPopupTable.setRowSelectionAllowed(false);
                   prgMemberPopupTable.setColumnSelectionAllowed(false);
                   prgMemberPopupTable.getColumnModel().getColumn(0).setHeaderValue("Name");
                   prgMemberPopupTable.getColumnModel().getColumn(1).setHeaderValue("Subrack");
                   prgMemberPopupTable.getColumnModel().getColumn(2).setHeaderValue("Slot");
                   prgMemberPopupTable.getColumnModel().getColumn(3).setHeaderValue("Active");
                   prgMemberPopupTable.getColumnModel().getColumn(4).setHeaderValue("Passive");
                   prgMemberPopupTable.setName("prgMemberPopupTable");
                   prgMemberPopupTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
                   prgMemberPopupTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
              return prgMemberPopupTable;
        class JTableToggle extends javax.swing.JTable {
            public JTableToggle(DefaultTableModel aDefaultTableModel){
                super(aDefaultTableModel);
            public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
                // toggle is true in the case where the control key is pressed, i will invert that case.
                toggle = !toggle;
                super.changeSelection(rowIndex,columnIndex,toggle,extend);
         class MyTableModel extends DefaultTableModel{
              public MyTableModel(int a, int b){
                   super(a, b);
              public Class getColumnClass(int index){
                   if (index == 3 || index == 4)
                        return Boolean.class;
                   return super.getColumnClass(index);
         }Grateful for all help
    //Roomi

    Thanks for your help.
    2 requirements has to be fulfiled here:
    Req.1. A member is selected. The memeber is selected either by checking Active or Passive checkbox
    Req.2. Every selected member is either Active or Passive.
    My solution is build on the ide that when you check the active checkbox, then that member is selected and its is an active member. If the passive checkbox is selected then it is a passive member.
    The thing is, not every member in the JTable is selected, only those who are relative to that specfic case are selected.
    Let's say that I have 10 members in my table (which means 10 rows). Then I can select for example the second and fifth members as an active members and the seventh member as a passive one. That means only those members are selected (Req.1.). And (2 and 5) are actives and (7) is passive (Req.2)
    But lets say that I change my mind, and decide that the seventh member should be active and not passive. Then when I modify the selection and check the active checkBox (on column 3) the passive checkBox (on column 4) should become unchecked.
    Camickr, with your suggestion I can not distinguish between if the member is passive or it is not selected at all.
    Even if I use JRadioButtons instead of JCheckBoxes the problems still the same, 2 different JRadioButtons (or JCheckBoxs), both of them are in seperate columns (seperate cells), how can I add them to one ButtonGroup? Or let me refrase the last sentence (question), How can build up the solution so that when one of them is selected the other one is unselected. If I don't use ButtonGroup and have to build my own buttonGroup then I have to start thinking about mouse listner, and where the mouse click to plase, ...etc which is a lot of work for a simble thing to do.
    Unfortuntly I cannot change the layout either, I'm stricted to this layout by the company.
    //Roomi

  • How to force check right value of a JTable cell?

    Hi,
    I have a JTable with a column that must have a value no empty and between 0 and 100. I made a sample with only one column for simplicity.
    The code works fine when the user types some value. However, when the user press ENTER to go to next column, without editing the cell, no checks run.
    I have also other column that the user may type a part of a name and the system must find the full name of a person. In this column, if user uses ENTER without editing the cell, the same problem ocurrs.
    The simplistic code is here, runnable:
    import java.awt.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.table.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.KeyEvent;
    import java.text.NumberFormat;
    import java.text.ParseException;
    import javax.swing.text.DefaultFormatterFactory;
    import javax.swing.text.NumberFormatter;
    public class TableCheckCell extends JFrame {
      /** Creates a new instance of TableCheckCell */
      public TableCheckCell() {
        Object[] columnNames = {"Percents"};
        Object[][] data =
          {new Integer(-1)}, // <--- DEFAULT VALUE FORCED TO BE OUT OF RANGE...
          {new Integer(-1)},
          {new Integer(-1)},
          {new Integer(-1)}
        DefaultTableModel model = new DefaultTableModel(data, columnNames);
        JTable table = new JTable(model);
        table.setPreferredScrollableViewportSize(table.getPreferredSize());
        JScrollPane scrollPane = new JScrollPane( table );
        getContentPane().add( scrollPane );
        TableColumn col = table.getColumnModel().getColumn(0);
        col.setCellEditor(new CellIntegerEditor(CellIntegerEditor.CHECKMINMAX,0,100));
      public static void main(String[] args) {
        TableCheckCell frame = new TableCheckCell();
        frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
        frame.pack();
        frame.setLocationRelativeTo( null );
        frame.setVisible(true);
    * Implements a cell editor that uses a formatted text field
    * to edit Integer values.
    class CellIntegerEditor extends DefaultCellEditor {
      public static final int NOCHECK = 0;
      public static final int CHECKMINMAX = 1;
      public static final int CHECKMIN = 2;
      public static final int CHECKMAX = 3;
      JFormattedTextField ftf;
      NumberFormat integerFormat;
      private int checkinterv;
      private Integer minimum, maximum;
      private boolean DEBUG = false;
      public CellIntegerEditor(int checkinterv, int min, int max) {
        super(new JFormattedTextField());
        init(checkinterv, min, max);
      void init(int checkinterv, int min, int max) {
        ftf = (JFormattedTextField)getComponent();
        this.checkinterv = checkinterv;
        minimum = new Integer(min);
        maximum = new Integer(max);
        //Set up the editor for the integer cells.
        integerFormat = NumberFormat.getIntegerInstance();
        NumberFormatter intFormatter = new NumberFormatter(integerFormat);
        intFormatter.setFormat(integerFormat);
        if (checkinterv == CHECKMIN || checkinterv == CHECKMINMAX)
          intFormatter.setMinimum(minimum);
        if (checkinterv == CHECKMAX || checkinterv == CHECKMINMAX)
          intFormatter.setMaximum(maximum);
        ftf.setFormatterFactory(new DefaultFormatterFactory(intFormatter));
        ftf.setValue(minimum);
        ftf.setHorizontalAlignment(JTextField.TRAILING);
        ftf.setFocusLostBehavior(JFormattedTextField.PERSIST);
        //React when the user presses Enter while the editor is
        //active.  (Tab is handled as specified by
        //JFormattedTextField's focusLostBehavior property.)
        ftf.getInputMap().put(KeyStroke.getKeyStroke(
          KeyEvent.VK_ENTER, 0),
          "check");
        ftf.getActionMap().put("check", new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            if (!ftf.isEditValid()) { //The text is invalid.
              if (userSaysRevert()) { //reverted
                ftf.postActionEvent(); //inform the editor
            } else try {              //The text is valid,
              ftf.commitEdit();     //so use it.
              ftf.postActionEvent(); //stop editing
            } catch (java.text.ParseException exc) { }
      //Override to invoke setValue on the formatted text field.
      public Component getTableCellEditorComponent(JTable table,
        Object value, boolean isSelected,
        int row, int column) {
        JFormattedTextField ftf =
          (JFormattedTextField)super.getTableCellEditorComponent(
          table, value, isSelected, row, column);
        ftf.setValue(value);
        return ftf;
      //Override to ensure that the value remains an Integer.
      public Object getCellEditorValue() {
        JFormattedTextField ftf = (JFormattedTextField)getComponent();
        Object o = ftf.getValue();
        if (o instanceof Integer) {
          return o;
        } else if (o instanceof Number) {
          return new Integer(((Number)o).intValue());
        } else {
          if (DEBUG) {
            System.out.println("getCellEditorValue: o isn't a Number");
          try {
            return integerFormat.parseObject(o.toString());
          } catch (ParseException exc) {
            System.err.println("getCellEditorValue: can't parse o: " + o);
            return null;
      //Override to check whether the edit is valid,
      //setting the value if it is and complaining if
      //it isn't.  If it's OK for the editor to go
      //away, we need to invoke the superclass's version
      //of this method so that everything gets cleaned up.
      public boolean stopCellEditing() {
        JFormattedTextField ftf = (JFormattedTextField)getComponent();
        if (ftf.isEditValid()) {
          try {
            ftf.commitEdit();
          } catch (java.text.ParseException exc) { }
        } else { //text is invalid
          if (!userSaysRevert()) { //user wants to edit
            return false; //don't let the editor go away
        return super.stopCellEditing();
       * Lets the user know that the text they entered is
       * bad. Returns true if the user elects to revert to
       * the last good value.  Otherwise, returns false,
       * indicating that the user wants to continue editing.
      protected boolean userSaysRevert() {
        Toolkit.getDefaultToolkit().beep();
        ftf.selectAll();
        Object[] options = {"Corrigir"};
        String msg = "";
        if (checkinterv == CHECKMINMAX)
          msg = "Value must be between " + minimum + " and " + maximum + ".";
        else if (checkinterv == CHECKMIN)
          msg = "Value must be >= " + minimum + ".";
        else if (checkinterv == CHECKMAX)
          msg = "Value must be <= " + maximum + ".";
        JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ftf),msg);
        ftf.setValue(ftf.getValue());
        return true;
    }Then, I'd like to know if there is any way to check the user typed ENTER to go out of the cell, check the value of the cell and, if it is wrong, to come back to the cell, forcing the user to type a right value.

    Editing to force the entry of data in a cell is typically done when you press a button to process the data. It doesn't make sense to "edit" the cell when the user presses enter to go to the next cell. What if the user never places focus on a particular cell. Then the cell will never be edited.
    To force a user to enter a valid value once they have started editing you can do something like this:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=575309
    But you can't force a user to visit every cell in the table so you need to handle that as described above.

  • How to highlight specific words in the Reader

    Hi!
    I am new to the Acrobat SDK and could need some guidance on how to solve the following problem:
    I need a plug-in that is able to highlight specific words in a pdf file (e.g. by underlining it or changing the background color) and offers a context menu with futher actions when the user clicks on a highlighted word. The first step would be searching the text to find the word that should be marked. I think that should not be that hard but how can I highlight specific words? I first thought of annotations but I need it in the Reader and I should not change the pdf file itself (just the view of it).
    The idea is similar to the skype plug-in for Firefox or IE. The skype plug-in highlights phone numbers. We need to highlight specific words.
    Thanks for every hint on how to achieve this!
    Fabian

    >The documentation says that AVPageViewHilightText is supposed to use >the current color set with AVPageViewSetColor - so it should work. >What version of Acrobat are you working with?
    Yes that how understood the documentation too. I tried the following:
    //Define red
    red.space = PDDeviceRGB;
    red.value[0] = ASInt32ToFixed(1);
    red.value[1] = 0;
    red.value[2] = 0;
    // highlight
    AVPageViewSetColor(pageView, &red);
    PDTextSelect pdTextSelect = PDDocCreateTextSelect(pdDoc, pageNum, &bbox);
    AVPageViewHighlightText(pageView, pdTextSelect);
    I am using Acrobat 7.0.9.
    >Drawing an image would be done with AVPageViewDrawCosObj
    >- which means you'll need to bring the image in as a PDF
    > object and then render it.
    Oh I should have seen that. Thanks for the hint!!
    >Interesting, there should be a way to get transparency,
    > but I am not seeing it at the moment.
    As far as I understood it, it is possible to set the color to transparent but thats not what I am looking for. I would like to have a way of changing the alpha channel of the color.
    Thanks!
    Fabian

  • How to do bold word in smart form

    hallow i wont to now how i can do bold word in sm

    Hi,
    Check the Output style you are using.
    Goto SMARTSTYLE and add a character node to that style and give your requiremnet their save and activete it.
    Now you can use that character format in your smartform.
    regards,
    amit
    Reward all helpful replies.

Maybe you are looking for

  • Extract values from an object trapped in TreeMap

    I can't figure out how to get the balance of an account Object (consisting of name plus balance)which is stored in a TreeMap. Normally it would go like this: For example accounts[2].getBalance(); Normally would return the value for the specified acco

  • IPhoto does not see any changes after editing a photo in Camera Raw

    Hello everyone , I have some small problem with my iPhoto. I have set up Camer Raw in iPhoto as  External Editor, so when I click on edit in IPhoto, automatically opens my JPG in Camera Raw. After editing in Camera Raw I'm clicking on ,,Save image" t

  • E73 Compatibility with iSync and Nokia Multimedia ...

    Just switched from an N95 to a E73 and can't get my Mac to sync with the phone. Are there updates available or planned?

  • Example of a metadata driven workflow?

    I see a post that highlights the fact that metadata driven workflows can be created (here), but I am looking for a complete example that I can run and modify.  Does anyone know where I could get a complete example of a metadata driven workflow?

  • Problems Restoration Internet and Mountain Lion Restoration

    Good morning everyone! I started with a simple procedure to format my MacBook Pro with command + R after Disk utilities deleted the Macintosh HD then went to restore OS X Mountain Lion then starting dai that really gets my problems. As soon as I pres