Home Answers Viewqa Java-Beginners Swings Menu Bar

 
 


Valli
Swings Menu Bar
2 Answer(s)      3 years and 3 months ago
Posted in : Java Beginners

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 Pages:
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
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
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
swings - Java Beginners
. In that application i created a menu bar,it contains menu items like file,Edit, view, map,analysis etc. In this i only developed the code for file, edit,viem menu items.Only... to disable these items in the application, means these items r appear in the menu
menu with scrollbar
and every component should inside the panel. I tried it but menu bar... java.awt.*; public class menu extends JFrame { MenuBar bar; Menu file,setting,rate,help,crate,prate; public menu() { JFrame frame =new JFrame("Stock Analysis"); bar
Jquery Slide-up Menu
Jquery Slide-up Menu  Hello, Excellent site. I am learning Jquery and I can produce a slide-down menu but don't know how to make a slide-up menu/nav bar to go at the bottom of the web page. Can you show a way how this can
Create Bar graph
Create Bar graph  hi............. In my project i want to create a BAR GRAPH to display the result. I HAVE certain values that want to show in graph form. Can u help me plzzzzzzz i require a very simple code in java swings were
Swings/awt - Swing AWT
Swings/awt  Hi, how to write action listeners to the Buttons in RichTextEditor tool bar.. thanks in advance...it's Urgent... i am very much new to Swings
menu
menu  Hi,i want write the menu that repeat several time
How to design a bar code, design a bar code, bar code
How to design a bar code       This tutorial will teach you to design a bar code, the bar code... to Filter Menu > Noise > Add Noise and use these settings. Motion Blur
Menu
Menu  Pl make a program which generates the following output. "Select from this menu" 1. Array 2. Stack 3. Queue. 4. Exit. If users press 1, then it will go in 1. Array. Welcome in Array. press 1. for Insertion press 2
Creating Menu using GWT
. Menu Bar File = new MenuBar(true) Creating a Menu bar named File. A Menu bar can... for adding item to the Menubar.Here we are adding New to the Menu bar named... Creating Menu using GWT     
Design a Toll bar - Swing AWT
Design a Toll bar  Hi,i am very new to Swings-awt..... Please any one send me the Logic to Create a Toolbar which is similar to --- winword(Standard/Formating Tool bar). it's very urgent. Thanks in Advance. Thanks
java swings - Swing AWT
the performance of the employees by using bar bharts. Please give me how can we write the code for bar charts using java swings.  Hi friend, I am.... http://www.roseindia.net/java/example/java/swing/draw-simple-bar
SWINGS
SWINGS  WHAT ARE THE DIFFERENCES BETWEEN AWT AND SWINGS
Java Swings-awt - Swing AWT
Java Swings-awt  Hi, Thanks for posting the Answer... I need to design a tool Bar which looks like a Formating toolbar in MS-Office Winword(Standard & Formating) tool Bar. Please help me... Thanks in Advance
java swings - Java Beginners
java swings  if i design the more than two menu on the frame, if i click on the menu than another frame open which contain the some data like as item... menuBar = new JMenuBar(); JMenu menu1 = new JMenu("Menu 1"); JMenuItem item1 = new
swings - Swing AWT
(); } public TwoMenuItem(){ JFrame frame; frame = new JFrame("Two menu item example"); JMenuBar menu = new JMenuBar(); JMenu filemenu = new JMenu... JCheckBoxMenuItem("A check box menu item"); JCheckBoxMenuItem
How to make an animated navigation bar with css
How to make an animated navigation bar with css In this example you will see how to make a CSS navigation bar in the photoshop... shape by the Rounded rectangle tool (U key). Effects: Go to Layer menu >
Bar graph
Bar graph  How to include a bar chart in iPhone sdk
menu driven
menu driven   menu driven programm in decimal to binary binary to decimal
bar chart
bar chart  how to create a bar chart from values of the database and the string value should be the entities of the database??plzz help..needed badly
menu problem
menu problem  Hi to all , I am inserting a menu in my jsp page.i have downloaded(free) a menu .In which 4 files are as below. 1. index.html 2. menu.css 3. menu.js 4. jquery.js I have edited
DropDown Menu
menu that has the list of Page 1- Page 5. if i select page 1 it will display only... is the problem.. for example; if i select page 1 in my dropdown menu, and click
Bar Chart
Bar Chart  hi...... Thanks 4 ur help for the bar graph creation i have got what i wanted. But now want to ask that in that bar graph i want multiple bar on one value means I want to create a graph where on my x-axis i have
progress bar
progress bar  Hi guys, I'm doing a file upload in spring MVC technology. For file upload i did validation in client side.While uploading how to use an ajax function to show the progress bar
Progress Bar
Progress Bar  Hi friend, I'm interested in knowing how to progress bar in oracle forms 9i for the trigger when-button-pressed.Thankyou. Thanks and Regards, M.SHANKAR
JSP & Swings
JSP & Swings  How to integrate jsp and swings
swings question
swings question  how to change the background color with the help of color values by using swings
How to make a navigation bar
How to make a navigation bar This is the navigation design... to Layer Menu > Layer Style > apply stroke as given below. Your image.... Gradient Overlay: Go to Layer Menu > Layer Style > Apply Gradient Overlay
swings for webnms
swings for webnms  if i am expanding node of jtree then i want to collapse previous expanding node of jtree in swings how is it possible
MenuBar Control in Flex4
MenuBar control in Flex4: A MenuBar control displays a horizontal bar of menu items. The menu item has a pop-up sub menu(optional). It is a static control. It does not work as a pop-up menu control. First you will make a XML List
Swings JTable
Swings JTable  add values to JTable with four coloums,two of them are comboboxes
creaing a menu - Java Beginners
creating a menu in JavaScript  How we can create a 3-level menu in java script
menu drive programm in java
menu drive programm in java  calculate area of circle, square,rectangele in menu driven programme in java
menu drive programm in java
menu drive programm in java  calculate area of circle, square,rectangele in menu driven programme in java
menu driven programme
menu driven programme   calculate the area of circle, square, rectangle in menu driven programme in java
Menu s - JSP-Servlet
Menu s  How to create menubar & menus & submenus in jsp
drop down menu
drop down menu  drop down menu using html