示例#1
0
 public void actionPerformed(ActionEvent ae) {
   if (ae.getActionCommand() == "timer") {
     if (counter >= imagePaths.length) {
       timer.stop();
       counter = 0;
       PlayStopButton.setText("Play");
     } else {
       try {
         // if the array contains URLs
         if (imagePaths[counter].contains("http://")) {
           scrollPane.setToolTipText(imagePaths[counter]);
           imageIcon = new ImageIcon((new URL(imagePaths[counter++])));
           scrollPane.setViewportView(new JLabel(imageIcon));
         }
         // if the array contains local images
         else {
           image.setIcon(new ImageIcon(imagePaths[counter]));
           image.setToolTipText(imagePaths[counter++]);
         }
       } catch (MalformedURLException ex) {
         Logger.getLogger(Slideshow.class.getName()).log(Level.SEVERE, null, ex);
         image = new JLabel("?" + imagePaths);
       }
     }
   }
 }
  public static void main(String[] args) {
    final JPopupMenu menu = new JPopupMenu();
    menu.setLayout(new GridLayout(0, 3, 5, 5));

    final MenuedButton button = new MenuedButton("Icons", menu);

    for (int i = 0; i < 9; i++) {
      // replace "print.gif" with your own image
      final JLabel label = new JLabel("" + i); // new ImageIcon("resources/images/print.gif") );
      label.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              button.getMainButton().setIcon(label.getIcon());
              menu.setVisible(false);
            }
          });
      menu.add(label);
    }

    JFrame frame = new JFrame("Button Test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(new JLabel("Click Arrow Button To Show Popup"), BorderLayout.NORTH);
    frame.getContentPane().add(button, BorderLayout.CENTER);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
示例#3
0
 public void ShowChessNumber() // 显示黑子白子数目
     {
   white = 0;
   black = 0;
   Count();
   blackNumberLabel.setText("黑子数:" + black + "		");
   whiteNumberLabel.setText("白子数:" + white + "		");
 }
 @Override
 public void paintComponent(Graphics g) {
   if (selected) {
     g.setColor(selColor);
     g.fillRoundRect(0, 0, getWidth(), getHeight(), getWidth() / 10, getHeight() / 10);
     label.setForeground(Color.YELLOW);
   } else label.setForeground(Color.WHITE);
   super.paintComponent(g);
 }
示例#5
0
 public void setVisible(boolean bShow, String title) {
   if (bShow) {
     String strDir = "";
     String strFreq = "";
     String strTraynum = "";
     m_strHelpFile = getHelpFile(title);
     String strSampleName = getSampleName(title);
     String frameBounds = getFrameBounds(title);
     StringTokenizer tok = new QuotedStringTokenizer(title);
     if (tok.hasMoreTokens()) strDir = tok.nextToken();
     if (tok.hasMoreTokens()) strFreq = tok.nextToken();
     if (tok.hasMoreTokens()) strTraynum = tok.nextToken();
     else {
       try {
         Integer.parseInt(strDir);
         // if strdir is number, then strdir is empty, and the
         // strfreq is the number
         strTraynum = strFreq;
         strFreq = strDir;
         strDir = "";
       } catch (Exception e) {
       }
     }
     try {
       setTitle(gettitle(strFreq));
       m_lblSampleName.setText("3");
       boolean bVast = isVast(strTraynum);
       CardLayout layout = (CardLayout) m_pnlSampleName.getLayout();
       if (!bVast) {
         if (strSampleName == null) {
           strSampleName = getSampleName(strDir, strTraynum);
         }
         m_lblSampleName.setText(strSampleName);
         layout.show(m_pnlSampleName, OTHER);
       } else {
         m_strDir = strDir;
         setTrays();
         layout.show(m_pnlSampleName, VAST);
         m_trayTimer.start();
       }
       boolean bSample = bVast || !strSampleName.trim().equals("");
       m_pnlSampleName.setVisible(bSample);
       m_lblLogin.setForeground(getBackground());
       m_lblLogin.setVisible(false);
       m_passwordField.setText("");
       m_passwordField.setCaretPosition(0);
     } catch (Exception e) {
       Messages.writeStackTrace(e);
     }
     setBounds(frameBounds);
     ExpPanel exp = Util.getActiveView();
     if (exp != null) exp.waitLogin(true);
   }
   writePersistence();
   setVisible(bShow);
 }
    public SidebarOption(String labelTxt, String rsc) {
      label = new JLabel(labelTxt);
      label.setForeground(Color.WHITE);
      label.setFont(font);
      add(label);
      setOpaque(false);
      setMaximumSize(new Dimension(1000, label.getPreferredSize().height + 5));

      this.rsc = ClassLoader.getSystemClassLoader().getResource(rsc);
    }
示例#7
0
 void addTextField(JPanel panel, String key, String label) {
   JLabel lab = new JLabel(label);
   lab.setAlignmentX(LEFT_ALIGNMENT);
   panel.add(lab);
   JTextField field = new JTextField();
   field.setText(sketch.configFile.get(key));
   field.setMaximumSize(new Dimension(Integer.MAX_VALUE, field.getPreferredSize().height));
   fields.put(key, field);
   panel.add(field);
 }
示例#8
0
 /**
  * Implementing the Observer interface. Receiving the response from the Pdu.
  *
  * @param obs the UpSincePdu variable
  * @param ov the date
  * @see uk.co.westhawk.snmp.pdu.UpSincePdu
  */
 public void update(Observable obs, Object ov) {
   Pdu pdu = (Pdu) obs;
   if (pdu.getErrorStatus() == AsnObject.SNMP_ERR_NOERROR) {
     Date dres = (Date) ov;
     if (dres != null) {
       // TODO: invokeLater
       v.setText(dres.toString());
     }
   } else {
     // TODO: invokeLater
     v.setText(pdu.getErrorStatusString());
   }
 }
示例#9
0
 void addTextArea(JPanel panel, String key, String label) {
   JLabel lab = new JLabel(label);
   lab.setAlignmentX(LEFT_ALIGNMENT);
   panel.add(lab);
   JTextArea field = new JTextArea();
   field.setText(sketch.configFile.get(key));
   field.setLineWrap(true);
   field.setWrapStyleWord(true);
   fields.put(key, field);
   JScrollPane scroll = new JScrollPane(field);
   scroll.setAlignmentX(0.0f);
   panel.add(scroll);
 }
示例#10
0
文件: About.java 项目: annsofi/kalken
  public About() {
    cl = ClassLoader.getSystemClassLoader();

    // ----------------------------------------CENTER--------------------------------//
    imgAbout = new ImageIcon(cl.getResource("om.png"));

    lblAbout = new JLabel(imgAbout);

    lblAbout.setBounds(0, 0, 450, 263);

    JPanel pnlCenter = new JPanel();
    pnlCenter.setLayout(null);
    pnlCenter.add(lblAbout);

    btnOk = new JButton(new ImageIcon(cl.getResource("ok.png")));
    btnOk.setBounds(390, 215, 40, 30);
    pnlCenter.add(btnOk);
    btnOk.addActionListener(this);

    // -----------------------------------CONTAINER----------------------------------//
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    c.add(pnlCenter, BorderLayout.CENTER);
    setSize(450, 280);
    setVisible(true);
    setResizable(false);
    setLocation(580, 280);
    // setDefaultCloseOperation(EXIT_ON_CLOSE);

  }
示例#11
0
  public Cliente(Socket s) {
    super("OPERACIONES CON BD");
    socket = s;
    try {
      salida = new DataOutputStream(socket.getOutputStream());
      inObjeto = new ObjectInputStream(socket.getInputStream());
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(0);
    }
    setLayout(null);
    etiqueta.setBounds(10, 10, 200, 30);
    add(etiqueta);
    empconsultar.setBounds(210, 10, 50, 30);
    add(empconsultar);

    textarea1 = new JTextArea();
    scrollpane1 = new JScrollPane(textarea1);
    scrollpane1.setBounds(10, 50, 400, 300);
    add(scrollpane1);
    boton.setBounds(420, 10, 100, 30);
    add(boton);
    desconectar.setBounds(420, 50, 100, 30);
    add(desconectar);

    textarea1.setEditable(false);
    boton.addActionListener(this);
    desconectar.addActionListener(this);
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  }
示例#12
0
  // Initialize all the GUI components and display the frame
  private static void initGUI() {
    // Set up the status bar
    statusField = new JLabel();
    statusField.setText(statusMessages[DISCONNECTED]);
    statusColor = new JTextField(1);
    statusColor.setBackground(Color.red);
    statusColor.setEditable(false);
    statusBar = new JPanel(new BorderLayout());
    statusBar.add(statusColor, BorderLayout.WEST);
    statusBar.add(statusField, BorderLayout.CENTER);

    // Set up the options pane
    JPanel optionsPane = initOptionsPane();

    // Set up the chat pane
    JPanel chatPane = new JPanel(new BorderLayout());
    chatText = new JTextArea(10, 20);
    chatText.setLineWrap(true);
    chatText.setEditable(false);
    chatText.setForeground(Color.blue);
    JScrollPane chatTextPane =
        new JScrollPane(
            chatText,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    chatLine = new JTextField();
    chatLine.setEnabled(false);
    chatLine.addActionListener(
        new ActionAdapter() {
          public void actionPerformed(ActionEvent e) {
            String s = chatLine.getText();
            if (!s.equals("")) {
              appendToChatBox("OUTGOING: " + s + "\n");
              chatLine.selectAll();

              // Send the string
              sendString(s);
            }
          }
        });
    chatPane.add(chatLine, BorderLayout.SOUTH);
    chatPane.add(chatTextPane, BorderLayout.CENTER);
    chatPane.setPreferredSize(new Dimension(200, 200));

    // Set up the main pane
    JPanel mainPane = new JPanel(new BorderLayout());
    mainPane.add(statusBar, BorderLayout.SOUTH);
    mainPane.add(optionsPane, BorderLayout.WEST);
    mainPane.add(chatPane, BorderLayout.CENTER);

    // Set up the main frame
    mainFrame = new JFrame("Simple TCP Chat");
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setContentPane(mainPane);
    mainFrame.setSize(mainFrame.getPreferredSize());
    mainFrame.setLocation(200, 200);
    mainFrame.pack();
    mainFrame.setVisible(true);
  }
示例#13
0
 public AnimatedToolTip(JLabel label) {
   super();
   this.iconlabel = label;
   LookAndFeel.installColorsAndFont(
       iconlabel, "ToolTip.background", "ToolTip.foreground", "ToolTip.font");
   iconlabel.setOpaque(true);
   setLayout(new BorderLayout());
   add(iconlabel);
 }
示例#14
0
  /**
   * Implementing the Observer interface. Receiving the response from the Pdu.
   *
   * @param obs the InterfacePdu variable
   * @param ov the varbind
   * @see uk.co.westhawk.snmp.pdu.InterfacePdu
   * @see uk.co.westhawk.snmp.stack.varbind
   */
  public void update(Observable obs, Object ov) {
    up = (InterfacePdu) obs;
    if (prev != null) {
      // TODO invokeLater
      v.setText(up.getSpeed(prev) + " bytes/sec ");
    }

    // keep the previous...
    prev = up;
  }
示例#15
0
  public ShowComp() throws InterruptedException, IOException {
    super("CONNECTED COMPUTERS");
    int x = 0, d = 20;
    mb = new JMenuBar();
    File = new JMenu("File");
    mb.add(File);
    exit = new JMenuItem("Exit");
    exit.addActionListener(this);
    File.add(exit);
    ta = new JTextArea();
    ta.setBounds(20, 30, 315, 470);
    ta.setEditable(false);
    add(ta);

    setJMenuBar(mb);

    sel = new JLabel("The connected computers are..");
    sel.setBounds(15, 5, 300, 30);
    add(sel);
    b1 = new JButton("<< BACK");
    b1.setBounds(140, 510, 100, 30);
    b1.setToolTipText("Back to main page");
    b1.addActionListener(this);
    add(b1);
    setLayout(null);
    while (x < 360) {
      x = x + d;
      setBounds(675, 50, x, 600);
      this.show();
    }
    // setVisible(true);
    String s = "192.168.0.", temp = null;
    Printer printer = new Printer();
    printer.start();
    Connector connector = new Connector(printer);
    connector.start();

    LinkedList targets = new LinkedList();
    for (int i = 1; i <= 255; i++) {
      temp = s + Integer.toString(i);
      Target t = new Target(temp);
      targets.add(t);
      connector.add(t);
    }
    Thread.sleep(2000);
    connector.shutdown();
    connector.join();

    for (Iterator i = targets.iterator(); i.hasNext(); ) {
      Target t = (Target) i.next();
      if (!t.shown) t.show();
    }

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  }
示例#16
0
  protected void setPref() {
    Color color = DisplayOptions.getColor("PlainText");
    Font font = DisplayOptions.getFont("PlainText");
    m_lblUsername.setForeground(color);
    m_lblUsername.setFont(font);
    m_lblPassword.setForeground(color);
    m_lblPassword.setFont(font);
    m_cmbUser.getEditor().getEditorComponent().setForeground(color);
    m_cmbUser.getEditor().getEditorComponent().setFont(font);
    m_passwordField.setForeground(color);
    m_passwordField.setFont(font);

    color = DisplayOptions.getColor("Heading3");
    font = DisplayOptions.getFont("Heading3");
    m_lblSampleName.setForeground(color);
    m_pnlTrays.setBorder(
        BorderDeli.createBorder("Empty", "Sample Trays", "Bottom", "Center", color, font));
    VBox.setforeground(color);
    VBox.setfont(font);
  }
 public void updateLanguage() {
   //////////////////////////////////////////////////////////////
   mdic = MonitorDictionary.getChildDictionary("ThreadManager");
   MonitorDictionary.applyButton(btnKick, "Kick");
   MonitorDictionary.applyButton(btnRefresh, "Refresh");
   MonitorDictionary.applyButton(btnSend, "Send");
   tblUser.setColumnNameEx(mdic.getString("LoginName"), 1);
   tblUser.setColumnNameEx(mdic.getString("LoginTime"), 2);
   tblUser.setColumnNameEx(mdic.getString("Host"), 3);
   //////////////////////////////////////////////////////////////
   MonitorDictionary.applyButton(mnuSelectAll, "jmenu.Edit.SelectAll");
   MonitorDictionary.applyButton(mnuClearAll, "jmenu.Edit.ClearAll");
   MonitorDictionary.applyButton(mnuClearSelected, "jmenu.Edit.ClearSelected");
   //////////////////////////////////////////////////////////////
   MonitorDictionary.applyButton(mnuSystem, "jmenu.System");
   MonitorDictionary.applyButton(mnuSystem_ChangePassword, "jmenu.System.ChangePassword");
   MonitorDictionary.applyButton(mnuSystem_StopServer, "jmenu.System.Shutdown");
   MonitorDictionary.applyButton(mnuSystem_EnableThreads, "jmenu.System.ThreadManager");
   MonitorDictionary.applyButton(mnuHelp, "jmenu.Help");
   MonitorDictionary.applyButton(mnuHelp_About, "jmenu.Help.About");
   //////////////////////////////////////////////////////////////
   MonitorDictionary.applyButton(mnuUI, "jmenu.UI");
   //////////////////////////////////////////////////////////////
   if (isOpen()) {
     lblStatus.setText(
         "  " + MonitorDictionary.getString("LoggedUser") + ": " + channel.getUserName());
     MonitorDictionary.applyButton(mnuSystem_Login, "jmenu.System.Logout");
     mnuSystem_ChangePassword.setEnabled(true);
     mnuSystem_StopServer.setEnabled(true);
     mnuSystem_EnableThreads.setEnabled(true);
   } else {
     lblStatus.setText("");
     MonitorDictionary.applyButton(mnuSystem_Login, "jmenu.System.Login");
     mnuSystem_ChangePassword.setEnabled(false);
     mnuSystem_StopServer.setEnabled(false);
     mnuSystem_EnableThreads.setEnabled(false);
   }
   //////////////////////////////////////////////////////////////
   for (int iIndex = 0; iIndex < pnlThread.getTabCount(); iIndex++)
     ((PanelThreadMonitor) pnlThread.getComponentAt(iIndex)).updateLanguage();
 }
示例#18
0
  // init
  private static void init() {
    if (frame != null) frame.setVisible(false);

    frame = new JFrame();
    offscreenImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    onscreenImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    offscreen = offscreenImage.createGraphics();
    onscreen = onscreenImage.createGraphics();
    setXscale();
    setYscale();
    offscreen.setColor(DEFAULT_CLEAR_COLOR);
    offscreen.fillRect(0, 0, width, height);
    setPenColor();
    setPenRadius();
    setFont();
    clear();

    // add anti-aliasing
    RenderingHints hints =
        new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    offscreen.addRenderingHints(hints);

    // frame stuff
    ImageIcon icon = new ImageIcon(onscreenImage);
    JLabel draw = new JLabel(icon);

    draw.addMouseListener(std);
    draw.addMouseMotionListener(std);

    frame.setContentPane(draw);
    frame.addKeyListener(std); // JLabel cannot get keyboard focus
    frame.setResizable(false);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // closes all windows
    // frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // closes only current window
    frame.setTitle("Standard Draw");
    frame.setJMenuBar(createMenuBar());
    frame.pack();
    frame.requestFocusInWindow();
    frame.setVisible(true);
  }
示例#19
0
 /**
  * Checks the passwords of the user
  *
  * @param e The ActionEvent for this action.
  */
 public void actionPerformed(ActionEvent e) {
   String cmd = e.getActionCommand();
   // checks if the user has a unix password, if it matches, then logs the user
   // in the interface, otherwise checks for the vnmrj password,
   // if neither password matches, then the user is not logged in the interface
   if (cmd.equalsIgnoreCase("enter")) enterLogin();
   else if (cmd.equalsIgnoreCase("cancel")) {
     m_passwordField.setText("");
     m_lblLogin.setForeground(getBackground());
     // setVisible(false);
   } else if (cmd.equalsIgnoreCase("help")) displayHelp();
 }
示例#20
0
  private void setUpGui() {
    area = JokemonDriver.Area.Stringville;
    mouse = new Point();
    int thingInt = 0;
    this.setTitle("Town Map");
    this.setSize(195, 239);
    this.setResizable(false);
    this.setLayout(null);
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    this.setVisible(false);
    visible = false;
    this.setLocationRelativeTo(null);
    Container cp = this.getContentPane();

    JLabel map = new JLabel();
    map.setBounds(1, -5, 188, 176);
    map.setIcon(new ImageIcon(townMap.class.getResource("Logos/townmap.png")));

    closeWindow = new JButton();
    closeWindow.setText("Close Window");
    closeWindow.setBounds(0, 192, 188, 20);

    areaDisplay = new JLabel();
    areaDisplay.setText(area.toString().replace('_', ' '));
    areaDisplay.setHorizontalAlignment(JLabel.CENTER);
    areaDisplay.setBounds(0, 171, 188, 20);

    addMouseMotionListener(this);
    closeWindow.addActionListener(this);
    cp.add(map);
    cp.add(closeWindow);
    cp.add(areaDisplay);
  }
示例#21
0
  public MainPanel() {
    super(new BorderLayout());
    l1.setToolTipText("Test1");
    l2.setToolTipText("Test2");
    l3.setToolTipText("<html><img src='" + url + "'>Test3</html>");

    JPanel p1 = new JPanel(new BorderLayout());
    p1.setBorder(BorderFactory.createTitledBorder("javax.swing.Timer"));
    p1.add(l1);
    JPanel p2 = new JPanel(new BorderLayout());
    p2.setBorder(BorderFactory.createTitledBorder("Animated Gif"));
    p2.add(l2, BorderLayout.NORTH);
    p2.add(l3, BorderLayout.SOUTH);

    Box box = Box.createVerticalBox();
    box.add(p1);
    box.add(Box.createVerticalStrut(20));
    box.add(p2);
    box.add(Box.createVerticalGlue());
    add(box);
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setPreferredSize(new Dimension(320, 240));
  }
示例#22
0
文件: Server.java 项目: w4-pwr/studia
  public void run() {
    Socket socket = null;
    try {
      host = InetAddress.getLocalHost().getHostAddress();
      l.setText("Adres servera : " + host);
      serverSocket = new ServerSocket(port);
      JOptionPane.showMessageDialog(null, "Serwer dzia³a na adresie " + host);
      while (true) {
        socket = serverSocket.accept();
        if (socket != null) {
          sList.add(new ServerThread(socket, clientList, this));
        }
      }
    } catch (Exception e) {

    }
  }
  // ------------------------
  // Handler for timer
  // ------------------------
  public void actionPerformed(ActionEvent e) {

    // if the current image nb is less than the length of the video
    if (imagenb < VIDEO_LENGTH) {
      // update current imagenb
      imagenb++;

      try {
        // get next frame to send from the video, as well as its size
        int image_length = video.getnextframe(buf);

        // Builds an RTPpacket object containing the frame
        RTPpacket rtp_packet =
            new RTPpacket(MJPEG_TYPE, imagenb, imagenb * FRAME_PERIOD, buf, image_length);

        // get to total length of the full rtp packet to send
        int packet_length = rtp_packet.getlength();

        // retrieve the packet bitstream and store it in an array of bytes
        byte[] packet_bits = new byte[packet_length];
        rtp_packet.getpacket(packet_bits);

        // send the packet as a DatagramPacket over the UDP socket
        senddp = new DatagramPacket(packet_bits, packet_length, ClientIPAddr, RTP_dest_port);
        RTPsocket.send(senddp);

        // System.out.println("Send frame #"+imagenb);
        // print the header bitstream
        rtp_packet.printheader();

        // update GUI
        label.setText("Send frame #" + imagenb);
      } catch (Exception ex) {
        System.out.println("Exception caught: " + ex);
        System.exit(0);
      }
    } else {
      // if we have reached the end of the video file, stop the timer
      timer.stop();
    }
  }
 /** Listener to handle table selection changes */
 public void valueChanged(ListSelectionEvent e) {
   int row = table.getSelectedRow();
   // Check if they selected a specific row
   if (row > 0) {
     remove_button.setEnabled(true);
   } else {
     remove_button.setEnabled(false);
   }
   // Check for "most recent" selection
   if (row == 0) {
     row = model.getRowCount() - 1;
     if (row == 0) {
       row = -1;
     }
   }
   if (row == -1) {
     // Clear the details panel
     details_time_value.setText("");
     details_target_value.setText("");
     details_status_value.setText("");
     request_text.setText("");
     response_text.setText("");
   } else {
     // Show the details for the row
     SOAPMonitorData soap = model.getData(row);
     details_time_value.setText(soap.getTime());
     details_target_value.setText(soap.getTargetService());
     details_status_value.setText(soap.getStatus());
     if (soap.getSOAPRequest() == null) {
       request_text.setText("");
     } else {
       request_text.setText(soap.getSOAPRequest());
       request_text.setCaretPosition(0);
     }
     if (soap.getSOAPResponse() == null) {
       response_text.setText("");
     } else {
       response_text.setText(soap.getSOAPResponse());
       response_text.setCaretPosition(0);
     }
   }
 }
示例#25
0
  public IUmenu(String host) {

    setTitle("GUUERRA_NAVAL");
    efectos = new Efectos();
    try {
      cliente = new Cliente(host);
    } catch (Exception ex) {
    }

    /* Titulo */
    titulo = new JLabel(" JHONMAN ");
    titulo.setForeground(Color.BLACK);
    titulo.setFont(new Font("Algerian", Font.BOLD, 24));
    titulo.setBounds(120, 40, 560, 40);
    titulo.setHorizontalAlignment(JLabel.CENTER);

    /* MeEnu de Opciones */
    mEnU = new JLabel("MENU DE OPCIONES");
    mEnU.setForeground(Color.BLACK);
    mEnU.setFont(new Font("Algerian", Font.BOLD, 24));
    mEnU.setBounds(40, 135, 390, 40);
    mEnU.setHorizontalAlignment(JLabel.LEFT);

    ImageIcon i = new ImageIcon("imagenes/apariencia/fondo_def.jpg");
    fondo = new JLabel(new ImageIcon(i.getImage().getScaledInstance(800, 600, Image.SCALE_SMOOTH)));
    fondo.setBounds(0, 0, 800, 600);

    ImageIcon i1 = new ImageIcon("imagenes/apariencia/botRegistrar.jpg");
    ImageIcon i2 = new ImageIcon("imagenes/apariencia/botPrincipiante.jpg");
    ImageIcon i3 = new ImageIcon("imagenes/apariencia/botDificil.jpg");
    ImageIcon i4 = new ImageIcon("imagenes/apariencia/botSalir.jpg");
    ImageIcon i5 = new ImageIcon("imagenes/apariencia/botRaking.jpg");
    ImageIcon i6 = new ImageIcon("imagenes/apariencia/brJuegoRed2.jpg");
    ImageIcon i11 = new ImageIcon("imagenes/apariencia/botRegistrar2.jpg");
    ImageIcon i22 = new ImageIcon("imagenes/apariencia/botPrincipiante2.jpg");
    ImageIcon i33 = new ImageIcon("imagenes/apariencia/botDificil2.jpg");
    ImageIcon i44 = new ImageIcon("imagenes/apariencia/botSalir2.jpg");
    ImageIcon i55 = new ImageIcon("imagenes/apariencia/botRaking2.jpg");
    ImageIcon i66 = new ImageIcon("imagenes/apariencia/brJuegoRed.jpg");

    /* Boton Puntajes */
    estad =
        new JButton(new ImageIcon(i5.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH)));
    estad.setBounds(98, 148, 170, 40);
    estad.setRolloverIcon(
        new ImageIcon(
            i55.getImage()
                .getScaledInstance(
                    170,
                    40,
                    Image
                        .SCALE_SMOOTH))); // cuando el mouse esta sobre el boton cambia a esta
                                          // imagen
    estad.setBorderPainted(false); // elimino los bordes de el boton
    estad.addActionListener(this);
    estad.setMnemonic(KeyEvent.VK_P);
    estad.setToolTipText("ver Raking ALT + P");

    /* Boton Registrar */
    registrar =
        new JButton(new ImageIcon(i1.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH)));
    registrar.setBounds(98, 205, 170, 40);
    registrar.setRolloverIcon(
        new ImageIcon(i11.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH)));
    registrar.setBorderPainted(false);
    registrar.addActionListener(this);
    registrar.setMnemonic(KeyEvent.VK_Q);
    registrar.setToolTipText("Registrarse ALT + Q");

    /* Boton TipoFacil */
    facil =
        new JButton(new ImageIcon(i2.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH)));
    facil.setBounds(97, 262, 170, 40);
    facil.setRolloverIcon(
        new ImageIcon(i22.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH)));
    facil.setBorderPainted(false);
    facil.addActionListener(this);
    facil.setMnemonic(KeyEvent.VK_F);
    facil.setToolTipText("jugar en modo principiante ALT + F");

    /* Boton TipoDificil */
    dific =
        new JButton(new ImageIcon(i3.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH)));
    dific.setBounds(97, 317, 170, 40);
    dific.setRolloverIcon(
        new ImageIcon(i33.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH)));
    dific.setBorderPainted(false);
    dific.addActionListener(this);
    dific.setMnemonic(KeyEvent.VK_D);
    dific.setToolTipText("jugar en modo dificil ALT + D");

    /* Boton Salir */
    salir =
        new JButton(new ImageIcon(i4.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH)));
    salir.setBounds(97, 430, 170, 40);
    salir.setRolloverIcon(
        new ImageIcon(i44.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH)));
    salir.setBorderPainted(false);
    salir.addActionListener(this);
    salir.setMnemonic(KeyEvent.VK_S);
    salir.setToolTipText("Salir ALT + S");

    /* Boton Red */
    red = new JButton(new ImageIcon(i6.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH)));
    red.setBounds(97, 374, 170, 40);
    red.setRolloverIcon(
        new ImageIcon(i66.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH)));
    red.setBorderPainted(false);
    red.addActionListener(this);
    red.setMnemonic(KeyEvent.VK_C);
    red.setToolTipText("Jugar con varios jugadores ALT + C");

    c = getContentPane();
    c.setLayout(null);

    c.add(titulo);
    c.add(estad);
    c.add(facil);
    c.add(registrar);
    c.add(dific);
    c.add(salir);
    c.add(red);
    c.add(fondo);
  }
