예제 #1
2
  AdminMain() {
    l = new JLabel();
    l.setBounds(10, 20, 1340, 1000);
    l.setBackground(Color.black);
    Font ft = new Font("Arial", Font.BOLD, 30);
    Font ft1 = new Font("Arial", Font.BOLD, 14);
    Font ft2 = new Font("Arial", Font.BOLD, 20);

    f1 = new Frame("Soft Test Management (Beta)");
    f1.setLayout(null);

    l1 = new Label("Test Instructions", l1.CENTER);
    l1.setBounds(10, 20, 1300, 60);
    l1.setForeground(Color.blue);
    l1.setBackground(Color.white);
    l1.setFont(ft);

    l2 = new JLabel("Deletion of Faculty/Students");
    l2.setBounds(20, 30, 1000, 500);
    l2.setBackground(Color.blue);
    l2.setFont(ft2);
    l3 = new JLabel("Test Pattern");
    l3.setBounds(20, 90, 1300, 500);
    l3.setBackground(Color.green);
    l3.setFont(ft2);

    b1 = new JButton("Go !");
    b1.setBounds(300, 220, 120, 30);
    b1.setBackground(Color.white);
    b1.setForeground(Color.blue);
    b1.setFont(ft2);

    b2 = new JButton("Go");
    b2.setBounds(300, 240, 120, 30);
    b2.setBackground(Color.white);
    b2.setForeground(Color.blue);
    b2.setFont(ft2);

    f1.add(l);
    l.add(l1);
    l2.add(b1);
    l.add(l2);
    l3.add(b2);
    l.add(l3);

    b1.addActionListener(this);
    b2.addActionListener(this);

    f1.setVisible(true);
    f1.setSize(1800, 800);
  }
예제 #2
0
 public void mouseExited(MouseEvent e) {
   JButton jbutton = (JButton) e.getSource();
   int comm = Integer.parseInt(jbutton.getActionCommand());
   int today = getNowCalendar().get(Calendar.DAY_OF_MONTH);
   if (comm == today) {
     jbutton.setBackground(todayBtnColor);
   } else {
     jbutton.setBackground(palletTableColor);
   }
 }
 /**
  * Modifie le compteur des tables sélectionnées.
  *
  * @param n Le nombre de tables sélectionnées.
  * @return true Si la sélection peut se faire.
  */
 public boolean setTableCounter(int n) {
   this.tableCounter = n;
   try {
     // Si on a renté un prix et que l'on a sélectionner des tables
     if (Float.parseFloat(payTextField.getText()) >= 0 && tableCounter > 0) {
       valider.setEnabled(true); // On active le bouton valider
       valider.setBackground(Color.GREEN);
     } else {
       valider.setEnabled(false); // On désactive le bouton valider
       valider.setBackground(Color.GRAY);
     }
   } catch (NumberFormatException e) { // Si le prix est invalide désactive le bouton valider
     valider.setEnabled(false);
     valider.setBackground(Color.GRAY);
   }
   return true;
 }
예제 #4
0
 // Set up the quiz window
 Quiz() {
   initializeData();
   setTitle("FOSS Quiz App");
   setDefaultCloseOperation(EXIT_ON_CLOSE);
   setSize(440, 400);
   setLocation(300, 100);
   setResizable(true);
   Container cont = getContentPane();
   cont.setLayout(null);
   cont.setBackground(Color.WHITE);
   bg = new ButtonGroup();
   choice1 = new JRadioButton("Choice1", true);
   choice2 = new JRadioButton("Choice2", false);
   choice3 = new JRadioButton("Choice3", false);
   choice4 = new JRadioButton("Choice4", false);
   bg.add(choice1);
   bg.add(choice2);
   bg.add(choice3);
   bg.add(choice4);
   lblmess = new JLabel("Choose a correct anwswer");
   lblmess.setForeground(Color.BLACK);
   lblmess.setFont(new Font("Sans_Serif", Font.BOLD, 15));
   btnext = new JButton("Next");
   btnext.setForeground(Color.WHITE);
   btnext.setFont(new Font("Sans_Serif", Font.BOLD, 17));
   btnext.setBackground(Color.DARK_GRAY);
   btnext.addActionListener(this);
   panel = new JPanel();
   panel.setBackground(Color.WHITE);
   panel.setLocation(10, 60);
   panel.setSize(400, 300);
   panel.setLayout(new GridLayout(0, 1));
   title = new JPanel();
   title.setBackground(Color.WHITE);
   title.setLocation(10, 10);
   title.setSize(1000, 50);
   title.setLayout(new GridLayout(1, 0));
   title.add(lblmess);
   panel.add(choice1);
   panel.add(choice2);
   panel.add(choice3);
   panel.add(choice4);
   panel.add(btnext);
   cont.add(title);
   cont.add(panel);
   setVisible(true);
   quizAnswerID = 0;
   readQuestionAnswer(quizAnswerID);
 }
예제 #5
0
 private JButton createCopyToClipboardButton() {
   JButton button = new JButton("COPY TO CLIPBOARD");
   button.setBackground(Color.BLACK);
   button.setForeground(Color.GRAY);
   button.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           try {
             copyOverviewToClipboard();
           } catch (InsufficientDataException ex) {
             ex.printStackTrace();
             JOptionPane.showMessageDialog(
                 ReviewDialog.this,
                 "Failed to copy the overview to clipboard: " + ex.getMessage());
           }
         }
       });
   return button;
 }
예제 #6
0
    private void initButton() {
      int actionCommandId = 1;
      for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 7; j++) {
          JButton numberButton = new JButton();
          numberButton.setBorder(BorderFactory.createEmptyBorder());
          numberButton.setHorizontalAlignment(SwingConstants.CENTER);
          numberButton.setActionCommand(String.valueOf(actionCommandId));

          numberButton.addMouseListener(this);

          numberButton.setBackground(palletTableColor);
          numberButton.setForeground(dateFontColor);
          numberButton.setText(String.valueOf(actionCommandId));
          numberButton.setPreferredSize(new Dimension(25, 25));
          daysButton[i][j] = numberButton;
          actionCommandId++;
        }
      }
    }
예제 #7
0
 /**
  * The function creates a button, which opens a file chooser and writes a summary of the displayed
  * results into a user-selected file.
  *
  * @return The 'save to file' button.
  */
 private JButton createSaveToFileButton() {
   JButton b = new JButton("SAVE TO FILE");
   b.setBackground(Color.BLACK);
   b.setForeground(Color.GRAY);
   b.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           try {
             checkTotal();
             fileChooser.setSelectedFile(new File(getDefaultFilename()));
             int returnValue = fileChooser.showDialog(ReviewDialog.this, "Save");
             if (returnValue != JFileChooser.APPROVE_OPTION) return;
             writeToFile(fileChooser.getSelectedFile());
             ReviewDialog.this.setVisible(false);
           } catch (Exception ex) {
             JOptionPane.showMessageDialog(
                 ReviewDialog.this, ex.getMessage(), "Error occurred", JOptionPane.ERROR_MESSAGE);
           }
         }
       });
   return b;
 }
예제 #8
0
  public void createGUI() {
    setLayout(new BorderLayout());
    toolBar = new JToolBar("options", JToolBar.HORIZONTAL);
    toolBar.setFloatable(false);
    toolBar.setOpaque(true);
    toolBar.setBackground(new Color(154, 12, 12));
    toolBar.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15));
    selectAllCB = new JCheckBox("Select All");
    selectAllCB.setVisible(false);
    selectAllCB.setForeground(Color.white);
    selectAllCB.addActionListener(this);
    refreshBut = new JButton(new ImageIcon(this.getClass().getResource("/images/reloadIcon.png")));
    refreshBut.setVisible(false);
    refreshBut.setToolTipText("Refresh");
    refreshBut.setForeground(new Color(20, 88, 49));
    refreshBut.addActionListener(this);
    backBut = new JButton(new ImageIcon(this.getClass().getResource("/images/backIcon.png")));
    backBut.setVisible(false);
    backBut.setToolTipText("Back");
    backBut.setForeground(new Color(20, 88, 49));
    backBut.addActionListener(this);
    deleteBut = new JButton(new ImageIcon(this.getClass().getResource("/images/trashIcon.png")));
    deleteBut.setToolTipText("Delete");
    deleteBut.setForeground(Color.red);
    deleteBut.setVisible(false);
    deleteBut.addActionListener(this);
    deleteBut.setBackground(Color.red);
    restoreBut = new JButton(new ImageIcon(this.getClass().getResource("/images/restoreIcon.png")));
    restoreBut.setToolTipText("Restore");
    restoreBut.setForeground(Color.blue);
    restoreBut.setVisible(false);
    restoreBut.addActionListener(this);
    toolBar.addSeparator(new Dimension(10, 5));
    toolBar.add(selectAllCB);
    toolBar.add(backBut);
    toolBar.add(refreshBut);
    toolBar.add(deleteBut);
    toolBar.add(restoreBut);
    add(toolBar, "North");
    JPanel centPan = new JPanel(new GridBagLayout());
    centPan.setBackground(new Color(52, 86, 70));
    JLabel label = new JLabel("Select A Category From Left Pane");
    label.setFont(new Font("arial", Font.BOLD, 35));
    label.setForeground(Color.yellow);
    centPan.add(label);
    contentPan = new JScrollPane(centPan);
    contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    add(contentPan, "Center");
    contentPan.repaint();

    db = new Database();
    //        inboxSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id
    // desc");
    //        sentmailSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id
    // desc");
    //        draftSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id
    // desc");
    //        outboxSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id
    // desc");
    //        trashSet = db.getData("SELECT * FROM messages,trash WHERE messages.tag='trash' and
    // messages.msg_id=trash.msg_id ORDER BY deleted_at desc");

  }
