没有找到适合的构造函数用于JDateChooser(string,string,char)。

huangapple go评论63阅读模式
英文:

No suitable constructor found for JDateChooser(string,string,char)

问题

i'm new to java and i tried fixing some code a friend was having trouble with, but i faced an error that kinda confused me the error i got was:

    no suitable constructor found for JDateChooser(String,String,char)
        constructor JDateChooser.JDateChooser() is not applicable
          (actual and formal argument lists differ in length)
        constructor JDateChooser.JDateChooser(ImageIcon) is not applicable
          (actual and formal argument lists differ in length)
        constructor JDateChooser.JDateChooser(boolean) is not applicable
          (actual and formal argument lists differ in length)
        constructor JDateChooser.JDateChooser(String,boolean) is not applicable
          (actual and formal argument lists differ in length)
        constructor JDateChooser.JDateChooser(JCalendar) is not applicable
          (actual and formal argument lists differ in length)
        constructor JDateChooser.JDateChooser(JCalendar,String,boolean,ImageIcon) is not applicable
          (actual and formal argument lists differ in lengt...

i tried adding a constructor for it but the knowledge i have about java wasn't enough to fix it
here's a sample of the code.
The error appeared on the last 2 lines of the code
英文:

i'm new to java and i tried fixing some code a friend was having trouble with, but i faced an error that kinda confused me the error i got was:

no suitable constructor found for JDateChooser(String,String,char)
    constructor JDateChooser.JDateChooser() is not applicable
      (actual and formal argument lists differ in length)
    constructor JDateChooser.JDateChooser(ImageIcon) is not applicable
      (actual and formal argument lists differ in length)
    constructor JDateChooser.JDateChooser(boolean) is not applicable
      (actual and formal argument lists differ in length)
    constructor JDateChooser.JDateChooser(String,boolean) is not applicable
      (actual and formal argument lists differ in length)
    constructor JDateChooser.JDateChooser(JCalendar) is not applicable
      (actual and formal argument lists differ in length)
    constructor JDateChooser.JDateChooser(JCalendar,String,boolean,ImageIcon) is not applicable
      (actual and formal argument lists differ in lengt...

i tried adding a constructor for it but the knowledge i have about java wasn't enough to fix it
here's a sample of the code.
The error appeared on the last 2 lines of the code

		public void actionPerformed(ActionEvent e) {
			Reservation = new JFrame();
			Reservation.setAlwaysOnTop(true);
			Reservation.setTitle("R\u00E9servation");
			Reservation.getContentPane().setLayout(null);
			
			
			JPanel clientPan = new JPanel();
			clientPan.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 0), 1, true), "Client", TitledBorder.LEADING, TitledBorder.TOP, null, null));
			clientPan.setBounds(10, 11, 424, 211);
			Reservation.getContentPane().add(clientPan);
			clientPan.setLayout(null);
			
			JPanel selectClientPan = new JPanel();
			selectClientPan.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 0), 1, true), "S\u00E9lection Client", TitledBorder.LEADING, TitledBorder.TOP, null, null));
			selectClientPan.setBounds(215, 21, 177, 154);
			clientPan.add(selectClientPan);
			selectClientPan.setLayout(null);
			
			
			final ComplexSwingX list = new ComplexSwingX(hotel);
			list.setBounds(10, 29, 157, 114);			
			selectClientPan.add(list);
			
			
			JPanel createClientPan = new JPanel();
			createClientPan.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 0), 1, true), "Cr\u00E9ation Client", TitledBorder.LEADING, TitledBorder.TOP, null, null));
			createClientPan.setBounds(10, 21, 195, 154);
			clientPan.add(createClientPan);
			createClientPan.setLayout(null);
			
			JLabel lblNom = new JLabel("Nom : ");
			lblNom.setBounds(10, 24, 60, 14);
			createClientPan.add(lblNom);
			
			JLabel lblAdresse = new JLabel("Adresse : ");
			lblAdresse.setBounds(10, 124, 60, 14);
			createClientPan.add(lblAdresse);
			
			JLabel lblPrnom = new JLabel("Pr\u00E9nom");
			lblPrnom.setBounds(10, 74, 60, 14);
			createClientPan.add(lblPrnom);
			
			clientName = new JTextField();
			clientName.setBounds(99, 21, 86, 20);
			createClientPan.add(clientName);
			clientName.setColumns(10);
			
			clientFirstname = new JTextField();
			clientFirstname.setBounds(99, 71, 86, 20);
			createClientPan.add(clientFirstname);
			clientFirstname.setColumns(10);
			
			clientAddress = new JTextField();
			clientAddress.setBounds(99, 118, 86, 20);
			createClientPan.add(clientAddress);
			clientAddress.setColumns(10);
			
			final JPanel reservationPan = new JPanel();
			reservationPan.setVisible(false);
			reservationPan.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 0), 1, true), "R\u00E9servation", TitledBorder.LEADING, TitledBorder.TOP, null, null));
			reservationPan.setBounds(69, 230, 323, 194);
		
			final JDateChooser D1 = new JDateChooser("dd/MM/yyyy", "####/##/####", '_');
			final JDateChooser D2 = new JDateChooser("dd/MM/yyyy", "####/##/####", '_');

答案1

得分: 1

你的问题正是错误信息所在。这些行:

final JDateChooser D1 = new JDateChooser("dd/MM/yyyy", "####/##/####", '_');
final JDateChooser D2 = new JDateChooser("dd/MM/yyyy", "####/##/####", '_');

是无效的语法,因为 JDateChooser 类没有接受两个字符串和一个字符作为参数的构造函数。错误信息列出了该类所包含的所有构造函数。如果你想要创建一个 JDateChooser,必须使用其中提供的构造函数之一。

英文:

Your problem is exactly what the error message is telling you. These lines:

final JDateChooser D1 = new JDateChooser("dd/MM/yyyy", "####/##/####", '_');
final JDateChooser D2 = new JDateChooser("dd/MM/yyyy", "####/##/####", '_');

are invalid syntax because the JDateChooser class does not have a constructor that takes two Strings and a character as parameters. The error message lists all of the constructors that the class does include. If you want to create a JDateChooser, you have to do it using one of the constructors that it provides.

huangapple
  • 本文由 发表于 2020年10月23日 01:10:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/64487214.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定