- 浏览: 214136 次
- 性别:
- 来自: 北京
-
文章分类
最新评论
-
fenglongcen:
java可以写测试脚本吗?
linux 通过脚本执行java程序 -
chensss2008:
我代为回答2楼的问题,呵呵,因为我也遇到了这个问题。使用adm ...
SVNManager使用介绍 -
小诗诗:
我想问一下怎么使用“服务器配置管理员”怎么登陆啊!!!! ...
SVNManager使用介绍 -
sbcqw93:
能创建文件夹吗?比如说:http://127.0.0.1/sv ...
SVNManager使用介绍 -
energykey:
yhjhoo 写道好像没有一个外部的jar包,请教以下如何在l ...
linux 通过脚本执行java程序
J2ME中关于Lwuit的标签的综合使用
由于我使用的主题对中文支持不好,希望大家下载或编辑一些好的主题。
由于我使用的主题对中文支持不好,希望大家下载或编辑一些好的主题。
package com.mopietek; import java.io.IOException; import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; import com.sun.lwuit.Button; import com.sun.lwuit.ButtonGroup; import com.sun.lwuit.CheckBox; import com.sun.lwuit.ComboBox; import com.sun.lwuit.Command; import com.sun.lwuit.Component; import com.sun.lwuit.Container; import com.sun.lwuit.Display; import com.sun.lwuit.Form; import com.sun.lwuit.Graphics; import com.sun.lwuit.Image; import com.sun.lwuit.Label; import com.sun.lwuit.List; import com.sun.lwuit.Painter; import com.sun.lwuit.RadioButton; import com.sun.lwuit.TabbedPane; import com.sun.lwuit.TextArea; import com.sun.lwuit.TextField; import com.sun.lwuit.animations.CommonTransitions; import com.sun.lwuit.animations.Transition; import com.sun.lwuit.animations.Transition3D; import com.sun.lwuit.events.ActionEvent; import com.sun.lwuit.events.ActionListener; import com.sun.lwuit.geom.Dimension; import com.sun.lwuit.geom.Rectangle; import com.sun.lwuit.layouts.BorderLayout; import com.sun.lwuit.layouts.BoxLayout; import com.sun.lwuit.layouts.GridLayout; import com.sun.lwuit.plaf.Style; import com.sun.lwuit.plaf.UIManager; import com.sun.lwuit.table.Table; import com.sun.lwuit.util.Resources; public class ComponentMIDlet extends MIDlet implements ActionListener{ public Form mainForm; public List mexampleList; public Command mBackCommand; protected void startApp() throws MIDletStateChangeException { if(mainForm == null){ Display.init(this); try { Resources res = Resources.open("/javaTheme.res"); UIManager.getInstance().setThemeProps(res.getTheme("javaTheme")); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Form f = new Form("测试组件"); mainForm = f; f.setLayout(new BorderLayout()); List exampleList = new List(); mexampleList = exampleList; exampleList.addItem("Labels"); exampleList.addItem("Buttons"); exampleList.addItem("More Buttons"); exampleList.addItem("List and ComboBox"); exampleList.addItem("Text"); exampleList.addItem("Layouts"); exampleList.addItem("Events"); exampleList.addItem("Style"); exampleList.addItem("TabbedPane"); exampleList.addItem("Painter"); exampleList.addItem("Exit"); exampleList.addActionListener(this); f.addComponent(BorderLayout.CENTER,exampleList); mBackCommand = new Command("返回"); } mainForm.show(); } protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { // TODO Auto-generated method stub } protected void pauseApp() { // TODO Auto-generated method stub } public void actionPerformed(ActionEvent ae) { if(ae.getSource() == mexampleList){ //选中的List列表 String selection = (String)mexampleList.getSelectedItem(); if(selection.equals("Labels")){ showLabels(); } else if(selection.equals("Buttons")){ showButtons(); } else if(selection.equals("More Buttons")){ showMoreButtons(); } else if(selection.equals("List and ComboBox")){ showListAndComboBox(); } else if(selection.equals("Text")){ showText(); } else if(selection.equals("Layouts")){ showLayouts(); } else if(selection.equals("Events")){ showEvents(); } else if(selection.equals("Style")){ showStyle(); } else if(selection.equals("TabbedPane")){ showTabbedPane(); } else if(selection.equals("Painter")){ showPainter(); } else if(selection.equals("Exit")){ try { destroyApp(true); } catch (MIDletStateChangeException e) { // TODO Auto-generated catch block e.printStackTrace(); } notifyDestroyed(); } } if(ae.getCommand() == mBackCommand){ mainForm.show(); } } public void showLabels(){ Form f = new Form("测试Label"); f.setLayout(new BoxLayout(BoxLayout.Y_AXIS)); Label label1 = new Label("label1"); Image image = null; try { image = Image.createImage("/baldy.png"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Label label2 = new Label(image); Label label3 = new Label(image); label3.setText("label3"); label3.setTextPosition(Component.BOTTOM); f.addComponent(label1); f.addComponent(label2); f.addComponent(label3); f.addCommand(mBackCommand); f.setCommandListener(this); f.show(); } public void showButtons(){ Form f = new Form("测试Button"); try { Button button1 = new Button("ClickMe"); button1.setTextPosition(Component.BOTTOM); Image image = Image.createImage("/baldy.png"); Button button2 = new Button(image); Button button3 = new Button("Pic",image); button3.setTextPosition(Component.BOTTOM); f.addComponent(button1); f.addComponent(button2); f.addComponent(button3); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } f.addCommand(mBackCommand); f.setCommandListener(this); f.show(); } public void showMoreButtons(){ Form f = new Form("MoreButtons"); ButtonGroup buttonGroup = new ButtonGroup(); RadioButton rb1 = new RadioButton("Mike"); RadioButton rb2 = new RadioButton("Coffer"); RadioButton rb3 = new RadioButton("Tea"); rb1.addActionListener(this); rb2.addActionListener(this); rb3.addActionListener(this); buttonGroup.add(rb1); buttonGroup.add(rb2); buttonGroup.add(rb3); f.addComponent(rb1); f.addComponent(rb2); f.addComponent(rb3); CheckBox checkBox1 = new CheckBox("checkBox1"); CheckBox checkBox2 = new CheckBox("checkBox2"); CheckBox checkBox3 = new CheckBox("checkBox3"); CheckBox checkBox4 = new CheckBox("checkBox4"); CheckBox checkBox5 = new CheckBox("checkBox5"); CheckBox checkBox6 = new CheckBox("checkBox6"); f.addComponent(checkBox1); f.addComponent(checkBox2); f.addComponent(checkBox3); f.addComponent(checkBox4); f.addComponent(checkBox5); f.addComponent(checkBox6); f.addCommand(mBackCommand); f.setCommandListener(this); f.show(); } public void showListAndComboBox(){ Form f = new Form("List and ComboBox"); List list = new List(); list.addItem("red"); list.addItem("green"); list.addItem("yellow"); list.addItem("blue"); list.addItem("white"); ComboBox comboBox = new ComboBox(list.getModel()); f.addComponent(list); f.addComponent(comboBox); f.addCommand(mBackCommand); f.setCommandListener(this); f.show(); } public void showText(){ Form f = new Form("测试 Text组件"); TextField textField = new TextField("this is write content in textField"); TextArea textArea = new TextArea("this is write content in TextArea!",5,20); textArea.setMaxSize(512); f.addComponent(textField); f.addComponent(textArea); f.addCommand(mBackCommand); f.setCommandListener(this); f.show(); } public void showLayouts(){ Form f = new Form("Text Layouts"); f.setLayout(new BorderLayout()); try{ Image image = Image.createImage("/baldy.png"); Label label = new Label(image); label.setAlignment(Component.CENTER); label.setText("Label in Layouts"); label.setTextPosition(Component.BOTTOM); // Container buttonContainer = new Container(new BoxLayout(BoxLayout.X_AXIS)); Container buttonContainer = new Container(); GridLayout exampleLayout = new GridLayout(3,2); buttonContainer.setLayout(exampleLayout); buttonContainer.addComponent(new Button("Add")); buttonContainer.addComponent(new Button("Remove")); buttonContainer.addComponent(new Button("Edit")); buttonContainer.addComponent(new Button("Send")); buttonContainer.addComponent(new Button("Receive")); buttonContainer.addComponent(new Button("Exit")); f.addComponent(BorderLayout.NORTH,label); f.addComponent(BorderLayout.CENTER,buttonContainer); f.addCommand(mBackCommand); f.setCommandListener(this); f.show(); }catch(IOException e){ e.printStackTrace(); } } public void showEvents(){ Form f = new Form("Test Events"); f.setLayout(new BorderLayout()); final Button button = new Button("Click Me"); button.addActionListener(new ActionListener(){ int i = 0; public void actionPerformed(ActionEvent av) { i++; button.setText("NO."+i+"Clicked"); } }); f.addComponent(BorderLayout.NORTH,button); f.addCommand(mBackCommand); f.setCommandListener(this); f.show(); } public void showStyle(){ Form f = new Form("Style"); f.setLayout(new BoxLayout(BoxLayout.Y_AXIS)); Label label1 = new Label("No using Style"); //设置标签为透明色 Label label2 = new Label("Transparent"); label2.getStyle().setBgTransparency(0); //改变标签背景色 Label label3 = new Label("Change the BackGroud Color and Font Color"); Style style = label3.getStyle(); style.setBgColor(0xaa00ff); //字体颜色为白色 style.setFgColor(0xffffff); //设置margin的大小 Label label4 = new Label("Margin around is 10px"); label4.getStyle().setMargin(10,10,10, 10); //设置padding的大小 Label label5 = new Label("Padding around is 20px"); label5.getStyle().setPadding(20,20,20,20); f.addComponent(label1); f.addComponent(label2); f.addComponent(label3); f.addComponent(label4); f.addComponent(label5); f.addCommand(mBackCommand); f.setCommandListener(this); f.show(); } public void showTabbedPane(){ Form f = new Form("TabbedPane"); f.setLayout(new BorderLayout()); TabbedPane tabbedPane = new TabbedPane(TabbedPane.TOP); tabbedPane.addTab("tab1", new Label("this is label One")); tabbedPane.addTab("Tab2", new Label("this is label Two")); f.addComponent(BorderLayout.NORTH, tabbedPane); f.addCommand(mBackCommand); f.setCommandListener(this); f.show(); } public void showPainter(){ Form f = new Form("Painter"); try { Label label = new Label("Baldy"); Image image = Image.createImage("/baldy.png"); Label pictureLabel = new Label(image); Label bottomText = new Label(image); bottomText.setText("Baldassare"); bottomText.setTextPosition(Component.BOTTOM); f.addComponent(label); f.addComponent(pictureLabel); f.addComponent(bottomText); } catch (IOException ioe) { System.out.println(ioe); } final int bg = f.getStyle().getBgColor(); final int fg = f.getStyle().getFgColor(); f.getStyle().setBgPainter(new Painter() { public void paint(Graphics g, Rectangle rect) { int s = 12; Dimension size = rect.getSize(); int rx = rect.getX(); int ry = rect.getY(); int rw = size.getWidth(); int rh = size.getHeight(); g.setColor(bg); g.fillRect(rx, ry, rw, rh); //画棱形 g.setColor(fg); for (int y = 0; y < rh; y += 2 * s) { for (int x = 0; x < rw; x += s) { g.fillTriangle(rx + x, ry + y + s, rx + x + s / 2, ry + y, rx + x + s, ry + y + s); g.fillTriangle(rx + x, ry + y + s, rx + x + s / 2, ry + y + 2 *s, rx + x + s, ry + y + s); } } } }); f.addCommand(mBackCommand); f.setCommandListener(this); //增加3D特效 //时间 //true为逆时针翻转(向右翻转) false为顺时针翻转(向左翻转) Transition t = Transition3D.createCube(400, true); if (t == null) //当t为null时,通过 CommonTransitions创建特效 //第一参数为type , 第二参数 为翻转, 第三参数时间 t = CommonTransitions.createSlide(CommonTransitions.SLIDE_VERTICAL, true, 700); f.setTransitionInAnimator(t); t = Transition3D.createCube(400, false); if (t == null) // type是"SLIDE_VERTICAL"为上下切换,SLIDE_HORIZONTAL为左右切换 t = CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, false, 700); f.setTransitionOutAnimator(t); f.show(); } }
发表评论
-
Lwuit---小细节疑难杂症整理
2010-05-04 17:41 14991、textArea 显示文本内容,在部分手机上无法显示全部内 ... -
Lwuit布局管理
2010-05-04 15:40 1662布局管理器中一个比较特殊的管理器CoordinateLa ... -
J2ME Socket编程
2010-04-25 23:35 4117Socket是套接字,它是基于TCP协议的传输。 在J2ME ... -
Alert用法
2010-04-08 18:21 3902在J2ME中,关于Alert类是用来向用户发出警告信息,一般A ... -
Midlet与Servlet传递Cookie
2010-03-31 11:47 2295Cookie在Java ME平台中没有得到支持,因此要想维持客 ... -
J2ME手机编程中使用字体与游戏键值
2010-03-25 10:02 1426J2me中关于字体Font类的介绍: Font fon ... -
J2me低级UI界面中Canvas类与GameCanvas类
2010-03-23 10:18 3383关于MIDlet类中destroyApp( ... -
J2ME从服务器解析并读取xml文件
2010-03-09 16:55 2239J2ME从服务器解析并读取xml文件,其实跟在本地读取xml文 ... -
J2me语言国际化
2010-03-04 16:39 1641J2me手机开发在早期的WTK没用jsr 238包,所以程序要 ... -
J2ME下载并读取服务器txt文件
2010-03-04 11:56 2110J2ME下载并读取服务器txt文件,我用的公司的服务器,大家如 ... -
J2ME解析并读取xml文件
2010-03-03 17:37 5828用KXML解析读取xml文本 首先需要kxml2-2.3.0. ... -
J2ME手机本地文件上传服务器
2010-02-23 10:20 2776J2ME手机本地存储文件的上传,核心代码如下: pac ... -
读取手机本地图片和文本文件(Lwuit版)
2010-02-22 13:21 2600读取手机存储文件的核心代码: package com.m ... -
J2ME实现从服务器端下载文件(J2me for HttpConnection)
2010-02-07 21:54 2660J2ME实现从服务器端下载文件: 我以下载服务器文件并在手机客 ... -
Lwuit中关于TextField限制输入为数字的内容代码
2010-01-28 10:50 2065Lwuit中关于TextField限制输入为数字的内容代码 ... -
Lwuit 钟表ClockWidget小应用程序
2010-01-26 12:59 1642J2ME关于Lwuit应用的钟表ClockWidget程序 ... -
Lwuit实现九宫图特效程序
2010-01-25 12:16 2248最近在网上看到很多九宫图的程序说明,但大多数是转载的,一些知识 ... -
Lwuit中关于TextArea、TabbedPane组件的使用说明
2010-01-21 16:15 2202TextArea组件的使用说明代码如下: package ... -
Lwuit中CheckBox、ComboBox组件的使用说明
2010-01-21 15:53 2459这几天刚刚开始接触LWUIT,前两天从网上搜到一兄台的博客写的 ... -
J2ME配置Lwuit
2010-01-20 11:34 2225使用Eclipse加入Lwuit jar包配置方法 1.先 ...
相关推荐
综合来看,这个压缩包提供了J2ME开发所需要的一些关键组件,包括EclipseME插件1.7.9版本,以及KXML2解析器和LWUIT库。开发者可以通过这些工具和库创建和调试J2ME应用程序,同时利用EclipseME提升开发效率。在资源...
开发者可能使用了J2ME的LWUIT( Lightweight User Interface Toolkit)或MIDP的Canvas类来构建UI。UI设计需要考虑到小屏幕显示、触摸操作和有限的颜色及字体选择。 ### 5. 网络视频播放 虽然主要强调本地视频播放...
【标题】:“计算机类毕业设计-手机游戏”指的是在计算机科学与技术专业中,学生以J2ME(Java Micro Edition)技术为基础,进行的一次针对手机平台的游戏开发毕业设计项目。这种设计通常是为了让学生掌握移动设备上...
python学习资源
jfinal-undertow 用于开发、部署由 jfinal 开发的 web 项目
基于Andorid的音乐播放器项目设计(国外开源)实现源码,主要针对计算机相关专业的正在做毕设的学生和需要项目实战练习的学习者,也可作为课程设计、期末大作业。
python学习资源
python学习资源
python学习一些项目和资源
【毕业设计】java-springboot+vue家具销售平台实现源码(完整前后端+mysql+说明文档+LunW).zip
HTML+CSS+JavaScarip开发的前端网页源代码
python学习资源
【毕业设计】java-springboot-vue健身房信息管理系统源码(完整前后端+mysql+说明文档+LunW).zip
成绩管理系统C/Go。大学生期末小作业,指针实现,C语言版本(ANSI C)和Go语言版本
1_基于大数据的智能菜品个性化推荐与点餐系统的设计与实现.docx
【毕业设计】java-springboot-vue交流互动平台实现源码(完整前后端+mysql+说明文档+LunW).zip
内容概要:本文主要探讨了在高并发情况下如何设计并优化火车票秒杀系统,确保系统的高性能与稳定性。通过对比分析三种库存管理模式(下单减库存、支付减库存、预扣库存),强调了预扣库存结合本地缓存及远程Redis统一库存的优势,同时介绍了如何利用Nginx的加权轮询策略、MQ消息队列异步处理等方式降低系统压力,保障交易完整性和数据一致性,防止超卖现象。 适用人群:具有一定互联网应用开发经验的研发人员和技术管理人员。 使用场景及目标:适用于电商、票务等行业需要处理大量瞬时并发请求的业务场景。其目标在于通过合理的架构规划,实现在高峰期保持平台的稳定运行,保证用户体验的同时最大化销售额。 其他说明:文中提及的技术细节如Epoll I/O多路复用模型以及分布式系统中的容错措施等内容,对于深入理解大规模并发系统的构建有着重要指导意义。
基于 OpenCV 和 PyTorch 的深度车牌识别
【毕业设计-java】springboot-vue教学资料管理系统实现源码(完整前后端+mysql+说明文档+LunW).zip