Home Answers Viewqa Java-Beginners how to create menubar and the below background color/image in java swing

 
 


mahalakshmi
how to create menubar and the below background color/image in java swing
1 Answer(s)      2 years and a month ago
Posted in : Java Beginners

how to create menubar and the below background color/image in java swing

View Answers

April 1, 2011 at 5:33 PM


import java.io.*;
import java.awt.*;
import javax.swing.*;
import javax.imageio.*;
import java.awt.image.*;
import java.awt.event.*;

public class MenuBarExample_BackgroundImage  implements ActionListener{
private  static BufferedImage image;
private  static JPanel  panel = new JPanel(){
protected void paintComponent(Graphics g){
super.paintComponent(g);
if(image != null){
g.drawImage(image, 0, 0, this);
}
}
};
MenuBarExample_BackgroundImage(){
panel.setLayout(null);
JMenuBar menubar = new JMenuBar();
    JMenu menu = new JMenu("Select");
    JMenuItem Item1 = new JMenuItem("c:\\flower1.jpg");
    JMenuItem Item2 = new JMenuItem("c:\\flower2.jpg");
    JMenuItem Item3 = new JMenuItem("c:\\flower3.jpg");
    JMenuItem Item4 = new JMenuItem("c:\\flower4.jpg");
    menu.add(Item1);
    menu.add(Item2);
    menu.add(Item3);
    menu.add(Item4);
    menubar.add(menu);
    Item1.addActionListener(this);
    Item2.addActionListener(this);
    Item3.addActionListener(this);
    Item4.addActionListener(this);
    JFrame f=new JFrame();
    f.setJMenuBar(menubar);
    f.add(MenuBarExample_BackgroundImage.getPanel());
    f.setSize(300,200);
    f.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
            String st=e.getActionCommand();
            try{
File file=new File(st);
image = ImageIO.read(file);
Dimension imageSize = new Dimension(image.getWidth(), image.getHeight());
panel.setPreferredSize(imageSize);
panel.repaint();     
}

catch(Exception ex){}
        }
public  static JPanel getPanel(){
return panel;
}

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









Related Pages:
how to create menubar and the below background color/image in java swing
how to create menubar and the below background color/image in java swing  how to create menubar and the below background color/image in java swing
Menubar and use <ul> <li> - Java Beginners
; background-image:url('MenuBackground.jpg... background-color:transparent...Menubar and use   I want to create a drop down menu with submenu...: uppercase; width: 18em; } #menu a { color: #000; background: url
Menubar and use <ul> <li> - Java Beginners
Menubar and use   I want to create a drop down menu with submenu, but have problem for one thing in IE, My button appear under the text of main menu. How can I bring it up? see the file at this address
Jbutton[] background & foregroundcolor change
Jbutton[] background & foregroundcolor change  how to change the color of the selected JButton in java swing. I am create JButton in an array... foreground and background color is changed. the remaining jbutton foreground
which values we have to use for compressing any color image
which values we have to use for compressing any color image  Sir........... in the process of compressing of any color image, which values do use as input for comprseeing algorithm. and how to get the image matrix from color
how to create reports in swing java?
how to create reports in swing java?  how to create reports in swing java
GRADIENT BACKGROUND
GRADIENT BACKGROUND  How to set gradient colors a s background for a jframe? pls help me..............   http://www.roseindia.net/java/example/java/swing/GradientColor.shtml
How to create a Java Runtime Editor - Swing AWT
How to create a Java Runtime Editor   Hi, I am working on a requirement in which I need to integrate a java runtime editor in swing application... using java swing, try the following code: import java.awt.BorderLayout
changing Background Color
changing Background Color   ... change background color of a pdf file. You can change the background color... color) to set the background color of that chunk. Here we pass
how to create a header in jtable using java swing
how to create a header in jtable using java swing  how to create a header in jtable using java swing   d
Storing the Color Image pixel values into 2d array
Storing the Color Image pixel values into 2d array  i want to store the color image pixel values into 2d array and agiain the array have to store into a text file using java... plz provide the code
java how to create visual swing editor
java how to create visual swing editor   How do I create a visual swing designer in java ?Meaning that I can "draw" a button,a JTextArea from within my designer program . I just need some basics . I've got no idea how to start
Get the color values as a matrix of color image
Get the color values as a matrix of color image  I am new to java and image processing, i want to get the color values as a matrix from the color image for giving input to the compression algorithm by using java. plz provide
How to create Runtime time jLabel in java swing ?
How to create Runtime time jLabel in java swing ?   hi sir. my problem is that i want to display database row on a jLabel. Suppose i retrived... will itself enter the number of Jlabel that will create on Panel. if user enter-3, ther
java swing in netbeans
java swing in netbeans  how can create sub menu in java swing using..."); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); JMenu... backwardMenuItem = new JMenuItem("Java"); newmenu.add(backwardMenuItem
background
background  how to add image as background to a frame
Java Swing Create LinkButton
Java Swing Create LinkButton You all are aware of JButtons, JRadioButtons, JToggleButtons and you have used these components in your applications. Here we are going to create a Link Button that will allow you to move to another page
Background Image for Navigation Bar
Background Image for Navigation Bar The tutorial illustrates how to add background image for UINavigationBar. To add a background image to UINavigationBar, you need to create a category that extends UINavigationBar. Just find the below
adding background image - Java Beginners
adding background image  how do i add background image to this code... = new JTextField (""); int average; JPanel background = new JPanel...); background.add(text11); getContentPane().add(background
Change Background of Slide Using Java
Change Background of Slide Using Java   ... respectively. Then create an object of Shape and set values, fill type, background..., setBackgroundColor(Color.blue) method to set background color
How to create Multiple Frames using Java Swing
Multiple Frames in Java Swing In this section, you will learn how to create multiple frames. Java Swing provides the utility to show frame within another frame by providing the class JInternalFrame. With the use of this class, you can
JSlider Component of Java Swing
JSlider Component of Java Swing       In this section, you will learn how to create a JSlider component of Java Swing. A Slider is a Swing tool which you can use for selecting
Create a JList Component in Java
Create a JList Component in Java       In this section, you will learn how to create a JList... items. This class extends the JComponent class in java swing. There has been
pdf background color
pdf background color       In this program we are going to tell you how we can change the background of the pdf file as well as the size of a pdf file irrespective of the fact
Java Swing : JLabel Example
In this tutorial, you will learn how to create a label in java swing
Create menus and submenus in Java
is given below: This program shows how to create menu bar, menus, submenus... Create menus and submenus in Java   ..., submenus and Separators in Java Swing. Menu bar contains a collection of menus
Change Background of Master Slide Using Java
Change Background of Master Slide Using Java  ... to create a slide then change background of the master slide. In this example we are creating a slide master for the slide show. To create slide show we
Change Background Picture of Slide Using Java
Change Background Picture of Slide Using Java  ...; In this example we are going to create a slide then change background picture of the slide... to set this picture as background. To set picture as background of slide we
How to create form in Swings
How to create form in Swings  How to create registration, login and question form in Java Swing?   Creating different forms in Java Swing - Examples how to create registration form in swing swing login form example
Convert Black & White Image to Color Image
selected in the image belowColor Setting: Now you have a selected black and white image to add color. Go to image > Adjustment > Color Balance... Convert Black & White Image to Color Image  
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
UIButton background image
UIButton background image  Hi, How to create uibutton with background image? Thanks
Create a ToolBar in Java
Create a ToolBar in Java       In this section, you will learn how to create toolbar in java. Swing provides a most important feature for creating an interactive component
java - Swing AWT
label3.setText( "Fill in the spaces below to create a Current Account...java  how can i link up these two interfaces ie CurrentAccount... import java.awt.FlowLayout; // specifies how components are arranged
UITextfield Background Color
is ..it's showing a background color. Though my text field color is white. Can you please suggest.. , how can i remove the background color of text field. Thanks!   iPhone UITextField Background Color Set the text field background color
Java swing
Java swing  how to create the login form?   1)LoginDemo.java: import javax.swing.*; import java.sql.*; import java.awt.*; import java.awt.event.*; class LoginDemo extends JFrame { JButton SUBMIT; JLabel
swing question - Java Beginners
swing question  how i can create login form in java with password entering i can to next page only if password is correct i want to use java swing feature
Change Background color using Custom Tag
Change Background color using Custom Tag In this program, We will create a Custom Tag which changes the background color. JSP Custom Tags : Provide... : In this Example, We will create a Custom Tag which changes the background color
create, edit ,open simple documents using java - Swing AWT
want to use Java Swing or JSP? Do you want to create word document file...create, edit ,open simple documents using java   In my program I have a text area.How to create document which will contain text in text
UITextField Background Image
UITextField Background Image  How can i set a background image... below.. on how to set the uitextfield leftview image.. - (void)viewDidLoad... a Background Image on UITextField - (void)viewDidLoad { [super viewDidLoad
JList Background Images..Urgent
JList Background Images..Urgent  I has done a JList that can change background color when i selected each of it, but if i want to change background image rather than background colors, how can i do it? Please help! my previous
Javascript background color - Java Beginners
Javascript background color  Hi How to compare background color...; Hi Friend, If you want to change the background color of the textbox, try the following code: Change background Color function check
How to Hide Button using Java Swing
Programming application how to hide the buttons using Java Swing. Please Visit this below reference link http://www.roseindia.net/tutorial/java/swing...How to Hide Button using Java Swing  Hi, I just begin to learn java
Java Swing : JFrame Example
Java Swing : JFrame Example In this section, you will learn how to create a frame in java swing. JFrame : JFrame class is defined in javax.swing.JFrame.... to create frame by using JFrame swingCreate object of JFrame
java swing question - Java Beginners
java swing question  how i can create login form in java with password entering i can to next page only if password is correct i want to use java swing feature
Java Swing Tutorials
a Frame   This program shows you how to create a frame in Java Swing... illustrates you how to create a Check Box component in Java Swing.   ... will learn how to create a radio button in java swing. Radio Button is like check box
create
create  how to create an excel file using java
Java swing - Java Beginners
Java swing  how to set the background picture for a panel in java swing .i m using Netbeans IDE.  Hi Friend, Try the following code... BufferedImage image; private JPanel panel = new JPanel(new GridLayout(4,2
How to design a beautiful background with flowers, design a beautiful background with flowers, beautiful flowers background
How to design a beautiful background with flowers       Follow this example to learn how...: Create a new file to make flower background. Fill: Go to File Menu >
Creating Check Box in Java Swing
Creating Check Box in Java Swing       This section illustrates you how to create a Check Box component in Java Swing. In this section, you can learn simply creating the Check Box

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.