Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.JTabbedPane;
- import javax.swing.JButton;
- import javax.swing.*;
- import java.awt.event.*;
- import java.awt.BorderLayout;
- import java.awt.GridLayout;
- import javax.swing.JTextField;
- import java.awt.Color;
- import java.awt.Dimension;
- import javax.swing.JComboBox;
- import javax.swing.BorderFactory;
- import javax.swing.JScrollPane;
- import javax.swing.JTextArea;
- import javax.swing.UIManager;
- import javax.swing.JTable;
- import javax.swing.JOptionPane;
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- public class TabbedPane extends JFrame {
- public TabbedPane() {
- //This will create the title you see in the upper left of the window
- setTitle("Sabre Local Data writer 1.0");
- setSize(400,500); //set size so the user can "see" it
- setResizable(false);
- JTabbedPane jtp = new JTabbedPane();
- //This creates the template on the windowed application that we will be using
- getContentPane().add(jtp);
- JPanel jp1 = new JPanel();//This will create the first tab
- JPanel jp2 = new JPanel();//This will create the second tab
- JPanel jp3 = new JPanel();
- jp1.setBorder(BorderFactory.createEmptyBorder(45, 45, 45, 45));
- JTextField names = new JTextField(50);
- JTextField pass = new JTextField(10);
- JComboBox combo1 = new JComboBox();
- combo1.setPreferredSize(new Dimension(100, 20));
- combo1.addItem("Option 1");
- combo1.addItem("Option 2");
- combo1.addItem("Option 3");
- combo1.addItem("Option 4");
- JTextArea textarea1 = new JTextArea("", 20, 20);
- jp1.setLayout(new GridLayout(0,1));
- JPanel pane = new JPanel(new GridLayout(0,1));
- pane.add(new JLabel("Username: "));
- pane.add(names);
- pane.add(new JLabel("Password: "));
- pane.add(pass);
- pane.add(new JLabel("Sélectionnez une option: "));
- pane.add(combo1);
- pane.add(new JLabel("Veuillez saisir un texte: "));
- pane.add(textarea1);
- pane.add(new JLabel(""));
- JButton submit = new JButton("Submit");
- pane.add(submit);
- //submit.addActionListener(new Handler());
- jp1.add(pane);
- //This adds the first and second tab to our tabbed pane object and names it
- jtp.addTab("Insérer données", jp1);
- jtp.addTab("Liste Saisies", jp2);
- jtp.addTab("Configuration", jp3);
- //This creates a new button called "Press" and adds it to the second tab
- JButton test = new JButton("Press");
- jp2.add(test);
- jp3.setLayout(new BorderLayout());
- // Create columns names
- String columnNames[] = { "Column 1", "Column 2", "Column 3" };
- // Create some data
- String dataValues[][] =
- {
- { "12", "234", "67" },
- { "-123", "43", "853" },
- { "93", "89.2", "109" },
- { "279", "9033", "3092" }
- };
- // Create a new table instance
- table = new JTable(dataValues, columnNames);
- // Add the table to a scrolling pane
- scrollPane = new JScrollPane(table);
- jp3.add( scrollPane, BorderLayout.CENTER);
- //This is an Action Listener which reacts to clicking on
- //the test button called "Press"
- ButtonHandler phandler = new ButtonHandler();
- test.addActionListener(phandler);
- setVisible(true); //otherwise you won't "see" it
- }
- //This is the internal class that defines what the above Action Listener
- //will do when the test button is pressed.
- class ButtonHandler implements ActionListener{
- public void actionPerformed(ActionEvent e){
- JOptionPane.showMessageDialog(null, "I've been pressed", "What happened?", JOptionPane. INFORMATION_MESSAGE);
- }
- }
- //example usage
- public static void main (String []args){
- TabbedPane tab = new TabbedPane();
- }
- }
- at TabbedPane.<init>(TabbedPane.java:1)
- at TabbedPane.main(TabbedPane.java:131)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement