How to use JEditorPane in Jtable

Hi
I'm trying to put HyperLinks in JTable but i don't not how to add Hand Cursor when mouse is over a hyperLink and how to active it when click it.
Thanks
DefaultTableModel tableModel = new DefaultTableModel(new String[][]{{"<a href=www.google.com>Google</a>, <a href=www.yahoo.com>Yahoo</a>"}}, new String[]{"URL"});
JTable table = new JTable(tableModel);
table.setRowHeight(24);
table.setDefaultRenderer(Object.class, new EditorPaneTableCellRenderer());
class EditorPaneTableCellRenderer extends JEditorPane implements TableCellRenderer
EditorPaneTableCellRenderer()
setContentType("text/html");
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
String link = String.valueOf(value);
setText(link);
setBackground(isSelected? table.getSelectionBackground() : table.getBackground());
return this;
}

Multi-post: http://forum.java.sun.com/thread.jspa?threadID=5273661&tstart=0

Similar Messages

  • How to use AbstractTableModel in JTable

    hi
    i want how to use AbstractTableModel in Jtable
    plz give code

    Multi-post: http://forum.java.sun.com/thread.jspa?threadID=5273661&tstart=0

  • How to use checkboxes in jtable ?

    I am trying to use checkboxes in
    JTable,I set the property in the jtable column to boolean.The proplem is that i do no know how to use this property in java program.My intension is that,I will have a java form and a java button on it,by clicking the button, i will have to write a code,for example a code that fetches records from a table and displays them on the jtable(on the user interface),when I select the check box corresponding to any row,It should let me either delete or edit that row and this modification has to be reflected to the table in the database. At this time,i can fetch and display but i can not delete or modify any row because I do no know how to use the check box inside the jtable.
    Thank you for your help!

    Multi-post: http://forum.java.sun.com/thread.jspa?threadID=5273661&tstart=0

  • Plz tell me how to use JSpinner with JTable

    I have retrieve records from database but as the number of records(rows) are more than 1000 , i want to use JSpinner with JTable . plz solve my problem by giving the appropriate code for the same.

    hi
    check this links
    http://www.exampledepot.com/egs/javax.swing.table/CustRend.html
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
    hope this will help you.. this explains exactly what you want.
    regards
    Aniruddha

  • How to use vector in JTable? Please help......

    Hi there
    I can use JTable using object array to manupulate data but it has a limitation of defining number of rows of the array. Alternatively i want to use vector. Anyone help me how to convert to using vector.
    Regards.
    mortoza, Dhaka

    hi,
    you could either use javax.swing.table.DefaultTableModel because this class uses a java.util.Vector for data storage or you could implements your own TableModel by extending javax.swing.table.AbstractTableModel.
    best regards, Michael

  • How to use/populate JTable in Jdev 3.0 ?

    Is there any tutorial or examples available
    on how to use JTable in JDeveloper 3.0 ?
    After creating business objects project
    and application, what steps do I take to
    a) put a jtable class object into my application ? I have tried creating a
    frame (JFrame) using new\objects\frame, and
    then dragging JTable into the UI, but don't
    know how to connect things from there.
    b). manipulate/populate the grid from there
    using the business objects created
    earlier in the project ?
    The html documentation included with JDev 3 provides some clues on individual key word searches, but does not at all connect the dots. What is needed
    here is a tutorial like some of the others
    included.
    null

    You may find the following steps useful.
    Create an InfoBus form by:
    Select menu File | New...
    Select "InfoBus Data Form" and press OK
    Go through the wizard and create a
    Detail or Master Detail form.
    Be sure to place the detail in a GRID control (last few pages of wizard).
    Then look at the generated code. This form will contain a useful class GridControl which contains a JTable element. Most noteworthy is that the JTable is already hooked up to the data source.
    In particular, the GridControl that is in
    your source has a public method:
    public final JTable getTable()
    This gives you access to the JTable to further customize the way you need.
    Ofcourse there are other tutorials that touch
    on the above, but you won't find a tutorial
    on how to hook up a JTable to a database because we have many more advanced classes
    (InfoSwing: GridControl,...) that do that
    and much more for you. You will be much more
    productive if you rely on the additional InfoSwing components.
    I hope this helps,
    John@Oracle JDeveloper Team http://technet.oracle.com
    null

  • How to use read() method in JEditorPane

    Hai,
    I not quite understand how to use the "read(InputStream in, Object desc)" method in JEditorPane, especially the "Object desc" argument. What should I put there? Can anyone give me an examples?
    Thank you and sorry for the trouble.

    The second parameter could be an HTMLDocument. If you
    just pass null, then it takes the default as Text
    document.
    Cheers~ Thank idreesmd :)

  • How to assign values to JTable using mysql database

    how to assign value to JTable using mysql...

    Search the forum. You use the values of the "ResultSet" to create a "DefaultTableModel" which you then add to the "JTable".
    I'll let you pick the search keywords to use, which I've suggested above. You can also throw in my userid if you want to specifically look for my solution.

  • How i use jtable

    hi master
    sir how i use jtable
    please send me any detail sample with swing interfas and code
    thank's
    aamir

    Did you read the JTable API???
    You will find a link titled "How to Use Tables" that takes you to the Swing tutorial.

  • How to use Jtable cell Editor

    HI,
    Here trying to populate the ImageIcon using JLabel in Jtable cell. For that I used DefaultCellRenderer. For implement the mouseListener to label I used the DefaultCellEditor. I am facing one problem here. After editing the label I selected the second row of the table, the first row image is not displaying. Can any one help on this issue?
    public class LabelCellEditor extends DefaultCellEditor {
    public LabelCellEditor(final JCheckBox checkBox) {
    super(checkBox);
    public Component getTableCellEditorComponent(final JTable table, final Object value,
    final boolean isSelected, final int row, final int column) {
    Color background = null;
    background = ColorManager.SELECTED_ROW_BGCOLOR;
    labelVal = (JLabel) value;
    labelVal.setOpaque(true);
    labelVal.setFont(FontManager.TABLE_DATA_FONT);
    labelVal.setBackground(background);
    labelPanel = new JPanel();
    labelPanel.setOpaque(true);
    labelPanel.setBackground(background);
    labelPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    labelPanel.setBorder(new EmptyBorder(5, 0, 0, 0));
    labelPanel.add(labelVal);
    return this.labelPanel;
    public Object getCellEditorValue() {
    return this.labelPanel;
    public class LabelCellRenderer extends DefaultTableCellRenderer {
    public LabelCellRenderer(final int alignment) {
    //setHorizontalAlignment(alignment);
    this.align = alignment;
    public Component getTableCellRendererComponent(final JTable table, final Object value,
    final boolean isSelected, final boolean hasFocus, final int row, final int column) {
    if (value != null) {
    if (value instanceof JLabel) {
    labelVal = (JLabel) value;
    labelVal.setOpaque(true);
    labelVal.setFont(FontManager.TABLE_DATA_FONT);
    labelVal.setBackground(background);
    labelVal.setHorizontalAlignment(this.align);
    labelVal.setBorder(new EmptyBorder(0, LRPADD, 0, LRPADD));
    JPanel panel = new JPanel();
    panel.setOpaque(true);
    panel.setBackground(background);
    panel.setLayout(new FlowLayout(FlowLayout.LEFT));
    panel.setBorder(new EmptyBorder(5, 0, 0, 0));
    panel.add(labelVal);
    return panel;
    return this;
    }

    With more than 30 postings you should know by now how to use the "Code" tags when posting code so the code reatains its original formatting and is therefore more readable.
    There is no need to create a custom editor, here is a simple example.

  • How to show an html page using JEditorPane in applet.

    I have never use jeditorpane with applet so i dont know how to show a html page.if you have some code or any example then please posted that.Thanks

    public class MyApplet extends JApplet{
        private JTextPane textPane = null;
        public void init(){
        HTMLEditorKit editorKit = new HTMLEditorKit();
        HTMLDocument  htmlDoc   = (HTMLDocument)editorKit.createDefaultDocument();
        textPane  = new JTextPane();
        textPane.setEditable(false);
        textPane.setEditorKit(editorKit);
        textPane.setContentType("text/html");
        textPane.setDocument(htmlDoc);
        Container c = getContentPane();
        c.add(new JScrollPane(textPane),    BorderLayout.CENTER);
        c.add(buttonPanel,                  BorderLayout.SOUTH);
        c.add(Box.createVerticalStrut(5),   BorderLayout.NORTH);     
        c.add(Box.createHorizontalStrut(5), BorderLayout.EAST);     
        c.add(Box.createHorizontalStrut(5), BorderLayout.WEST);
        public void setHtml(String html){
            // you should check the textpane's document to detrmine if there
            // is already text in there..if so, then clear the textpane text and then
            // set the new html...Note: JTextPane only show basic Html ..
            // not like a full blown browser
            textPane.setTextt(html);
            textPane.setCaretPosition(0);
    }

  • How to use JTable model listener???

    Anyone got idea , how to use table model listener. Can explain in simple example with code?? how to pass back to resultset ??

    Well, your pretty good at asking questions, but not very good at thanking people for the help given to you so I don't think I'll waste too much time helping this time.
    A TableModelListener notifies you when the contents of a cell are changed. So simply take the data from the cell and update your ResultSet. You question is so general I don't know how you expect any more advice than that.

  • How to use JTable and database

    how i want to know how to store data into Jtable from the database for the end users.
    any tutorial or example will be helpfull.
    thank you

    my problem is i want to store data that i will get from the database into a JTableThen you problem is with Swing in which case you should be searching the Swing forum for answers. This question has been asked and answered several times. I know I've posted solutions before.

  • How do I make a JTable's header sorting actually change the actual table?

    How do I make a JTable's header sorting actually change the actual table?
    Currently, I'm using
    table.setAutoCreateRowSorter(true);to allow the user to sort the table.
    However, I want to be able to load something based on the selected row's index. The problem is that when the table is rearranged, the change appears to only be local, in other words, the actual table isn't changing.
    For instance:
    index 0 "A"
    index 1 "B"
    index 2 "C"
    Sorted in reverse gives me
    "C"
    "B"
    "A"
    But C is still index 2 (instead of 0).
    Thanks in advance.

    Cross posted and answered in the Swing forum.
    [http://forums.sun.com/thread.jspa?threadID=5353865]
    I see this is not your first incidence of cross posting. In future, please post a question once only.
    db

  • How to put data in JTable from database

    hi everyone,
    i want to query the databse and put the result in the JTable and if possible i want to edit some information. For example: i have 5 records in the database query them and place them in JTable and each record has its own status. if i want to change the status For Example: the status of the 4 records are "Cleared" and the other one is "RELEASEd" so if i have JCombo Box to set the 4 records in to RELEASED status and then save the changes is that possible?
    thank you
    dhing

    In [url /thread.jsp?forum=54&thread=387565]this thread I describe how to use a result set as a basis for table data. Check some database tutorials for information on getting a result set.

Maybe you are looking for