twitter.SingleTweet.java Source code

Java tutorial

Introduction

Here is the source code for twitter.SingleTweet.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package twitter;

import twitter4j.Status;

/**
 *
 * @author Administrator
 */
public class SingleTweet extends javax.swing.JPanel {

    /**
     * Creates new form PanelX
     */
    public SingleTweet() {
        initComponents();
    }

    public SingleTweet(Status st) {
        this();
        mainTxt.setText(st.getText());
        timeTxt.setText(st.getCreatedAt().toString());
        userTxt.setText(st.getUser().getName());
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        mainTxt = new javax.swing.JTextArea();
        timeTxt = new javax.swing.JTextField();
        userTxt = new javax.swing.JTextField();

        setBackground(new java.awt.Color(255, 153, 0));

        mainTxt.setEditable(false);
        mainTxt.setColumns(20);
        mainTxt.setLineWrap(true);
        mainTxt.setRows(2);
        mainTxt.setWrapStyleWord(true);
        mainTxt.setAutoscrolls(false);
        jScrollPane1.setViewportView(mainTxt);

        timeTxt.setEditable(false);

        userTxt.setEditable(false);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(timeTxt)
                                .addComponent(userTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 510,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                        .addComponent(timeTxt, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(userTxt, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 85,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 49, Short.MAX_VALUE)));
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea mainTxt;
    private javax.swing.JTextField timeTxt;
    private javax.swing.JTextField userTxt;
    // End of variables declaration//GEN-END:variables
}