i need to write a program that uses tabbedpane and each tab displays a flag
i have this much and have no clue where to go from here or if im heading in the right direction
import javax.swing.JTabbedPane;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.*;
import java.awt.event.*;
public class TabbedPaneDemo extends JPanel {
public TabbedPaneDemo() {
JTabbedPane tabbedPane = new JTabbedPane();
ImageIcon icon1 = new ImageIcon("images/us.gif");
tabbedPane.addTab("USA", icon1);
tabbedPane.setSelectedIndex(0);
ImageIcon icon2 = new ImageIcon("images/uk.gif");
tabbedPane.addTab("UK", icon2);
ImageIcon icon3 = new ImageIcon("images/germany.gif");
tabbedPane.addTab("Germany", icon3);
ImageIcon icon4 = new ImageIcon("images/ca.gif");
tabbedPane.addTab("Canada", icon4);
ImageIcon icon5 = new ImageIcon("images/china.gif");
tabbedPane.addTab("China", icon5);
ImageIcon icon6 = new ImageIcon("images/india.gif");
tabbedPane.addTab("India", icon6);
//Add the tabbed pane to this panel.
setLayout(new GridLayout(1, 1));
add(tabbedPane);
}
public static void main(String[] args) {
JFrame frame = new JFrame("TabbedPaneDemo");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
});
frame.getContentPane().add(new TabbedPaneDemo(),
BorderLayout.CENTER);
frame.setSize(400, 125);
frame.setVisible(true);
}
}
~Marsha
i have this much and have no clue where to go from here or if im heading in the right direction
import javax.swing.JTabbedPane;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.*;
import java.awt.event.*;
public class TabbedPaneDemo extends JPanel {
public TabbedPaneDemo() {
JTabbedPane tabbedPane = new JTabbedPane();
ImageIcon icon1 = new ImageIcon("images/us.gif");
tabbedPane.addTab("USA", icon1);
tabbedPane.setSelectedIndex(0);
ImageIcon icon2 = new ImageIcon("images/uk.gif");
tabbedPane.addTab("UK", icon2);
ImageIcon icon3 = new ImageIcon("images/germany.gif");
tabbedPane.addTab("Germany", icon3);
ImageIcon icon4 = new ImageIcon("images/ca.gif");
tabbedPane.addTab("Canada", icon4);
ImageIcon icon5 = new ImageIcon("images/china.gif");
tabbedPane.addTab("China", icon5);
ImageIcon icon6 = new ImageIcon("images/india.gif");
tabbedPane.addTab("India", icon6);
//Add the tabbed pane to this panel.
setLayout(new GridLayout(1, 1));
add(tabbedPane);
}
public static void main(String[] args) {
JFrame frame = new JFrame("TabbedPaneDemo");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
});
frame.getContentPane().add(new TabbedPaneDemo(),
BorderLayout.CENTER);
frame.setSize(400, 125);
frame.setVisible(true);
}
}
~Marsha