Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.80 KB | None | 0 0
  1. package fr.kinjerjs.os;
  2.  
  3.  
  4.  
  5. import java.awt.Color;
  6. import java.awt.Graphics;
  7. import java.util.Calendar;
  8. import java.util.GregorianCalendar;
  9. import java.util.logging.Level;
  10. import java.util.logging.Logger;
  11.  
  12. import javax.swing.JLabel;
  13. import javax.swing.JPanel;
  14. import javax.swing.JTextField;
  15.  
  16. import fr.kinjerjs.fenetre.FenetreFrame;
  17. import fr.theshark34.swinger.Swinger;
  18. import fr.theshark34.swinger.event.SwingerEvent;
  19. import fr.theshark34.swinger.event.SwingerEventListener;
  20. import fr.theshark34.swinger.textured.STexturedButton;
  21.  
  22.  
  23.  
  24. @SuppressWarnings("serial")
  25. public class OSPanel extends JPanel implements SwingerEventListener{
  26.  
  27. private STexturedButton background = new STexturedButton(Swinger.getResource("background.png"),Swinger.getResource("ostache.png"));
  28. private JTextField rechercheapp = new JTextField();
  29.  
  30. private STexturedButton application = new STexturedButton(Swinger.getResource("app.png"));
  31. private JLabel titleapplication = new JLabel("Fenetre");
  32.  
  33. private STexturedButton ostache = new STexturedButton(Swinger.getResource("ostache.png"),Swinger.getResource("ostache.png"));
  34. private STexturedButton offtache = new STexturedButton(Swinger.getResource("off.png"));
  35. private STexturedButton offarrowtache = new STexturedButton(Swinger.getResource("offarrow.png"));
  36. private STexturedButton os = new STexturedButton(Swinger.getResource("os bouton.png"),Swinger.getResource("os bouton hide.png"));
  37. private STexturedButton btbureau = new STexturedButton(Swinger.getResource("barretache.png"));
  38. private STexturedButton barretache = new STexturedButton(Swinger.getResource("barretache.png"),Swinger.getResource("ostache.png"));
  39. private JLabel heure = new JLabel("00:00");
  40. private JLabel date = new JLabel("04/04/2004");
  41.  
  42.  
  43.  
  44.  
  45. public OSPanel() {
  46. date();
  47. ostache();
  48.  
  49. setLayout(null);
  50.  
  51. offtache.setBounds(250,520,50,15);
  52. offtache.addEventListener(this);
  53. offtache.setVisible(false);
  54. add(offtache);
  55. offarrowtache.setBounds(300,520,10,15);
  56. offarrowtache.addEventListener(this);
  57. offarrowtache.setVisible(false);
  58. add(offarrowtache);
  59.  
  60. rechercheapp.setForeground(Color.BLACK);
  61. rechercheapp.setBounds(18, 518, 210, 20);
  62. rechercheapp.setVisible(false);
  63. add(rechercheapp);
  64.  
  65. application.setBounds(10,10);
  66. application.addEventListener(this);
  67. add(application);
  68.  
  69. titleapplication.setBounds(22,60,50,50);
  70. titleapplication.setFont(titleapplication.getFont().deriveFont(13.0F));
  71. titleapplication.setForeground(Color.WHITE);
  72. add(titleapplication);
  73.  
  74.  
  75. heure.setBounds(900, 540, 50, 50);
  76. add(heure);
  77.  
  78. date.setBounds(885, 555, 70, 50);
  79. add(date);
  80.  
  81. os.setBounds(0, 547);
  82. os.addEventListener(this);
  83. add(os);
  84.  
  85. btbureau.setBounds(960, 547,10,50);
  86. btbureau.addEventListener(this);
  87. add(btbureau);
  88.  
  89. barretache.setBounds(0, 547);
  90. add(barretache);
  91.  
  92. ostache.setBounds(0, 131,0,0);
  93. ostache.addEventListener(this);
  94. add(ostache);
  95.  
  96.  
  97. background.setBounds( 0, 0,1600,900 );
  98. background.addEventListener(this);
  99. add(background);
  100.  
  101.  
  102.  
  103. }
  104.  
  105. public void ostache() {
  106.  
  107. }
  108.  
  109. //public static boolean ostachebool = false;
  110. public static boolean osclic = true;
  111. @Override
  112. public void onEvent(SwingerEvent e) {
  113. if(e.getSource() == os && osclic == true) {
  114. OSPanel.this.setOstache(true);
  115. osclic = false;
  116. }else if(e.getSource() == os && osclic == false){
  117. OSPanel.this.setOstache(false);
  118. osclic = true;
  119. }
  120. if(e.getSource() == background) {
  121. OSPanel.this.setOstache(false);
  122. osclic = true;
  123. }
  124. if(e.getSource() == offtache) {
  125. System.exit(0);
  126. }
  127. if(e.getSource() == application) {
  128. FenetreFrame fen= new FenetreFrame();
  129. }
  130. }
  131.  
  132.  
  133. public void setOstache(boolean t) {
  134.  
  135. if(t == false) {
  136. ostache.setBounds(0, 131,0,0);
  137. rechercheapp.setVisible(t);
  138. offtache.setVisible(t);
  139. offarrowtache.setVisible(t);
  140.  
  141. }else if (t == true) {
  142. ostache.setBounds(0, 131);
  143. rechercheapp.setVisible(t);
  144. offtache.setVisible(t);
  145. offarrowtache.setVisible(t);
  146.  
  147. }
  148.  
  149. }
  150.  
  151. public void paintComponent(Graphics g) {
  152. super.paintComponent(g);
  153.  
  154.  
  155. //g.drawImage(ostache, 0, 131, this);
  156. }
  157.  
  158.  
  159.  
  160. public void date() {
  161.  
  162. Thread clock = new Thread(){
  163. public void run() {
  164. for(;;) {
  165. Calendar Cal = new GregorianCalendar();
  166. //int sconde = Cal.get(Calendar.SECOND);
  167. int minute = Cal.get(Calendar.MINUTE);
  168. int hour = Cal.get(Calendar.HOUR);
  169.  
  170. int jour = Cal.get(Calendar.DATE);
  171. int mois = Cal.get(Calendar.MONTH)+1;
  172. int an = Cal.get(Calendar.YEAR);
  173.  
  174. if (hour == 1) {
  175.  
  176. }
  177.  
  178.  
  179. heure.setText(hour + ":"+ minute);
  180. date.setText(" "+jour +"/"+ mois+"/"+an);
  181. try {
  182. sleep(1000);
  183. }catch(InterruptedException ex){
  184. Logger.getLogger(Calendar.class.getName()).log(Level.SEVERE, null, ex);
  185. }
  186.  
  187. }
  188. }
  189. };
  190. clock.start();
  191.  
  192.  
  193.  
  194. }
  195.  
  196.  
  197. }
  198.  
  199. --------------------------------------------------------------------------------------------------------------
  200. package fr.kinjerjs.fenetre;
  201.  
  202. import javax.swing.JFrame;
  203.  
  204. import fr.theshark34.swinger.Swinger;
  205.  
  206. public class FenetreFrame extends JFrame {
  207. private static final long serialVersionUID = 519422512460448887L;
  208. private static FenetreFrame instance;
  209. private FenetrePanel fenetrepanel;
  210.  
  211. public FenetreFrame() {
  212. setTitle("Fenetre test");
  213. setSize(975, 625);
  214. setDefaultCloseOperation(3);
  215. setLocationRelativeTo(null);
  216. setIconImage(Swinger.getResource("os bouton.png"));
  217. setContentPane(this.fenetrepanel = new FenetrePanel());
  218. setResizable(false);
  219. setVisible(true);
  220. }
  221.  
  222. public static void main(String[] args) {
  223. Swinger.setSystemLookNFeel();
  224. Swinger.setResourcePath("/src/");
  225. instance = new FenetreFrame();
  226. }
  227.  
  228. public static FenetreFrame getInstance() {
  229. return instance;
  230. }
  231.  
  232. public FenetrePanel getLauncherPanel() {
  233. return this.fenetrepanel;
  234. }
  235.  
  236. }
  237. -----------------------------------------------------------------------------------------------
  238. package fr.kinjerjs.fenetre;
  239.  
  240. import java.awt.Graphics;
  241.  
  242. import javax.swing.JPanel;
  243.  
  244. import fr.theshark34.swinger.Swinger;
  245. import fr.theshark34.swinger.event.SwingerEvent;
  246. import fr.theshark34.swinger.event.SwingerEventListener;
  247. import fr.theshark34.swinger.textured.STexturedButton;
  248.  
  249. @SuppressWarnings("serial")
  250. public class FenetrePanel extends JPanel implements SwingerEventListener {
  251.  
  252. private STexturedButton background = new STexturedButton(Swinger.getResource("background.png"));
  253.  
  254. public FenetrePanel() {
  255. setLayout(null);
  256. }
  257.  
  258. @Override
  259. public void onEvent(SwingerEvent e) {
  260.  
  261. }
  262.  
  263. public void paintComponent(Graphics g) {
  264. super.paintComponent(g);
  265.  
  266. // g.drawImage(ostache, 0, 131, this);
  267. }
  268.  
  269. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement