⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tabbedpanedemo.java

📁 J2ME lwuit实现屏幕九宫图,功能十分强大
💻 JAVA
字号:
/* * Copyright ?2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * */package com.sun.lwuit.uidemo;import com.sun.lwuit.Button;import com.sun.lwuit.ButtonGroup;import com.sun.lwuit.Command;import com.sun.lwuit.Container;import com.sun.lwuit.Dialog;import com.sun.lwuit.Form;import com.sun.lwuit.Label;import com.sun.lwuit.RadioButton;import com.sun.lwuit.TabbedPane;import com.sun.lwuit.TextArea;import com.sun.lwuit.TextField;import com.sun.lwuit.events.ActionEvent;import com.sun.lwuit.events.ActionListener;import com.sun.lwuit.layouts.BorderLayout;import com.sun.lwuit.layouts.BoxLayout;/** * 本例演示如何使用Tabbed、Text控件 */public class TabbedPaneDemo implements ActionListener {    public Form form = new Form("TabbedPaneDemo");    private  Command backCommand = new Command("Back", 1);    final TextArea title ;    final TextArea body;    TabbedPane tp = null;    TabbedPaneDemo() {        form.setLayout(new BorderLayout());        form.setScrollable(false);        form.addCommand(backCommand);        form.setCommandListener(this);        tp = new TabbedPane();        //addTab可以为页面添加控件,也可以是Container(相当于容器的控件)        tp.addTab("Tab 1", new Label("Welcome to TabbedPane demo!"));        //---------------------第二页的内容------------------------------------        //Container就是一个控件,只不过相当于容器,建议每页有自己的事件处理        Container radioButtonsPanel = new Container(new BoxLayout(BoxLayout.Y_AXIS));        RadioButton topRB = new RadioButton("Top");        RadioButton LeftRB = new RadioButton("Left");        RadioButton BottomRB = new RadioButton("Bottom");        RadioButton RightRB = new RadioButton("Right");        RadioListener rbListener = new RadioListener();//自定义接收事件的类        topRB.addActionListener(rbListener);        LeftRB.addActionListener(rbListener);        BottomRB.addActionListener(rbListener);        RightRB.addActionListener(rbListener);        ButtonGroup group1 = new ButtonGroup();        group1.add(topRB);        group1.add(LeftRB);        group1.add(BottomRB);        group1.add(RightRB);        radioButtonsPanel.addComponent(new Label("Please choose a tab placement direction:"));        radioButtonsPanel.addComponent(topRB);        radioButtonsPanel.addComponent(LeftRB);        radioButtonsPanel.addComponent(BottomRB);        radioButtonsPanel.addComponent(RightRB);        tp.addTab("Tab 2", radioButtonsPanel);        //----------------------第三页的内容----------------------------------        //Container就是一个控件,只不过相当于容器,建议每页有自己的事件处理        Container TextPanel = new Container(new BoxLayout(BoxLayout.Y_AXIS));        ButtonListener txtListener = new ButtonListener();//按钮事件处理        title = new TextField("Title");           title.getStyle().setBgTransparency(100);        body = new TextArea("This is the body of the alert....", 3, 20);        body.getStyle().setBgTransparency(100);        final Button ShowMessage =new Button("ok");        ShowMessage.getStyle().setBgTransparency(100);        ShowMessage.addActionListener(txtListener);        TextPanel.addComponent(title);        TextPanel.addComponent(body);        TextPanel.addComponent(ShowMessage);        tp.addTab("Tab 3", TextPanel);        form.addComponent("Center", tp);    }    /** 监听 radio buttons事件 */    class RadioListener implements ActionListener {        public void actionPerformed(ActionEvent e) {            String title = ((RadioButton) e.getSource()).getText();            Dialog.show("TabbedPaneDemo", title, "OK", null);        }    }    /** 监听 buttons事件 */    class ButtonListener implements ActionListener {        public void actionPerformed(ActionEvent e) {           Dialog.show(title.getText(), body.getText(), "OK", null);        }    }    /** 监听command事件 */    public void actionPerformed(ActionEvent arg0) {        UIDemoMIDlet.backToMainMenu();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -