|
| 1 | +package com.genuinecoder; |
| 2 | + |
| 3 | +import java.awt.Color; |
| 4 | +import java.awt.GridLayout; |
| 5 | +import java.util.Random; |
| 6 | +import javax.swing.JLabel; |
| 7 | +import javax.swing.JOptionPane; |
| 8 | +import javax.swing.JPanel; |
| 9 | +import javax.swing.border.LineBorder; |
| 10 | +import org.kordamp.ikonli.materialdesign.MaterialDesign; |
| 11 | +import org.kordamp.ikonli.swing.FontIcon; |
| 12 | + |
| 13 | +/** |
| 14 | + * @author Villan |
| 15 | + */ |
| 16 | +public class Main extends javax.swing.JFrame { |
| 17 | + |
| 18 | + public Main() { |
| 19 | + initComponents(); |
| 20 | + setTitle("Genuine Coder"); |
| 21 | + prepareIcons(); |
| 22 | + pack(); |
| 23 | + setLocationRelativeTo(null); |
| 24 | + } |
| 25 | + |
| 26 | + @SuppressWarnings("unchecked") |
| 27 | + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
| 28 | + private void initComponents() { |
| 29 | + |
| 30 | + jPanel1 = new javax.swing.JPanel(); |
| 31 | + root = new javax.swing.JPanel(); |
| 32 | + |
| 33 | + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
| 34 | + setBackground(new java.awt.Color(255, 255, 255)); |
| 35 | + |
| 36 | + jPanel1.setBackground(new java.awt.Color(255, 255, 255)); |
| 37 | + |
| 38 | + root.addMouseListener(new java.awt.event.MouseAdapter() { |
| 39 | + public void mouseClicked(java.awt.event.MouseEvent evt) { |
| 40 | + rootMouseClicked(evt); |
| 41 | + } |
| 42 | + }); |
| 43 | + root.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); |
| 44 | + |
| 45 | + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); |
| 46 | + jPanel1.setLayout(jPanel1Layout); |
| 47 | + jPanel1Layout.setHorizontalGroup( |
| 48 | + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
| 49 | + .addGroup(jPanel1Layout.createSequentialGroup() |
| 50 | + .addComponent(root, javax.swing.GroupLayout.PREFERRED_SIZE, 955, javax.swing.GroupLayout.PREFERRED_SIZE) |
| 51 | + .addGap(0, 0, Short.MAX_VALUE)) |
| 52 | + ); |
| 53 | + jPanel1Layout.setVerticalGroup( |
| 54 | + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
| 55 | + .addComponent(root, javax.swing.GroupLayout.DEFAULT_SIZE, 719, Short.MAX_VALUE) |
| 56 | + ); |
| 57 | + |
| 58 | + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); |
| 59 | + getContentPane().setLayout(layout); |
| 60 | + layout.setHorizontalGroup( |
| 61 | + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
| 62 | + .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
| 63 | + ); |
| 64 | + layout.setVerticalGroup( |
| 65 | + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
| 66 | + .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
| 67 | + ); |
| 68 | + |
| 69 | + pack(); |
| 70 | + }// </editor-fold>//GEN-END:initComponents |
| 71 | + |
| 72 | + private void rootMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_rootMouseClicked |
| 73 | + FontIcon fontIcon = FontIcon.of(MaterialDesign.MDI_YOUTUBE_PLAY); |
| 74 | + fontIcon.setIconSize(50); |
| 75 | + fontIcon.setIconColor(Color.RED); |
| 76 | + JOptionPane.showConfirmDialog(rootPane, "Upload to YouTube?", "Upload video", JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE, fontIcon); |
| 77 | + }//GEN-LAST:event_rootMouseClicked |
| 78 | + |
| 79 | + public static void main(String args[]) { |
| 80 | + try { |
| 81 | + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { |
| 82 | + if ("Nimbus".equals(info.getName())) { |
| 83 | + javax.swing.UIManager.setLookAndFeel(info.getClassName()); |
| 84 | + break; |
| 85 | + } |
| 86 | + } |
| 87 | + } catch (ClassNotFoundException ex) { |
| 88 | + java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); |
| 89 | + } catch (InstantiationException ex) { |
| 90 | + java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); |
| 91 | + } catch (IllegalAccessException ex) { |
| 92 | + java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); |
| 93 | + } catch (javax.swing.UnsupportedLookAndFeelException ex) { |
| 94 | + java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); |
| 95 | + } |
| 96 | + |
| 97 | + java.awt.EventQueue.invokeLater(new Runnable() { |
| 98 | + public void run() { |
| 99 | + new Main().setVisible(true); |
| 100 | + } |
| 101 | + }); |
| 102 | + } |
| 103 | + |
| 104 | + private void prepareIcons() { |
| 105 | + addIcon(MaterialDesign.MDI_ACCOUNT); |
| 106 | + addIcon(MaterialDesign.MDI_ACCOUNT_ALERT); |
| 107 | + addIcon(MaterialDesign.MDI_ACCOUNT_BOX); |
| 108 | + addIcon(MaterialDesign.MDI_ACCOUNT_CHECK); |
| 109 | + addIcon(MaterialDesign.MDI_ACCOUNT_CIRCLE); |
| 110 | + addIcon(MaterialDesign.MDI_ACCOUNT_MULTIPLE); |
| 111 | + addIcon(MaterialDesign.MDI_ACCOUNT_STAR_VARIANT); |
| 112 | + addIcon(MaterialDesign.MDI_AIRPLANE_OFF); |
| 113 | + addIcon(MaterialDesign.MDI_ZIP_BOX); |
| 114 | + addIcon(MaterialDesign.MDI_YOUTUBE_PLAY); |
| 115 | + addIcon(MaterialDesign.MDI_YELP); |
| 116 | + addIcon(MaterialDesign.MDI_XBOX_CONTROLLER); |
| 117 | + addIcon(MaterialDesign.MDI_WINDOW_OPEN); |
| 118 | + addIcon(MaterialDesign.MDI_WEATHER_WINDY_VARIANT); |
| 119 | + addIcon(MaterialDesign.MDI_VIEW_CAROUSEL); |
| 120 | + addIcon(MaterialDesign.MDI_SALE); |
| 121 | + addIcon(MaterialDesign.MDI_SATELLITE); |
| 122 | + addIcon(MaterialDesign.MDI_SAXOPHONE); |
| 123 | + addIcon(MaterialDesign.MDI_SCALE_BALANCE); |
| 124 | + addIcon(MaterialDesign.MDI_SCHOOL); |
| 125 | + addIcon(MaterialDesign.MDI_ACCOUNT_MINUS); |
| 126 | + addIcon(MaterialDesign.MDI_JEEPNEY); |
| 127 | + addIcon(MaterialDesign.MDI_LAMBDA); |
| 128 | + addIcon(MaterialDesign.MDI_KETTLE); |
| 129 | + } |
| 130 | + |
| 131 | + private void addIcon(MaterialDesign icon) { |
| 132 | + JPanel panel = new JPanel(); |
| 133 | + panel.setBackground(Color.decode("#FAFAFA")); |
| 134 | + panel.setBorder(new LineBorder(Color.GRAY)); |
| 135 | + panel.setLayout(new GridLayout()); |
| 136 | + panel.setSize(300, 300); |
| 137 | + |
| 138 | + FontIcon fontIcon = FontIcon.of(icon); |
| 139 | + fontIcon.setIconSize(150); |
| 140 | + fontIcon.setIconColor(Color.decode(getRandomColor())); |
| 141 | + |
| 142 | + JLabel label = new JLabel(); |
| 143 | + label.setIcon(fontIcon); |
| 144 | + panel.add(label); |
| 145 | + root.add(panel); |
| 146 | + } |
| 147 | + |
| 148 | + private String getRandomColor() { |
| 149 | + String[] colors = {"#d32f2f", "#C2185B", "#7B1FA2", "#512DA8", "#303F9F", "#1976D2", "#0288D1", "#0097A7", "#00796B"}; |
| 150 | + int index = new Random().nextInt(colors.length); |
| 151 | + return colors[index]; |
| 152 | + } |
| 153 | + |
| 154 | + // Variables declaration - do not modify//GEN-BEGIN:variables |
| 155 | + private javax.swing.JPanel jPanel1; |
| 156 | + private javax.swing.JPanel root; |
| 157 | + // End of variables declaration//GEN-END:variables |
| 158 | + |
| 159 | +} |
0 commit comments