Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Swing-AWT menu with scrollbar

Have Programming Question? Ask it here!
 
 
 


FaizalArafath
menu with scrollbar
1 Answer(s)      3 years and 9 months ago
Posted in : Swing AWT


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(); } }


Advertisement
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
menu
menu  fibonaci & prime no. display in menu driven in java programme
menu
menu  Hi,i want write the menu that repeat several time
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
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
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
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
menu driven
menu driven  display the 1-30 prime no. and fibonacie series in menu driven programme
menu driven
menu driven   menu driven programm in decimal to binary binary to decimal
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
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
Visibal Certical scrollbar with struts collection layout.
Visibal Certical scrollbar with struts collection layout.  how to Visibal Vertical scroll bar with struts collection layout
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
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
menu driven programme
menu driven programme   calculate the area of circle, square, rectangle 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 drive programm in java
menu drive programm in java  calculate area of circle, square,rectangele in menu driven programme in java
creaing a menu - Java Beginners
creating a menu in JavaScript  How we can create a 3-level menu in java script
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
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 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
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>
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
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
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
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
HTML - menu tag example
HTML - menu tag example Description : The <menu> is a tag of HTML. Which is used to create a menu list in our web page. Code : <!DOCTYPE...>HTML -- menu tag.</h1> <p>Creates a menu list
tree menu delete node
tree menu delete node  I have crated a tree menu having various sub nodes now i want to delete parent node and also want to delete sub nodes when parent node is deleted........i am using servlet and giving nodeid to servlet
Add menu - IDE Questions
Add menu  sir,i m student and learning netbean in which i want to develop web application but i cant find how to add menu item(not the case for java application where menu can be added from palette)so that when i run
Dojo Menu and Menu Item
Dojo Menu and Menu Item          In this section, you will learn about the menu and how to create it in dojo. Try Online: Menu and Menu Item Menu : This is the widget models
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
Advertisements
 

 

 

DMCA.com