Exemplo n.º 1
1
 private static void decryptRSA(JFrame screen) {
   screen.dispose();
   screen = init();
   JFrame screen1 = screen;
   JPanel screem = new JPanel();
   JTextField mess = new JTextField("Encoded Message");
   JTextField n = new JTextField("Private Key");
   JTextField d = new JTextField("Public Key");
   JTextField ea = new JTextField("Exponent");
   JButton x = new JButton("submit");
   ActionListener xa =
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           String m = mess.getText();
           String prk = n.getText();
           String puk = d.getText();
           String plk = ea.getText();
           rSAdisplayOutput(screen1, RSACode.decrypt(new String[] {prk, puk, plk, m}));
         }
       };
   x.addActionListener(xa);
   screem.add(mess);
   screem.add(n);
   screem.add(d);
   screem.add(ea);
   screem.add(x);
   screen.add(screem);
   screen.revalidate();
 }
Exemplo n.º 2
1
  public void loadClassListScreen(String sessionKey, String username) {
    RequestMessage<Void> req = new RequestMessage<>();
    req.setAction("listClosedClasses");
    req.setSessionKey(sessionKey);

    MessageBroker broker = MainController.get().getMessageBroker();

    CompletableFuture<ResponseMessage<List<Claass>>> resFut;

    resFut = broker.sendMessageAsync(req);

    resFut.whenComplete(
        (res, e) -> {
          JFrame frame = MainController.get().getMainWindow().getFrame();

          if (e != null) {
            JOptionPane.showMessageDialog(
                frame, "Houve um erro ao tentar carregar lista", "Erro", JOptionPane.ERROR_MESSAGE);
            e.printStackTrace();
            return;
          }

          StudentClassListPanel panel =
              new StudentClassListPanel(sessionKey, res.getValue(), username);

          EventQueue.invokeLater(
              () -> {
                frame.setContentPane(panel);
                frame.revalidate();
              });
        });
  }
Exemplo n.º 3
0
 public void actionPerformed(ActionEvent event) {
   PanImage1 panImage1 = new PanImage1();
   PanImage2 panImage2 = new PanImage2();
   PanImage3 panImage3 = new PanImage3();
   revalidate();
   if (event.getSource() == btnClick) {
     if (nImg == 0) {
       nImg = 3;
     } else {
       nImg--;
     }
   } else if (event.getSource() == btnClick2) {
     if (nImg == 4) {
       nImg = 1;
     } else {
       nImg++;
     }
   } else if (event.getSource() == btnClick3) {
     System.exit(0);
   }
   if (nImg == 1) {
     add(panImage1);
   }
   if (nImg == 2) {
     add(panImage2);
   }
   if (nImg == 3) {
     add(panImage3);
   }
 }
Exemplo n.º 4
0
 private void showPanel(JPanel p) {
   setUpUnitLists();
   mainPanel.removeAll();
   mainPanel.add(p);
   mainFrame.repaint();
   mainFrame.revalidate();
 }
Exemplo n.º 5
0
  public void loadQuestionList(String sessionKey, Claass clazz, String username) {
    JFrame frame = MainController.get().getMainWindow().getFrame();

    StudentQuestionListPanel panel = new StudentQuestionListPanel(sessionKey, clazz, username);

    frame.setContentPane(panel);
    frame.revalidate();
  }
Exemplo n.º 6
0
 // --------------------refresh Window----------------------------------
 private void neu(int xx, int yy) {
   XX = xx;
   YY = yy;
   lastButtonY = 0;
   lastButtonX = 0;
   lastIcon = null;
   firstClick = true;
   window.getContentPane().removeAll();
   baueButton();
   window.revalidate();
 }
Exemplo n.º 7
0
 private static void rSAdisplay(JFrame screen, String[] code) {
   screen.dispose();
   screen = init();
   JPanel screem = new JPanel();
   JButton messbut = new JButton("copy message");
   JButton k1 = new JButton("copy value of key1");
   JButton k2 = new JButton("copy value of key2");
   JButton k3 = new JButton("copy value of key3");
   messbut.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent arg0) {
           String myString = code[3];
           StringSelection stringSelection = new StringSelection(myString);
           Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
           clpbrd.setContents(stringSelection, null);
         }
       });
   k1.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent arg0) {
           String myString = code[0];
           StringSelection stringSelection = new StringSelection(myString);
           Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
           clpbrd.setContents(stringSelection, null);
         }
       });
   k2.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent arg0) {
           String myString = code[1];
           StringSelection stringSelection = new StringSelection(myString);
           Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
           clpbrd.setContents(stringSelection, null);
         }
       });
   k3.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent arg0) {
           String myString = code[2];
           StringSelection stringSelection = new StringSelection(myString);
           Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
           clpbrd.setContents(stringSelection, null);
         }
       });
   screem.add(messbut);
   screem.add(k1);
   screem.add(k2);
   screem.add(k3);
   screen.add(screem);
   screen.revalidate();
 }
Exemplo n.º 8
0
 public void actionPerformed(
     ActionEvent e) { // action event for when either the button or the enter key is pressed
   nameInput =
       summonerTextField.getText().toLowerCase().replaceAll(" ", ""); // change text format for URL
   if (nameInput.equals("")) {
     errorLabel.setText("You need to type something!");
   } else {
     errorLabel.setText("Loading...");
     String comboBoxValue = getComboBoxValue(regionsComboBox).toString(); // get combobox string
     ConvertToCountryCode(comboBoxValue); // convert it to country code ex. na, eu, ru, etc.
     getMostRecentVersion(regionCodeValue);
     System.out.println("Loading next page...");
     // System.out.println("The button was pressed.\nnameInput text: " + nameInput + "\nRegion
     // code: " + regionCodeValue+"\nVersion: " + version);
     /*This is where the next page will be called. JSON information must be retrieved from another class.*/
     // class objects
     Summoner_ByName objSummByName =
         new Summoner_ByName(
             nameInput, regionCodeValue, version); // get Summoner_ByName information from endpoint
     if (objSummByName.getDoesExist()) { // if the searched summoner exists
       // prepare frame for next page
       masterFrame.getContentPane().removeAll();
       masterFrame.revalidate();
       masterFrame.repaint();
       Game_ById GAME_BY_ID =
           new Game_ById(
               objSummByName.getSummonerId(),
               regionCodeValue,
               version); // get Game_ById information from endpoint
       LoLStaticData_AllChampions DATA_ALL_CHAMPIONS =
           new LoLStaticData_AllChampions(
               GAME_BY_ID.getChampionIdList(),
               regionCodeValue,
               version); // get data for all champions from endpoint
       League_ById LEAGUE_BY_ID = new League_ById(regionCodeValue, objSummByName.getSummonerId());
       MatchHistoryPage MATCH_HISTORY_PAGE =
           new MatchHistoryPage(
               regionCodeValue,
               masterFrame,
               objSummByName,
               GAME_BY_ID,
               DATA_ALL_CHAMPIONS,
               LEAGUE_BY_ID); // proceed to match history page
       frameTimer.cancel(); // stop frame timer from going forever
     } else {
       errorLabel.setText("Player does not exist. Please try again.");
     }
   }
 }
  public static void main(String[] args) {

    JFrame frame = new JFrame("Network Tables");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocationRelativeTo(null);
    Display display = new Display();
    frame.getContentPane().add(display);

    frame.setLocation(0, 0);
    frame.setSize(new Dimension(2000, 700));

    frame.revalidate();
    frame.repaint();
    frame.setVisible(true);
  }
Exemplo n.º 10
0
 private static void aESoutput(String encryptMessage, JFrame screen) {
   screen.dispose();
   screen = init();
   JPanel myp = new JPanel();
   JButton x = new JButton("Copy Encrypted Message");
   x.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent arg0) {
           String myString = encryptMessage;
           StringSelection stringSelection = new StringSelection(myString);
           Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
           clpbrd.setContents(stringSelection, null);
         }
       });
   myp.add(x);
   screen.add(myp);
   screen.revalidate();
 }
Exemplo n.º 11
0
 public static void main(String[] args) {
   final JFrame screen = init();
   ActionListener encryptAction =
       new ActionListener() {
         public void actionPerformed(ActionEvent arg0) {
           encrypt(screen);
         }
       };
   ActionListener decryptAction =
       new ActionListener() {
         public void actionPerformed(ActionEvent arg0) {
           decrypt(screen);
         }
       };
   button(encrypt, encryptAction, "Encryption", screen, 0, 0, 500, 1000);
   button(decrypt, decryptAction, "Decryption", screen, 500, 0, 500, 1000);
   screen.revalidate();
 }
Exemplo n.º 12
0
 public static JPanel button(
     String path,
     ActionListener act,
     String text,
     JFrame screen,
     int x,
     int y,
     int xend,
     int yend) {
   JPanel myp = new JPanel();
   JButton x1 = new JButton(text, new ImageIcon(path));
   x1.addActionListener(act);
   x1.setBounds(new Rectangle(x, y, xend - x, yend - y));
   myp.add(x1);
   myp.revalidate();
   screen.add(myp);
   screen.revalidate();
   return myp;
 }
Exemplo n.º 13
0
 private static void decryptAESOutput(String decryptMessage, JFrame screen) {
   screen.dispose();
   screen = init();
   JPanel m = new JPanel();
   JButton copy = new JButton("Copy Decrypted Message");
   ActionListener l =
       new ActionListener() {
         public void actionPerformed(ActionEvent arg0) {
           String myString = decryptMessage;
           StringSelection stringSelection = new StringSelection(myString);
           Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
           clpbrd.setContents(stringSelection, null);
         }
       };
   copy.addActionListener(l);
   m.add(copy);
   screen.add(m);
   screen.revalidate();
 }
  private static void createAndShowPostReviewGraphMainGUI(
      final JFrame jFrame, final GridBagLayout gbl) {

    jFrame.getContentPane().removeAll();

    jFrame.setTitle("Show Graph");

    jFrame.setBackground(new Color(100, 230, 240));

    btnAddNewPost2 = new JButton("Graph");

    jFrame
        .getContentPane()
        .add(
            btnAddNewPost2,
            new GridBagConstraints(
                1,
                0,
                1,
                1,
                0.0,
                1,
                GridBagConstraints.FIRST_LINE_END,
                GridBagConstraints.HORIZONTAL,
                new Insets(100, 150, 0, 0),
                0,
                0));

    jFrame.setVisible(true);

    jFrame.revalidate();

    jFrame.repaint();

    btnAddNewPost2.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            createAndShowMainGUI(jFrame, gbl);
          }
        });
  }
Exemplo n.º 15
0
 private static void rSA(JFrame screen) {
   screen.dispose();
   final JFrame screen1 = screen = init();
   JTextField inputField = new JTextField("    Input    ");
   JPanel a = new JPanel();
   a.add(inputField);
   JButton x = new JButton("submit");
   ActionListener l =
       new ActionListener() {
         public void actionPerformed(ActionEvent arg0) {
           String c = inputField.getText();
           String[] code = RSACode.encrypt(c);
           rSAdisplay(screen1, code);
         }
       };
   x.addActionListener(l);
   a.add(x);
   screen.add(a);
   screen.revalidate();
 }
Exemplo n.º 16
0
 private static void encrypt(JFrame screen) {
   screen.dispose();
   screen.setVisible(false);
   screen = init();
   final JFrame screen1 = screen;
   ActionListener RSAAction =
       new ActionListener() {
         public void actionPerformed(ActionEvent arg0) {
           rSA(screen1);
         }
       };
   ActionListener AESAction =
       new ActionListener() {
         public void actionPerformed(ActionEvent arg0) {
           aES(screen1);
         }
       };
   button(RSA, RSAAction, "RSA", screen, 0, 0, 500, 1000);
   button(AES, AESAction, "AES", screen, 500, 0, 500, 1000);
   screen.revalidate();
 }
Exemplo n.º 17
0
 private static void decryptAES(JFrame screen) {
   screen.dispose();
   screen = init();
   JPanel screem = new JPanel();
   final JFrame screen1 = screen;
   JTextField s = new JTextField("Message");
   JTextField a = new JTextField("Password");
   JButton x = new JButton("submit");
   ActionListener l =
       new ActionListener() {
         public void actionPerformed(ActionEvent arg0) {
           decryptAESOutput(AESCode.decryptMessagage(s.getText(), a.getText()), screen1);
         }
       };
   x.addActionListener(l);
   screem.add(s);
   screem.add(a);
   screem.add(x);
   screen.add(screem);
   screen.revalidate();
 }
