java swing problem

java swing problem

View Answers

July 1, 2009 at 11:53 AM

Hi Friend,

Try the following code:

/*import javax.swing.*;
import java.io.*;
import java.awt.*;

public class CreatePanel extends JFrame {

JPanel [] pane = new JPanel[3];

public CreatePanel () {
super("Example Class");
setBounds(100,100,200,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

for ( int i=0; i<pane.length; i++ ) {
pane [i] = new JPanel(null);
}

for ( int i=1; i<pane.length; i++ ) {
pane[0].add(pane[i]);
}

pane[0].setBackground(Color.white);
pane[1].setBackground(Color.red);
pane[2].setBackground(Color.blue);

setContentPane(pane[0]);
setVisible(true);

}

public static void main ( String [] args ) {
new CreatePanel();
}

public void paint(Graphics g) {
pane[1].setBounds(0,0,100,100);
pane[2].setBounds(100,100,100,100);

this.paintComponents(g);
}

}*/
import java.io.*;
import java.awt.*;
import javax.swing.*;

class CreatePanel extends JFrame {
CreatePanel()
{
JPanel panel;
JLabel label1,label2;
JTextField text1,text2;

label1 = new JLabel();
label1.setText("Enter Name:");
text1 = new JTextField(20);

label2 = new JLabel();
label2.setText("Enter Address:");
text2 = new JTextField(20);

panel=new JPanel(new GridLayout(2,2));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
add(panel,BorderLayout.CENTER);
}
public static void main(String[]args){
CreatePanel panel=new CreatePanel();
panel.setTitle("FORM");
panel.setVisible(true);
panel.setSize(300,100);
}
}

Thanks









