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

📄 convertor.java

📁 It it a convertor program. Just need to input your birth , it will show your astrology
💻 JAVA
字号:
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BoxLayout;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextPane;

import javax.swing.WindowConstants;


public class Convertor extends javax.swing.JFrame {
	private JPanel mainPanel;
	private JPanel jDayinPanel;
	private JPanel jMoninPanel;
	private JLabel jLabel4;
	private JTextPane resultPane1;
	private JButton okButton;
	private JLabel jLabel3;
	private JLabel jLabel2;
	private JLabel jLabel1;
	private JComboBox inputMon;
	private JComboBox inputDay;
	private int inMon,inDay;


	public static void main(String[] args) {
		Convertor inst = new Convertor();
		inst.setVisible(true);
	}
	
	public Convertor() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setTitle("Finding your Signs of Zodiac");
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{	
				mainPanel = new JPanel();
				BoxLayout mainPanelLayout = new BoxLayout(
					mainPanel,
					javax.swing.BoxLayout.X_AXIS);
				mainPanel.setLayout(mainPanelLayout);
				getContentPane().add(mainPanel, BorderLayout.CENTER);
				{
					jDayinPanel = new JPanel();
					BoxLayout jDayinPanelLayout = new BoxLayout(
						jDayinPanel,
						javax.swing.BoxLayout.Y_AXIS);
					jDayinPanel.setLayout(jDayinPanelLayout);
					mainPanel.add(jDayinPanel);
					{
						jLabel1 = new JLabel();
						jDayinPanel.add(jLabel1);
						jLabel1.setText("Day:");
					}
					{
						ComboBoxModel inputDayModel = new DefaultComboBoxModel(
							new String[] { "01", "02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31" });
						inputDay = new JComboBox();
						jDayinPanel.add(inputDay);
						inputDay.setModel(inputDayModel);
						inputDay.setMaximumSize(new java.awt.Dimension(60, 20));
					}
					{
						jLabel2 = new JLabel();
						jDayinPanel.add(jLabel2);
						jLabel2.setText("               ");
					}
				}
				{
					jMoninPanel = new JPanel();
					BoxLayout jMoninPanelLayout = new BoxLayout(
						jMoninPanel,
						javax.swing.BoxLayout.Y_AXIS);
					jMoninPanel.setLayout(jMoninPanelLayout);
					mainPanel.add(jMoninPanel);
					{
						jLabel4 = new JLabel();
						jMoninPanel.add(jLabel4);
						jLabel4.setText("Month:");
					}
					{
						ComboBoxModel inputMonModel = new DefaultComboBoxModel(
							new String[] { "Jan", "Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" });
						inputMon = new JComboBox();
						jMoninPanel.add(inputMon);
						inputMon.setModel(inputMonModel);
						inputMon.setMaximumSize(new java.awt.Dimension(60, 20));
					}
					{
						jLabel3 = new JLabel();
						jMoninPanel.add(jLabel3);
						jLabel3.setText("                         ");
					}
				}
				{
					okButton = new JButton("OK");
					mainPanel.add(okButton);
					okButton.addActionListener(new MyListener());
				}
				{
					resultPane1 = new JTextPane();
					mainPanel.add(resultPane1);
					resultPane1.setEditable(false);
					resultPane1.setPreferredSize(new java.awt.Dimension(
						121,
						128));
				}
			}
			pack();
			this.setSize(360, 171);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	class MyListener implements ActionListener
	{
		public void actionPerformed(ActionEvent event)
		{	String result="";
			inMon = inputMon.getSelectedIndex()+1;
			inDay = inputDay.getSelectedIndex()+1;
			if((inMon==1 && inDay>=21) || (inMon==2&& inDay<=18))
					result = "\n\n\nYou are Aquarius";
			else if((inMon==2 && inDay>=19 && inDay<30) || (inMon==3&& inDay<=20))
					result = "\n\n\nYou are Pisces";
			else if((inMon==3 && inDay>=21) || (inMon==4&& inDay<=20))
					result = "\n\n\nYou are Aries";
			else if((inMon==4 && inDay>=21 && inDay<31) || (inMon==5&& inDay<=21))
					result = "\n\n\nYou are Taurus";
			else if((inMon==5 && inDay>=22) || (inMon==6&& inDay<=21))
				result = "\n\n\nYou are Gemini";
			else if((inMon==6 && inDay>=22 && inDay<31) || (inMon==7&& inDay<=22))
				result = "\n\n\nYou are Cancer";
			else if((inMon==7 && inDay>=23) || (inMon==8&& inDay<=23))
				result = "\n\n\nYou are Leo";
			else if((inMon==8 && inDay>=24) || (inMon==9&& inDay<=22))
				result = "\n\n\nYou are Virgo";
			else if((inMon==9 && inDay>=23 && inDay<31) || (inMon==10&& inDay<=23))
				result = "\n\n\nYou are Libra";
			else if((inMon==10 && inDay>=24) || (inMon==11&& inDay<=22))
				result = "\n\n\nYou are Scorpio";
			else if((inMon==11 && inDay>=23 && inDay<31) || (inMon==12&& inDay<=21))
				result = "\n\n\nYou are Sagittarius";
			else if((inMon==12 && inDay>=22) || (inMon==1&& inDay<=20))
				result = "\n\n\nYou are Capricorn";
			else result = "Hey~ ARE YOU SURE?\nNO ONE BORN IN:\n"+inDay+" "+inputMon.getSelectedItem()+"\nInvalid Date!";
			resultPane1.setText(result);
		}
	}
}

⌨️ 快捷键说明

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