コード例 #1
2
ファイル: AdminMain.java プロジェクト: nikhilsaxena/STM
  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
  @Override
  public void paint(Graphics g) {
    for (int i = 0; i < 5; i++) {
      g.drawRect(i, i, 410 - 2 * i, 410 - 2 * i);
    }
    if (gameOver) {
      g.setColor(Color.RED);
      g.fillRect(0, 0, 410, 410);
      score.setBackground(Color.RED);
      score.setText("Your score is: " + (int) points);
      score.setSize(160, 20);
      score.setLocation(120, 50);

      record.setBackground(Color.RED);
      record.setSize(160, 20);
      record.setLocation(120, 80);

      tips.setBackground(Color.RED);
      tips.setSize(400, 20);
      tips.setLocation(0, 350);

    } else {
      map.paint(g);
      snake.paint(g);
      food.paint(g);
    }
  }
コード例 #3
0
 @SuppressWarnings({"boxing"})
 public void show(Point point, Vehicle vehicle) {
   final String exitString;
   if (vehicle.exitRoadSegmentId() == Vehicle.ROAD_SEGMENT_ID_NOT_SET) {
     exitString = this.trafficCanvas.popupStringExitEndRoad;
   } else {
     exitString = this.trafficCanvas.roadNetwork.findById(vehicle.exitRoadSegmentId()).userId();
   }
   final PhysicalQuantities vehiclePhysical = vehicle.physicalQuantities();
   final String string =
       String.format(
           this.trafficCanvas.popupString,
           vehicle.getId(),
           vehicle.getLabel(),
           vehicle.lane(),
           vehiclePhysical.getFrontPosition(),
           vehiclePhysical.getSpeed() * Units.MS_TO_KMH,
           vehiclePhysical.getAcc(),
           vehicle.totalTravelDistance(),
           exitString);
   final Label label = new Label(string, Label.LEFT);
   label.setBackground(new Color(200, 220, 240));
   removeAll();
   add(label);
   pack();
   final Point screenLocation = owner.getLocationOnScreen();
   setLocation(point.x + screenLocation.x + 15, point.y + screenLocation.y + 90);
   currentPopupId = vehicle.getId();
   setVisible(true);
   final PopupTimer popupTimer = new PopupTimer();
   popupTimer.start(currentPopupId);
 }
コード例 #4
0
ファイル: FGSplashScreen.java プロジェクト: Auzzy/school
 /* WARNING: THIS METHOD WILL BE REGENERATED. */
 private java.awt.Label getLabel121() {
   if (ivjLabel121 == null) {
     try {
       ivjLabel121 = new java.awt.Label();
       ivjLabel121.setName("Label121");
       ivjLabel121.setAlignment(java.awt.Label.CENTER);
       ivjLabel121.setText("E.O. Stinson");
       ivjLabel121.setBackground(java.awt.Color.white);
       ivjLabel121.setBounds(7, 23, 384, 23);
       // user code begin {1}
       // user code end
     } catch (java.lang.Throwable ivjExc) {
       // user code begin {2}
       // user code end
       handleException(ivjExc);
     }
   }
   return ivjLabel121;
 }
コード例 #5
0
ファイル: FGSplashScreen.java プロジェクト: Auzzy/school
 /* WARNING: THIS METHOD WILL BE REGENERATED. */
 private java.awt.Label getLabel11() {
   if (ivjLabel11 == null) {
     try {
       ivjLabel11 = new java.awt.Label();
       ivjLabel11.setName("Label11");
       ivjLabel11.setAlignment(java.awt.Label.LEFT);
       ivjLabel11.setText("foo");
       ivjLabel11.setBackground(java.awt.Color.white);
       ivjLabel11.setBounds(26, 45, 362, 18);
       // user code begin {1}
       // user code end
     } catch (java.lang.Throwable ivjExc) {
       // user code begin {2}
       // user code end
       handleException(ivjExc);
     }
   }
   return ivjLabel11;
 }
コード例 #6
0
ファイル: ReciveFile.java プロジェクト: poomshen/kosta
  public ReciveFile() {
    super("파일전송");
    setLayout(null);
    lbl = new Label("파일 전송을 기다립니다.");
    lbl.setBounds(10, 30, 230, 20);
    lbl.setBackground(Color.gray);
    lbl.setForeground(Color.white);
    add(lbl);
    txt = new TextArea("", 0, 0, TextArea.SCROLLBARS_BOTH);
    txt.setBounds(10, 60, 230, 100);
    txt.setEditable(false);
    add(txt);
    btn = new Button("닫기");
    btn.setBounds(105, 170, 40, 20);
    btn.setVisible(false);
    btn.addActionListener(this);
    add(btn);
    addWindowListener(new WinListener());
    setSize(250, 200);
    show();

    try {
      ServerSocket socket = new ServerSocket(port);
      Socket sock = null;
      FileThread client = null;
      try {
        sock = socket.accept();
        client = new FileThread(this, sock);
        client.start();
      } catch (IOException e) {
        System.out.println(e);
        try {
          if (sock != null) sock.close();
        } catch (IOException e1) {
          System.out.println(e1);
        } finally {
          sock = null;
        }
      }
    } catch (IOException e) {
    }
  }
コード例 #7
0
  /**
   * displays a simpel message like a JOptionPane. After OK is pressed the programm will exit with
   * errorcode 1
   *
   * @param titel the titel of the window
   * @param message the message that should displayed
   */
  public MsgFrame(String titel, String message) {
    super(new Frame(), true);
    this.setTitle(titel);
    setLayout(new BorderLayout());
    setBackground(Color.lightGray);

    // Label:
    Label msg = new Label(message);
    msg.setBackground(Color.lightGray);
    add("North", msg);
    msg.setAlignment(Label.CENTER);

    Panel panelButton = new Panel();

    // CloseButton
    Button closeButton = new Button("Close");
    closeButton.addActionListener(this);

    panelButton.add(closeButton);

    add("South", panelButton);

    // enable close button:
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            dispose();
            System.exit(1);
          }
        });
    pack();
    // find the middel of screen
    Dimension dimFrame = getSize();
    Dimension dimSystem = Toolkit.getDefaultToolkit().getScreenSize();
    int y = (dimSystem.height - dimFrame.height) / 2;
    int x = (dimSystem.width - dimFrame.width) / 2;
    setLocation(x, y);

    // to be compatible with early java versions
    // setVisible(true);
    show();
  }
コード例 #8
0
ファイル: QueuePanel.java プロジェクト: stuartwdouglas/jacorb
 /* WARNING: THIS METHOD WILL BE REGENERATED. */
 private java.awt.Label getLabel2() {
   if (ivjLabel2 == null) {
     try {
       ivjLabel2 = new java.awt.Label();
       ivjLabel2.setName("Label2");
       ivjLabel2.setLocation(10, 22);
       ivjLabel2.setText("");
       ivjLabel2.setBackground(java.awt.SystemColor.control);
       ivjLabel2.setSize(70, 12);
       ivjLabel2.setForeground(java.awt.Color.black);
       ivjLabel2.setFont(new java.awt.Font("dialog", 2, 10));
       ivjLabel2.setAlignment(1);
       // user code begin {1}
       // user code end
     } catch (java.lang.Throwable ivjExc) {
       // user code begin {2}
       // user code end
       handleException(ivjExc);
     }
   }
   ;
   return ivjLabel2;
 }
コード例 #9
0
ファイル: main.java プロジェクト: spiralcode/applet_bmi
 public void init() {
   setLayout(new GridLayout(4, 4));
   check = new Button("Check");
   height = new TextField();
   weight = new TextField();
   result = new TextField();
   l1 = new Label("Height in Centimeters ");
   l2 = new Label("Weight in Kilogram");
   l3 = new Label("Index Value");
   not = new Label("Status");
   not.setBackground(Color.black);
   Font notf = new Font("Arial", Font.BOLD, 30);
   not.setFont(notf);
   add(l1);
   add(height);
   add(l2);
   add(weight);
   add(l3);
   add(result);
   add(check);
   add(not);
   check.addActionListener(this);
 }
コード例 #10
0
ファイル: RGBColorChooser.java プロジェクト: malves1982/POO2
  public void init() {

    /*
     * O construtor usado cria "uma barra" com valor inicial 0,
     * de largura 10 pixels, valor m�ni,o poss�vel 0 e m�ximo 265
     * como a barra de rolagem tem 10 pixels, seu canto inferior
     * esquerdo d� pode chegar ate 255 (valor m�ximo em RGB)
     */
    redScroll = new Scrollbar(Scrollbar.HORIZONTAL, 0, 10, 0, 265);
    greenScroll = new Scrollbar(Scrollbar.HORIZONTAL, 0, 10, 0, 265);
    blueScroll = new Scrollbar(Scrollbar.HORIZONTAL, 0, 10, 0, 265);

    /* Create Labels showing current RGB and HSB values. */
    redLabel = new Label(" R = 0");
    greenLabel = new Label(" G = 0");
    blueLabel = new Label(" B = 0");

    /* Set background colors for Scrollbars and Labels, so they don't
      inherit the gray background of the applet.
    */

    redScroll.setBackground(Color.lightGray);
    greenScroll.setBackground(Color.lightGray);
    blueScroll.setBackground(Color.lightGray);

    redLabel.setBackground(Color.white);
    greenLabel.setBackground(Color.white);
    blueLabel.setBackground(Color.white);

    /* Set the applet to listen for changes to the Scrollbars' values */ redScroll
        .addAdjustmentListener(this);
    greenScroll.addAdjustmentListener(this);
    blueScroll.addAdjustmentListener(this);

    /* Create a canvas whose background color will always be set to the currently selected color. */ colorCanvas =
        new Canvas();
    colorCanvas.setBackground(Color.black);

    /* Create the applet layout, which consists of a row of three equal-sized regions holding the Scrollbars, the Labels, and the color patch. The background color of the applet is gray, which will show around the edges and between components. */

    setLayout(new GridLayout(1, 3, 3, 3));
    setBackground(Color.gray);

    Panel scrolls = new Panel();
    Panel labels = new Panel();
    add(scrolls);
    add(labels);
    add(colorCanvas);

    /* Add the Scrollbars and the Labels to their respective panels. */

    scrolls.setLayout(new GridLayout(3, 1, 2, 2));
    scrolls.add(redScroll);
    scrolls.add(greenScroll);
    scrolls.add(blueScroll);

    labels.setLayout(new GridLayout(3, 1, 2, 2));
    labels.add(redLabel);
    labels.add(greenLabel);
    labels.add(blueLabel);

    setSize(new Dimension(500, 100));
    // curiosamente, aqui n�o funcionou setPreferredSize() !!!
  } // end init();
コード例 #11
0
  public RatePlotFileDialogue(
      int X, int Y, int width, int height, Color fg, Color bg, String title, String text) {

    this.setLayout(new BorderLayout());
    this.setSize(width, height);
    this.setLocation(X, Y);

    Label topLabel = new Label(text, Label.CENTER);
    topLabel.setFont(warnFont);
    topLabel.setForeground(fg);
    topLabel.setBackground(bg);

    Panel midPanel = new Panel();
    midPanel.setBackground(bg);
    midPanel.setLayout(null);
    midPanel.add(hT);
    hT.setSize(width, 25);
    this.setTitle(title);

    hT.setForeground(fg);
    hT.setBackground(Color.white);
    hT.setFont(inputFont);
    this.add("North", topLabel);
    this.add("Center", midPanel);

    // Add Cancel and Save buttons

    Panel botPanel = new Panel();
    botPanel.setBackground(bg);
    botPanel.setFont(buttonFont);
    Label label1 = new Label();
    Label label2 = new Label();
    Label label3 = new Label();
    label2.setBackground(bg);
    label3.setBackground(bg);

    Button dismissButton = new Button("Cancel");
    Button saveButton = new Button("Save");
    botPanel.add(dismissButton);
    botPanel.add(label1);
    botPanel.add(saveButton);

    this.add("South", botPanel);
    this.add("West", label2);
    this.add("East", label3);

    // Add inner class event handler for Dismiss button

    dismissButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            hide();
            dispose();
          }
        }); // -- end inner class for Dismiss button processing

    // Add inner class event handler for postscript Save button

    saveButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {

            // Following invokes gp.PSfile() to print the PS
            // file.  Can't invoke this method directly from
            // here because object gp is not recognized.  This
            // works by declaring
            // RateGraphicsPad instance gp to be static and then
            // invoking the static method makePS from RatePlotFrame
            // to in turn invoke gp.PSfile(file).  (Note the use
            // of the "RatePlotFileDialogue.this" construction to
            // invoke the "this" reference for the outer class
            // RatePlotFileDialogue from this anonymous inner class.)
            // In other applications, the second line of the if
            // clause would likely require modification to
            // correspond to the particular classes in use.

            if (RatePlotFileDialogue.this.hT.getText().length() > 0) {
              RatePlotFrame.makePS(RatePlotFileDialogue.this.hT.getText());
              hide();
              dispose();
            } else {

              makeTheWarning(
                  100,
                  100,
                  200,
                  100,
                  Color.black,
                  Color.lightGray,
                  "Warning",
                  "You must supply a file name!",
                  true,
                  RatePlotFileDialogue.this);

              return;
            }
          }
        });

    // Add window close button (inner class)

    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            hide();
            dispose();
          }
        });
  }