示例#26
0
 @Override
 public String getTipText() {
   return Objects.nonNull(iconlabel) ? iconlabel.getText() : "";
 }
示例#27
0
  private void initComponents() {
    try {
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (Exception e) {
      // If Nimbus is not available, you can set the GUI to another look and feel.
    }

    usernameLabel = new JLabel();
    usernameField = new JTextField();
    chatroomScrollPane = new JScrollPane();
    chatroomArea = new JTextArea();
    chatMsgLabel = new JLabel();
    chatMsgField = new JTextField();
    chatIPLabel = new JLabel();
    chatIPField = new JTextField();
    portLabel = new JLabel();
    portField = new JTextField();
    joinButton = new JToggleButton();
    sendButton = new JButton();
    leaveButton = new JButton();
    exitButton = new JButton();

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    usernameLabel.setText("Username:"******" ");

    chatroomArea.setEditable(false);
    chatroomArea.setColumns(20);
    chatroomArea.setRows(5);
    chatroomScrollPane.setViewportView(chatroomArea);

    chatMsgLabel.setText("Chat Message:");

    chatIPLabel.setText("Chat Group IP");

    chatIPField.setText("224.27.43.188");

    portLabel.setText("Port");

    portField.setText("4001");

    joinButton.setText("JOIN CHAT");
    joinButton.addActionListener(this);

    sendButton.setText("SEND MESSAGE");
    sendButton.addActionListener(this);

    leaveButton.setText("LEAVE CHAT");
    leaveButton.addActionListener(this);

    exitButton.setText("EXIT");
    exitButton.addActionListener(this);

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addGroup(
                                GroupLayout.Alignment.TRAILING,
                                layout
                                    .createSequentialGroup()
                                    .addGap(0, 0, Short.MAX_VALUE)
                                    .addComponent(usernameLabel)
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(
                                        usernameField,
                                        GroupLayout.PREFERRED_SIZE,
                                        83,
                                        GroupLayout.PREFERRED_SIZE))
                            .addComponent(chatroomScrollPane)
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addGroup(
                                        layout
                                            .createParallelGroup(GroupLayout.Alignment.LEADING)
                                            .addGroup(
                                                layout
                                                    .createSequentialGroup()
                                                    .addComponent(chatMsgLabel)
                                                    .addPreferredGap(
                                                        LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(
                                                        chatMsgField,
                                                        GroupLayout.PREFERRED_SIZE,
                                                        296,
                                                        GroupLayout.PREFERRED_SIZE))
                                            .addGroup(
                                                layout
                                                    .createSequentialGroup()
                                                    .addGroup(
                                                        layout
                                                            .createParallelGroup(
                                                                GroupLayout.Alignment.TRAILING,
                                                                false)
                                                            .addComponent(
                                                                chatIPField,
                                                                GroupLayout.Alignment.LEADING)
                                                            .addComponent(
                                                                chatIPLabel,
                                                                GroupLayout.Alignment.LEADING,
                                                                GroupLayout.DEFAULT_SIZE,
                                                                GroupLayout.DEFAULT_SIZE,
                                                                Short.MAX_VALUE))
                                                    .addGap(18, 18, 18)
                                                    .addGroup(
                                                        layout
                                                            .createParallelGroup(
                                                                GroupLayout.Alignment.LEADING,
                                                                false)
                                                            .addComponent(
                                                                portField,
                                                                GroupLayout.DEFAULT_SIZE,
                                                                46,
                                                                Short.MAX_VALUE)
                                                            .addComponent(
                                                                portLabel,
                                                                GroupLayout.DEFAULT_SIZE,
                                                                GroupLayout.DEFAULT_SIZE,
                                                                Short.MAX_VALUE))
                                                    .addGap(18, 18, 18)
                                                    .addGroup(
                                                        layout
                                                            .createParallelGroup(
                                                                GroupLayout.Alignment.LEADING,
                                                                false)
                                                            .addGroup(
                                                                layout
                                                                    .createSequentialGroup()
                                                                    .addComponent(leaveButton)
                                                                    .addGap(18, 18, 18)
                                                                    .addComponent(
                                                                        exitButton,
                                                                        GroupLayout.DEFAULT_SIZE,
                                                                        GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE))
                                                            .addGroup(
                                                                layout
                                                                    .createSequentialGroup()
                                                                    .addComponent(
                                                                        joinButton,
                                                                        GroupLayout.PREFERRED_SIZE,
                                                                        93,
                                                                        GroupLayout.PREFERRED_SIZE)
                                                                    .addGap(18, 18, 18)
                                                                    .addComponent(sendButton)))))
                                    .addGap(0, 8, Short.MAX_VALUE)))
                    .addContainerGap()));

    layout.setVerticalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(GroupLayout.Alignment.LEADING, false)
                            .addComponent(usernameField)
                            .addComponent(
                                usernameLabel,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE))
                    .addGap(3, 3, 3)
                    .addComponent(
                        chatroomScrollPane,
                        GroupLayout.PREFERRED_SIZE,
                        178,
                        GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(
                                chatMsgLabel,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                chatMsgField,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE))
                    .addGroup(
                        layout
                            .createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(
                                        layout
                                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                                            .addComponent(chatIPLabel)
                                            .addComponent(portLabel))
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(
                                        layout
                                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                                            .addComponent(
                                                chatIPField,
                                                GroupLayout.PREFERRED_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.PREFERRED_SIZE)
                                            .addComponent(
                                                portField,
                                                GroupLayout.PREFERRED_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.PREFERRED_SIZE)))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addGap(16, 16, 16)
                                    .addGroup(
                                        layout
                                            .createParallelGroup(
                                                GroupLayout.Alignment.LEADING, false)
                                            .addComponent(
                                                joinButton,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE)
                                            .addComponent(
                                                sendButton,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE))
                                    .addGap(8, 8, 8)
                                    .addGroup(
                                        layout
                                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                                            .addComponent(leaveButton)
                                            .addComponent(exitButton))))
                    .addGap(17, 17, 17)));
    pack();
    setVisible(true);
  }
 public void loadImage(String filename) {
   theImage.setIcon(new MyImageIcon(filename));
 }
