Java Populate JTable From Multidimensional Array

How To Fill A JTable With Multidimensional Array Data Using Java NetBeans

Fill JTable From Multidimensional Array Using Java



In this Java Tutorial we will see How To Populate A JTable From A 2D Array Values Using For Loop In Java NetBeans .




Project Source Code:


public void _2DArrayToTable()
    {
    
        String[][] data = {
                             {"A1","B1","C1","D1"},
                             {"A2","B2","C2","D2"},
                             {"A3","B3","C3","D3"},
                             {"A4","B4","C4","D4"},
                             {"A5","B5","C5","D5"},
                             {"A6","B6","C6","D6"},
                             {"A7","B7","C7","D7"},
                             {"A8","B8","C8","D8"},
                             {"A9","B9","C9","D9"},
                             {"A10","B10","C10","D10"} 
                          };
        
        DefaultTableModel model = (DefaultTableModel)jTable1.getModel();
        
//        for(int i = 0; i < data.length; i++)
//        {
//            String[] row = new String[data[i].length];
//            
//            for(int j = 0; j < data[i].length; j++)
//            {
//                row[j] = data[i][j];
//            }
//            
//            model.addRow(row);
//        }
        
         for(String[] row : data){
             model.addRow(row);
         }
        
    } 


OutPut:

Populate JTable Using 2D Array In Java

Java Display Multidimensional Array Content

How To Display 2D Array Data Using Java NetBeans

Display Multidimensional Array Vaues Using Java



In this Java Tutorial we will see How To Display Values From A Multidimensional Array Into A jTextArea Using For Loop In Java NetBeans .




Project Source Code:


public void showData(){
        
        String[][] data = {
                             {"A1","B1","C1","D1","E","F","G"},
                             {"A2","B2","C2","D2","E","F","G"},
                             {"A3","B3","C3","D3","E","F","G"},
                             {"A4","B4","C4","D4"},
                             {"A5","B5","C5","D5"},
                             {"A6","B6","C6","D6"},
                             {"A7","B7","C7","D7"},
                          };
        String txt = "";
        for(int i = 0; i < data.length; i++){
            for(int c = 0; c < data[i].length; c++){
                //jTextArea1.setText(jTextArea1.getText() + "");
                txt = txt + data[i][c] + " , ";
            }
            txt = txt + "\n";
        }
        
        jTextArea1.setText(txt);
        
    }
    


OutPut:

Show 2D Array Values Using Java

Java Search In A Multidimensional Array

How To Search Value In A 2D Array Using Java NetBeans

Search Data In A Multidimensional Array Using Java



In this Java Tutorial we will see How To Search And Find A Value Position Inside A  Multidimensional Array Using For Loop And Display The Position Into A JTextArea On A JButton Click Event In Java NetBeans .




Project Source Code:


 // the array
        String[][] data = {
                             {"A1","B1","C1","D1","E","F","G"},
                             {"A2","B2","C2","D2","E","B1","G"},
                             {"A3","B3","C3","B1","E","F","G"},
                             {"A4","B4","B1","D4"},
                             {"A5","B5","C5","D5"},
                             {"A6","B6","C6","B1"},
                             {"B1","B7","C7","D7"},
                          };
    
        // show array data in textArea
    public void showArrayData()
    {
        String txt = "";
        for(int i = 0; i < data.length; i++){
            for(int c = 0; c < data[i].length; c++){
                //jTextArea1.setText(jTextArea1.getText() + "");
                txt = txt + data[i][c] + " , ";
            }
            txt = txt + "\n";
        }
        
        jTextAreaData.setText(txt);
    } 


// get positions
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                      

        String pos = "", valToSearch = jTextField1.getText();
        
        for(int i = 0; i < data.length; i++){
            for(int j = 0; j < data[i].length; j++)
            {
                if(data[i][j].equals(valToSearch)){
                    pos = pos + "POSITION [ "+i+" , "+j+" ]";
                    pos = pos + "\n";
                }
            }
            
        }
        jTextAreaPos.setText(pos);
    }


OutPut:

Get Value Position Inside A 2D Array Using Java

Sell Your Source Code Online


if you're asking yourself how you can sell your app / apps source code online, you are in the right place.
in this post i will show you how to sell your source code using sellfy ?
and how much did i make selling my codes using sellfy ?

 What Is Sellfy ? 

Sellfy.com is website that give you the ability to sell your source code or any of your digital products easly .


 What Sellfy Does ? 


Sellfy.com host your products files, handle the payments and automatically send the products to customers after a purchase is made.


 How To Start Using Sellfy ? 



just go to Sellfy.com and click sign up and start selling your products.


 How To Add A Product To Sellfy ? 



