Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Display Money Separator To jTable

  1. #1
    Junior Member
    Join Date
    May 2013
    Location
    Indonesia
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Display Money Separator To jTable

    Greetings all the master java programming language, please guidance. I find it difficult to display the number format from database to JTable with a money separator. I've been googling but all the ways that I get failed.

    Thank you,
    Best Regards.


  2. #2
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: Display Money Separator To jTable

    I have no idea what you're trying to do, but it sounds like a renderer problem.
    How to Use Tables (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)

  3. #3
    Junior Member
    Join Date
    May 2013
    Location
    Indonesia
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Display Money Separator To jTable

    i want to Render Cell to locale Germany, so I can display the numeric data from database to JTable column with format money.
    because the money format separator German same as my country Indonesia,
    Example Money Format : Rp. 1.000.000,00

  4. #4
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: Display Money Separator To jTable

    Yup, you need a tableCellRenderer.

  5. #5
    Junior Member
    Join Date
    May 2013
    Location
    Indonesia
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Display Money Separator To jTable

    can give me sample code, because I am not too understand jTable column render ^_^.

  6. #6
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: Display Money Separator To jTable

    Uhm, Ive posted a link to the tutorial in my previous post. There is example code.

  7. #7
    Junior Member
    Join Date
    May 2013
    Location
    Indonesia
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Re: Display Money Separator To jTable

    this my code :
    public final class TransaksiMhs extends javax.swing.JInternalFrame {
        DefaultTableModel tabelModel = new DefaultTableModel(); 
     
        static class DecimalFormatRenderer extends DefaultTableCellRenderer {
        private static final DecimalFormat formatter = new DecimalFormat( "#.00" );}
     
        /*Jika ingin menggunakan horizontal jScrollpane setAutoRezieMode tabel
        harus di off*/
     
        /** Creates new form TransaksiMhs */
        public TransaksiMhs() {
            initComponents();
            tabelBiaya.setModel(tabelModel);
            tabelModel.addColumn("NO.TRANS");
            tabelModel.addColumn("NAMA");
            tabelModel.addColumn("BIAYA");
            tabelModel.addColumn("HARGA");
            tabelModel.addColumn("JUMLAH");        
            tabelModel.addColumn("TOTAL"); 
            tabelBiaya.getColumnModel().getColumn(5).setCellRenderer(new DecimalFormatRenderer());

    but nothing happen to jTable Column, what wrong with my code?

Similar Threads

  1. while looping a swing worker does not display results on jtable?
    By harshilshah in forum AWT / Java Swing
    Replies: 6
    Last Post: May 2nd, 2013, 05:49 AM
  2. Deposit Money
    By spyxdaxworld in forum Java Theory & Questions
    Replies: 1
    Last Post: October 25th, 2012, 11:55 PM
  3. How to display data and time in JTable
    By kpat in forum AWT / Java Swing
    Replies: 2
    Last Post: April 8th, 2012, 12:19 PM
  4. Urgent help needed regarding JTable display
    By kasi in forum AWT / Java Swing
    Replies: 5
    Last Post: July 10th, 2010, 06:25 AM
  5. [SOLVED] find the position of the field separator in the String---need help ASAP
    By rajesh.mv in forum Java Theory & Questions
    Replies: 6
    Last Post: August 17th, 2009, 10:33 AM