当前位置: 代码迷 >> Java相关 >> [求助]各位来看看,我这个程序不知道怎么写了
  详细解决方案

[求助]各位来看看,我这个程序不知道怎么写了

热度:330   发布时间:2006-05-29 12:10:00.0
[求助]各位来看看,我这个程序不知道怎么写了
大家来帮我看可按,这个程序,我的意思是,按上面的《操作员维护》的按钮,在右下最大的区域里显示一个窗口的面版,但是到这里,不知道怎么写了,请大家看看,如果能帮小弟我,写出这一点程序,小弟将十分感激,呵呵,我还是个菜鸟,请大家多帮忙.
----------------解决方案--------------------------------------------------------
[求助]各位来看看,我这个程序不知道怎么写了
大家来帮我看可按,这个程序,我的意思是,按上面的《操作员维护》的按钮,在右下最大的区域里显示一个窗口的面版,但是到这里,不知道怎么写了,请大家看看,如果能帮小弟我,写出这一点程序,小弟将十分感激,呵呵,我还是和菜鸟

----------------解决方案--------------------------------------------------------
[求助]这个是代码


点上面的小方块就是按钮,《操作员维护》按钮就是倒数第二个就是了
import java.beans.*;

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

public class MainFrame extends JFrame implements ActionListener, TreeSelectionListener
{
JPanel pan1=new JPanel();
JPanel pan2=new JPanel();
//String url = System.getProperty("user.dir") + "\\src\\images\\";
private ImageIcon image1 = new ImageIcon("b1.jpg");
private ImageIcon image2 = new ImageIcon("b2.jpg");
private ImageIcon image3 = new ImageIcon("b7.jpg");
private ImageIcon image7 = new ImageIcon("b8.jpg");
private ImageIcon image4 = new ImageIcon("b4.jpg");
private ImageIcon image5 = new ImageIcon("b5.jpg");
private ImageIcon image6 = new ImageIcon("b6.jpg");


private JButton btnAgein = new JButton(image1);
private JButton btnCustomer = new JButton(image2);
private JButton btnAddMainCall = new JButton(image3);
private JButton btnMoney = new JButton(image7);
private JButton btnSearch = new JButton(image4);
private JButton btnManager = new JButton(image5);
private JButton btnexit = new JButton(image6);

JToolBar toolBar = new JToolBar(); //工具条
JMenuBar menuBar = new JMenuBar();

JMenu menu = new JMenu("菜单");
JMenuItem addAgent = new JMenuItem("代理商录入(A)");
JMenuItem addCustomer = new JMenuItem("客户录入(C)");
JMenuItem addMainCall = new JMenuItem("添加主叫号码(L)");
JMenuItem moneyFrame = new JMenuItem("主叫号码付费(P)");
JMenuItem searchFrame = new JMenuItem("信息查询(S)");
JMenuItem managerFrame = new JMenuItem("管理员操作(M)");
JMenuItem exitFrame = new JMenuItem("退出(X)");

DefaultMutableTreeNode treAddAgein = new DefaultMutableTreeNode("代理商录入");//Tree 树的几个节点
DefaultMutableTreeNode treAddCustomer = new DefaultMutableTreeNode("客户录入");
DefaultMutableTreeNode treaddMaincall = new DefaultMutableTreeNode("添加主叫号码");
DefaultMutableTreeNode tremoneyFrame = new DefaultMutableTreeNode("主叫号码付费");
DefaultMutableTreeNode tresearchFrame = new DefaultMutableTreeNode("信息查询");
DefaultMutableTreeNode tremanagerFram = new DefaultMutableTreeNode("管理员操作");
DefaultMutableTreeNode trefunction = new DefaultMutableTreeNode("功能列表");

JDesktopPane deskPane = new JDesktopPane(); //获得MDI窗口容器 Multiple-document interface

public MainFrame()
{
Toolkit tools = this.getToolkit(); //获得窗口工具箱
Dimension sd = tools.getScreenSize(); //获得屏幕尺寸
int width = (int) sd.width * 7/ 8; //窗口宽度
int height = (int) sd.height * 5 / 6; //窗口高度
this.setJMenuBar(menuBar);

menu.add(addAgent);
menu.add(addCustomer);
menu.add(addMainCall);
menu.add(moneyFrame);
menu.add(searchFrame);
menu.add(managerFrame);
menu.addSeparator();
menu.add(exitFrame);
menuBar.add(menu);

toolBar.add(btnAgein);//将按钮加到工具条上
toolBar.add(btnCustomer);
toolBar.add(btnAddMainCall);
toolBar.add(btnMoney);
toolBar.add(btnSearch);
toolBar.add(btnManager);
toolBar.add(btnexit);


JTree tree = new JTree(trefunction); //生成一棵树 以trefunction做为根节点
trefunction.add(treAddAgein); //将几个树叶节点(子节点)加入根节点中
trefunction.add(treAddCustomer);
trefunction.add(treaddMaincall);
trefunction.add(tremoneyFrame);
trefunction.add(tresearchFrame);
trefunction.add(tremanagerFram);


tree.addTreeSelectionListener(this); //给TREE添加选择监听事件

JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tree, deskPane); //创建分割栏将tree与deskPane左右分割
jsp.setDividerLocation(width / 5); //设置JSplitPane分割栏的位置
jsp.setDividerSize(7); //设置JSplitPane分割栏的宽度
jsp.setOneTouchExpandable(true); //设置JSplitPane可最小化

this.getContentPane().add(toolBar, BorderLayout.NORTH); //将工具栏加入窗口的北部
this.getContentPane().add(jsp, BorderLayout.CENTER); //将分割后的容器加如窗口的中间

addAgent.addActionListener(this);
addCustomer.addActionListener(this);
moneyFrame.addActionListener(this);
searchFrame.addActionListener(this);
managerFrame.addActionListener(this);
btnAddMainCall.addActionListener(this);
exitFrame.addActionListener(this);
btnManager.addActionListener(this);


this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设定窗口的默认关闭方式
this.setBounds(50, 50, width, height);//设置窗口位置和大小
this.setVisible(true);//设置窗口显示属性
}

public static void main(String args[])
{
new MainFrame();
}

public void actionPerformed(ActionEvent e) //按钮的监听事件
{

}


public void valueChanged(TreeSelectionEvent e)//树的监听事件
{

}

}


----------------解决方案--------------------------------------------------------
  相关解决方案