you can watch a video tutorial from HERE
go to your Sellfy store and click products



and click "Add new product"  

this form will show up
just select your project file and add the product information and that's it


 How To Create Product Discounts / Coupon Codes ? 



you can watch a video tutorial from HERE
go to your Sellfy store and click discounts


this form will show up



click on "Add new discount"



and you can choose between "Coupon" And "Sale"


if you select "Sale" option you will see the form below, and you will have to enter "Sale" discounts information ( name, product, amount, expiration date )

if you select "Coupon" it's the same as "Sale"


to add a coupon to a sellfy product url:
product link : https://sellfy.com/p/aH3W/
product link + coupon: https://sellfy.com/p/aH3W/-POST40OFF/
formula: product link + "/-" + coupon code


 How To Embed The Product Button / Card To Your Blog / Website ? 


you can watch a video tutorial from HERE
go to your Sellfy store and click "Embed"



this form will show up



and you can select to get the "Button" or "Product Card" or "Store view"
if you select "button":

and copy and past the code in your blog
for the others "Product Card" and "Store view" it's tha same
copy and past.
you can see a "Store view" example from HERE 


 What Is My Sellfy Store ? 



go to https://sellfy.com/1bestcsharp you can only see the products visible on the store page ( you can hide a product from the store page if you want ) .


 Sellfy Video Tutorial 



 My Earnings Using Sellfy ? 


my best month on Sellfy is December 2017
you can watch my revenue for every month HERE
my total revenue for 2017 : $351.77

 How Much Does Sellfy Take ? 


if you are using Sellfy 'Free' or 'Basic' plans Sellfy charge 5% for every transaction
- i use 'free' (Legacy) plan myself
- there's more plans if you want
charge 5% + PayPal fees


 Payment Methods Available 


PayPal + Stripe

My Payment Email Message For A Sale






if you have any question leave it in the comments section below and i will give an answer or add it to this post as soon as i can .

good luck with your code :)

VB.Net DataGridView Header

How To Customize Datagridview Header In Vbnet

Style DataGridView Columns Header In VB.Net


In This VB.Net Tutorial  We Will See How To Change Datagridview Header Text Size, Text Color, Font Name, Background Color, Text Alignment ( center, left, right ), In Visual Basic.Net Programming Language And Visual Studio Editor .


Project Source Code:


Public Class Vbnet_DataGridView_Header

    Dim table As New DataTable()
    Private Sub Vbnet_DataGridView_Header_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        ' Add columns to your datatable 
        ' with the name of the columns and their type 

        table.Columns.Add("Id", Type.GetType("System.Int32"))
        table.Columns.Add("First Name", Type.GetType("System.String"))
        table.Columns.Add("Last Name", Type.GetType("System.String"))
        table.Columns.Add("Age", Type.GetType("System.Int32"))

        ' Add rows to the datatable with some data 

        table.Rows.Add(1, "XXXX", "YYYYY", 21)
        table.Rows.Add(2, "SSDD", "hGSQ", 33)
        table.Rows.Add(3, "fgfgd", "jgfdd", 53)
        table.Rows.Add(4, "cvfghyghj", "sdrgtyh", 19)
        table.Rows.Add(5, "hghfd", "ghjgdf", 36)
        table.Rows.Add(6, "cvvdfgh", "juyrfdvc", 63)

        ' now set the datagridview datasource equals to your datatable name 

        DataGridView1.DataSource = table


        ' set a different font familly and size and style for each column header 
        'DataGridView1.Columns(0).HeaderCell.Style.Font = New Font("SansSerif", 15, FontStyle.Bold)
        'DataGridView1.Columns(1).HeaderCell.Style.Font = New Font("Tahoma", 20, FontStyle.Italic)
        'DataGridView1.Columns(2).HeaderCell.Style.Font = New Font("SansSerif", 25, FontStyle.Strikeout)
        'DataGridView1.Columns(3).HeaderCell.Style.Font = New Font("Tahoma", 30, FontStyle.Underline)

          ' set font familly and size and style for all columns header 
        DataGridView1.ColumnHeadersDefaultCellStyle.Font = New Font("SansSerif", 20, FontStyle.Bold)

          ' set a different foreColor for each column header 
        'DataGridView1.Columns(0).HeaderCell.Style.ForeColor = Color.Red
        'DataGridView1.Columns(3).HeaderCell.Style.ForeColor = Color.Green

         ' set a foreColor for all columns header 
        DataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.Blue
        DataGridView1.EnableHeadersVisualStyles = False

        ' set a different background color for each column header 
        'DataGridView1.Columns(0).HeaderCell.Style.BackColor = Color.LightGreen
        'DataGridView1.Columns(3).HeaderCell.Style.BackColor = Color.Yellow

         ' set a background color for all columns header 
        DataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.LightGreen

 ' set the text position (center,left,right.......) for each column header 
        'DataGridView1.Columns(0).HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter
        'DataGridView1.Columns(3).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft

 ' set the text position (center,left,right.......) for all columns header 
        DataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter


    End Sub