Exemplo n.º 18
0
 private static void aES(JFrame screen) {
   screen.dispose();
   final JFrame screen1 = screen = init();
   JTextField inputField = new JTextField("Message");
   JTextField pdField = new JTextField("Password");
   JPanel a = new JPanel();
   a.add(inputField);
   a.add(pdField);
   JButton x = new JButton("Submit");
   ActionListener l =
       new ActionListener() {
         public void actionPerformed(ActionEvent arg0) {
           String b = inputField.getText();
           String c = pdField.getText();
           aESoutput(AESCode.encryptMessage(b, c), screen1);
         }
       };
   x.addActionListener(l);
   a.add(x);
   screen.add(a);
   screen.revalidate();
 }
Exemplo n.º 19
0
  void drawIcon(int i, int j, Piece p) {

    if (icon != null) icon.getImage().flush();

    if (p.getType() == Chess.Type.pawn) {
      if (p.getColor() == Chess.Color.black)
        icon = new ImageIcon(path + "\\src\\chess\\pieces\\bpawn.png");
      else icon = new ImageIcon(path + "\\src\\chess\\pieces\\wpawn.png");

    } else if (p.getType() == Chess.Type.bishop) {
      if (p.getColor() == Chess.Color.black)
        icon = new ImageIcon(path + "\\src\\chess\\pieces\\bbishop.png");
      else icon = new ImageIcon(path + "\\src\\chess\\pieces\\wbishop.png");

    } else if (p.getType() == Chess.Type.knight) {
      if (p.getColor() == Chess.Color.black)
        icon = new ImageIcon(path + "\\src\\chess\\pieces\\bknight.png");
      else icon = new ImageIcon(path + "\\src\\chess\\pieces\\wknight.png");

    } else if (p.getType() == Chess.Type.rook) {
      if (p.getColor() == Chess.Color.black)
        icon = new ImageIcon(path + "\\src\\chess\\pieces\\brook.png");
      else icon = new ImageIcon(path + "\\src\\chess\\pieces\\wrook.png");

    } else if (p.getType() == Chess.Type.queen) {
      if (p.getColor() == Chess.Color.black)
        icon = new ImageIcon(path + "\\src\\chess\\pieces\\bqueen.png");
      else icon = new ImageIcon(path + "\\src\\chess\\pieces\\wqueen.png");

    } else if (p.getType() == Chess.Type.king) {
      if (p.getColor() == Chess.Color.black)
        icon = new ImageIcon(path + "\\src\\chess\\pieces\\bking.png");
      else icon = new ImageIcon(path + "\\src\\chess\\pieces\\wking.png");
    }
    squares[i][j].setIcon(icon);
    window.revalidate();
    window.repaint();
  }
  @Override
  public void actionPerformed(ActionEvent e) {

    PanelBienvenidaJugador panelBienvenida = null;
    try {
      panelBienvenida = new PanelBienvenidaJugador(ventana, campo);
    } catch (ParserConfigurationException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    } catch (TransformerException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    } catch (SAXException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    } catch (IOException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    ventana.getContentPane().removeAll();
    ventana.getContentPane().add(panelBienvenida.obtenerPanel());
    ventana.revalidate();
  }
Exemplo n.º 21
0
 void removeIcon(int i, int j) {
   squares[i][j].setIcon(null);
   window.revalidate();
   window.repaint();
 }
Exemplo n.º 22
0
  private void createGUI() {

    frame.getContentPane().removeAll();

    Container contentPane = frame.getContentPane();
    SpringLayout layout = new SpringLayout();
    contentPane.setLayout(layout);
    contentPane.add(colorLabel);
    contentPane.add(redButton);
    contentPane.add(blueButton);
    contentPane.add(greenButton);
    contentPane.add(yellowButton);
    contentPane.add(confirmButton);

    final int topMarginX = 175;
    final int topMarginY = 50;
    final int buttonX = 100;
    final int buttonY = 50;
    final int bottomMargin = -50;

    layout.putConstraint(
        SpringLayout.EAST, colorLabel, topMarginX, SpringLayout.HORIZONTAL_CENTER, contentPane);
    layout.putConstraint(
        SpringLayout.SOUTH, colorLabel, topMarginY, SpringLayout.NORTH, contentPane);

    layout.putConstraint(
        SpringLayout.HORIZONTAL_CENTER,
        redButton,
        -buttonX,
        SpringLayout.HORIZONTAL_CENTER,
        contentPane);
    layout.putConstraint(
        SpringLayout.VERTICAL_CENTER,
        redButton,
        -buttonY,
        SpringLayout.VERTICAL_CENTER,
        contentPane);

    layout.putConstraint(
        SpringLayout.HORIZONTAL_CENTER,
        blueButton,
        buttonX,
        SpringLayout.HORIZONTAL_CENTER,
        contentPane);
    layout.putConstraint(
        SpringLayout.VERTICAL_CENTER, blueButton, 0, SpringLayout.VERTICAL_CENTER, redButton);

    layout.putConstraint(
        SpringLayout.HORIZONTAL_CENTER, greenButton, 0, SpringLayout.HORIZONTAL_CENTER, redButton);
    layout.putConstraint(
        SpringLayout.VERTICAL_CENTER,
        greenButton,
        buttonY,
        SpringLayout.VERTICAL_CENTER,
        contentPane);

    layout.putConstraint(
        SpringLayout.HORIZONTAL_CENTER,
        yellowButton,
        0,
        SpringLayout.HORIZONTAL_CENTER,
        blueButton);
    layout.putConstraint(
        SpringLayout.VERTICAL_CENTER,
        yellowButton,
        buttonY,
        SpringLayout.VERTICAL_CENTER,
        contentPane);

    layout.putConstraint(
        SpringLayout.EAST, confirmButton, bottomMargin, SpringLayout.EAST, contentPane);
    layout.putConstraint(
        SpringLayout.SOUTH, confirmButton, bottomMargin, SpringLayout.SOUTH, contentPane);

    frame.repaint();
    frame.revalidate();
  }
Exemplo n.º 23
0
  public ImageReaderV(int width, int height, String fileName) {

    BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel label = new JLabel(new ImageIcon(img));
    label.setPreferredSize(new Dimension(width, height));
    frame.getContentPane().add(label, BorderLayout.CENTER);
    label.addMouseListener(this);
    label.addMouseMotionListener(this);

    // Bottons
    JPanel buttonPanel = new JPanel();
    buttonPanel.setPreferredSize(new Dimension(width, 50));
    frame.getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    MyButton splitButton = new MyButton("Split");
    buttonPanel.add(splitButton, BorderLayout.WEST);

    MyButton initButton = new MyButton("Initialize");
    buttonPanel.add(initButton, BorderLayout.WEST);

    MyButton resetButton = new MyButton("Reset");
    buttonPanel.add(resetButton, BorderLayout.WEST);

    MyButton closeButton = new MyButton("Close");
    buttonPanel.add(closeButton, BorderLayout.WEST);

    frame.pack();
    frame.setVisible(true);
    int ind = 0;
    // byte[] bytes;

    try {
      File file = new File(fileName);
      InputStream is = new FileInputStream(file);

      long len = file.length();
      System.out.println(len);
      byte[] bytes = new byte[(int) len];

      int offset = 0;
      int numRead = 0;
      while (offset < bytes.length
          && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) {
        offset += numRead;
      }
      //  height =320;
      // width = 240;

      while (true) {
        for (int i = 1; i <= 500; i++) {

          int temp = height * width;

          for (int y = 0; y < height; y++) {

            for (int x = 0; x < width; x++) {

              byte a = 0;
              byte r = bytes[ind];
              byte g = bytes[ind + temp];
              byte b = bytes[ind + temp * 2];

              int pix = 0xff000000 | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff);

              img.setRGB(x, y, pix);
              if (ind < len) ind++;
            }
          }

          // Use a label to display the image
          label.setIcon(null);
          label.revalidate();
          label.setIcon(new ImageIcon(img));
          label.setPreferredSize(new Dimension(width, height));
          frame.getContentPane().add(label, BorderLayout.CENTER);
          label.revalidate();
          frame.revalidate();
          frame.pack();
          frame.setVisible(true);

          // if(i==10)
          try {
            Thread.sleep(50L);
          } catch (Exception e) {
          }
          temp = temp + height * width * 2;
          ind = ind + height * width * 2;
          if (ind >= len) break;
          System.out.println(ind + " " + height * width + " " + i);
        }
        break;
      }
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }