我现在做了一个项目,要求在主页显示的时候有菜单选项、工具栏,并且要有个背景图片,我做好了之后发现工具栏在出来后显示在整个框架上,将背景图片给挡住了,我拖动工具栏,背景图片又出来了,我该怎么做才能把工具栏固定在菜单选项下面并且不许拖动呀?我的主要目的是工具栏不要影响背景的显示!
解决方案 »
- 关于文件读写的疑问
- 关于Java提交get/post请求的
- HQL语句疑问!
- 输出的文本已经有内容 如何再次输出时不替换原来的文本内容 而写入文本的下一行阿?额地神,急呦。。。。。。
- 一个运行java的问题
- 关于JDBC的问题(请路过的人进来帮我看看)
- 用java.exe执行一个xxx.class文件后出现如下错误是怎么回事?
- 为什么我的文本框不能写入字符
- 原来还可以编译的 现在却不行了 提示如下:
- 如何在dos下编译java程序
- 高手来看看这几句代码你们怎么写
- 程序出现Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
package UserMain;import java.awt.AWTException;
import java.awt.Color;
import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.SystemTray;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneLayout;
import javax.swing.UIManager;import Commont.DataBaseOperate;
import Commont.FormatInformation;
import MenuInfor.FileInduction;
import MenuInfor.StudentInduction;
import ResultConstrue.ClassResult;
import ResultConstrue.GradPlace;
import ResultConstrue.ResultCheck;
import SystemOperata.RunUserChat;public class AfterLogin {
private SystemTray systemTray;
public void show(){
final JFileChooser JFile = new JFileChooser();
JLabel myabel;
//主界面
final JFrame frame = new JFrame(FormatInformation.frame);
((JPanel) frame.getContentPane()).setOpaque(false);
ImageIcon img = new ImageIcon(FormatInformation.ImageBackground);
JLabel background = new JLabel(img);
frame.getLayeredPane().add(background, new Integer(Integer.MIN_VALUE));
background.setBounds(0, 0, img.getIconWidth(), img.getIconHeight()); JMenuBar menuBar = new JMenuBar();
//*******************************************************************************
//文件处理阶段
JMenu menuInfor = new JMenu(FormatInformation.menuInfor);
//文件导入
JMenuItem induction = new JMenuItem(FormatInformation.induction);
//文件导出
JMenuItem deriving = new JMenuItem(FormatInformation.deriving);
//文件报表打印
JMenuItem printing = new JMenuItem(FormatInformation.printing);
//导入学生成绩
JMenuItem inductResult = new JMenuItem(FormatInformation.inductResult);
//退出系统管理
JMenuItem exitSystem = new JMenuItem(FormatInformation.exitSystem);
//**********************************************************************************
//下载管理
JMenu download = new JMenu(FormatInformation.download);
//下载题库
JMenuItem downloadSubject = new JMenuItem(FormatInformation.downloadSubject);
//下载成绩
JMenuItem downloadResult = new JMenuItem(FormatInformation.downloadResult);
menuBar.add(menuInfor);
menuBar.add(download);
frame.setJMenuBar(menuBar);
menuInfor.add(induction );
menuInfor.add(deriving);
menuInfor.add(printing);
menuInfor.add(inductResult);
menuInfor.addSeparator();
menuInfor.add(exitSystem);
download.add(downloadSubject);
download.add(downloadResult);
JToolBar toolBar = new JToolBar();
JButton button1,button2,button3,button4,button5,button6,button7,button8;
button1 = new JButton("按班级查询");
button2 = new JButton("按年级统计");
button3 = new JButton("按班级统计");
button4 = new JButton("按学科统计");
button5 = new JButton("题型");
button6 = new JButton("错题统计");
button7 = new JButton("查看错题库");
button8 = new JButton("系统退出");
toolBar.add(button1);
toolBar.add(button2);
toolBar.add(button3);
toolBar.add(button4);
toolBar.add(button5);
toolBar.add(button6);
toolBar.add(button7);
toolBar.add(button8);
frame.add(toolBar);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800,600);
frame.setLocation(150,80);
frame.setVisible(true);
frame.setIconImage(new ImageIcon(getClass().getResource(FormatInformation.pictureURL)).getImage());
}
public static void main(String []args){
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception exception) {
exception.printStackTrace();
}
AfterLogin aLogin=new AfterLogin();
aLogin.show();
}
}