End Class

// OUTPUT :

Customize Datagridview Columns Header In Visual Basic.Net

C# Transfer TreeView Nodes To DataGridView

How To Set TreeView Nodes Values Into DataGridView Rows Using C#

Transfer TreeView Nodes To DataGridView Using C#



In this C# Tutorial we will see How To Get TreeView Nodes Data And Set It Into DataGridView Rows Using For Loop On Button Click Event In CSharp Programming Language And Visual  Studio Editor.




Project Source Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class TreeView_To_DataGridView : Form
    {
        public TreeView_To_DataGridView()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            for(int i = 0; i < treeView1.Nodes.Count; i++)
            {
                TreeNode node = treeView1.Nodes[i];

                Object[] row = new Object[node.Nodes.Count];

                for(int j = 0; j < node.Nodes.Count; j++)
                {
                    row[j] = node.Nodes[j].Text;
                }

                dataGridView1.Rows.Add(row);
            }
        }
    }
}

OutPut:

TreeView To DataGridView In C#


C# Transfer DataGridView Data To TreeView

How To Set DataGridView Values Into TreeView Nodes Using C#

Transfer DataGridView Data To TreeView Using C#



In this C# Tutorial we will see How To Get DataGridView Rows Data And Set It Into TreeView Node Using For Loop And Datatable On Button Click Event In CSharp  Programming Language And Visual  Studio Editor.


Project Source Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class DatGridView_To_TreeView : Form
    {
        public DatGridView_To_TreeView()
        {
            InitializeComponent();
        }

        private void DatGridView_To_TreeView_Load(object sender, EventArgs e)
        {
            DataTable table = new DataTable();

            // add columns to datatable
            table.Columns.Add("Id", typeof(int));
            table.Columns.Add("First Name", typeof(string));
            table.Columns.Add("Last Name", typeof(string));
            table.Columns.Add("Age", typeof(int));

            // add rows to datatable
            table.Rows.Add(1, "First A", "Last A", 10);
            table.Rows.Add(2, "First B", "Last B", 20);
            table.Rows.Add(3, "First C", "Last C", 30);
            table.Rows.Add(4, "First D", "Last D", 40);
            table.Rows.Add(5, "First E", "Last E", 50);
            table.Rows.Add(6, "First F", "Last F", 60);
            table.Rows.Add(7, "First G", "Last G", 70);
            table.Rows.Add(8, "First H", "Last H", 80);

            dataGridView1.DataSource = table;
        }

        private void button1_Click(object sender, EventArgs e)
        {

            for(int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                int rowIndex = i + 1;
                TreeNode node = new TreeNode("Row_"+rowIndex);
                for(int j = 0; j < dataGridView1.Columns.Count; j++)
                {
                    node.Nodes.Add(dataGridView1.Rows[i].Cells[j].Value.ToString());
                }
                treeView1.Nodes.Add(node);
            }

        }
    }
}



OutPut:

DataGridView Data To TreeView Using C#

C# Add, Edit, Remove TreeView Node

How To Insert Update Delete Selected Node From TreeView Using C#

Add Edit Remove TreeView Node Using C#



In this C# Tutorial we will see How To Add Edit Remove The Selected TreeView Node Using TextBox Value On treeView AfterSelect To Get The Selected Node And 3 Button To Do The Insert, Update, Delete In CSharp Programming Language And Visual  Studio Editor.




Project Source Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class TreeView_Add_Edit_Delete_Node : Form
    {
        public TreeView_Add_Edit_Delete_Node()
        {
            InitializeComponent();
        }

        // add
        private void button1_Click(object sender, EventArgs e)
        {
            TreeNode node = new TreeNode(textBox1.Text);
            try
            {
                treeView1.SelectedNode.Nodes.Add(node);
            }
            catch (Exception ex)
            {
                treeView1.Nodes.Add(node);
            }

        }

      // edit
        private void button2_Click(object sender, EventArgs e)
        {
            treeView1.SelectedNode.Text = textBox1.Text;
        }

       // get selected node
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            textBox1.Text = treeView1.SelectedNode.Text;
        }

        // delete selected node
        private void button3_Click(object sender, EventArgs e)
        {
            treeView1.SelectedNode.Remove();
        }
    }
}


OutPut:

insert update delete treeview node using c#