예제 #9
0
  public void initialize(final Controller controller) {
    super.initialize(controller);

    WWMenu fileMenu = (WWMenu) this.getController().getRegisteredObject(Constants.FILE_MENU);
    if (fileMenu != null) fileMenu.addMenu(this.getFeatureID());

    this.tabbedPane = new JTabbedPane();
    this.tabbedPane.setOpaque(false);

    this.tabbedPane.add(new JPanel());
    this.tabbedPane.setTitleAt(0, "+"); // this tab is just a button for adding servers/panels
    this.tabbedPane.setToolTipTextAt(0, "Connect to WMS Server");

    this.tabbedPane.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent changeEvent) {
            if (tabbedPane.getSelectedIndex() == 0) {
              addNewPanel(tabbedPane); // Add new panel when '+' is selected
            }
          }
        });

    // Add an initial panel to the tabbed pane
    this.addNewPanel(this.tabbedPane);
    tabbedPane.setSelectedIndex(1);

    this.setTaskComponent(this.tabbedPane);
    this.setLocation(SwingConstants.CENTER, SwingConstants.CENTER);
    this.getJDialog().setResizable(true);

    JButton deleteButton =
        new JButton(ImageLibrary.getIcon("gov/nasa/worldwindow/images/delete-20x20.png"));
    deleteButton.setToolTipText("Remove Server");
    deleteButton.setOpaque(false);
    deleteButton.setBackground(new Color(0, 0, 0, 0));
    deleteButton.setBorderPainted(false);
    deleteButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            deleteCurrentPanel();
          }
        });
    deleteButton.setEnabled(true);
    this.insertLeftDialogComponent(deleteButton);
    //
    //        JButton cancelButton = new JButton("Cancel");
    //        cancelButton.setToolTipText("Cancel capabilities retrieval from server");
    //        cancelButton.setOpaque(false);
    //        cancelButton.addActionListener(new ActionListener()
    //        {
    //            public void actionPerformed(ActionEvent actionEvent)
    //            {
    //                cancelCurrentRetrieval();
    //            }
    //        });
    //        this.insertRightDialogComponent(cancelButton);

    this.setTitle("WMS Servers");
    this.dialog.validate();
    this.dialog.pack();
  }
예제 #10
0
 public void mouseEntered(MouseEvent e) {
   JButton jbutton = (JButton) e.getSource();
   jbutton.setBackground(moveButtonColor);
 }
