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

public class CreateTabbedPane extends JFrame implements ActionListener
{

JButton b1;
JTextField txt1;
public CreateTabbedPane()
{

JFrame frame = new JFrame("Tabbed Pane Frame");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
JTabbedPane tab = new JTabbedPane();
  
  tab.addTab("Jay",new abc());
  tab.addTab("RD",ram a);

  
}

class abc extends JPanel
{
public abc()
{
txt1=new JTextField(15);
b1=new JButton("submit");
b1.addActionListeners(this);
add(b1);
}
}

class ram extends JPanel
{
public ram()
{
String s=txt1.getText();
JLabel la=new JLabel(s);
add(la);
}
}

public void actionPerformed(ActionEvent ae)
{
a=new ram();

}


public static void main(String[] args)
{
  frame.setSize(400,400);
  frame.setVisible(true);
  }
}

Guys this is Advanced java program(Swings)...
this is about JTabbedPane
Details of the program:
I'm trying to make a program in which in first tab there is a textfield and a button...
if i enter any word in that textfield and press the button submit,the same word should be shown in label in the second tab...
but i tried my level best,but it is showing some error which i can't solve or debug...
pls pls help me...i don't hav any1 to teach me so please help me

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by NormR1
1
// First Define "a" outside addTab then add "a", Compiler cant recognize ram a
tab.addTab("RD",ram a);
// Its Listener
b1.addActionListeners(this);
//Implement Action Listener
class abc extends JPanel
{
public abc()
{
txt1=new JTextField(15);
b1=new JButton("submit");
b1.addActionListeners(this);
add(b1);
}
}
// JFrame is not visible to void main function , also u are using Jframe Extend then why a new JFrame.
JFrame frame

See some Java Program's.....

Votes + Comments
thank u,i'l debug now
0

it is showing some error which i can't solve or debug...

When you get an error please copy and paste it here. That will speed things up for you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.