Related Tutorials/Questions & Answers:
Java Problem Steps - Swing AWT
Java Problem Steps  How to create a Jar File From the Dos prompt of a Swing program having two classes in the program with one is public class one of them
java swing problem - Java Beginners
java swing problem  i doesn't know about the panel in swings here i had created one frame then created a panel and i added that to my frame but which is not adding any item and it not showing that item on the panel tell me how
Advertisements
Java Swings problem - Swing AWT
Java Swings problem  Sir, I am facing a problem in JSplitPane. I want the divider in the splitpane to be customized. I have a splitpane with Horizontal orientation and here, there lies the divider between left component and right
problem in swing-awt
problem in swing-awt  I am doing project in core java and i am facing one problem. I have to add command prompt(terminal) to the fream at bottom but not getting the solution. So please help me. thanks and regards, Aakash
Swing Problem on submission of button
Swing Problem on submission of button  How to close current frame (Frame1) and open a new frame (Frame2) already created and pass the data to frame2 from frame1 on the clicking of button in swing
java image loadin and saving problem - Swing AWT
java image loadin and saving problem  hey in this code i am trying to load a picture and save it.........but image is only visible whn we maximize the frame savin is nt done plzz help me with this code......... import
jdbc and swing problem in netbeans
jdbc and swing problem in netbeans  i reteived the table from database in a jdbc program. next i want to do is place the table as it is in a jpanel.. i am using netbeans IDE can u tel me how to do that one?? urgent
jdbc and swing problem in netbeans
jdbc and swing problem in netbeans  i reteived the table from database in a jdbc program. next i want to do is place the table as it is in a jpanel.. i am using netbeans IDE can u tel me how to do that one?? urgent
Swing and AWT Problem - Swing AWT
Swing and AWT Problem  hi sir i have a problem i know from one Jframe we can send values to another Jframe. so in my project i have one fame containing three textfields CODE: String a=TNa.getText().toString(); String b
tooltip problem - Swing AWT
tooltip problem  Hi All, I am using SWT_AWT bridge in my code to embed swing components into SWT Composite. I am using a Swing JButton in SWT Composite. My problem is that I am unable to see the tooltip for this button even
swing frame problem
swing frame problem  Hi All, I m creating a swing/awt based window application which will take some data from user and according to that data it will display some information from DB to user etc.. Now when I will create
swing text field problem
swing text field problem  I want to navigate the content of text field from one class to another and viceversa through button but when I am getting the text from first class I am getting null value.please help me..here
swing text field problem
swing text field problem  I want to navigate the content of text field from one class to another and viceversa through button but when I am getting the text from first class I am getting null value.please help me..here
problem with JTable - Swing AWT
problem with JTable  hi guys, i was a student and i am very new to swings.i was having an assignment like i need to create a JTable with checkboxes inside it.i do have another checkbox outside the Table.i need to write
Multiple session problem - Swing AWT
Multiple session problem  I am working in a Linux based java swing application. Problem: I have optimized JDialog and JPanel for my use.... This problem is quite critical as UI looks quite unpredictable due
Jfree chart problem - Swing AWT
Jfree chart problem  hello i have a problem related to jfree chart i have some data and i want to display data in two different chart stacked area chart and line chart both in a single frame. That is hybrid combination
Frame refresh problem - Swing AWT
to correct this problem....its urgent!! thnks in adv..  Hi Friend
java swing - Swing AWT
java swing  how i can insert multiple cive me exampleolumn and row in one JList in swing?plz g  Hi Friend, Please clarify your question. Thanks
Java swing
Java swing  what are the root classes of all classes in swing
Java swing
Java swing  Does Swing contains any heavy weight component
java swing
java swing  view the book details using swing
java swing - Swing AWT
java swing  how to add image in JPanel in Swing?  Hi Friend, Try the following code: import java.awt.*; import java.awt.image....: http://www.roseindia.net/java/example/java/swing/ Thanks
java swing - Swing AWT
java swing   how i can insert in JFrame in swing?  Hi Friend, Try the following code: import java.awt.*; import javax.swing.*; import java.awt.event.*; class FormDemo extends JFrame { JButton ADD; JPanel
java swing - Swing AWT
java swing   Iam developing a java web browser.Actually my code works fine ie. i can load a web page without proxy.But in my place i have only proxy... a proxy or how to make my java web browser to listen to proxy setting??? please help
java swing
java swing  what is java swing   Swing is a principal GUI toolkit for the Java programming language. It is a part of the JFC (Java Foundation Classes), which is an API for providing a graphical user interface for Java
java swing
java swing  how to connect database with in grid view in java swing   Hi Friend, Please visit the following link:ADS_TO_REPLACE_1 Grid view in java swing Thanks
java swing
java swing  add two integer variables and display the sum of them using java swing
Java swing
Java swing  Write a java swing program to calculate the age from given date of birth
New Problem in Form Resizing - Swing AWT
New Problem in Form Resizing  Hi, I am using a MDI application...)); The problem is arising when the user resizes the form. The EditorPane(old... HeadPane.setBounds(0, 0, this.getWidth(), 100); But it creates another problem. it overwrites
Problem when resizing the form - Swing AWT
Problem when resizing the form  Hi, I am facing a problem when resizing the form. I have a JTextPane on the JInternalFrame which occupy all... The EditorPane(Old) overlaps the HeadPane(new). I think this problem is occuring whenever
SWT_AWT bridge ,jtextfield edit problem - Swing AWT
visit to : http://www.roseindia.net/java/example/java/swing/ Thanks... bridge in my code to embed swing components in to SWT Composite. I am using SWT_AWT bridge frame and adding JTextfield to it, My problem is that the JTextfield
java swing.
java swing.  Hi How SetBounds is used in java programs.The values in the setBounds refer to what? ie for example setBounds(30,30,30,30) and in that the four 30's refer to what
JAVA SWING
JAVA SWING  Hi.... Iam doing project in java...and my front end in swing ..our project is like billing software... then what are the topics i want cover? then how to design? pls help me
java swing - Swing AWT
java swing  how to save data in sql 2005 while insert in textfield  Hi Friend, Try the following code: import java.sql.*; import javax.swing.*; import javax.swing.border.*; import java.awt.*; import
Java swing
are displayed in the table..I need the source code in java swing...Java swing  If i am login to open my account the textfield,textarea and button are displayed. if i am entering the time of the textfield
Java swing
to the database using java swing...Java swing  I create one table. That table contains task ID and Task Name. When I click the task ID one more table will be open and that table
java - Swing AWT
What is Java Swing AWT  What is Java Swing AWT
swing - Java Beginners
Swing application testing  What are the conventions for testing a Java swing application
problem in swing program for opening two windows with same login credentials
problem in swing program for opening two windows with same login credentials  I Face two problems while writing the code in swing program 1.i... representation problem is when i delete a node the tree is not automatically
Java swing
Java swing  how to create simple addition program using java swing?   import java.awt.*; import javax.swing.*; import java.awt.event.*; class SumOfNumbers extends JFrame { SumOfNumbers(){ JLabel lab1=new
Java swing
Java swing  when i enter the time into the textbox and activities into the textarea the datas saved into the database.the java swing code for the above item   import java.sql.*; import java.awt.*; import javax.swing.
java swing
java swing  what is code for diplay on java swing internal frame form MYSQL DB pls send   Here is a code of creating form on jinternalframe and connect to mysql. import java.io.*; import java.sql.*; import java.awt.
SWING
SWING  A JAVA CODE OF MOVING TRAIN IN SWING
Java swing in NetBeans - Swing AWT
Java swing in NetBeans   thanks a lot sir for everything you answered for my last questions now sir i just have another 3 questions that is Q 1. i will specify a swing code for JTable using NETBEANS so would you tell me
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form

Ads