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

📄 inventory.java

📁 适合与JAVA初级程序员 适合JAVA初学者编程
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Inventory extends JFrame
{
     private JLabel cartonsJLabel;
     private JTextField cartonsJTextField;
     private JLabel itemsJLabel;
     private JTextField itemsJTextField;
     private JLabel totalJLabel;
     private JTextField totalResultJTextField;
     private JButton calculateJButton;
     public Inventory()
     {
        createUserInterface();
     }
     public void createUserInterface()
     {
        Container contentPane = getContentPane();
        contentPane.setLayout(null);
        
        cartonsJLabel = new JLabel();
        cartonsJLabel.setText("cartons per shipment:");
        cartonsJLabel.setBounds(16,16,130,21);
        contentPane.add(cartonsJLabel);

        itemsJLabel = new JLabel();
        itemsJLabel.setText("Items per carton:");
        itemsJLabel.setBounds(16,48,104,21);
        contentPane.add(itemsJLabel);
  
        totalJLabel = new JLabel();
        totalJLabel.setText("Total:");
        totalJLabel.setBounds(204,16,40,21);
        contentPane.add(totalJLabel);

        cartonsJTextField = new JTextField();
        cartonsJTextField.setText("0");
        cartonsJTextField.setBounds(148,16,40,21);
        cartonsJTextField.setHorizontalAlignment(JTextField.RIGHT);
        contentPane.add(cartonsJTextField);

        itemsJTextField = new JTextField();
        itemsJTextField.setText("0");
        itemsJTextField.setBounds(148,48,40,21);
        itemsJTextField.setHorizontalAlignment(JTextField.RIGHT);
        contentPane.add(itemsJTextField);

        totalResultJTextField = new JTextField();
        totalResultJTextField.setBounds(244,16,86,21);
        totalResultJTextField.setHorizontalAlignment(JTextField.RIGHT);
        totalResultJTextField.setEditable(false);
        contentPane.add(totalResultJTextField);

        calculateJButton = new JButton();
        calculateJButton.setText("Calculate Total");
        calculateJButton.setBounds(204,48,126,24);
        contentPane.add(calculateJButton);
 
        setTitle("Inventory");
        setSize(354,112);
        setVisible(true);
      }

      public static void main(String[]args)
      {
          Inventory application = new Inventory();
          application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      }

}  

⌨️ 快捷键说明

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