예제 #11
0
    private void flushWeekAndDayPanal(Calendar c) {
      //            c.set
      c.set(Calendar.DAY_OF_MONTH, 1);
      c.setFirstDayOfWeek(0);
      int firstdayofWeek = c.get(Calendar.DAY_OF_WEEK);
      int lastdayofWeek = c.getActualMaximum(Calendar.DAY_OF_MONTH);
      String colname[] = {"日", "一", "二", "三", "四", "五", "六"};
      int today = getNowCalendar().get(Calendar.DAY_OF_MONTH);
      // 璁剧疆鍥哄畾瀛椾綋锛屼互鍏嶈皟鐢ㄧ幆澧冩敼鍙樺奖鍝嶇晫闈㈢編瑙�
      dayPanel.setFont(new java.awt.Font("寰蒋闆呴粦", java.awt.Font.PLAIN, 12));
      dayPanel.setLayout(new GridBagLayout());
      dayPanel.setBackground(palletTableColor);

      JLabel cell;

      for (int i = 0; i < 7; i++) {
        cell = new JLabel(colname[i]);
        cell.setHorizontalAlignment(JLabel.CENTER);
        cell.setPreferredSize(new Dimension(25, 25));
        if (i == 0 || i == 6) {
          cell.setForeground(weekendFontColor);
        } else {
          cell.setForeground(weekFontColor);
        }
        dayPanel.add(
            cell,
            new GridBagConstraints(
                i,
                0,
                1,
                1,
                0.0,
                0.0,
                GridBagConstraints.CENTER,
                GridBagConstraints.NONE,
                new Insets(0, 0, 0, 0),
                0,
                0));
      }

      int actionCommandId = 1;
      for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 7; j++) {

          JButton numberButton = daysButton[i][j];
          actionCommandId = Integer.parseInt(numberButton.getActionCommand());
          if (actionCommandId == today) {
            numberButton.setBackground(todayBtnColor);
          }
          if ((actionCommandId + firstdayofWeek - 2) % 7 == 6
              || (actionCommandId + firstdayofWeek - 2) % 7 == 0) {
            numberButton.setForeground(weekendFontColor);
          } else {
            numberButton.setForeground(dateFontColor);
          }
          if (actionCommandId <= lastdayofWeek) {
            int y = 0;
            if ((firstdayofWeek - 1) <= (j + firstdayofWeek - 1) % 7) {
              y = i + 1;
            } else {
              y = i + 2;
            }
            dayPanel.add(
                numberButton,
                new GridBagConstraints(
                    (j + firstdayofWeek - 1) % 7,
                    y,
                    1,
                    1,
                    0.0,
                    0.0,
                    GridBagConstraints.CENTER,
                    GridBagConstraints.NONE,
                    new Insets(0, 0, 0, 0),
                    0,
                    0));
          }
        }
      }
    }
