How will you add panel to a frame?

How will you add panel to a frame?

How will you add panel to a frame?
View Answers

August 18, 2010 at 2:36 AM

you can simply use add method to add panel to a frame
i.e panelA.add(frameA)

August 18, 2010 at 4:26 PM

Hi Friend,

Using add() method of JFrame.

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

class FormDemo extends JFrame {
JButton ADD;
JPanel panel;
JFrame f;

FormDemo(){
JLabel label1,label2;
final JTextField text1,text2;
label1 = new JLabel();
label1.setText("Name:");
text1 = new JTextField(20);

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

f=new JFrame();
panel=new JPanel(new GridLayout(2,2));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
f.add(panel,BorderLayout.CENTER);
f.setTitle("FORM");
f.setVisible(true);
f.pack();
}
public static void main(String[]args){
FormDemo ff=new FormDemo();
}
}

Thanks









Related Tutorials/Questions & Answers:
How will you add panel to a frame? - Java Interview Questions
How to create Multiple Frames using Java Swing
Advertisements
how to add panel inside frame?
frames - Java3D
ModuleNotFoundError: No module named 'framer'
ModuleNotFoundError: No module named 'frameq'
ModuleNotFoundError: No module named 'frameq'
Frames
How to add image in panel as background in net beans IDE?
ModuleNotFoundError: No module named 'framed'
HTML framed documents
Html framed document
in my project, i have to add scrollbars to a panel,. i need some example on it,how to doit.
how to connect two swing frames
How to access the "Add/Remove Programs" list in Control Panel using Java Program? - Java Beginners
in my project, i have to add only vertical scrollbar to a panel,but not horizontal scrollbar. i need some example on it,how to doit.
How do you add a numerical value to a regex
how to divide a web page into some frames.....
How would you read in and add all this into a list?
ModuleNotFoundError: No module named 'frames'
how to devide a web page into parts and setting the targets like frames but without using frames
create frames
how to get the image of a selected JRadioButton to another panel?
how to design control panel for web applications
How can you add elements of two arrayLists in java?
How To Create Internal Frames In Java
HTML frames
update two frames at once
ModuleNotFoundError: No module named 'gif-frames'
ModuleNotFoundError: No module named 'gif-frames'
ModuleNotFoundError: No module named 'markdown_frames'
ModuleNotFoundError: No module named 'gif-frames'
Getting all frames in a JDesktopPane container
HTML frames
frame1
frame2
frame3
border around frames
HTML combination of frames
HTML Frames Example
Extract frames from Video File
panel visibility
how to send joption panel dialog from server to multipleclients using sockets?
how to send joption panel dialog from server to multipleclients using sockets?
how to send joption panel dialog from server to multipleclients using sockets?
ModuleNotFoundError: No module named 'panel'
java Frames - Java Beginners
org.openforis.collect - collect-control-panel version 3.26.21 Maven dependency. How to use collect-control-panel version 3.26.21 in pom.xml?
how to display the selected row from the data table in model panel ??
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for mind-map-swing-panel version 1.4.9

Ads