示例#29
0
  // Checks the current state and sets the enables/disables
  // accordingly
  public void run() {
    switch (connectionStatus) {
      case DISCONNECTED:
        connectButton.setEnabled(true);
        disconnectButton.setEnabled(false);
        ipField.setEnabled(true);
        portField.setEnabled(true);
        hostOption.setEnabled(true);
        guestOption.setEnabled(true);
        chatLine.setText("");
        chatLine.setEnabled(false);
        statusColor.setBackground(Color.red);
        break;

      case DISCONNECTING:
        connectButton.setEnabled(false);
        disconnectButton.setEnabled(false);
        ipField.setEnabled(false);
        portField.setEnabled(false);
        hostOption.setEnabled(false);
        guestOption.setEnabled(false);
        chatLine.setEnabled(false);
        statusColor.setBackground(Color.orange);
        break;

      case CONNECTED:
        connectButton.setEnabled(false);
        disconnectButton.setEnabled(true);
        ipField.setEnabled(false);
        portField.setEnabled(false);
        hostOption.setEnabled(false);
        guestOption.setEnabled(false);
        chatLine.setEnabled(true);
        statusColor.setBackground(Color.green);
        break;

      case BEGIN_CONNECT:
        connectButton.setEnabled(false);
        disconnectButton.setEnabled(false);
        ipField.setEnabled(false);
        portField.setEnabled(false);
        hostOption.setEnabled(false);
        guestOption.setEnabled(false);
        chatLine.setEnabled(false);
        chatLine.grabFocus();
        statusColor.setBackground(Color.orange);
        break;
    }

    // Make sure that the button/text field states are consistent
    // with the internal states
    ipField.setText(hostIP);
    portField.setText((new Integer(port)).toString());
    hostOption.setSelected(isHost);
    guestOption.setSelected(!isHost);
    statusField.setText(statusString);
    chatText.append(toAppend.toString());
    toAppend.setLength(0);

    mainFrame.repaint();
  }
示例#30
0
 //     @Override public Dimension getPreferredSize() {
 //         Insets i = getInsets();
 //         Dimension d = iconlabel.getPreferredSize();
 //         d.width  += i.left + i.right;
 //         d.height += i.top + i.bottom;
 //         return d;
 //     }
 @Override
 public void setTipText(final String tipText) {
   String oldValue = iconlabel.getText();
   iconlabel.setText(tipText);
   firePropertyChange("tiptext", oldValue, tipText);
 }