예제 #12
0
  Intern_Chat() {

    frame = new JFrame("Guide ME");
    frame.setSize(480, 550);
    frame.setResizable(false);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setBackground(new Color(211, 211, 211));
    frame.getContentPane().setLayout(null);

    // getContentPane().addMouseListener(new action2());
    JLabel lblGuideMe = new JLabel("Guide ME");
    lblGuideMe.setFont(new Font("Tahoma", Font.BOLD, 16));
    lblGuideMe.setBounds(10, 11, 85, 21);
    frame.getContentPane().add(lblGuideMe);

    textField = new JTextField();
    textField.setBounds(105, 11, 135, 21);
    frame.getContentPane().add(textField);
    textField.setColumns(10);

    ImageIcon search = new ImageIcon("list.PNG");
    btnNewButton = new JButton(search);
    btnNewButton.addActionListener(new Intern_Chat_action());
    btnNewButton.setBackground(new Color(255, 255, 255));
    btnNewButton.setFont(new Font("Tahoma", Font.BOLD, 11));
    btnNewButton.setBounds(240, 11, 20, 21);
    frame.getContentPane().add(btnNewButton);

    btnNewButton_1 = new JButton("Home");
    btnNewButton_1.addActionListener(new Intern_Chat_action());
    btnNewButton_1.setForeground(new Color(0, 0, 0));
    btnNewButton_1.setBackground(new Color(65, 105, 225));
    btnNewButton_1.setBounds(265, 12, 78, 21);
    frame.getContentPane().add(btnNewButton_1);

    ImageIcon list = new ImageIcon("Capture.PNG");
    btnNewButton_2 = new JButton(list);
    btnNewButton_2.setBounds(350, 11, 22, 23);
    btnNewButton_2.setForeground(new Color(0, 0, 0));
    btnNewButton_2.setBackground(new Color(65, 105, 225));
    frame.getContentPane().add(btnNewButton_2);
    btnNewButton_2.addActionListener(new Intern_Chat_action());

    btnNewButton_3 = new JButton(list);
    btnNewButton_3.addActionListener(new Intern_Chat_action());
    btnNewButton_3.setBounds(380, 11, 22, 23);
    frame.getContentPane().add(btnNewButton_3);

    String content[] = {
      "Friends",
      "Places",
      "Brands",
      "Notifications",
      "Tastes",
      "Rates",
      "Message",
      "settings",
      "Log out"
    };

    // for view frinds and palces and brands
    lists = new JList(content);
    lists.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lists.setBackground(new Color(65, 105, 225));
    frame.getContentPane().add(lists);
    lists.setBounds(295, 35, 74, 171);
    lists.hide();

    String content2[] = {
      "Chick In",
      "Add Friend",
      "Add Place",
      "Add Brand",
      "Give Rate",
      "Remove Friend",
      "Remove Brand",
      "Remove Place",
      "chat"
    };
    lists1 = new JList(content2);
    lists1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lists1.setBackground(new Color(65, 105, 225));
    frame.getContentPane().add(lists1);
    lists1.setBounds(379, 35, 95, 171);
    lists1.hide();

    lists.addListSelectionListener(new Intern_Chat_action());
    lists1.addListSelectionListener(new Intern_Chat_action());

    JPanel panel_1 = new JPanel();
    panel_1.setBackground(new Color(0, 191, 255));
    panel_1.setBounds(0, 0, 560, 50);
    frame.getContentPane().add(panel_1);

    panel = new JPanel();
    panel.setBounds(0, 101, 185, 418);
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    JScrollPane scr1 = new JScrollPane(panel);
    scr1.setBounds(0, 101, 185, 418);
    JLabel Users[] = new JLabel[20];
    JLabel message[] = new JLabel[20];
    for (int i = 0; i < 20; i++) {
      if (i % 2 == 0) {
        Users[i] = new JLabel("12:52 : alaa");
        message[i] = new JLabel("how are you bitch ?");
      } else {
        Users[i] = new JLabel("12:52: You");
        message[i] = new JLabel("f**k you");
      }
      panel.add(Users[i]);
      panel.add(message[i]);
    }
    frame.getContentPane().add(scr1);

    lblChat = new JLabel("Chat");
    lblChat.setFont(new Font("Tahoma", Font.BOLD, 14));
    lblChat.setBounds(23, 61, 72, 29);
    frame.getContentPane().add(lblChat);

    textArea = new JTextArea();
    textArea.setBounds(230, 120, 173, 69);
    JScrollPane scr = new JScrollPane(textArea);
    scr.setBounds(230, 120, 173, 69);
    frame.getContentPane().add(scr);

    JButton btnSend = new JButton("Send");
    btnSend.setFont(new Font("Tahoma", Font.BOLD, 14));
    btnSend.setBounds(264, 197, 78, 23);
    frame.getContentPane().add(btnSend);
  }
