⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 databasetoolbar.java

📁 java数据库编程。JDBC+SQL+GUI。用java写的一个影碟租赁系统
💻 JAVA
字号:
//Vedio rental System Developed by Banu

import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.event.ActionListener;

public class databaseToolbar extends JPanel
{
	//construct the tool bar items with the tool tip and tool name
	private final String[] strToolbarTitles = new String[] {"View", "Edit", "Close", "Close All", "XML", "TXT", "Delete", "Exit"};
	private final String[] strToolbarTips = new String[] {"Select a table for Viewing", "Select a table for editing", "Close the selected table", "Close all open tables", "Output the current table's records to XML", "Output the current table's records to TXT", "Delete a table", "Exit the application"}; 
	private final String[] strToolbarAction = new String[]{"toolViewTable", "toolSelectTable", "closeTable", "closeAll", "outputXML", "outputTXT", "deleteTable", "exit"};
	
	// define the separator sequence to group the related button
	private final boolean[] spaceSort = new boolean[] {false, false, true, false, true, false, true, false};
	
	//Settingup the tool active state and disable state
	private final boolean[] allowDisable = new boolean[] {false, false, true, true, true, true, false, false};
	private JButton[] cmdToolbarButton;
	private JButton cmdView, cmdSelect, cmdClose, cmdCloseAll, cmdDelete, cmdExit;
	private JButton cmdXML, cmdTXT;
	
	public databaseToolbar (ActionListener mainApp)
	{
		// create an array of toolBar button
		cmdToolbarButton = new JButton[strToolbarTitles.length];
		
		for (int i = 0; i < strToolbarTitles.length; i++)
		{
			
			cmdToolbarButton[i] = new JButton(strToolbarTitles[i]);
			cmdToolbarButton[i].setToolTipText(strToolbarTips[i]);
			cmdToolbarButton[i].addActionListener(mainApp);
			cmdToolbarButton[i].setActionCommand(strToolbarAction[i]);
			
			if (spaceSort[i])
			{
				this.add(new JLabel(" | "));
			}
			// adding the button to tool bar
			this.add(cmdToolbarButton[i]);
			
		}
		
		try
		{
			
			for (int i = 0; i < strToolbarTitles.length; i++)
			{
				cmdToolbarButton[i].setIcon(objCreateAppletImage.getImageIcon("images/toolbarIcon" + i + ".gif", "", 3000));
			}
			
		}
		catch (Exception ex)
		{
		}		
		
	}	
	
	// the following methode will enable or disable the Jbutton depending on the table open state and close state. 
	public void tableOpen (boolean state)
	{
		
		for (int i = 0; i < strToolbarTitles.length; i++)
		{
			
			if (allowDisable[i])
			{
				cmdToolbarButton[i].setEnabled(state);
			}
			
		}
		
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -