📄 ResimliDuvarTakvimi.java .java dosyası

⬇️ İndir
/** * Resimli Duvar Takvimi v1.0 * Released under GNU GPLv3 license, * Open Source Calendar Application * Copyright (C) 15 January 2023 Java Blackboard * * This program is free software: * you can redistribute it and/or modify it * under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. --------------------------------------------------------------------------- YouTube Description: Resimli Duvar Takvimi is released under GNU GPLv3 license, ensuring that this interactive calendar tool remains free and open source forever. Anyone can use, modify, and distribute the code, but derivative works must also be open source under the same license. Features dynamic monthly calendars with random images and color schemes. #GPL #OpenSource #Calendar #Java #Programming --------------------------------------------------------------------------- */ import java.awt.Color; import java.awt.Font; import java.awt.Image; import java.io.IOException; import java.net.URL; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Locale; import java.util.Random; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class ResimliDuvarTakvimi { public static int secilenYil = 2005; public ResimliDuvarTakvimi() throws IOException { JFrame frame = new JFrame("Resimli Duvar Takvimi v1.0 | Java Blackboard [097]"); frame.add(takvimPaneli()); frame.setSize(1250,585); frame.setLayout(null); frame.setLocationRelativeTo(null); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } public static JPanel takvimPaneli() throws IOException { JPanel panel = new JPanel(); panel.setBackground(Color.black); panel.setLayout(null); panel.setBounds(25,25,1200,500); panel.add(resimPaneli()); panel.add(ayPaneli()); return panel; } public static JPanel resimPaneli() throws IOException { JPanel panel = new JPanel(); panel.setLayout(null); panel.setBackground(new Color(242, 131, 121)); panel.setBounds(10,10,695,480); panel.add(resimEkle(695,480)); // Panel'e bir JLabel döndüren metod. return panel; } public static JLabel resimEkle(int w, int h) throws IOException { // Rastgele bir resim seçiyoruz web sitesinden. URL resimLinki = new URL("https://picsum.photos/"+w+"/"+h); Image resim = ImageIO.read(resimLinki); // Resmi JLabel'e ekleyelim JLabel label = new JLabel(new ImageIcon(resim)); label.setBounds(0,0,w,h); return label; } public static JPanel ayPaneli() { JPanel panel = new JPanel(); panel.setBackground(new Color(121, 137, 168));//121, 137, 168 panel.setLayout(null); panel.setBounds(715,10,475,480); JPanel ayIsimPaneli = new JPanel(); // Ay ismi ve yil yazan panel. ayIsimPaneli.setBackground(new Color(199, 154, 216));//242, 68, 82 ayIsimPaneli.setLayout(null); ayIsimPaneli.setBounds(10,8,455,70); SimpleDateFormat tarihFormati = new SimpleDateFormat("EEEE"); // Ay ismini bütün olarak yazdirmak istiyoruz Calendar takvim = Calendar.getInstance(); // sistem saatine göre ayarlanmış bir takvim nesnesi oluşturduk. takvim.set(Calendar.DAY_OF_MONTH, 1); // Ayin ilk gününü ayarliyoruz. // takvim.set(Calendar.MONTH, Calendar.JANUARY); // Hangi ay gosterilecek belirtiyoruz. takvim.set(Calendar.MONTH, 6); // 0 - OCAK 1 - SUBAT 2 - MART .... takvim.set(Calendar.YEAR, secilenYil); // Hangi yil seçilecek belirtiyoruz. int ayinGunSayisi = takvim.getActualMaximum(Calendar.DAY_OF_MONTH); String ayIsim = takvim.getDisplayName(Calendar.MONTH, Calendar.LONG, new Locale("TR")).toUpperCase(); int yil = takvim.get(Calendar.YEAR); // Belirtilen yili aliyoruz integer olarak. JLabel ayIsimLabel = new JLabel(ayIsim + " - " + yil); ayIsimLabel.setHorizontalAlignment(JLabel.CENTER); ayIsimLabel.setFont(new Font("Ubuntu", Font.BOLD, 30)); ayIsimLabel.setBounds(0,0,460,70); int ayBaslangic = 0; // Secilen ayin ilk gununun ismini 2 sekilde de alabiliriz. String gunAdi = tarihFormati.format(takvim.getTime()); // Biz bunu tercih ettik. String ayinIlkGunIsmi = takvim.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.getDefault()); // System.out.println("Calendar ilk gün ismi : " + ayinIlkGunIsmi); // System.out.println("TarihFormat ilk gün ismi : " + ayinIlkGunIsmi); switch(gunAdi) { case "Monday" : ayBaslangic = 0; break; case "Tuesday" : ayBaslangic = 1; break; case "Wednesday" : ayBaslangic = 2; break; case "Thursday" : ayBaslangic = 3; break; case "Friday" : ayBaslangic = 4; break; case "Saturday" : ayBaslangic = 5; break; case "Sunday" : ayBaslangic = 6; break; } JPanel[] gunler = new JPanel[42]; Random random = new Random(); int x = 10 + ((ayBaslangic-1)*65); // ayin gunleri yazan paneller 65X65 int y = 85; int hafta = ayBaslangic-1; for(int i = 1; i<=ayinGunSayisi; i++) { int r = random.nextInt(55)+200; // 0-255 arasi bir deger olmali. int g = random.nextInt(55)+200; // RGB 255, 255, 255 int b = random.nextInt(55)+200; if(((i+hafta)%7) == 0 && i == 0) { x = 10; } else if(((i+hafta)%7) == 0 ) { x = 10; y = y + 65; } else { x = x + 65; } takvim.set(Calendar.DAY_OF_MONTH, i); gunAdi = tarihFormati.format(takvim.getTime()); JLabel gunLabel = new JLabel(gunAdi); gunLabel.setFont(new Font("Ubuntu", Font.PLAIN, 12)); gunLabel.setHorizontalAlignment(JLabel.CENTER); gunLabel.setBounds(0,0,65,20); JLabel gunSayi = new JLabel(i+""); gunSayi.setFont(new Font("Ubuntu", Font.BOLD, 35)); gunSayi.setHorizontalAlignment(JLabel.CENTER); gunSayi.setBounds(0,20,65,45); gunler[i] = new JPanel(); gunler[i].setLayout(null); gunler[i].setBackground(new Color(r,g,b)); gunler[i].setBounds(x,y,65,65); gunler[i].add(gunLabel); gunler[i].add(gunSayi); panel.add(gunler[i]); // Seçili ayin günlerini dogrudan panele ekliyoruz... } ayIsimPaneli.add(ayIsimLabel); panel.add(ayIsimPaneli); return panel; } }