salve a tutti ho realizzato un jframe contenente un calendario ( in realtà non è tutta farina del mio sacco ecco perchè non trovo l'errore ) che quando appare è già con la data del giorno selezionata, il problema è che se la cambio l'unicao giorno che non mi fa più selezionare è proprio quello della data del giorno. Posto il codice perchè non riesco ad individuare l'errore. Ciao a tutti
codice:public Example1(jPanel panel) { parent = panel; this.setSize(300,300); this.setLocation(700,150); // Set up the frame setTitle("Example1"); setDefaultCloseOperation(DISPOSE_ON_CLOSE); Container contentPane = getContentPane(); // Create a border for all calendars Border etchedBorder = BorderFactory.createEtchedBorder(); Border emptyBorder = BorderFactory.createEmptyBorder(10, 10, 10, 10); Border compoundBorder = BorderFactory.createCompoundBorder(etchedBorder, emptyBorder); // Create a date listener to be used for all calendars MyDateListener listener = new MyDateListener(); // Display date and time using the default calendar and locale. // Display today's date at the bottom. JCalendar calendar1 = new JCalendar( JCalendar.DISPLAY_DATE | JCalendar.DISPLAY_TIME, true); calendar1.addDateListener(listener); calendar1.setBorder(compoundBorder); // Set fonts rather than using defaults calendar1.setTitleFont(new Font("Serif", Font.BOLD|Font.ITALIC, 24)); calendar1.setDayOfWeekFont(new Font("SansSerif", Font.ITALIC, 12)); calendar1.setDayFont(new Font("SansSerif", Font.BOLD, 16)); calendar1.setTimeFont(new Font("DialogInput", Font.PLAIN, 10)); calendar1.setTodayFont(new Font("Dialog", Font.PLAIN, 14)); JPanel panel1 = new JPanel(new FlowLayout()); panel1.add(calendar1); contentPane.add(panel1); pack(); setVisible(true); } private class MyDateListener implements DateListener { public void dateChanged(DateEvent e) { Calendar c = e.getSelectedDate(); if (c != null) { //System.out.println(c.getTime()); if(parent!=null) parent.setData(c.getTime()); } else { System.out.println("No time selected."); } } }

Rispondi quotando