예제 #13
0
  public void init() {

    areaventana = new JPanel();
    areabotones = new JPanel();
    imagen = new JLabel("");
    presentacion = new JButton(imgPlay);
    siguiente = new JButton(imgSiguiente);
    atras = new JButton(imgAnterior);
    ptiempo = new JSlider();
    carpeta = new JButton(imgNuevaCarpeta);
    grid = new JButton(imgGrid);
    bcomentario = new JButton(imgComentario);
    zoom = new JButton(imgZoom);

    /* Agregando los componentes */

    areaventana.add(imagen);
    // areaventana.add(desplazamiento);

    areabotones.add(grid);
    areabotones.add(atras);
    areabotones.add(presentacion);
    areabotones.add(siguiente);
    areabotones.add(ptiempo);
    areabotones.add(carpeta);
    areabotones.add(bcomentario);
    areabotones.add(zoom);

    areabotones.setBackground(colorGris);
    areaventana.setBackground(colorGris);

    // desplazamiento.setVisible(false);
    // areaventana.add(desplazamiento);

    /* GUI GUI GUI GUI  */
    presentacion.setBackground(colorGris);
    atras.setBackground(colorGris);
    siguiente.setBackground(colorGris);
    carpeta.setBackground(colorGris);
    grid.setBackground(colorGris);
    ptiempo.setBackground(colorGris);
    bcomentario.setBackground(colorGris);
    zoom.setBackground(colorGris);

    presentacion.setPreferredSize(new Dimension(100, 80));
    atras.setPreferredSize(new Dimension(100, 80));
    siguiente.setPreferredSize(new Dimension(100, 80));
    carpeta.setPreferredSize(new Dimension(100, 80));
    grid.setPreferredSize(new Dimension(100, 80));
    bcomentario.setPreferredSize(new Dimension(100, 80));
    zoom.setPreferredSize(new Dimension(100, 80));

    grid.setFocusPainted(false);
    atras.setFocusPainted(false);
    siguiente.setFocusPainted(false);
    carpeta.setFocusPainted(false);
    presentacion.setFocusPainted(false);
    bcomentario.setFocusPainted(false);
    zoom.setFocusPainted(false);

    grid.setBorder(null);
    atras.setBorder(null);
    siguiente.setBorder(null);
    carpeta.setBorder(null);
    presentacion.setBorder(null);
    areabotones.setBorder(null);
    areaventana.setBorder(null);
    bcomentario.setBorder(null);
    zoom.setBorder(null);
    /* GUI GUI GUI GUI  */

    /* Action Listeners */
    siguiente.addActionListener(this);
    atras.addActionListener(this);
    presentacion.addActionListener(this);
    carpeta.addActionListener(this);
    grid.addActionListener(this);
    bcomentario.addActionListener(this);
    zoom.addActionListener(this);

    this.setLayout(new BorderLayout());
    add(areaventana, BorderLayout.CENTER);
    add(areabotones, BorderLayout.SOUTH);

    ptiempo.setVisible(false);

    siguiente.setEnabled(false);
    atras.setEnabled(false);
    presentacion.setEnabled(false);
    grid.setEnabled(false);
    bcomentario.setEnabled(false);
    zoom.setEnabled(false);

    /* Abre el selector desde que inicia el programa */

    chooser = new JFileChooser();
    chooser.setDialogTitle("Selecciona una imagen...");
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setAcceptAllFileFilterUsed(false);

    // Abrir archivo es de acá...
    returnChooser = chooser.showOpenDialog(ArcViewer.this);

    if (returnChooser == 0) {

      imagenes = lista.Miranda(chooser, returnChooser);

      siguiente.setEnabled(true);
      atras.setEnabled(true);
      presentacion.setEnabled(true);
      grid.setEnabled(true);
      bcomentario.setEnabled(true);
      zoom.setEnabled(true);

      for (int asd1 = 0; asd1 < imagenes.size(); asd1++) {
        imagenesbean.add(new ImagenBean(imagenes.get(asd1), 0, 0));
      }

      String getImgSelected = chooser.getSelectedFile().getPath();

      for (int index = 0; index < imagenesbean.size(); index++) {
        if (getImgSelected.equals(imagenesbean.get(index).getIcon())) {
          imagen.setIcon(new ImageIcon(imagenesbean.get(index).getIcon()));
          indexaux = index;
        }
      }
    } else {
      System.out.println("No Selection");
      carpeta.setEnabled(true);
    }

    // for (int asd1=0; asd1 < imagenes.size(); asd1++) {
    // 	imagenesbean.add(new ImagenBean(imagenes.get(asd1),0,0));
    // }
    // String getImgSelected = chooser.getSelectedFile().getPath();
    // for (int index=0; index < imagenesbean.size(); index++) {
    // 	if (getImgSelected.equals( imagenesbean.get(index).getIcon() )) {
    // 		imagen.setIcon(new ImageIcon(imagenesbean.get(index).getIcon()));
    // 		indexaux = index;
    // 	}
    // }

  }
