Minggu, 13 Maret 2016

Java - Populate JTable From ArrayList In Java



Java - How To Populate JTable From ArrayList In Java Using  NetBeans


In this Java Tutorial we will see How To Load Data Into JTable From ArrayList In Java Using
 NetBeans .





Project Source Code:

package java_tutorials;

import java.util.ArrayList;
import javax.swing.table.DefaultTableModel;

/**
 * @author 1bestcsharp.blogspot.com
 */
public class Java_Populate_JTable_Using_ArrayList extends javax.swing.JFrame {

    /**
     * Creates new form Java_Populate_JTable_Using_ArrayList
     */
    public Java_Populate_JTable_Using_ArrayList() {
        initComponents();

         // use the addRowToJTable
        addRowToJTable();

    }
    
// create a class User and use it to populate the arraylist
    public class User{
        public int id;
        public String fname;
        public String lname;
        public int age;
        
        public User(int Id, String FName, String LName, int Age)
        {
            this.id = Id;
            this.fname = FName;
            this.lname = LName;
            this.age = Age;
        }
    }
    
// create a list of users
    public ArrayList ListUsers()
    {
        ArrayList<User> list = new ArrayList<User>();
        User u1 = new User(1,"FNA","LNA",10);
        User u2 = new User(2,"FNB","LNB",20);
        User u3 = new User(3,"FNC","LNC",30);
        User u4 = new User(4,"FND","LND",40);
        User u5 = new User(5,"FNE","LNE",50);
        User u6 = new User(6,"FNF","LNF",60);
        list.add(u1);
        list.add(u2);
        list.add(u3);
        list.add(u4);
        list.add(u5);
        list.add(u6);
        return list;
    }
    
// added rows from arraylist to jtable
    public void addRowToJTable()
    {
        DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
        ArrayList<User> list = ListUsers();
        Object rowData[] = new Object[4];
        for(int i = 0; i < list.size(); i++)
        {
            rowData[0] = list.get(i).id;
            rowData[1] = list.get(i).fname;
            rowData[2] = list.get(i).lname;
            rowData[3] = list.get(i).age;
            model.addRow(rowData);
        }
                
    }


    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Id", "First Name", "Last Name", "Age"
            }
        ));
        jScrollPane1.setViewportView(jTable1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(61, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Java_Populate_JTable_Using_ArrayList.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Java_Populate_JTable_Using_ArrayList.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Java_Populate_JTable_Using_ArrayList.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Java_Populate_JTable_Using_ArrayList.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Java_Populate_JTable_Using_ArrayList().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    // End of variables declaration                   
}

OutPut :

populate jtable from arraylist
JTable Data From ArrayList

Baca selengkapnya

Rabu, 09 Maret 2016

C# Course: Learn C# And Become A Pro

Use This Coupon Code 50% Off = LEARN058


                       
           Instructor : Mosh Hamedani
1 - C# Basics for Beginners: Learn C# Fundamentals by Coding

What are the requirements?

  • Visual Studio Community Edition (FREE)

What am I going to get from this course?

  • Learn the fundamentals of C# and .NET Framework
  • Work with primitive types and expressions
  • Work with non-primitive types (classes, structs, arrays and enums)
  • Learn the difference between value types and reference types
  • Control the flow of programs using conditional statements
  • Use arrays and lists
  • Work with files and directories
  • Work with text
  • Work with date and time
  • Debug C# applications effectively

What is the target audience?

  • Newbies or students looking for a refresher on the basics of C# and .NET

                                                             



2 - C# Intermediate: Classes, Interfaces And OOP

What are the requirements?

  • Basic understanding of C# constructs: variables, type conversion, classes, conditionals and loops

What am I going to get from this course?

  • Work with classes, constructors, fields, properties, methods and indexers
  • Use encapsulation to improve the robustness of the code and reduce the impact of change
  • Re-use code using inheritance and composition
  • Understand the problems with inheritance and how composition solves these problems
  • Change the behaviour of an application by extending its code, rather than changing it
  • Develop loosely-coupled, testable and extensible applications using interfaces

What is the target audience?

  • Any C# developer who wants to master classes and interfaces
  • Any C# programmer who wants to better understand object-oriented programming

                                                             





3 - C# Advanced Topics: Take Your C# Skills to the Next Level

Course Description


Chances are you're familiar with the basics of C# and are hungry to learn more. Or you've been out of touch with C# for a while and are looking for a quick course as a refresher to get you up to speed with advanced C# constructs. If so, then this course is for you.

In C# Advanced Topics, the third part in Mosh's best-selling C# series, he walks you through the advanced features of C# that are frequently used in building real-world applications:
  • Exception Handling
  • Generics
  • Delegates
  • Events
  • Lambda Expressions
  • Extensions Methods
  • LINQ
  • Nullable Types
  • Dynamics
  • Asynchronous Programming with Async / Await
  • And more

There are lots of free tutorials and videos on YouTube. Why should you take this course?
This course has a clean structure with a perfect pace (not too fast to confuse you, and not too slow to bore you or waste your time). It gives you an in-depth understanding of advanced C# features, and iscreated by a C# expert and best-selling author with in-depth knowledge of the C# language and .NET Framework as well as 13 years of professional experience in the industry. So, from the very beginning to the very end, you'll be confident that you'll be in good hands. If you got questions along the way, Mosh is here to help you.

                                                                 



    You Want More C# Course ? Ok

    4 - C# Developers: Double Your Coding Speed with Visual Studio



    Course Description


    If you want to be a real pro C# coder, you need to master your keyboard and Visual Studio. You need to be able to navigate in your code base, find and modify code in seconds. Great coders hardly ever use the mouse. They do everything with the keyboard. They use shortcuts and some tricks to type less and generate more code in less time. And that is what this course is all about. 
    Ideal Student
    This course is most suited to junior C# developers new to Visual Studio. But even if you've been programming in Visual Studio for a few years, you may still learn tips and tricks that you're not aware of. There is a whole section dedicated to ReSharper, which is one of the greatest plug-ins for Visual Studio. If you've never used ReSharper before, this course is a must for you.

    What are the requirements?

    • Visual Studio 2010 or higher
    • Basic knowledge of Visual Studio

    What am I going to get from this course?

    • Over 60 keyboard shortcuts that speed up your coding
    • Learn to write more code with less typing
    • Learn to use your keyboard like a pro and rely less on the mouse
    • Learn to navigate in your projects and find files, classes and members more quickly
    • Learn to compile, run and debug applications faster
    • Learn about great add-ons that make coding fun and easy

    What is the target audience?

    • Any .NET developer who wants to increase their productivity and write code fast
    • Any .NET developer who wants to master their keyboard skills

                                                                   


      5 - C# Developers: Learn the Art of Writing Clean Code





      Course Description


      "Any fool can write code that a computer can understand. Good programmers write code that humans can understand." - Martin Fowler
      Poorly written code is hard to understand, maintain and test. But what separates poorly written code (aka code that smells) from beautiful code that talks? In this course, Mosh walks you through common code smells found in C# programs and how to refactor them using ReSharper. Refactoring is changing the design of the existing code without changing its external behaviour.
      This course is packed with techniques and is a must for any C# developer who wants to improve the quality of their code.

      What are the requirements?

      • C# (at any level)

      What am I going to get from this course?

      • Tell the difference between good and bad good
      • Identify the smells in your code
      • Refactor your code in a safe and fast way using ReSharper
      • Write clean code that reveals the intent
      • Decompose long methods into smaller, more maintainable ones
      • Refactor lengthy switch statements into an object-oriented design
      • Simplify nested / complex conditional blocks
      • Remove duplicated code
      • Design the proper signature for your methods

      What is the target audience?

      • Any C# developer who has an interest in improving the quality of their code

                                                                     


        Now Start Making Your Own Apps


        Baca selengkapnya

        Web Development Course:


        Use This Coupon Code 50% Off = LEARN058

        1 - The Complete Web Developer Course - Build 14 Websites




                             
                   Instructor : Rob Percival
                   Lectures   : 236
                   Hours        : 28
                   Students   > 225.900
                   Rating        = 4.7 / 5

        Course Description

        Over 11 chapters you will learn:
          ·Setting up your (free) hosting
          ·HTML
          ·CSS
          ·Javascript
          ·jQuery
          ·CMSs and WordPress
          ·Responsive Design
          ·PHP Coding
          ·MySQL Databases
          ·APIs
          ·Mobile Apps

          What are the requirements?

          • No pre-knowledge required
          • Any computer - Windows, OSX or Linux
          • No special software required

          What am I going to get from this course?

          • Develop a website or app for your business
          • Learn how to make beautiful, interactive websites
          • Develop mobile applications
          • Earn money from your new skills

          What is the target audience?

          • Anyone wanting to learn how to build websites and apps
          • People wanting to make a living (or side-income) from web development



        2 - The Web Developer Bootcamp

                                                
                               
                   Instructor : Colt Steele
                   Lectures   : 287
                   Hours        : 41.5
                   Students   > 19.400

        Course Description

        Throughout the course we cover tons of tools and technologies including:
        • HTML5
        • CSS3
        • JavaScript
        • Bootstrap
        • SemanticUI
        • DOM Manipulation
        • jQuery
        • Unix(Command Line) Commands
        • NodeJS
        • NPM
        • ExpressJS
        • REST
        • MongoDB
        • Database Associations
        • Authentication
        • PassportJS
        • Authorization
        This course is also unique in the way that it is structured and presented. Many online courses are just a long series of "watch as I code" videos. This course is different. I've incorporated everything I learned in my years of teaching to make this course not only more effective but more engaging. The course includes:
        • Lectures
        • Code-Alongs
        • Projects
        • Exercises
        • Research Assignments
        • Slides
        • Downloads
        • Readings
        If you have any questions, please don't hesitate to contact me. I got into this industry because I love 

        What am I going to get from this course?

        • Make REAL web applications using cutting-edge technologies
        • Continue to learn and grow as a developer, long after the course ends
        • Create a blog application from scratch using Express, MongoDB, and Semantic UI
        • Create a complicated yelp-like application from scratch
        • Write your own browser-based game
        • Create static HTML and CSS portfolio sites and landing pages
        • Think like a developer. Become an expert at Googling code questions!
        • Create complex HTML forms with validations
        • Write web apps with full authentication
        • Use Bootstrap to create good-looking responsive layouts
        • Implement responsive navbars on websites
        • Use JavaScript variables, conditionals, loops, functions, arrays, and objects
        • Write Javascript functions, and understand scope and higher order functions
        • Create full-stack web applications from scratch
        • Manipulate the DOM with vanilla JS
        • Manipulate the DOM using jQuery
        • Translate between jQuery and vanillas JS
        • Write JavaScript based browser games
        • Use NodeJS to write server-side JavaScript
        • Write complex web apps with multiple models and data associations
        • Write a REAL application using everything in the course
        • Use Express and MongoDB to create full-stack JS applications
        • Use common JS data structures like Arrays and Objects
        • Master the command line interface
        • Use NPM to install all sorts of useful packages
        • Understand the ins and outs of HTTP requests
        • Create your own Node modules
        • Make a beautiful, responsive photographer's portfolio page
        • Create a beautiful, responsive landing page for a startup
        • Implement user authentication
        • Create a beautiful animated todo list application

        What is the target audience?

        • This course is for anyone who wants to learn about web development, regardless of previous experience
        • It's perfect for complete beginners with zero experience
        • It's also great for anyone who does have some experience in a few of the technologies(like HTML and CSS) but not all



        3 - PHP for Beginners -Become a PHP Master - Project Included




                           
                   Instructor : Edwin Diaz
                   Lectures   : 265
                   Hours        : 28.5
                   Students   > 13.900
                   Rating        = 4.7 / 5

        Course Description

        This PHP Course Covers the following and then some...
        • Databases in PHP
        • Object Oriented PHP
        • CMS project-similar to (Wordpress)
        • Form Submissions in PHP
        • Security in PHP
        • Variables in PHP
        • Math in PHP
        • Arrays in PHP
        • Control Structures in PHP
        • Comparison Operators in PHP
        • Mayor Loops in PHP
        • Functions in PHP
        • Constants in PHP
        • Super Globals in PHP
        • Sessions in PHP
        • Cookies in PHP
        • And much more .....
        Please look at all the lectures to see more things that are covered.

        What are the requirements?

        • Some HTML is needed for this course

        What am I going to get from this course?

        • Create a (CMS) Content Management System like wordpress
        • Create Databases
        • Use MYSQL with PHP
        • Use OOP in PHP
        • Create custom functions
        • And much more....

        What is the target audience?

        • This course is meant for TOTAL beginners in PHP
        • No programming experience is needed at all



        Now Start Making Your Own WebSite

        Baca selengkapnya

        Java Course


        Use This Coupon Code 50% Off = LEARN058

        1 - The Complete Java Developer Course 


                             
                   Instructor : Tim Buchalka
                   Lectures   : 183
                   Hours        : 38
                   Students   > 27.000
                   Rating        = 4.7 / 5

        Course Description

        Are you ready to learn how to program?
        This course assumes no previous experience and takes you from the absolute beginner concepts like showing you the tools you need to download and install, writing you very first Java program, and then goes into more detail as we explore the entire Java feature set.
        All the essential Java keywords, operators, statements, and expressions are explained in great detail, together with complete chapters on object-oriented programming and the Java API.
        You learn to develop powerful Java applications using one of the most powerful Integrated Development Environments on the market, IntelliJ IDEA!
        But don't worry, if you are used to using Eclipse, NetBeans or some other IDE. Because this is a pure Java course you are free to use any IDE you wish and you will have no problems getting the most out of the course.


        What are the requirements?

        • computer - Windows, Mac and Linux are all supported and setup and installation videos for each platform are included!
        • Nothing else is needed, everything you need to get started programming in Java is included in the course, and all the tools used are free.

        What am I going to get from this course?

        • Program fluently in Java
        • Understand the concepts of Object Oriented Programming
        • Be able to download and install Java on their computer
        • Understand Java Keywords, Expressions, Operators and Statements
        • Create their own java programs
        • Take their knowledge of Java to write applications for Android devices, the web, or even desktop applications

        What is the target audience?

        • The course is aimed at complete beginners and intermediate programmers. No previous programming experience is assumed!
        • If you are an expert Java program with extensive knowledge and many years experience, you may not get a lot out of this course. For everyone else the course is perfect for you!

        Click Here To Get Java Developer Course
        ||
        \/



        2 - Java Swing ( GUI ) Programming From Beginner To Expert


                                    
                                   Watch The Course Introduction



                               
                   Instructor : John Purcell
                   Lectures   : 93
                   Hours        : 14
                   Students   > 7.000

        Learn how to create desktop and Internet GUI Java programs and take your Java programming to the next level.


        Course Description

        This course teaches you how to create desktop and web-based applications using Java Swing, Java's built-in user interface toolkit.
        Among other things we'll look at nearly all Swing widgets, we'll take a look at JDBC for database access, the graphics API, model-view-controller (MVC) architecture, serialization for saving data, the listener-event model and even basic animation.




        Now Create Your Own Apps

        Baca selengkapnya