All pastes #917996 Raw Edit

mrcheeks

public java v1 · immutable
#917996 ·published 2008-02-25 20:51 UTC
rendered paste body
import java.awt.BorderLayout;import java.awt.Container;import java.awt.EventQueue;import java.awt.FlowLayout;import java.util.List;/* * To change this template, choose Tools | Templates * and open the template in the editor. */import java.util.Vector;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.table.DefaultTableModel;/** * * @author r0bby */public class ChannelListEventRunnableExample{    public void receiveEvent(Object ircEvent)    {        List channelListEventData = new Vector(); //(List)ircEvent;                JFrame sandIRCFrameINSTANCE = null; //SandIRCFrame.getInstance().getFrame();        final JDialog channelListDialog = new JDialog(sandIRCFrameINSTANCE, true);        channelListDialog.setTitle("Channel list");        channelListDialog.setLayout(new BorderLayout(2,2));                Container container = channelListDialog.getContentPane();                Vector columnNames = new Vector();        columnNames.add("Channel name");        columnNames.add("Users");        columnNames.add("Topic");        Vector data = new Vector();        // loop on your data        //        for(int i=0;i<li.size();i++){        //             Vector row = new Vector();        //             row.add("");        //                row.add("");        //                row.add("");        //             data.add(row);        //        }        // see above - the loop        Vector row = new Vector();        row.add("##swing");        row.add("10");        row.add("Swing topic");        data.add(row);        DefaultTableModel channelListModel = new DefaultTableModel(data,                columnNames);        JTable channelListTable = new JTable(channelListModel);        JScrollPane channelListScrollPane = new JScrollPane();        channelListScrollPane.getViewport().add(channelListTable);        JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));        JButton refreshButton = new JButton("Refresh list");        JButton joinButton = new JButton("Join channel");        JButton saveListButton = new JButton("Save list");        buttonsPanel.add(refreshButton);        buttonsPanel.add(saveListButton);        buttonsPanel.add(joinButton);                container.add(channelListScrollPane, BorderLayout.CENTER);        container.add(buttonsPanel, BorderLayout.SOUTH);                channelListDialog.pack();                EventQueue.invokeLater(new Runnable() {            public void run() {                channelListDialog.setVisible(true);            }        });    }}