Question: Container - add()

Ads

 
 
 

Share on Google+Share on Google+

shraddha
Container - add()
1 Answer(s)      8 years ago
Posted in : Framework
Ads
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.

Ads









Related Tutorials/Questions & Answers:
Tutorials   
Java Spring Hibernate Struts Training Spring 3 MVC Login Form Example Spring 3 MVC Login Form Example Error with LogIn with mysql database Selenium webdriver - Getting Xpath for element in IE Selenium webdriver - Getting Xpath for element in IE springframework Industrial problem maths Groovy Editor using Eclipse RCP Plugin Development Selenium-HP-Alm framework containment how to implement Single Sign On in enterprise application using spring framework Deploy war file Hadoop Mapreduce Java spring 15/03/14 How to found which class or method contain specific annotation? com.pixelmed.dicom.DicomException: No reader for jpeg-lossless available What is Software development framework? pie chart Struts 2 is it necessary to have depth knowledge on servlets jsp and jdbc to learn java frameworks Spring MVC and Hibernate with DWR 3 -- Configuration Using MySQL Database Spring Validations project web programming web programming is it possible to display page in full frame...after dividing page into frames...and is it possible to close frame write code in c# in an application one task has to done for every 15 minutes ? How con you do it? What is the structure of Spring framework? Scheduler triggering cron jobs multiple times at the scheduled time and job is retained even after deleting How to align the select tags in a single column. struts 1.3 array matrix i got illegal start of expression error , plese tell me the mistake where i did... zend2 frame work Spring Login Page Error not able to deploy application war on JBOSS 6.0 running on linux 5.5 URL Regular Expression for Struts Validator URL Regular Expression for Struts Validator getOutputStream() has already been called for this response how to develope a struts application using hibernate? Dialling from computer with other phone via modem card ORACLE- ATG -E Commerce ORACLE- ATG -E Commerce struts need of frameworks in java? need of frameworks in java? need of frameworks in java?

Ads

 
Advertisement null

Ads