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

📄 inventorygui.java

📁 it is an inventory system which is used to maintain all the accounts of stores
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
		if(cmd.equals("Update Prices"))		{			jTabbedPaneLayout.setSelectedComponent(jPanelUpdate);		}				if(cmd.equals("Financial Information"))		{			jTabbedPaneLayout.setSelectedComponent(jPanelFinancialInformation);		}				if(cmd.equals("Sort Name"))		{			jMenuItemSortName.setSelected(true);			boolSortName = true;			refreshTable();		}						if(cmd.equals("Sort ID"))		{			jMenuItemSortID.setSelected(true);			boolSortName = false;			refreshTable();		}				if(cmd.equals("Update Funds"))		{			DecimalFormat dollar = new DecimalFormat("$0.00");			String funds = JOptionPane.showInputDialog(this, "Current Funds: " + dollar.format(companyObject.getFunds()), "Update Funds", JOptionPane.PLAIN_MESSAGE);			try			{				double newFunds = Double.parseDouble(funds);				if(newFunds >= 0)				{					companyObject.setFunds(newFunds);					JOptionPane.showMessageDialog(this, "Funds Updated!", "",JOptionPane.INFORMATION_MESSAGE);				}				else				{					JOptionPane.showMessageDialog(this, "Invalid Entry", "Input Error", JOptionPane.ERROR_MESSAGE);				}			}			catch(Exception e)			{				JOptionPane.showMessageDialog(this, "Not Changed", "", JOptionPane.ERROR_MESSAGE);			}			refreshTable();		}					if(cmd.equals("Open File"))		{			int save = JOptionPane.showConfirmDialog(this,"Do you want to save?","", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);			if(save == JOptionPane.YES_OPTION)	    	{	    		try	    		{	    			companyObject.endProgram();	    		}	    		catch(Exception e)	    		{						JOptionPane.showMessageDialog(null, "Saving Error", "File Error", JOptionPane.ERROR_MESSAGE);	    		}		    	}		            		int returnVal = fileChooser.showOpenDialog(this);	    	if (returnVal == JFileChooser.APPROVE_OPTION) 	    	{    	    	File file = fileChooser.getSelectedFile();				String fileName = file.getName();				try				{					if(!file.exists())					{						JOptionPane.showMessageDialog(null, "File does not exist", "File         Error", JOptionPane.ERROR_MESSAGE);					}					else					{						companyObject.openFile(fileName);					}				}				catch(Exception e)				{					JOptionPane.showMessageDialog(null, "Bad File", "File Error", JOptionPane.ERROR_MESSAGE);				}			}			refreshTable();	        		}					if(cmd.equals("Save As"))		{			int returnVal = fileChooser.showSaveDialog(this);	        if (returnVal == JFileChooser.APPROVE_OPTION)	      	{	        	File file = fileChooser.getSelectedFile();	            String fileName = file.getName();				if(file.exists())				{					int saveAs = JOptionPane.showConfirmDialog(null, "\"" + file.getName() + "\" Already       Exists, \n Do You Want to Override It?", "",  JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);				    if(saveAs == JOptionPane.YES_OPTION)				    {					    	try				    	{					    		companyObject.setFileName(fileName);				        	companyObject.endProgram();				    	}				    	catch(Exception e)				    	{							JOptionPane.showMessageDialog(null, "Saving Error", "File Error", JOptionPane.ERROR_MESSAGE);					    }						  	}				}				else				{					try					{						companyObject.setFileName(fileName);						companyObject.endProgram();					}					catch(Exception e)					{							JOptionPane.showMessageDialog(null, "Saving Error", "File Error", JOptionPane.ERROR_MESSAGE);							}				}	    	}		}										}    	    private void initComponents() throws IOException    // Initializes and sets up the Gui components    {    	companyObject = new Company();    	boolSortName = true;    	fileChooser = new JFileChooser();		// File Chooser    	    	// Groups the two sorting Radio Menu Items that are used to sort the Inventory Table    	sortGroup = new ButtonGroup();    	    	// Main Panel    	jPanelMain = new  JPanel();                // Panel that contains the Layout        jPanelLayout = new  JPanel();               	 // Split Panel Layout        jSplitPaneLayout = new  JSplitPane();               	 // Top portion of the Layout        jPanelLayoutTop = new  JPanel();        		// Tabbed Panel        jTabbedPaneLayout = new  JTabbedPane();         		// Sales Portion of the Tab Panel		jPanelSales = new  JPanel();		jPanelSalesItemNumber = new  JPanel();		jLabelSalesItemNumber = new  JLabel();		jTextFieldSalesItemNumber = new  JTextField();		jPanelSalesQuantity = new  JPanel();		jLabelSalesQuantity = new  JLabel();		jTextFieldSalesQuantity = new  JTextField();		jPanelSalesEnter = new  JPanel();		jLabelSalesBlank = new  JLabel();                 // Sales Data Button       	jButtonSalesEnter = new  JButton();		jButtonSalesEnter.setActionCommand("Sales");		jButtonSalesEnter.addActionListener(this);                		// New Orders Portion of the Tab Panel       	jPanelOrders = new  JPanel(); 		jPanelOrderItemNumber = new  JPanel();    	jLabelOrderItemNumber = new  JLabel();    	jTextFieldOrderItemNumber = new  JTextField();    	jPanelOrderQuantity = new  JPanel();    	jLabelOrderQuantity = new  JLabel();    	jTextFieldOrderQuantity = new  JTextField();    	jPanelOrderEnter = new  JPanel();    	jLabelOrderBlank = new  JLabel();                    	// New Orders Button    	jButtonOrderEnter = new  JButton();		jButtonOrderEnter.setActionCommand("Order");		jButtonOrderEnter.addActionListener(this);                     	// Liquidate Portion of the Tab Panel    	jPanelLiquidate = new  JPanel();    	jPanelLiquidateIItemNumber = new  JPanel();    	jLabelLiquidateItemNumber = new  JLabel();    	jTextFieldlLiquidateItemNumber = new  JTextField();    	jPanelLiquidateEnter = new  JPanel();    	jLabelLiquidateBlank = new  JLabel();            	// Liquidate Button    	jButtonLiquidateEnter = new  JButton();		jButtonLiquidateEnter.setActionCommand("Liquidate");		jButtonLiquidateEnter.addActionListener(this);             	// New Item Portion of the Tab Panel    	jPanelNewItem = new  JPanel();    	jPanelNewItemLeft = new  JPanel();    	jPanelNewItemItemNumber = new  JPanel();    	jLabelNewItemItemNumber = new  JLabel();    	jTextFieldNewItemNumber = new  JTextField();    	jPanelNewItemName = new  JPanel();    	jLabelNewItemName = new  JLabel();    	jTextFieldNewItemName = new  JTextField();    	jPanelNewItemDescription = new  JPanel();    	jLabelNewItemDescprition = new  JLabel();    	jTextFieldNewItemDescrpition = new  JTextField();    	jPanelNewItemRight = new  JPanel();    	jPanelNewItemSalesPrice = new  JPanel();    	jLabelNewItemSalesPrice = new  JLabel();    	jTextFieldNewItemSalesPrice = new  JTextField();       	jPanelNewItemOrderPrice = new  JPanel();    	jLabelNewItemOrderPrice = new  JLabel();    	jTextFieldNewItemOrderPrice = new  JTextField();    	jPanelNewItemInitialAmount = new  JPanel();    	jLabelNewItemInitialAmount = new  JLabel();    	jTextFieldNewItemInitialAmount = new  JTextField();    	jPanelNewItemEnter = new  JPanel();    	jLabelNewItemBlank = new  JLabel();       	// New Item Button        jButtonNewItemEnter = new  JButton();		jButtonNewItemEnter.setActionCommand("New");		jButtonNewItemEnter.addActionListener(this);             	// Update Portion of the Tab Panel    	jPanelUpdate = new  JPanel();    	jPanelUpdateSub = new  JPanel();    	jPanelUpdateItemNumber = new  JPanel();    	jLabelUpdateItemNumber = new  JLabel();    	jTextFieldUpdateItemNumber = new  JTextField();    	jPanelUpdateSalesPrice = new  JPanel();    	jLabelUpdateSalesPrice = new  JLabel();    	jTextFieldUpdateSalesPrice = new  JTextField();    	jPanelUpdateOrderPrice = new  JPanel();    	jLabelUpdateOrderPrice = new  JLabel();    	jTextFieldUpdateOrderPrice = new  JTextField();    	jPanelUpdateEnter = new  JPanel();    	jLabelUpdateBlank = new  JLabel();        // Update Button        jButtonUpdate = new  JButton();		jButtonUpdate.setActionCommand("Update");		jButtonUpdate.addActionListener(this);             	// Financial Information Portion of the Tab Panel    	jPanelFinancialInformation = new  JPanel();    	jPanelFinancialStatement = new  JPanel();    	jLabelFinancialStatement = new  JLabel();    	jPanelLayoutBottom = new  JPanel();    	jPanelInventory = new  JPanel();    	jScrollPaneInventory = new  JScrollPane();                		// Table that displays the Inventory Information           	jTableInventory = new  JTable()    	{        		// Overriding of the getToolTipText Method			public String getToolTipText(MouseEvent e)			{			        String tip = null;			        Point p = e.getPoint();			        int rowIndex = jTableInventory.rowAtPoint(p);			        int colIndex = jTableInventory.columnAtPoint(p);									try				{			        		return toolTips[rowIndex][colIndex];        					}    			catch(Exception ex)    			{    				return null;    			}        			        }	    };  	  		  	// Menu Bar        	menuBar = new  JMenuBar();                	// File Menu        	fileMenu = new  JMenu();        	openMenuItem = new  JMenuItem();        	saveMenuItem = new  JMenuItem();        	jSeparator1 = new  JSeparator();        	saveAsMenuItem = new  JMenuItem();        	jSeparator2 = new  JSeparator();        	exitMenuItem = new  JMenuItem();                	// Tools Menu        	toolsMenu = new  JMenu();        	jMenuItemSalesData = new  JMenuItem();        	jMenuItemNewOrders = new  JMenuItem();        	jMenuItemLiquidation = new  JMenuItem();        	jMenuItemNewItem = new  JMenuItem();        	jMenuItemUpdatePrice = new  JMenuItem();        	jMenuItemFinancialInformation = new  JMenuItem();    	jMenuItemUpdateFunds = new JMenuItem();    	    	// Sorting Sub Menu    	jMenuSortSubMenu = new  JMenu();        	jMenuItemSortName = new JRadioButtonMenuItem();  	jMenuItemSortID = new JRadioButtonMenuItem();  		    		        	// Setup of the Frame content        	getContentPane().setLayout(new  BoxLayout(getContentPane(),  BoxLayout.Y_AXIS));        	setTitle("Inventory Deluxe v 1.03");        	addWindowListener(new  WindowAdapter() {            		public void windowClosing( WindowEvent evt) {                		exitForm(evt);            	}});			// Setup of the Main Panel        	jPanelMain.setLayout(new  BoxLayout(jPanelMain,  BoxLayout.Y_AXIS));        	jPanelMain.setMaximumSize(new  Dimension(1024, 768));        	jPanelMain.setMinimumSize(new  Dimension(800, 600));        	jPanelMain.setPreferredSize(new  Dimension(800, 600));                	// Setup of the Layout Panel        	jPanelLayout.setLayout(new  BoxLayout(jPanelLayout,  BoxLayout.Y_AXIS));        	jPanelLayout.setMaximumSize(new  Dimension(1024, 768));        	jPanelLayout.setMinimumSize(new  Dimension(800, 600));        	jPanelLayout.setPreferredSize(new  Dimension(800, 600));                	// Setup of the Split Panel        	jSplitPaneLayout.setBorder(null);        	jSplitPaneLayout.setDividerLocation(200);        	jSplitPaneLayout.setDividerSize(5);        	jSplitPaneLayout.setOrientation( JSplitPane.VERTICAL_SPLIT);                	// Setup of the Top Portion of the Layout        	jPanelLayoutTop.setLayout(new  BoxLayout(jPanelLayoutTop,  BoxLayout.Y_AXIS));        	jPanelLayoutTop.setBorder(new  javax.swing.border.EtchedBorder());        	jPanelLayoutTop.setMaximumSize(new  Dimension(1024, 768));        	jPanelLayoutTop.setMinimumSize(new  Dimension(215, 176));        	jPanelLayoutTop.setPreferredSize(new  Dimension(215, 176));                	// Setup of the Sales Portion of Tab Panel        	jPanelSales.setLayout(new  BoxLayout(jPanelSales,  BoxLayout.Y_AXIS));jPanelSales.setBorder(new  javax.swing.border.TitledBorder(null, "Sales Data",       javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,       javax.swing.border.TitledBorder.DEFAULT_POSITION, new  Font("Dialog", 1, 11)));        	jPanelSales.setMaximumSize(new  Dimension(200, 110));        	jPanelSales.setMinimumSize(new  Dimension(200, 110));        	jPanelSales.setName("");        	jPanelSales.setPreferredSize(new  Dimension(200, 110));        	jPanelSalesItemNumber.setLayout(new  BoxLayout(jPanelSalesItemNumber,  BoxLayout.X_AXIS));		        	jPanelSalesItemNumber.setMaximumSize(new  Dimension(150, 35));        	jPanelSalesItemNumber.setPreferredSize(new  Dimension(150, 35));        	jLabelSalesItemNumber.setFont(new  Font("Dialog", 0, 12));

⌨️ 快捷键说明

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