Home Answers Viewqa Java-Beginners java swing problem

 
 


gunasekarathondaimon
java swing problem
1 Answer(s)      3 years and 11 months ago
Posted in : Java Beginners

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 Pages:
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
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
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
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
SWING
SWING  A JAVA CODE OF MOVING TRAIN 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
swing
swing  Write a java swing program to delete a selected record from a table
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
Swing
Swing  Write a java swing program to search the details of the students. Searching is performed on studentā??s first name. The details of all those students having same name as in given in searching criterion will be displayed
Swing
Swing  Write a java swing program to search the details of the students. Searching is performed on studentā??s first name. The details of all those students having same name as in given in searching criterion will be displayed
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
Swing - Applet
information on swing visit to : http://www.roseindia.net/java/example/java...Swing  Hello, I am creating a swing gui applet, which is trying... on in order to retrieve the result. The problem i have is that i think the solution
Java - Swing AWT
Java  program to read,add,update,delete the database using swing and servlet  Hello Just Refer Don't Copy the content of this URL... the problem to visit...... http://roseindia.net/servlets/web-application.shtml
Mine Problem
Mine Problem  how to view a row from a table created in mysql in a java swing application
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
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-swings - Swing AWT
java-swings  How to move JLabel using Mouse? Here the problem is i have a set of labels in a panel. I want to arrange them in a customized order...://www.roseindia.net/java/example/java/swing/ Thanks. Amardeep
code - Swing AWT
code  i want example problem for menubar in swings  Hi Friend, Please visit the following links: http://www.roseindia.net/java/example/java/swing/SwingMenu.shtml http://www.roseindia.net/java/example/java/swing
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
java - Swing AWT
java  hello sir.. i want to start the project of chat server in java please help me out how to start it?? urgently....  Hi friend, To solve problem to visit this link....... http://www.roseindia.net
java,eclipse - Swing AWT
java,eclipse  Hi, I have made on program SimpleCalculator on eclipse 3.4.0.But while running the code I am getting the problem for Class File Editor Source not found Source attachment doesnot contain the source
java problem - Java Beginners
/java/example/java/swing/calculator-in-swing.shtml Thanks...java problem  Write a program to model a simple calculator. Each data line should consist of the next operation to be performed from the list below
problem
problem  Hi, what is java key words   Hi Friend, Java Keywords are the reserved words that are used by the java compiler for specific... information, visit the following link: Java Keywords Thanks
problem
problem  hi'sir mai niit student hu.mujhe java ka program samaj me nhi aata mai kya karu and mai kaise study karu please help me.   Learn Java from the given link: Java Tutorials
Java question - Swing AWT
Java question  I want to create two JTable in a frame. The data in one JTable will be shown as a result of a query i.e. the data in a resultset... be displayed. PLEASE SOLVE MY PROBLEM AS SOON AS POSSIBLE.  Hi Friend, Try
printout problem
information, visit the following link: http://www.roseindia.net/java/example/java/swing...printout problem  Hi I have created a swing application which enter some data and fetch some data from DB . Now I want a print feature by which i
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
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: Grid view in java swing Thanks
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
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
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
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
Frame refresh problem - Swing AWT
to correct this problem....its urgent!! thnks in adv..  Hi Friend
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
can interface solve this problem in java
/tutorial/java/swing/datePicker.html   thanks very much...can interface solve this problem in java  I have a JDialog which... this calander class. can interface solve this problem. If yes then how. pls
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
Authentication of password - Swing AWT
information. http://www.roseindia.net/java/example/java/swing/ Thanks... running code. If you have any problem then explain in detail. import java.io.
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
Swing UI alignment Issue on different Platform - Swing AWT
Swing UI alignment Issue on different Platform  Hi, We are developing screens using Java Swing on windows. The problem is when we take the same screen in Linux machine, The alignment is changing. This is happening if we change

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.