Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Framework Container - add()
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


shraddha
Container - add()
1 Answer(s)      6 years and 3 months ago
Posted in : Framework



Advertisement
View Answers

October 23, 2008 at 3:15 PM


Hi,



I am sending simple code.


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

public class ContainerDemo {

private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("using component");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create the menu bar.
JMenuBar menuBar = new JMenuBar();
menuBar.setOpaque(true);
menuBar.setBackground(new Color(154, 165, 127));
menuBar.setPreferredSize(new Dimension(200, 20));
//Create a yellow label to put in the content pane.
JLabel yellowLabel = new JLabel();
yellowLabel.setOpaque(true);
yellowLabel.setBackground(new Color(248, 213, 131));
yellowLabel.setPreferredSize(new Dimension(200, 180));

//Set the menu bar and add the label to the content pane.
frame.setJMenuBar(greenMenuBar);
frame.getContentPane().add(yellowLabel, BorderLayout.CENTER);

frame.setSize(300,200);
frame.setVisible(true);
}

public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
---------------------------
if you have any problem then send me code in detail.


---------------------------------

Read for more information.

http://www.roseindia.net/java/example/java/swing/

Thanks.


Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com