예제 #14
0
  editprof(String str, String user) {
    cp = getContentPane();
    cp.setLayout(null);
    user1 = user;
    try {

      UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

    } catch (Exception e) {
    }

    JTextField ft = new JTextField();
    name1 = new JLabel("First Name");
    try {
      r = new FileReader(user + "/First name.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    name = new JTextField();
    name.setText(ft.getText());

    last1 = new JLabel("Enter Last Name");
    try {
      r = new FileReader(user + "/last name.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    last = new JTextField();
    last.setText(ft.getText());

    pass = new JLabel("Password");
    try {
      r = new FileReader(user + "/password.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    pwd = new JPasswordField();
    pwd.setText(ft.getText());
    pwd.setEditable(false);

    email1 = new JLabel("Enter email address");
    try {
      r = new FileReader(user + "/email.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    email = new JTextField();
    email.setText(ft.getText());

    addimage = new JButton("Add Image");
    icon = new JLabel();

    date1 = new JLabel("Date Of Birth");
    date = new JComboBox();
    for (int i = 1; i <= 31; i++) {
      date.addItem(i);
    }

    month = new JComboBox();
    month.addItem("Jan");
    month.addItem("Feb");
    month.addItem("Mar");
    month.addItem("Apr");
    month.addItem("May");
    month.addItem("Jun");
    month.addItem("Jul");
    month.addItem("Aug");
    month.addItem("Sep");
    month.addItem("Oct");
    month.addItem("Nov");
    month.addItem("Dec");

    year = new JComboBox();
    for (int j = 1900; j <= 2010; j++) {
      year.addItem(j);
    }

    sx = new JLabel("Gender");
    gen = new JComboBox();
    gen.addItem("Male");
    gen.addItem("Female");

    con1 = new JLabel("Country Name");
    con = new JComboBox();
    con.addItem(" Austrelia");
    con.addItem(" America");
    con.addItem(" Antartica");
    con.addItem(" Africa");
    con.addItem(" Canda");
    con.addItem(" Corea");
    con.addItem(" Chaina");
    con.addItem(" Denmark");
    con.addItem(" England");
    con.addItem(" Franc");
    con.addItem(" Hangery");
    con.addItem(" Holand");
    con.addItem(" Itali");
    con.addItem(" India");
    con.addItem(" Indonesia");
    con.addItem(" Jermany");
    con.addItem(" Japan");
    con.addItem(" Korea");
    con.addItem(" Kembridge");
    con.addItem(" Merusalem");
    con.addItem(" Noth America");
    con.addItem(" Norvey");
    con.addItem(" West Indies");
    con.addItem(" Peru");
    con.addItem(" Zimbawe");

    about = new JLabel("About me");
    try {
      r = new FileReader(user + "/about.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;
    int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;

    main = new JTextArea();
    main.setText(ft.getText());

    JScrollPane jsp = new JScrollPane(main, v, h);

    allow = new JLabel("Allow To:");
    JCheckBox c1 = new JCheckBox(" orkut Friends");
    JCheckBox c2 = new JCheckBox("Collage Friends");
    JCheckBox c3 = new JCheckBox("Business Partner");
    JCheckBox c4 = new JCheckBox("Relatives");

    col = new JLabel("Collage Name:");
    try {
      r = new FileReader(user + "/Collage.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    col1 = new JTextField();
    col1.setText(ft.getText());
    try {
      r = new FileReader(user + "/UniverSity.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    uni = new JLabel("Univercity");
    uni1 = new JTextField();
    uni1.setText(ft.getText());

    state1 = new JLabel("State Name");
    try {
      r = new FileReader(user + "/state.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    state = new JTextField();
    state.setText(ft.getText());

    city = new JLabel("City");
    try {
      r = new FileReader(user + "/City.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    city1 = new JTextField();
    city1.setText(ft.getText());

    try {
      r = new FileReader(user + "/imagepath.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    ImageIcon io = new ImageIcon(ft.getText());
    icon.setIcon(io);

    next = new JButton("Update");
    next.setBackground(Color.white);
    // adding to container

    name1.setBounds(10, 10, 130, 25);
    name.setBounds(150, 10, 130, 25);

    last1.setBounds(10, 40, 130, 25);
    last.setBounds(150, 40, 130, 25);

    email1.setBounds(10, 70, 130, 25);
    email.setBounds(150, 70, 130, 25);

    pass.setBounds(290, 70, 130, 25);
    pwd.setBounds(390, 70, 130, 25);

    addimage.setBounds(350, 440, 100, 25);
    icon.setBounds(490, 410, 100, 100);

    date1.setBounds(10, 100, 130, 25);
    date.setBounds(120, 100, 40, 25);
    month.setBounds(180, 100, 130, 25);
    year.setBounds(320, 100, 130, 25);

    sx.setBounds(10, 140, 130, 25);
    gen.setBounds(150, 140, 130, 25);

    about.setBounds(10, 180, 130, 25);
    jsp.setBounds(150, 180, 250, 80);

    allow.setBounds(10, 260, 130, 25);
    c1.setBounds(150, 260, 130, 25);
    c2.setBounds(290, 260, 130, 25);

    c3.setBounds(150, 290, 130, 25);
    c4.setBounds(290, 290, 130, 25);

    uni.setBounds(10, 330, 130, 25);
    uni1.setBounds(150, 330, 130, 25);
    col.setBounds(10, 360, 130, 25);
    col1.setBounds(150, 360, 130, 25);

    con1.setBounds(10, 390, 130, 25);
    con.setBounds(150, 390, 130, 25);

    state1.setBounds(10, 430, 130, 25);
    state.setBounds(150, 430, 130, 25);

    city.setBounds(10, 460, 130, 25);
    city1.setBounds(150, 460, 130, 25);

    next.setBounds(50, 490, 130, 25);

    cp.add(name);
    cp.add(name1);
    cp.add(last);
    cp.add(last1);
    cp.add(email);
    cp.add(email1);
    cp.add(addimage);
    cp.add(icon);
    cp.add(date1);
    cp.add(date);
    cp.add(month);
    cp.add(year);
    cp.add(about);
    cp.add(jsp);
    cp.add(sx);
    cp.add(gen);
    cp.add(allow);
    cp.add(c1);
    cp.add(c2);
    cp.add(c3);
    cp.add(c4);
    cp.add(next);
    cp.add(uni);
    cp.add(uni1);
    cp.add(col);
    cp.add(col1);
    cp.add(con);
    cp.add(con1);
    cp.add(state1);
    cp.add(state);
    cp.add(city);
    cp.add(city1);
    cp.add(next);
    cp.add(pwd);
    cp.add(pass);

    addimage.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            filepath = name.getText();
            JFileChooser chooser = new JFileChooser();

            while (true) {
              int val = chooser.showOpenDialog(editprof.this);
              File f = chooser.getSelectedFile();
              String path = f.getPath();
              String name = f.getName();

              try {

                if (val == JFileChooser.CANCEL_OPTION || val == -1) {
                  break;
                } else {
                  image = new ImageIcon(path);
                  icon.setIcon(image);
                  w = new FileWriter(filepath + "/" + "imagePath.txt");
                  w.write(path + "");
                  w.close();
                  break;
                }
              } catch (Exception se) {
              }
            }
          }
        });

    date.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            int str = (Integer) e.getItem();
            File f = new File(name.getText());
            f.mkdir();
            try {
              w = new FileWriter(name.getText() + "/" + "date.txt");
              w.write(str + "");
              w.close();
            } catch (IOException de) {
            }
          }
        });

    month.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e1) {
            String str = (String) e1.getItem();
            File f = new File(name.getText());
            f.mkdir();
            try {
              w = new FileWriter(name.getText() + "/" + "month.txt");
              w.write(str + "");
              w.close();
            } catch (IOException de) {
            }
          }
        });
    con.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e2) {
            String str = (String) e2.getItem();
            File f = new File(name.getText());
            f.mkdir();
            try {
              w = new FileWriter(name.getText() + "/" + "contry.txt");
              w.write(str + "");
              w.close();
            } catch (IOException de) {
            }
          }
        });
    year.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e2) {
            int str = (Integer) e2.getItem();
            File f = new File(name.getText());
            f.mkdir();
            try {
              w = new FileWriter(name.getText() + "/" + "year.txt");
              w.write(str + "");
              w.close();
            } catch (IOException de) {
            }
          }
        });
    gen.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e3) {
            String str = (String) e3.getItem();
            File f = new File(name.getText());
            f.mkdir();
            try {
              w = new FileWriter(name.getText() + "/" + "gender.txt");
              w.write(str + "");
              w.close();
            } catch (IOException de) {
            }
          }
        });

    next.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent se) {
            try {

              w = new FileWriter(name.getText() + "/" + "First name.txt");
              w.write(name.getText());
              w.close();

              w = new FileWriter(name.getText() + "/" + "last name.txt");
              w.write(last.getText());
              w.close();

              w = new FileWriter(name.getText() + "/" + "email.txt");
              w.write(email.getText());
              w.close();

              w = new FileWriter(name.getText() + "/" + "Collage.txt");
              w.write(col1.getText());
              w.close();

              w = new FileWriter(name.getText() + "/" + "UniverSity.txt");
              w.write(uni1.getText());
              w.close();

              w = new FileWriter(name.getText() + "/" + "state.txt");
              w.write(state.getText());
              w.close();

              w = new FileWriter(name.getText() + "/" + "City.txt");
              w.write(city1.getText());
              w.close();

              w = new FileWriter(name.getText() + "/" + "about.txt");
              w.write(main.getText());
              w.close();

              w = new FileWriter(name.getText() + "/" + "password.txt");
              w.write(pwd.getText());
              w.close();

              profile e1 = new profile("My Profile", user1);
              e1.setVisible(true);
              e1.setLocation(00, 00);
              e1.setSize(800, 800);
              setVisible(false);
            } catch (Exception be) {
            }
          }
        });
  }