Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: James Rivera   on Jan 08 In Java Category.

  
Question Answered By: Erin Dunn   on Jan 08

the following program  working well but I have another program to do, I am
trying these few days ,can u help  me to do this program thanks for your help

Write a swing  program to create  the Tabbed Panels.

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.event.*;

public class  MyFrame extends JFrame implements ChangeListener
{
JTabbedPane mTabbedPane;
JPanel mPanel1;
JPanel mPanel2;
JPanel mPanel3;

public MyFrame(){
setTitle("JTabbedPanel");
JPanel contentPane = (JPanel)getContentPane();
contentPane.setLayout(new BorderLayout());
mTabbedPane = new JTabbedPane();

mPanel1 = new JPanel();
mPanel1.setLayout(new BorderLayout());
JLabel jLbl1 = new JLabel("This is panel  1");
jLbl1.setFont(new Font("TimesRoman", Font.BOLD, 36));
mPanel1.add("Center", jLbl1);
mTabbedPane.addTab("Panel 1", mPanel1);

mPanel2 = new JPanel();
mPanel2.setLayout(new BorderLayout());
JLabel jLbl2 = new JLabel("This is panel 2");
jLbl2.setFont(new Font("TimesRoman", Font.BOLD, 36));
mPanel2.add("Center", jLbl2);
mTabbedPane.addTab("Panel 2", mPanel2);

mPanel3 = new JPanel();
mPanel3.setLayout(new BorderLayout());
JLabel jLbl3 = new JLabel("This is panel 3");
jLbl3.setFont(new Font("TimesRoman", Font.BOLD, 36));
mPanel3.add("Center", jLbl3);
mTabbedPane.addTab("Panel 3", mPanel3);

contentPane.add("Center",mTabbedPane);
mTabbedPane.setSelectedIndex(0);
mTabbedPane.addChangeListener(this);
}

public void  stateChanged(ChangeEvent e) {
System.out.println(e);
}

public static void main(String args[]) {
MyFrame mf = new MyFrame();
mf.setVisible(true);
mf.setSize(200,200);
mf.show();
mf.pack();

mf.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}

Write a Swing program to create Buttons with

a) Tool tip text b) Image c) Border d) Short cut Key

Share: 

 

This Question has 10 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on JFC / Swing Or get search suggestion and latest updates.


Tagged: