menu with scrollbar

menu with scrollbar

I want to use MenuBar with Scrollbar. I tried it. I dont know how to do it. so please help me. The program should be.... 1.add JScrollPane into the panel. 2.Panel layout should be null. 3.Use menubar 4.Each and every component should inside the panel. I tried it but menu bar is not working in this program. Here is the code......

import javax.swing.*; import 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=new MenuBar(); file=new Menu("File"); setting=new Menu("Setting"); rate=new Menu("Rate"); help=new Menu("Help");

setMenuBar(bar); bar.add(file); bar.add(rate); bar.add(setting); bar.add(help);

JPanel panel=new JPanel(); JButton b1=new JButton("Button1"); JButton b2=new JButton("Button2"); panel.setLayout(null); panel.setPreferredSize(new Dimension(1000, 1500));

b1.setBounds(100,100,150,50); b2.setBounds(100,200,150,50);

panel.add(b1); panel.add(b2);

JScrollPane s = new JScrollPane(panel); frame.add(s); frame.setVisible(true); frame.setSize(500,500); } public static void main(String arg[]) { menu m=new menu(); } }

View Answers

October 19, 2010 at 3:21 PM

Hi Friend,

Try the following code:

import java.awt.*;
import javax.swing.*;
public class menu extends JFrame{

    private JPanel panel;
    public menu() 
    {
      JMenuBar bar = new JMenuBar();
JMenu m = new JMenu("Info");
JMenuItem file = new JMenuItem("File");
JMenuItem setting = new JMenuItem("Setting");
JMenuItem rate = new JMenuItem("Rate");
JMenuItem help = new JMenuItem("Help");
m.add(file);
m.add(setting);
m.add(rate);
m.add(help);
bar.add(m);
this.setJMenuBar(bar);
 panel = new JPanel();
JButton b1=new JButton("Button1"); 
JButton b2=new JButton("Button2");
panel.setLayout(null);
panel.setPreferredSize(new Dimension(1000, 1500));
b1.setBounds(100,100,150,50); 
b2.setBounds(100,200,150,50);
panel.add(b1);
panel.add(b2);
JScrollPane s = new JScrollPane(panel);
 this.add(s); 
         this.setSize(500,500);        
        this.setVisible(true);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }
        public static void main(String[]args){
        menu me=new menu();
        }
}

Thanks









Related Tutorials/Questions & Answers:
menu with scrollbar
menu with scrollbar  I want to use MenuBar with Scrollbar. I tried... 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
scrollbar
scrollbar  I add a scrollbar to my Frame and its not working
Advertisements
Java Scrollbar
Java Scrollbar   What is the difference between a Scrollbar and a ScrollPane
vertical scrollbar but without a horizontal scrollbar
vertical scrollbar but without a horizontal scrollbar  How do I make a frame with a vertical scrollbar but without a horizontal scrollbar
Horizontal Scrollbar
Horizontal Scrollbar  How can I implement a horizontal scrollbar
Scrollbar
Scrollbar       A scrollbar is represented by a "slider" widget. The characteristics of it are specified by integer values which are being set at the time of scrollbar
frame with a vertical scrollbar but without a horizontal scrollbar.
frame with a vertical scrollbar but without a horizontal scrollbar.  How do I make a frame with a vertical scrollbar but without a horizontal scrollbar
Horizontal Scrollbar
Horizontal Scrollbar  I am creating a JSF project that has a print("<af:table/>"); the table is too wide to display in the browser. I was wondering if there was anyway to implement a horizontal scrollbar in this table so
scrollbar in JPanel
scrollbar in JPanel  Scroll bar is not working when i am using the panel layout is null. If i change the panel layout to flow or grid its working. I..., JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);f.add(s
menu
menu  Hi,i want write the menu that repeat several time
menu
menu  fibonaci & prime no. display in menu driven in java programme
java program:scrollbar
java program:scrollbar  my program logic is that when i scrolling scrollbar according to that the oval shap is changed by fetching the value of scrollbar the oval is drawn please give me a proper code of this logic
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. (adsbygoogle = window.adsbygoogle || []).push
CSS ScrollBar Properties
CSS ScrollBar Properties  How can i set ScrollBar properties in CSS? I am using HTML, CSS and Div in my code. Thanks!!   overflow: scroll; overflow-y: scroll; overflow-x: scroll; overflow:-moz-scrollbars-vertical
scrollbar - applet - Applet
scrollbar - applet  Hi!! It is the program for a vertical scroll bar and the output is (small vertical scrollbar). Suppose if I want a lengthy... ScrollbarDemo extends Applet { public void init() { Scrollbar sb = new
Scrollbar problem with struts <layout:collection>
Scrollbar problem with struts   How activate the vertical scrollbar in struts in mozilla firefox
dropdown to vert. scrollbar - Java Beginners
a dropdown into scrollbar when we resize th window in java script  Hi... drop down menu javascript will save you a lot of space. Great for sites that give volumes of information, the visitor chooses the topic from the drop down menu
div to scrollbar - Java Beginners
vertical scrollbar. for this i am using a css for that div in which i tried to add... who replied my answer.  hi, div and scrollbar html... ""; } function scrollBar(ownerID, ownerContentID, upID, dnID) { this.ownerID
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when... it shows the scrollbar but do not show the scrolling tabs here is my code pls do help
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when... it shows the scrollbar but do not show the scrolling tabs here is my code pls do help
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when... it shows the scrollbar but do not show the scrolling tabs here is my code pls do help
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when... it shows the scrollbar but do not show the scrolling tabs here is my code pls do help
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when... it shows the scrollbar but do not show the scrolling tabs here is my code pls do help
Visibal Certical scrollbar with struts collection layout.
Visibal Certical scrollbar with struts collection layout.  how to Visibal Vertical scroll bar with struts collection layout
Scrollbar click in safari browser not Collapsing opened dropdowns
Scrollbar click in safari browser not Collapsing opened dropdowns  When im clicking on the scrollbar in safari browser the click not collapsing the opened dropdowns....i mean if iam scrolling the scrollbars after content is being
How set the height of Thumb in Vertical scrollbar..?
How set the height of Thumb in Vertical scrollbar..?  I have created a Vertical scrollbar. I have removed up arrow and down arrow. also i have changed the skin of thumb by including an image to it. I want the size of thumb same
Flex scrollbar control
Flex ScrollBar Control:- If the user handles data that are displayed but data is too much and not fit in the display area then the user use ScrollBar... the button depends on the current state of the ScrollBar controls. If user Example
How to Collapse Dropdowns on mouseclick on scrollbar in Safari Browser using javascript
How to Collapse Dropdowns on mouseclick on scrollbar in Safari Browser using javascript  How to Collapse Dropdowns on mouseclick on scrollbar in Safari Browser using javascript
in my project, i have to add only vertical scrollbar to a panel,but not horizontal scrollbar. i need some example on it,how to doit.
in my project, i have to add only vertical scrollbar to a panel,but not horizontal scrollbar. i need some example on it,how to doit.  in my project, i have to add only vertical scrollbar to a panel,but not horizontal scrollbar
menu driven
menu driven   menu driven programm in decimal to binary binary to decimal
menu driven
menu driven  display the 1-30 prime no. and fibonacie series in menu driven programme
Fix Scrollbar position in a checkboxList after postback
Fix Scrollbar position in a checkboxList after postback  Hi, I have a CheckBoxList in which have lot of items and i set AutoPostBack="True".I am using Scrollbar on this list.Now when I am checking any item then after postback
how i can add an horizontal scrollbar at my PdfAnnotation ? - JSP-Servlet
how i can add an horizontal scrollbar at my PdfAnnotation ?  How to add the an horizontal scrollbar at my PdfAnnotation ? for example document d=new document(0. document.open
java scrollbar
Version of struts-menu>struts-menu dependency
List of Version of struts-menu>struts-menu dependency
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
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
How to get Scrollbar value of textarea in html? - Design concepts & design patterns
How to get Scrollbar value of textarea in html?  Hi All, I have one registration page with terms & policy in read only textarea (Html input tag type). Requirement: Till user didn't scroll down textarea at the last line
ModuleNotFoundError: No module named 'Menu'
ModuleNotFoundError: No module named 'Menu'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Menu' How to remove the ModuleNotFoundError: No module named 'Menu' error
drop down menu
drop down menu  drop down menu using html
Menu s - JSP-Servlet
Menu s  How to create menubar & menus & submenus in jsp
Menu Bar prob.
Menu Bar prob.  I want a menu to be displayed in each page of my swing appl. how to go abt
how to add the scrollbar to the pdf page when generating the pdf file from jsp - JSP-Servlet
how to add the scrollbar to the pdf page when generating the pdf file from jsp  I am not able to see all the columns when i generated the pdf file from jsp.i have 12 colums so how to add the scrollbar
highlight menu item html
highlight menu item html  highlight menu item in html or CSS   <body id="index"> <div id="menu"> <ul> <li class...; </ul> </div> <!-- menu --> </body>
creating pop up menu
creating pop up menu   how to create a pop up menu when a link in html page is clicked using jquery? and the link should be a text file   Please visit the following links: http://www.roseindia.net/tutorial/jquery
context menu overlapped in IE8
context menu overlapped in IE8  I developed a contex menu in XHTML while opening it is overlapped in border of IE8 browser. even i have tried change the zaxis in css. I am using like below

Ads