Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Vector;
- import javax.swing.*;
- public class Foo2 extends JPanel {
- private String[] nameLst = { "One", "Two", "Three", "Four" };
- private JTable namTab;
- private JPanel namPan = new JPanel();
- public Foo2() {
- printNames();
- add(namPan);
- }
- public void printNames() {
- Vector<String> label = new Vector<String>();
- Vector<Vector<String>> helper = new Vector<Vector<String>>();
- for (String nametmp : nameLst) {
- Vector<String> a = new Vector<String>();
- a.add(nametmp);
- helper.add((Vector<String>/* just a cast */) a.clone());
- }
- label.add("Currently active:");
- namTab = new JTable(helper, label);
- namPan.add(new JScrollPane(namTab));
- }
- private static void createAndShowGui() {
- Foo2 mainPanel = new Foo2();
- JFrame frame = new JFrame("Foo2");
- frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- frame.getContentPane().add(mainPanel);
- frame.pack();
- frame.setLocationByPlatform(true);
- frame.setVisible(true);
- }
- public static void main(String[] args) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- createAndShowGui();
- }
- });
- }
- }
Add Comment
Please, Sign In to add comment