当前位置:  技术问答>java相关

Menu problem

    来源: 互联网  发布时间:2015-06-29

    本文导语:  Now I would like to create a menu contains more childern that a window can handle (say 1000), is there anyway for me to scroll throught the menu? Or possible to add something like combo in the menu? Or is there any other create ideas to han...

Now I would like to create a menu contains more childern that a window can handle (say 1000), is there anyway for me to scroll throught the menu?
Or possible to add something like combo in the menu? Or is there any other create ideas to handle that?

|
/*http://forum.java.sun.com/thread.jsp?forum=57&thread=123183
Re: scrollable JMenu? 
Author: frankm29 
In Reply To: scrollable JMenu?  Apr 30, 2002 6:35 PM   

Reply 4 of 5   
 
 
Here's a cl*** I made to make JMenu scrollable, use it if it can help you...

Frank
*/

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

// This cl*** implements a scrollable JMenu
// This cl*** was hacked out in a couple of hours, and is meant to be used
// such that you create an instance, add all the items you want, and then throw it away and
// create a new one if you want the menu items to change (there is no remove/insertAt functionality)
// Use "addScrollableItems(JMenuItem j)" to add all of the items
// You can change MAX_ITEMS_TO_DISPLAY to whatever you want, I used 10 because it seems to always fit on screen
// I have NOT tested this cl*** very much to see if it loses items, etc, ***USE AT YOUR OWN RISK***
// Feel free to use and modify. I'll probably add a thread on the up & down scrollers to make them scroll automatically (as long as mouse-over),
// let me know if you want it via email (frank.mccreedy@nrlssc.navy.mil).
//
// This cl*** should only be used until SUN makes a real scrollable JMenu

public cl*** ScrollableJMenu extends JMenu implements MouseListener{
ScrollUpOrDownButtonItem scrollUp, scrollDown;
Vector vtrScrollableMenuItems;
static final int MAX_ITEMS_TO_DISPLAY = 10;
int beginIndexIntoVector;

public ScrollableJMenu(String strMenuTitle){
setText(strMenuTitle);

scrollUp = new ScrollUpOrDownButtonItem("up");
add(scrollUp);
removeAllMouseListeners(scrollUp);
scrollUp.addMouseListener(this);
scrollUp.addMouseListener(scrollUp);

scrollDown = new ScrollUpOrDownButtonItem("down");
add(scrollDown);
removeAllMouseListeners(scrollDown);
scrollDown.addMouseListener(this);
scrollDown.addMouseListener(scrollDown);

vtrScrollableMenuItems = new Vector();
beginIndexIntoVector = 0;
}

public void addScrollableItem(JMenuItem jmiMenuItemToAdd){
vtrScrollableMenuItems.addElement(jmiMenuItemToAdd);
if ( vtrScrollableMenuItems.size() 

    
 
 

您可能感兴趣的文章:

 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • java命名空间java.awt类menu的类成员方法: menu定义及介绍
  • Android动态添加menu菜单的简单方法
  • java命名空间java.awt类menu.accessibleawtmenu的类成员方法: menu.accessibleawtmenu定义及介绍
  • Fancy Sliding Tab Menu
  • java命名空间java.awt类systemcolor的类成员方法: menu定义及介绍
  • Animated Outline Menu
  • java命名空间javax.swing.plaf.synth类region的类成员方法: menu定义及介绍
  • php开源软件 iis7站长之家
  • java命名空间javax.accessibility类accessiblerole的类成员方法: popup_menu定义及介绍
  • CSS Dock Menu
  • java命名空间javax.accessibility类accessiblerole的类成员方法: menu定义及介绍
  • jQuery Multi Level horizontal CSS Menu
  • java命名空间javax.accessibility类accessiblerole的类成员方法: menu_bar定义及介绍
  • jQuery 菜单插件 Square Menu
  • java命名空间javax.accessibility类accessiblerole的类成员方法: menu_item定义及介绍
  • QuickAccess Menu
  • java命名空间javax.swing.text.html类html.tag的类成员方法: menu定义及介绍
  • jQuery Horizon Menu Plugin
  • java命名空间javax.swing.plaf.basic类basicmenuui.changehandler的类成员方法: menu定义及介绍
  • jQuery可折叠菜单 Accordion Menu script
  • java命名空间java.awt类systemcolor的类成员方法: menu_text定义及介绍
  • jQuery 下拉菜单插件 menu-aim


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3