コード例 #12
0
  public void makeTheWarning(
      int X,
      int Y,
      int width,
      int height,
      Color fg,
      Color bg,
      String title,
      String text,
      boolean oneLine,
      Frame frame) {

    Font warnFont = new java.awt.Font("SanSerif", Font.BOLD, 12);
    FontMetrics warnFontMetrics = getFontMetrics(warnFont);

    // Create Dialog window with modal blocking set to true.
    // Make final so inner class below can access it.

    final Dialog mww = new Dialog(frame, title, true);
    mww.setLayout(new BorderLayout());
    mww.setSize(width, height);
    mww.setLocation(X, Y);

    // Use Label for 1-line warning

    if (oneLine) {
      Label hT = new Label(text, Label.CENTER);
      hT.setForeground(fg);
      hT.setBackground(bg);
      hT.setFont(warnFont);
      mww.add("Center", hT);

      // Use TextArea for multiline warning

    } else {
      TextArea hT = new TextArea("", height, width, TextArea.SCROLLBARS_NONE);
      hT.setEditable(false);
      hT.setForeground(fg);
      hT.setBackground(bg); // no effect once setEditable (false)?
      hT.setFont(warnFont);
      mww.add("Center", hT);
      hT.appendText(text);
    }

    mww.setTitle(title);

    // Add dismiss button

    Panel botPanel = new Panel();
    botPanel.setBackground(Color.lightGray);
    Label label1 = new Label();
    Label label2 = new Label();

    Button dismissButton = new Button("Dismiss");
    botPanel.add(label1);
    botPanel.add(dismissButton);
    botPanel.add(label2);

    // Add inner class event handler for Dismiss button.  This must be
    // added to the dismissButton before botPanel is added to mww.

    dismissButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            mww.hide();
            mww.dispose();
          }
        });

    mww.add("South", botPanel);

    // Add window closing button (inner class)

    mww.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            mww.hide();
            mww.dispose();
          }
        });

    mww.show(); // Note that this show must come after all the above
    // additions; otherwise they are not added before the
    // window is displayed.
  }
