资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

菜单删除添加Java代码,java添加删除组件

在java程序中加个右击弹出菜单(剪切 复制 删除) 求大神帮忙 急用!!!!!!!

根据你的要求,改完的程序如下:(改动的地方见注释,未写入的程序不需要改动)

创新互联建站主营甘南网站建设的网络公司,主营网站建设方案,成都app软件开发,甘南h5小程序定制开发搭建,甘南网站营销推广欢迎甘南等地区企业咨询

主要是把JTextArea text;改成JTextArea text=new JTextArea();

加了右击弹出菜单一段。

import java.awt.*;import java.awt.event.*;

import javax.swing.*;

import java.io.*;

public class jishiben extends JFrame{

File file=null;

private JLabel stateBar;

private JTextArea text=new JTextArea();//这里把JTextArea text;改成JTextArea text=new JTextArea();

private JMenuBar mb;

private JMenu files, edit, help;

private JMenuItem Open,New,Save,SaveAs,Exit,Cut,Copy,Paste,Delete,SelectAll,About;

public jishiben()

//构造函数

{

super("我的记事本");

//菜单栏

mb=new JMenuBar();

files=new JMenu("文件");

edit=new JMenu("编辑");

help=new JMenu("帮助");

About=new JMenuItem("关于");

Open=new JMenuItem("打开"); //文件菜单的下拉菜单

New=new JMenuItem("新建");

Save=new JMenuItem("保存");

SaveAs=new JMenuItem("另存为");

Exit=new JMenuItem("退出");

Cut=new JMenuItem("剪切"); //编辑菜单的下拉菜单

Copy=new JMenuItem("复制");

Paste=new JMenuItem("粘贴");

Delete=new JMenuItem("删除");

SelectAll=new JMenuItem("全选");

stateBar=new JLabel("未修改");

//右击弹出菜单 //这里加一段

JPopupMenu menu = new JPopupMenu();

JMenuItem menuItemCut = new JMenuItem("剪切");

JMenuItem menuItemCopy = new JMenuItem("复制");

JMenuItem menuItemDelete = new JMenuItem("删除");

menu.add(menuItemCut);

menu.add(menuItemCopy);

menu.add(menuItemDelete);

text.setComponentPopupMenu(menu);

menuItemCut.addActionListener(new actionListener());

menuItemCopy.addActionListener(new actionListener());

menuItemDelete.addActionListener(new actionListener());

//添加标签

stateBar.setHorizontalAlignment(SwingConstants.LEFT);

stateBar.setBorder(BorderFactory.createEtchedBorder());

mb.add(files);mb.add(edit);mb.add(help);

files.add(New);files.add(Open);files.add(Save);files.add(SaveAs);files.addSeparator(); //分割线

files.add(Exit);

edit.add(Cut);edit.add(Copy);edit.add(Paste);edit.add(Delete); //分割线

edit.add(SelectAll);

help.add(About);

setJMenuBar(mb);

//text=new JTextArea(); //这里去掉一句移到上面

add(new JScrollPane(text)); //滚动面板

setSize(600,500);

setVisible(true);

}

class actionListener implements ActionListener{

public void actionPerformed(ActionEvent e) {

}

}

public static void main(String[] args) {

new jishiben();

}

}

用java编写一个简单的学生管理系统实现添加,删除,修改,查询的功能

你需要的是基于gui界面的还是javaweb的呢?

这两种项目有共性也有区别, 比如在数据层的部分可以统一的抽象出来公用。

但是在view层差别还蛮大的, swing是各种基于listener来触发业务逻辑, 与javaweb开发不太一样, 我最近两种都有实现, 感受是还算简单。

希望能够帮助你

急急急!!!高分求助!!!java 中实现 左右选择菜单添加、删除、排序。 注意: 不用下拉框实现。

只有下拉菜单的例子:

div id="wrapBody" class="wrap_body" style="width: 100%px;height:421px;*height:424px;"

div style="padding: 30px;height:429px;text-align:center;" id="login"

table width="80%"

td valign="top" align="left" width="30%" colspan="2"

div style="text-align:center; display:inline"         

        font size="2"s:text name="country.choice.wait"//font/divbr /

     

select multiple="multiple" size="20" id="unSelectedCountry" style="width:240px!important;height:300px!important;"

option value="0"交易/option

option value="1"交易明细/option

option value="2"风险挡掉交易/option

option value="3"重复订单号交易/option

option value="4"冻结拒付交易/option

/select

/td

td valign="middle" width="20%" colspan="2" br /

table border="0"

tr

td height="25" align="center"input type="button"

name="submit1" value="---[添加]" class="button" id="choiceBtn"

onClick="choiceCountry('unSelectedCountry','range','1');" //td

/tr

tr

td height="25" align="center"input type="button"

name="submit22" value="---[移除]" class="button" id="exitbackBtn"

onClick="choiceCountry('range','unSelectedCountry','1');" //td

/tr

tr

td height="25" align="center"input type="button"

name="submit4" value="==[全部移除]" class="button" id="allexitBtn"

onClick="choiceCountry('range','unSelectedCountry','0');" //td

/tr

/table

/td

td valign="top" width="30%" colspan="2"

div style="text-align:center; display:inline"

        font size="2"s:text name='country.choice.choice'//font/div

br /

    select theme="simple" id="range" size="20"

style="width: 240px!important;height:300px!important;" multiple="true" name="range"

/select/td

/table

/div

/div

script type="text/javascript"

function choiceCountry(srcSelect, objSelect, type) {

srcSelect = document.getElementById(srcSelect);

objSelect = document.getElementById(objSelect);

if (type == "0") {

var length = srcSelect.options.length - 1;

for ( var i = length; i = 0; i--) {

var varItem = new Option(srcSelect.options[i].text,

srcSelect.options[i].value);

objSelect.options.add(varItem);

srcSelect.options[i] = null;

}

} else {

var length = srcSelect.options.length - 1;

var changelength = length;

if(length == -1)

return

for ( var i = length; i = 0; i--) {

if (srcSelect[i].selected == true) {

var varItem = new Option(srcSelect.options[i].text,

srcSelect.options[i].value);

objSelect.options.add(varItem);

srcSelect.options[i] = null;

changelength = length - 1;

}

}

if (changelength == length) {

var varItem = new Option(srcSelect.options[0].text,

srcSelect.options[0].value);

objSelect.options.add(varItem);

srcSelect.options[0] = null;

}

}

/script

java中如何实现:添加、删除、查找、修改

添加、删除、查找、修改就是执行sql语句啊。

除了查找用executeQuery(),其他三个但是用executeUpdate()


分享题目:菜单删除添加Java代码,java添加删除组件
转载源于:http://cdkjz.cn/article/hsegdo.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220