Swings Menu Bar

Swings Menu Bar

Hello,

I created a menu bar using Java Swings...
n New Record, Edit Record etc are the menu items.
Now, I want to display the appropriate fields according the menu Item selected..below it..

i.e.
If we selected New Record,
then Desired TextFields and new button should be displayed
and if we selected edit Record,
then the textfields related to editing and edit button should be displayed.

Everything should be displayed below the menu bar...

How to do this..??
or atleast what to use to get this..??
View Answers

March 15, 2010 at 11:28 AM

Hi Friend,

Try the following code:

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

public class MenuData extends JFrame{
JTextField text1,text2,text3;
JLabel label1,label2,label3;
JPanel panel;
JButton button1,button2;
public MenuData(){
JMenuBar menuBar = new JMenuBar();
JMenu menu1 = new JMenu("Record");
JMenuItem item1 = new JMenuItem("Add Record");
JMenuItem item2 = new JMenuItem("Edit Record");
label1=new JLabel("ID:");
text1=new JTextField(20);
label2=new JLabel("Name:");
text2=new JTextField(20);
label3=new JLabel("Address:");
text3=new JTextField(20);
button1=new JButton("Add");
button2=new JButton("Edit");

panel=new JPanel(new GridLayout(4,2));
menuBar.add(menu1);

menu1.add(item1);
menu1.add(item2);
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(label3);
panel.add(text3);
panel.add(button1);
panel.add(button2);

add(panel);
setJMenuBar(menuBar);
setVisible(true);
setSize(400,160);

label1.setVisible(false);
text1.setVisible(false);
label2.setVisible(false);
text2.setVisible(false);
label3.setVisible(false);
text3.setVisible(false);
button1.setVisible(false);
button2.setVisible(false);

item1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
label1.setVisible(true);
text1.setVisible(true);
label2.setVisible(true);
text2.setVisible(true);
label3.setVisible(true);
text3.setVisible(true);
button1.setVisible(true);
button2.setVisible(false);

}

});
item2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
label1.setVisible(true);
text1.setVisible(true);
label2.setVisible(true);
text2.setVisible(true);
label3.setVisible(true);
text3.setVisible(true);
button1.setVisible(false);
button2.setVisible(true);


}

});
}
public static void main(String args[]){
MenuData data=new MenuData();
}

}

Thanks

March 15, 2010 at 11:37 AM

The above answer is good...

But what i require is...
to delete a record i just need only one textfield to ask the user the id to delete the record

and to show a list there should be only one text area... to show the list of records..









Related Tutorials/Questions & Answers:
Swings Menu Bar - Java Beginners
Swings Menu Bar  Hello, I created a menu bar using Java Swings... n New Record, Edit Record etc are the menu items. Now, I want to display the appropriate fields according the menu Item selected..below it.. i.e. If we
Menu Bar prob.
Menu Bar prob.  I want a menu to be displayed in each page of my swing appl. how to go abt
Advertisements
menu bar in javascript - JSP-Servlet
menu bar in javascript  sir i need to display menu bar with some background color.in each menu,there are some values to display as menu.again if i select each value,again a sub menu to display.plz send me some code. menubar
Create Menu Bar in SWT
Create Menu Bar in SWT       This section illustrates you how to create a menu bar. In SWT... to create a menu bar. The method setMenu() sets the pull down menu. The SWT.SEPERATOR
common Menu bar(toolBar) at the top of all view
common Menu bar(toolBar) at the top of all view  I creat on login page and after sign in I move to next page. Now I want to add menu bar at the top of my all view. Any one have any idea abt how to do
How to remove the background color of bootstrap menu bar?
How to remove the background color of bootstrap menu bar?  Hi, What css can be used to remove the color of bootstrap menu bar? thanks   ... the background image for the nabvar in a bootstrap based menu. Thanks
Menu Bar in Java
Menu Bar in Java       A Menu Bar is a set of option that allow the user to choose from...; a user can choose in a menu bar. In this Tutorial we want to describe you how
Menu Bar in Java
Menu Bar in Java       A Menu Bar is a set of option that allow the user to choose from any one... choose in a menu bar. In this Tutorial we want to describe you how to create a Menu
com.vaadin - vaadin-menu-bar-flow version 24.2.8 Maven dependency. How to use vaadin-menu-bar-flow version 24.2.8 in pom.xml?
com.vaadin  - Version 24.2.8 of vaadin-menu-bar-flow Maven dependency? How to use  com.vaadin  - Version 24.2.8 of vaadin-menu-bar-flow in pom.xml? How to use vaadin-menu-bar-flow version 24.2.8 in pom.xml? Learn to use
com.vaadin - vaadin-menu-bar-flow version 23.2.16 Maven dependency. How to use vaadin-menu-bar-flow version 23.2.16 in pom.xml?
com.vaadin  - Version 23.2.16 of vaadin-menu-bar-flow Maven dependency? How to use  com.vaadin  - Version 23.2.16 of vaadin-menu-bar-flow in pom.xml? How to use vaadin-menu-bar-flow version 23.2.16 in pom.xml? Learn to use
com.vaadin - vaadin-menu-bar-flow version 24.1.2 Maven dependency. How to use vaadin-menu-bar-flow version 24.1.2 in pom.xml?
com.vaadin  - Version 24.1.2 of vaadin-menu-bar-flow Maven dependency? How to use  com.vaadin  - Version 24.1.2 of vaadin-menu-bar-flow in pom.xml? How to use vaadin-menu-bar-flow version 24.1.2 in pom.xml? Learn to use
com.vaadin - vaadin-menu-bar-flow version 24.0.2 Maven dependency. How to use vaadin-menu-bar-flow version 24.0.2 in pom.xml?
com.vaadin  - Version 24.0.2 of vaadin-menu-bar-flow Maven dependency? How to use  com.vaadin  - Version 24.0.2 of vaadin-menu-bar-flow in pom.xml? How to use vaadin-menu-bar-flow version 24.0.2 in pom.xml? Learn to use
SWINGS
SWINGS  WHAT ARE THE DIFFERENCES BETWEEN AWT AND SWINGS
Maven Repository/Dependency: com.vaadin | vaadin-menu-bar-flow
Maven Repository/Dependency of Group ID com.vaadin and Artifact ID vaadin-menu-bar-flow. Latest version of com.vaadin:vaadin-menu-bar-flow dependencies. # Version Release Date 1
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 1.2.4 is released. Learn to use vaadin-menu-bar-flow version 1.2.4 in Maven based Java projects
Maven dependency for  com.vaadin  - Version 1.2.4 of vaadin-menu-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 1.2.4.
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 14.5.0 is released. Learn to use vaadin-menu-bar-flow version 14.5.0 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 14.5.0. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 14.5.1 is released. Learn to use vaadin-menu-bar-flow version 14.5.1 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 14.5.1. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 14.5.2 is released. Learn to use vaadin-menu-bar-flow version 14.5.2 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 14.5.2. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 14.5.3 is released. Learn to use vaadin-menu-bar-flow version 14.5.3 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 14.5.3. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 14.5.4 is released. Learn to use vaadin-menu-bar-flow version 14.5.4 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 14.5.4. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 14.5.5 is released. Learn to use vaadin-menu-bar-flow version 14.5.5 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 14.5.5. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 14.6.0 is released. Learn to use vaadin-menu-bar-flow version 14.6.0 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 14.6.0. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 14.6.1 is released. Learn to use vaadin-menu-bar-flow version 14.6.1 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 14.6.1. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 14.6.2 is released. Learn to use vaadin-menu-bar-flow version 14.6.2 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 14.6.2. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 14.6.3 is released. Learn to use vaadin-menu-bar-flow version 14.6.3 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 14.6.3. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 14.6.4 is released. Learn to use vaadin-menu-bar-flow version 14.6.4 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 14.6.4. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 14.6.5 is released. Learn to use vaadin-menu-bar-flow version 14.6.5 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 14.6.5. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 18.0.4 is released. Learn to use vaadin-menu-bar-flow version 18.0.4 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 18.0.4. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 18.0.5 is released. Learn to use vaadin-menu-bar-flow version 18.0.5 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 18.0.5. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 18.0.6 is released. Learn to use vaadin-menu-bar-flow version 18.0.6 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 18.0.6. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 18.0.7 is released. Learn to use vaadin-menu-bar-flow version 18.0.7 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 18.0.7. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 19.0.0 is released. Learn to use vaadin-menu-bar-flow version 19.0.0 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 19.0.0. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 19.0.1 is released. Learn to use vaadin-menu-bar-flow version 19.0.1 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 19.0.1. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 19.0.2 is released. Learn to use vaadin-menu-bar-flow version 19.0.2 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 19.0.2. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 19.0.3 is released. Learn to use vaadin-menu-bar-flow version 19.0.3 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 19.0.3. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 19.0.4 is released. Learn to use vaadin-menu-bar-flow version 19.0.4 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 19.0.4. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 19.0.5 is released. Learn to use vaadin-menu-bar-flow version 19.0.5 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 19.0.5. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 19.0.6 is released. Learn to use vaadin-menu-bar-flow version 19.0.6 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 19.0.6. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 19.0.7 is released. Learn to use vaadin-menu-bar-flow version 19.0.7 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 19.0.7. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 19.0.8 is released. Learn to use vaadin-menu-bar-flow version 19.0.8 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 19.0.8. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 19.0.9 is released. Learn to use vaadin-menu-bar-flow version 19.0.9 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 19.0.9. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 20.0.0 is released. Learn to use vaadin-menu-bar-flow version 20.0.0 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 20.0.0. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 20.0.1 is released. Learn to use vaadin-menu-bar-flow version 20.0.1 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 20.0.1. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 20.0.2 is released. Learn to use vaadin-menu-bar-flow version 20.0.2 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 20.0.2. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 20.0.3 is released. Learn to use vaadin-menu-bar-flow version 20.0.3 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 20.0.3. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 20.0.4 is released. Learn to use vaadin-menu-bar-flow version 20.0.4 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 20.0.4. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 22.0.7 is released. Learn to use vaadin-menu-bar-flow version 22.0.7 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 22.0.7. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 22.0.11 is released. Learn to use vaadin-menu-bar-flow version 22.0.11 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 22.0.11. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 23.0.3 is released. Learn to use vaadin-menu-bar-flow version 23.0.3 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 23.0.3. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version
Maven dependency for com.vaadin - vaadin-menu-bar-flow version 14.9.1 is released. Learn to use vaadin-menu-bar-flow version 14.9.1 in Maven based Java projects
-bar-flow released The developers of   com.vaadin - vaadin-menu-bar-flow..., the released version of  com.vaadin - vaadin-menu-bar-flow library is 14.9.1. Developer can use this version ( com.vaadin - vaadin-menu-bar-flow version

Ads