コード例 #13
0
ファイル: MyScreenAbout.java プロジェクト: atrilla/magnus
  /** This is the main method for configuring the <it>MyScreenAbout</it>. */
  public MyScreenAbout() { // constructor
    setSize(470, 600);
    setTitle("informació sobre el MAGNUS");
    setResizable(false);
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    URL url = getClass().getResource("icon.png");
    Image image = toolkit.getImage(url);
    setIconImage(image);
    ScrollPane scrollPane = new ScrollPane(ScrollPane.SCROLLBARS_NEVER);
    scrollPane.setSize(470, 148);
    scrollPane.setBackground(new Color(0, 128, 0));
    Canvas canvas = new MyCanvasAbout();
    canvas.setSize(470, 148);
    scrollPane.add(canvas);
    add(scrollPane, BorderLayout.NORTH);

    ScrollPane infoscroll = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
    infoscroll.setSize(470, 400);
    infoscroll.setBackground(new Color(255, 255, 255));
    Panel info = new Panel();
    info.setLayout(new GridLayout(56, 1));
    infoscroll.add(info);

    Label ts1 = new Label("MAGNUS 0.1.1");
    ts1.setFont(new Font("SansSerif", Font.BOLD, 10));
    ts1.setForeground(new Color(0, 0, 0));
    ts1.setBackground(new Color(255, 255, 255));
    info.add(ts1);

    Label ts2 = new Label("http://magnusproject.wordpress.com");
    ts2.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts2.setForeground(new Color(0, 0, 255));
    ts2.setBackground(new Color(255, 255, 255));
    info.add(ts2);

    Label ts3 = new Label(" ");
    ts3.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts3.setForeground(new Color(0, 0, 255));
    ts3.setBackground(new Color(255, 255, 255));
    info.add(ts3);

    Label ts4 = new Label("Alexandre Trilla Castelló");
    ts4.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts4.setForeground(new Color(0, 0, 0));
    ts4.setBackground(new Color(255, 255, 255));
    info.add(ts4);

    Label ts5 = new Label("          http://www.salle.url.edu/~atrilla/");
    ts5.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts5.setForeground(new Color(0, 0, 255));
    ts5.setBackground(new Color(255, 255, 255));
    info.add(ts5);

    Label ts7 = new Label("Departament d'Educació de la Generalitat de Catalunya");
    ts7.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts7.setForeground(new Color(0, 0, 0));
    ts7.setBackground(new Color(255, 255, 255));
    info.add(ts7);

    Label ts8 = new Label("          http://www.xtec.cat");
    ts8.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts8.setForeground(new Color(0, 0, 255));
    ts8.setBackground(new Color(255, 255, 255));
    info.add(ts8);

    Label ts9 = new Label("Universitat Ramon Llull La Salle Enginyeria de Telecomunicació");
    ts9.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts9.setForeground(new Color(0, 0, 0));
    ts9.setBackground(new Color(255, 255, 255));
    info.add(ts9);

    Label ts10 = new Label("          http://www.salle.url.edu");
    ts10.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts10.setForeground(new Color(0, 0, 255));
    ts10.setBackground(new Color(255, 255, 255));
    info.add(ts10);

    Label ts11 = new Label(" ");
    ts11.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts11.setForeground(new Color(0, 0, 0));
    ts11.setBackground(new Color(255, 255, 255));
    info.add(ts11);

    Label ts111 = new Label(" ");
    ts111.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts111.setForeground(new Color(0, 0, 255));
    ts111.setBackground(new Color(255, 255, 255));
    info.add(ts111);

    DesenvCanvas dc = new DesenvCanvas();
    info.add(dc);

    Label ts17 = new Label("MAGNUS ha estat desenvolupat per Alexandre Trilla");
    ts17.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts17.setForeground(new Color(0, 0, 0));
    ts17.setBackground(new Color(255, 255, 255));
    info.add(ts17);

    Label ts18 = new Label("pel Servei de Tecnologies per l'Aprenentatge i el");
    ts18.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts18.setForeground(new Color(0, 0, 0));
    ts18.setBackground(new Color(255, 255, 255));
    info.add(ts18);

    Label ts19 = new Label("Coneixement del Departament d'Educació de la");
    ts19.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts19.setForeground(new Color(0, 0, 0));
    ts19.setBackground(new Color(255, 255, 255));
    info.add(ts19);

    Label ts20 = new Label("Generalitat de Catalunya.");
    ts20.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts20.setForeground(new Color(0, 0, 0));
    ts20.setBackground(new Color(255, 255, 255));
    info.add(ts20);

    Label ts21 = new Label(" ");
    ts21.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts21.setForeground(new Color(0, 0, 0));
    ts21.setBackground(new Color(255, 255, 255));
    info.add(ts21);

    Label ts22 = new Label("Alhora, MAGNUS ha constituït el Projecte Final de");
    ts22.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts22.setForeground(new Color(0, 0, 0));
    ts22.setBackground(new Color(255, 255, 255));
    info.add(ts22);

    Label ts23 = new Label("Carrera de l'autor, havent cursat d'Enginyeria");
    ts23.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts23.setForeground(new Color(0, 0, 0));
    ts23.setBackground(new Color(255, 255, 255));
    info.add(ts23);

    Label ts24 = new Label("Superior de Telecomunicacions a la Universitat");
    ts24.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts24.setForeground(new Color(0, 0, 0));
    ts24.setBackground(new Color(255, 255, 255));
    info.add(ts24);

    Label ts25 = new Label("Ramon Llull La Salle de Barcelona.");
    ts25.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts25.setForeground(new Color(0, 0, 0));
    ts25.setBackground(new Color(255, 255, 255));
    info.add(ts25);

    Label ts26 = new Label(" ");
    ts26.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts26.setForeground(new Color(0, 0, 0));
    ts26.setBackground(new Color(255, 255, 255));
    info.add(ts26);

    Label ts261 = new Label(" ");
    ts261.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts261.setForeground(new Color(0, 0, 0));
    ts261.setBackground(new Color(255, 255, 255));
    info.add(ts261);

    CredenCanvas cc = new CredenCanvas();
    info.add(cc);

    Label ts12 = new Label("Aquest producte inclou programari desenvolupat per:");
    ts12.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts12.setForeground(new Color(0, 0, 0));
    ts12.setBackground(new Color(255, 255, 255));
    info.add(ts12);

    Label ts121 = new Label(" ");
    ts121.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts121.setForeground(new Color(0, 0, 0));
    ts121.setBackground(new Color(255, 255, 255));
    info.add(ts121);

    Label ts13 = new Label("Sphinx-4");
    ts13.setFont(new Font("SansSerif", Font.BOLD, 10));
    ts13.setForeground(new Color(0, 0, 0));
    ts13.setBackground(new Color(255, 255, 255));
    info.add(ts13);

    Label ts14 = new Label("Carnegie Mellon University");
    ts14.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts14.setForeground(new Color(0, 0, 0));
    ts14.setBackground(new Color(255, 255, 255));
    info.add(ts14);

    Label ts142 = new Label("          http://cmusphinx.sourceforge.net/sphinx4/");
    ts142.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts142.setForeground(new Color(0, 0, 255));
    ts142.setBackground(new Color(255, 255, 255));
    info.add(ts142);

    Label ts141 = new Label(" ");
    ts141.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts141.setForeground(new Color(0, 0, 0));
    ts141.setBackground(new Color(255, 255, 255));
    info.add(ts141);

    Label ts15 = new Label("Jdom");
    ts15.setFont(new Font("SansSerif", Font.BOLD, 10));
    ts15.setForeground(new Color(0, 0, 0));
    ts15.setBackground(new Color(255, 255, 255));
    info.add(ts15);

    Label ts16 = new Label("The JDOM Project");
    ts16.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts16.setForeground(new Color(0, 0, 0));
    ts16.setBackground(new Color(255, 255, 255));
    info.add(ts16);

    Label ts162 = new Label("          http://www.jdom.org");
    ts162.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts162.setForeground(new Color(0, 0, 255));
    ts162.setBackground(new Color(255, 255, 255));
    info.add(ts162);

    Label ts161 = new Label(" ");
    ts161.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts161.setForeground(new Color(0, 0, 0));
    ts161.setBackground(new Color(255, 255, 255));
    info.add(ts161);

    Label ts163 = new Label(" ");
    ts163.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts163.setForeground(new Color(0, 0, 0));
    ts163.setBackground(new Color(255, 255, 255));
    info.add(ts163);

    LicCanvas lc = new LicCanvas();
    info.add(lc);

    Label ts64 = new Label("Copyright (C) 2007 Alexandre Trilla &");
    ts64.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts64.setForeground(new Color(0, 0, 0));
    ts64.setBackground(new Color(255, 255, 255));
    info.add(ts64);

    Label ts65 = new Label("Departament d'Educació de la Generalitat de Catalunya &");
    ts65.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts65.setForeground(new Color(0, 0, 0));
    ts65.setBackground(new Color(255, 255, 255));
    info.add(ts65);

    Label ts66 = new Label("Universitat Ramon Llull La Salle Enginyeria de Telecomunicació");
    ts66.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts66.setForeground(new Color(0, 0, 0));
    ts66.setBackground(new Color(255, 255, 255));
    info.add(ts66);

    Label ts67 = new Label(" ");
    ts67.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts67.setForeground(new Color(0, 0, 0));
    ts67.setBackground(new Color(255, 255, 255));
    info.add(ts67);

    Label ts68 = new Label("Aquest programa és lliure. Podeu distribuir-lo i/o modificar-");
    ts68.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts68.setForeground(new Color(0, 0, 0));
    ts68.setBackground(new Color(255, 255, 255));
    info.add(ts68);

    Label ts69 = new Label("lo conforme a les disposicions de la Llicència Pública General");
    ts69.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts69.setForeground(new Color(0, 0, 0));
    ts69.setBackground(new Color(255, 255, 255));
    info.add(ts69);

    Label ts70 = new Label("de GNU (GPL), publicada per la Free Software Foundation, ja");
    ts70.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts70.setForeground(new Color(0, 0, 0));
    ts70.setBackground(new Color(255, 255, 255));
    info.add(ts70);

    Label ts71 = new Label("sigui la versió 3 de la llicència o qualsevol versió posterior.");
    ts71.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts71.setForeground(new Color(0, 0, 0));
    ts71.setBackground(new Color(255, 255, 255));
    info.add(ts71);

    Label ts711 = new Label(" ");
    ts711.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts711.setForeground(new Color(0, 0, 0));
    ts711.setBackground(new Color(255, 255, 255));
    info.add(ts711);

    Label ts72 = new Label("Aquest programa es distribueix amb la intenció de resultar");
    ts72.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts72.setForeground(new Color(0, 0, 0));
    ts72.setBackground(new Color(255, 255, 255));
    info.add(ts72);

    Label ts73 = new Label("útil, però SENSE CAP GARANTIA, fins i tot sense la garantia");
    ts73.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts73.setForeground(new Color(0, 0, 0));
    ts73.setBackground(new Color(255, 255, 255));
    info.add(ts73);

    Label ts74 = new Label("implícita de COMERCIABILITAT o CONVENIÈNCIA PER A UN");
    ts74.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts74.setForeground(new Color(0, 0, 0));
    ts74.setBackground(new Color(255, 255, 255));
    info.add(ts74);

    Label ts75 = new Label("PROPÒSIT PARTICULAR. Per a més detalls, vegeu la Llicència");
    ts75.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts75.setForeground(new Color(0, 0, 0));
    ts75.setBackground(new Color(255, 255, 255));
    info.add(ts75);

    Label ts76 = new Label("Pública General de GNU.");
    ts76.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts76.setForeground(new Color(0, 0, 0));
    ts76.setBackground(new Color(255, 255, 255));
    info.add(ts76);

    Label ts77 = new Label(" ");
    ts77.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts77.setForeground(new Color(0, 0, 0));
    ts77.setBackground(new Color(255, 255, 255));
    info.add(ts77);

    Label ts771 = new Label(" ");
    ts771.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts771.setForeground(new Color(0, 0, 0));
    ts771.setBackground(new Color(255, 255, 255));
    info.add(ts771);

    SupCanvas supc = new SupCanvas();
    info.add(supc);

    Label ts1234 = new Label("Desenvolupat en col·laboració amb Enginyeria i");
    ts1234.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts1234.setForeground(new Color(0, 0, 0));
    ts1234.setBackground(new Color(255, 255, 255));
    info.add(ts1234);

    Label ts12345 = new Label("Arquitectura La Salle (Universitat Ramon Llull)");
    ts12345.setFont(new Font("SansSerif", Font.PLAIN, 10));
    ts12345.setForeground(new Color(0, 0, 0));
    ts12345.setBackground(new Color(255, 255, 255));
    info.add(ts12345);

    SalleCanvas sallec = new SalleCanvas();
    // info.add(sallec);
    add(sallec, BorderLayout.SOUTH);

    add(infoscroll, BorderLayout.CENTER);

    addWindowListener(
        new WindowAdapter() {

          /**
           * This method catches the closing event and react accordingly.
           *
           * @param e WindowEvent: the window closing event.
           */
          public void windowClosing(WindowEvent e) {
            setVisible(false);
          }
        });
  }
