/
Bananka_ana
/
help
Обзор
Документация
Войти
/
Bananka_ana
/
help
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
package-info.java
301 строка
12 KB
Bananka_ana
upload files
27 апр 2025, 18:45
27 апр 2025, 18:45
391128e
Код
Авторство
О чём код?
import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.net.URI; public class BadenBadenApp { private JFrame mainFrame; private Color fiol = new Color(180, 136, 242); private Color t_sin = new Color(14, 13, 64); private Color sin = new Color(28, 63, 166); private Color gol = new Color(109, 130, 253); private Color wh = Color.WHITE; private Color bl = Color.BLACK; private boolean darkMode = false; public BadenBadenApp() { // Создаем главное окно mainFrame = new JFrame("ФИИТ УрФУ"); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainFrame.setSize(1022, 616); mainFrame.setLayout(null); mainFrame.setResizable(false); mainFrame.getContentPane().setBackground(wh); // Создаем меню createMenu(); // Создаем основной контент createMainContent(); // Создаем блок с контактами createContactsSection(); // Создаем блок с соцсетями createSocialSection(); mainFrame.setVisible(true); } private void createMenu() { JButton historyBtn = createMenuButton("История", 47, 0, 80, 50); historyBtn.addActionListener(e -> openHistoryWindow()); JButton programBtn = createMenuButton("Программа", 174, 0, 100, 50); programBtn.addActionListener(e -> openProgramWindow()); JButton teachersBtn = createMenuButton("Преподаватели", 321, 0, 130, 50); teachersBtn.addActionListener(e -> openTeachersWindow()); JButton internshipsBtn = createMenuButton("Стажировки", 498, 0, 100, 50); internshipsBtn.addActionListener(e -> openInternshipsWindow()); JButton reviewsBtn = createMenuButton("Отзывы", 645, 0, 70, 50); reviewsBtn.addActionListener(e -> openReviewsWindow()); JButton paidEduBtn = createMenuButton("Платное обучение", 762, 0, 150, 50); paidEduBtn.addActionListener(e -> openPaidEducationWindow()); // Кнопка смены темы ImageIcon moonIcon = new ImageIcon("moon.png"); JButton themeBtn = new JButton(moonIcon); themeBtn.setBounds(945, 0, 50, 50); themeBtn.setBorderPainted(false); themeBtn.setContentAreaFilled(false); themeBtn.addActionListener(e -> toggleTheme()); mainFrame.add(themeBtn); } private JButton createMenuButton(String text, int x, int y, int width, int height) { JButton button = new JButton(text); button.setBounds(x, y, width, height); button.setForeground(fiol); button.setBackground(wh); button.setFont(new Font("Segoe UI", Font.PLAIN, 14)); button.setBorderPainted(false); button.setFocusPainted(false); button.setContentAreaFilled(false); // Эффекты при наведении button.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { button.setForeground(darkMode ? wh : t_sin); } @Override public void mouseExited(MouseEvent e) { button.setForeground(fiol); } }); mainFrame.add(button); return button; } private void createMainContent() { // Логотип ImageIcon logoIcon = new ImageIcon("logo.png"); JLabel logoLabel = new JLabel(logoIcon); logoLabel.setBounds(25, 55, logoIcon.getIconWidth(), logoIcon.getIconHeight()); mainFrame.add(logoLabel); // Основной заголовок JLabel titleLabel = new JLabel("IT-направление на матмехе УрФУ"); titleLabel.setBounds(463, 35, 600, 165); titleLabel.setFont(new Font("Segoe UI", Font.PLAIN, 50)); titleLabel.setForeground(t_sin); mainFrame.add(titleLabel); // Описание JTextArea description = new JTextArea( "ФИИТ - фундаментальная информатика и информационные\n" + "технологии. Готовим разработчиков, способных работать\n" + "в любой IT-компании. Направление курируют IT-компании\n" + "Контур, NAUMEN, Doubletapp, JetStyle и IT-сообщество\n" + "Екатеринбурга."); description.setBounds(466, 220, 600, 150); description.setFont(new Font("Arial", Font.PLAIN, 14)); description.setForeground(t_sin); description.setBackground(wh); description.setEditable(false); mainFrame.add(description); } private void createContactsSection() { JLabel contactsLabel = new JLabel("Связь с нами:"); contactsLabel.setBounds(466, 380, 150, 36); contactsLabel.setFont(new Font("Arial", Font.PLAIN, 15)); contactsLabel.setForeground(sin); mainFrame.add(contactsLabel); // Telegram ImageIcon tgIcon = new ImageIcon("tg.png"); JLabel tgLabel = new JLabel(tgIcon); tgLabel.setBounds(467, 416, tgIcon.getIconWidth(), tgIcon.getIconHeight()); mainFrame.add(tgLabel); JButton tgBtn = createSocialButton("https://t.me/fiit_urfu", 536, 416, 170, 50); tgBtn.addActionListener(e -> openWebPage("https://t.me/fiit_urfu")); // VK ImageIcon vkIcon = new ImageIcon("vk.png"); JLabel vkLabel = new JLabel(vkIcon); vkLabel.setBounds(471, 476, vkIcon.getIconWidth(), vkIcon.getIconHeight()); mainFrame.add(vkLabel); JButton vkBtn = createSocialButton("vk.com/fiiturfu", 541, 476, 120, 50); vkBtn.addActionListener(e -> openWebPage("https://vk.com/fiiturfu")); // Email ImageIcon mailIcon = new ImageIcon("pochta.png"); JLabel mailLabel = new JLabel(mailIcon); mailLabel.setBounds(471, 536, mailIcon.getIconWidth(), mailIcon.getIconHeight()); mainFrame.add(mailLabel); JButton mailBtn = createSocialButton("fiit@kontur.ru", 544, 536, 110, 50); mailBtn.addActionListener(e -> openWebPage("mailto:fiit@kontur.ru")); } private void createSocialSection() { JLabel socialLabel = new JLabel("Мы в других соц. сетях:"); socialLabel.setBounds(741, 380, 250, 36); socialLabel.setFont(new Font("Arial", Font.PLAIN, 15)); socialLabel.setForeground(sin); mainFrame.add(socialLabel); // Сайт ImageIcon siteIcon = new ImageIcon("sait.png"); JLabel siteLabel = new JLabel(siteIcon); siteLabel.setBounds(741, 411, siteIcon.getIconWidth(), siteIcon.getIconHeight()); mainFrame.add(siteLabel); JButton siteBtn = createSocialButton("vk.com/mmabiturient", 820, 416, 175, 50); siteBtn.addActionListener(e -> openWebPage("https://vk.com/mmabiturient")); // YouTube ImageIcon ytIcon = new ImageIcon("youtube.png"); JLabel ytLabel = new JLabel(ytIcon); ytLabel.setBounds(746, 476, ytIcon.getIconWidth(), ytIcon.getIconHeight()); mainFrame.add(ytLabel); JButton ytBtn = createSocialButton("youtube.com/@user-ep1yj8gz7b", 823, 471, 175, 50); ytBtn.addActionListener(e -> openWebPage("https://www.youtube.com/channel/UC-dOXcKANMkRrChuUYML-FQ")); } private JButton createSocialButton(String text, int x, int y, int width, int height) { JButton button = new JButton(text); button.setBounds(x, y, width, height); button.setForeground(sin); button.setBackground(wh); button.setFont(new Font("Segoe UI", Font.PLAIN, 13)); button.setBorderPainted(false); button.setFocusPainted(false); button.setContentAreaFilled(false); button.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { button.setForeground(t_sin); } @Override public void mouseExited(MouseEvent e) { button.setForeground(sin); } }); mainFrame.add(button); return button; } private void toggleTheme() { darkMode = !darkMode; if (darkMode) { // Темная тема wh = t_sin; t_sin = Color.WHITE; sin = gol; bl = Color.WHITE; } else { // Светлая тема wh = Color.WHITE; t_sin = new Color(14, 13, 64); sin = new Color(28, 63, 166); bl = Color.BLACK; } // Обновляем цвета всех компонентов updateColors(); } private void updateColors() { mainFrame.getContentPane().setBackground(wh); // Обновляем цвета всех компонентов, которые нужно перекрасить // (это упрощенный пример, в реальном приложении нужно перебрать все компоненты) Component[] components = mainFrame.getContentPane().getComponents(); for (Component component : components) { if (component instanceof JLabel) { JLabel label = (JLabel) component; if (label.getText() != null) { if (label.getText().equals("IT-направление на матмехе УрФУ") || label.getText().equals("Связь с нами:") || label.getText().equals("Мы в других соц. сетях:")) { label.setForeground(darkMode ? Color.WHITE : t_sin); } } } else if (component instanceof JTextArea) { ((JTextArea) component).setForeground(darkMode ? Color.WHITE : t_sin); ((JTextArea) component).setBackground(wh); } } } private void openWebPage(String url) { try { Desktop.getDesktop().browse(new URI(url)); } catch (Exception e) { e.printStackTrace(); } } private void openHistoryWindow() { JFrame historyFrame = new JFrame("История развития ФИИТ"); historyFrame.setSize(645, 647); historyFrame.setLayout(null); historyFrame.setResizable(false); // Добавьте содержимое окна истории здесь historyFrame.setVisible(true); } private void openProgramWindow() { // Реализация окна с программой обучения } private void openTeachersWindow() { // Реализация окна с преподавателями } private void openInternshipsWindow() { // Реализация окна со стажировками } private void openReviewsWindow() { // Реализация окна с отзывами } private void openPaidEducationWindow() { // Реализация окна с платным обучением } public static void main(String[] args) { SwingUtilities.invokeLater(() -> new BadenBadenApp()); } }