java中工具栏使用代码 java菜单栏工具栏( 三 )


JToolBar toolBar = new JToolBar();//实例化工具条
for(int i=0; i actions.length;i++){
JButton bt = new JButton(actions[i]);
bt.setRequestFocusEnabled(false);
//设置不需要焦点
toolBar.add(bt);//增加按钮到工具栏
}
return toolBar; //返回工具栏
}
/**************************数据库动作操作*************************************/
void shujuku_actionPerformed(ActionEvent e) {
shujuku.setSelected(false);
datamainframe d_view = new datamainframe();
d_view.pack();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = d_view.getSize();
if (frameSize.heightscreenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.widthscreenSize.width) {
frameSize.width = screenSize.width;
}
d_view.setLocation( (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
d_view.setSize(270,190);
d_view.setVisible(true);
}
class mainframe_shujuku_actionAdapter
implements java.awt.event.ActionListener {
mainframe adaptee;
mainframe_shujuku_actionAdapter(mainframe adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.shujuku_actionPerformed(e);
}
}
/***********************************************************************/
/********************网络动作操作**************************************/
void wangluo_actionPerformed(ActionEvent e) {
wangluo.setSelected(false);
netview n_view = new netview();
n_view.pack();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = n_view.getSize();
if (frameSize.heightscreenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.widthscreenSize.width) {
frameSize.width = screenSize.width;
}
n_view.setLocation( (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
n_view.setSize(800,700);
n_view.setVisible(true);
}
class mainframe_wangluo_actionAdapter
implements java.awt.event.ActionListener {
mainframe adaptee;
mainframe_wangluo_actionAdapter(mainframe adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.wangluo_actionPerformed(e);
}
}
/***********************************************************************/
class ExitAction extends AbstractAction{ //退出命令
public ExitAction(){
super("退出");
}
public void actionPerformed(ActionEvent e){
System.exit(0);
}
}
class AboutAction extends AbstractAction{//关于选项命令
public AboutAction(){
super("关于");
}
public void actionPerformed(ActionEvent e){
JOptionPane.showMessageDialog(mainframe.this,"JAVA综合操作平台V1.1\n"+"杨聪制作");
}
}
public static void main(String args[]){
new mainframe();
}
}
【java中工具栏使用代码 java菜单栏工具栏】java中工具栏使用代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java菜单栏工具栏、java中工具栏使用代码的信息别忘了在本站进行查找喔 。

推荐阅读