コード例 #14
0
  /** Création de l'intérieur de la fenêtre */
  private void initConteneur() {
    // le fond
    fond = getToolkit().getImage("./images/preference/bomber_fond.gif");
    tracker = new MediaTracker(this);
    tracker.addImage(fond, 0);
    try {
      tracker.waitForID(0);
    } catch (Exception a) {
      System.out.println("Erreur lors chargement de l'image: initConteneur() Preference");
      a.printStackTrace();
    }

    // le layout manager
    GridBagLayout layout = new GridBagLayout();
    setLayout(layout);
    GridBagConstraints c = new GridBagConstraints();
    c.weightx = 10;
    c.weighty = 10;
    c.ipadx = 10;
    c.ipady = 10;
    c.fill = GridBagConstraints.BOTH;

    // label "Joueurs:"
    Label lbl_joueurs = new Label("Joueurs:");
    lbl_joueurs.setAlignment(Label.CENTER);
    lbl_joueurs.setFont(new Font("SansSerif", Font.BOLD, 16));
    lbl_joueurs.setBackground(Color.black);
    lbl_joueurs.setForeground(Color.red);
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 6;
    c.gridheight = 1;
    c.insets = new Insets(20, 10, 10, 10);
    c.anchor = GridBagConstraints.SOUTH;
    layout.setConstraints(lbl_joueurs, c);
    add(lbl_joueurs);

    // choix de couleur du joueur ayant l'identifiant 0
    choix_couleur0 = new Choice();
    choix_couleur0.addItem("rouge");
    choix_couleur0.addItem("bleu");
    choix_couleur0.addItemListener(this);
    choix_couleur0.setBackground(Color.red);
    choix_couleur0.setForeground(Color.black);
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.insets = new Insets(10, 10, 5, 20);
    c.anchor = GridBagConstraints.EAST;
    layout.setConstraints(choix_couleur0, c);
    add(choix_couleur0);

    // nom du joueur ayant l'identifiant 0
    txt_joueur0 = new TextField(noms[0]);
    c.gridx = 2;
    c.gridy = 1;
    c.gridwidth = 4;
    c.gridheight = 1;
    c.insets = new Insets(10, 10, 5, 20);
    c.anchor = GridBagConstraints.WEST;
    layout.setConstraints(txt_joueur0, c);
    add(txt_joueur0);

    // choix de couleur du joueur ayant l'identifiant 1
    choix_couleur1 = new Choice();
    choix_couleur1.addItem("bleu");
    choix_couleur1.addItem("rouge");
    choix_couleur1.addItemListener(this);
    choix_couleur1.setBackground(Color.blue);
    choix_couleur1.setForeground(Color.black);
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.insets = new Insets(10, 10, 20, 20);
    c.anchor = GridBagConstraints.EAST;
    layout.setConstraints(choix_couleur1, c);
    add(choix_couleur1);

    // nom du joueur ayant l'identifiant 1
    txt_joueur1 = new TextField(noms[1]);
    c.gridx = 2;
    c.gridy = 2;
    c.gridwidth = 4;
    c.gridheight = 1;
    c.insets = new Insets(10, 10, 30, 20);
    c.anchor = GridBagConstraints.WEST;
    layout.setConstraints(txt_joueur1, c);
    add(txt_joueur1);

    // label "Nombre De Vies:"
    Label lbl_nbvies = new Label("Nombre De Vies:");
    lbl_nbvies.setAlignment(Label.CENTER);
    lbl_nbvies.setFont(new Font("SansSerif", Font.BOLD, 14));
    lbl_nbvies.setBackground(Color.black);
    lbl_nbvies.setForeground(Color.yellow);
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(20, 10, 5, 10);
    c.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(lbl_nbvies, c);
    add(lbl_nbvies);
    // un choix possible
    cbg_vies = new CheckboxGroup();
    Checkbox cb;
    for (int i = 1; i <= 5; i++) {
      if (i == nb_vies) cb = new Checkbox("" + i, cbg_vies, true);
      else cb = new Checkbox("" + i, cbg_vies, false);
      c.gridx = i;
      c.gridy = 4;
      c.gridwidth = 1;
      c.gridheight = 1;
      c.insets = new Insets(20, 10, 5, 10);
      c.anchor = GridBagConstraints.CENTER;
      layout.setConstraints(cb, c);
      add(cb);
    } // for

    // label "Nombre	De Victoires:"
    lbl_victoires = new Label();
    lbl_victoires.setAlignment(Label.CENTER);
    lbl_victoires.setFont(new Font("SansSerif", Font.BOLD, 14));
    lbl_victoires.setText("Nombre De Victoires: " + nb_victoires);
    lbl_victoires.setBackground(Color.black);
    lbl_victoires.setForeground(Color.green);
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(20, 10, 5, 10);
    c.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(lbl_victoires, c);
    add(lbl_victoires);

    // choix du nombre de victoires entre un 1 et 9
    sb_victoires = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 1, 10);
    sb_victoires.setUnitIncrement(1);
    sb_victoires.setBlockIncrement(2);
    sb_victoires.addAdjustmentListener(this);
    sb_victoires.setValue(nb_victoires);
    c.gridx = 1;
    c.gridy = 6;
    c.gridwidth = 5;
    c.gridheight = 1;
    c.insets = new Insets(20, 10, 5, 10);
    c.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(sb_victoires, c);
    add(sb_victoires);

    // tirage aléatoire des niveaux
    cb_aleatoire = new Checkbox("Niveaux Aléatoires", aleatoire);
    cb_aleatoire.setFont(new Font("SansSerif", Font.BOLD, 14));
    cb_aleatoire.setBackground(Color.black);
    cb_aleatoire.setForeground(Color.magenta);
    c.gridx = 0;
    c.gridy = 8;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(20, 12, 5, 10);
    c.anchor = GridBagConstraints.EAST;
    layout.setConstraints(cb_aleatoire, c);
    add(cb_aleatoire);

    // label "FPS:" nombre de frames par seconde
    lbl_fps = new Label();
    lbl_fps.setAlignment(Label.CENTER);
    lbl_fps.setFont(new Font("SansSerif", Font.BOLD, 14));
    lbl_fps.setText("FPS: " + fps);
    lbl_fps.setBackground(Color.black);
    lbl_fps.setForeground(Color.orange);
    c.gridx = 0;
    c.gridy = 10;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(20, 10, 5, 10);
    c.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(lbl_fps, c);
    add(lbl_fps);

    // choix du nombre de frames par seconde
    sb_fps = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 1, 51);
    sb_fps.setUnitIncrement(1);
    sb_fps.setBlockIncrement(10);
    sb_fps.addAdjustmentListener(this);
    sb_fps.setValue(fps);
    c.gridx = 1;
    c.gridy = 10;
    c.gridwidth = 5;
    c.gridheight = 1;
    c.insets = new Insets(20, 10, 5, 10);
    c.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(sb_fps, c);
    add(sb_fps);

    // bouton de confirmation
    button_ok = new Button("Ok");
    c.gridx = 0;
    c.gridy = 12;
    c.gridwidth = 6;
    c.gridheight = 1;
    c.insets = new Insets(20, 5, 20, 5);
    c.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(button_ok, c);
    add(button_ok);
    button_ok.addActionListener(this);
  } // initConteneur()