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



Home Answers Viewqa Swing-AWT menu with scrollbar
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


FaizalArafath
menu with scrollbar
1 Answer(s)      4 years and 2 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
Java Scrollbar
Java Scrollbar   What is the difference between a Scrollbar and a ScrollPane
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
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
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
menu driven programme
menu driven programme   calculate the area of circle, square, rectangle in menu driven programme in java
 

 

 

DMCA.com