@Override
  public void display(HashBasedTable<String, String, Double> data) {

    roomToCodeMapping = generateNewRoomToCodeMapping();
    dataSet = createDataSet(data);
    final JFreeChart chart = createChart(dataSet);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(1000, 540));
    createNewFrameAndSetLocation();
    currentFrame.setTitle(this.getTitle());
    currentFrame.setContentPane(chartPanel);
    currentFrame.setVisible(true);
    currentFrame.setSize(new Dimension(1020, 560));
    currentFrame.addWindowListener(this);

    if (type == MarkovDataDialog.HeatMapType.COMPARISON) {
      unscaledDifferenceSlider.setLabelTable(unscaledDifferenceSlider.createStandardLabels(5, 5));
      differenceSelectorFrame = new JFrame("Choose Size of difference");
      differenceSelectorFrame.setLayout(new BorderLayout());
      differenceSelectorFrame.add(unscaledDifferenceSlider, BorderLayout.NORTH);

      statusLabel.setHorizontalAlignment(SwingConstants.CENTER);
      statusLabel.setText("Current difference size:" + this.unscaledDifference);

      differenceSelectorFrame.add(statusLabel, BorderLayout.CENTER);

      differenceSelectorFrame.add(regenerate, BorderLayout.SOUTH);

      regenerate.addActionListener(this);

      differenceSelectorFrame.setLocation(100, 10);
      differenceSelectorFrame.setSize(300, 200);
      differenceSelectorFrame.setVisible(true);
    }
  }
Example #2
0
  public start() {

    MyModel lm = new MyModel();
    JList<Integer> jl = new JList<>(lm);
    JButton b = new JButton("ADD");
    b.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            lm.add(zahl++);
          }
        });

    JFrame jf = new JFrame("List Test");
    jf.setLayout(new BorderLayout());
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JScrollPane scrollen = new JScrollPane(jl);

    jf.add(b, BorderLayout.SOUTH);
    jf.add(scrollen, BorderLayout.NORTH);
    jf.setSize(300, 300);
    jf.setLocation(400, 500);
    jf.setVisible(true);
  }
Example #3
0
  public static void main(String[] args) {
    JFrame frame = new JFrame("Reaction Timer");
    frame.setSize(280, 120);

    final TextField disp = new TextField();
    final JButton btn = new JButton("Go");

    btn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            u = System.currentTimeMillis();
            if (u - t < ONE_SECOND) {
              disp.setText("" + (u - t));
            }
            t = u;
          }
        });

    frame.setLayout(null);
    disp.setBounds(10, 10, 230, 20);
    frame.add(disp);
    btn.setBounds(10, 40, 210, 40);
    frame.add(btn);

    frame.setVisible(true);
    frame.setLocationRelativeTo(null);
    frame.setResizable(false);
  }
Example #4
0
 Main() {
   f = new JFrame("Wiki Seach");
   JPanel p = new JPanel();
   JPanel p1 = new JPanel();
   b = new JButton("Search");
   b1 = new JButton("Exit");
   t = new JTextField(30);
   b.addActionListener(this);
   b1.addActionListener(this);
   p1.add(b);
   p1.add(b1);
   p.add(t);
   f.setLayout(new GridLayout(2, 1));
   f.add(p);
   f.add(p1);
   f.pack();
   f.setLocationRelativeTo(null);
   f.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   f.setVisible(true);
 }
  // -------------------------------------------------------------------
  public static void main(String[] args) {
    // Create the window
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(new Dimension(300, 100));
    frame.setTitle("A frame");
    frame.setLayout(new FlowLayout()); // This will be discuss in the next lesson

    // Create and add the first button
    JButton button1 = new JButton();
    button1.setText("I'm a button.");
    button1.setBackground(Color.BLUE);
    frame.add(button1);

    // Create and add the second button
    JButton button2 = new JButton();
    button2.setText("Click me!");
    button2.setBackground(Color.RED);
    frame.add(button2);

    // Reset the sizes of the buttons and window
    frame.pack();

    // Actually put the window on the screen and draw all its components
    frame.setVisible(true);
  }
Example #6
0
 public RemoveFrame() {
   frame = new JFrame("Select Files you wish to Remove from Drive");
   frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
   frame.getRootPane().setDefaultButton(confirm);
   try {
     files = DriveList.list();
   } catch (IOException e) {
     files = new ArrayList<File>();
   }
   confirm = new JButton("Remove");
   quit = new JButton("Cancel");
   confirm.addActionListener(this);
   quit.addActionListener(this);
   frame.setLayout(new BorderLayout());
   checkPanel = new JPanel();
   control = new JPanel();
   control.setLayout(new GridLayout(1, 2));
   control.add(confirm);
   control.add(quit);
   frame.add(control, BorderLayout.SOUTH);
   drawCheckPanel();
   frame.add(checkPanel, BorderLayout.CENTER);
   frame.pack();
   frame.setVisible(true);
 }
Example #7
0
  public SchiebePuzzle() {
    JFrame jF = new JFrame("Misc_2015/SchiebePuzzle");
    jF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    jF.setLayout(new GridLayout(YY, XX)); // ggf zu ändern
    try {
      BufferedImage fuYou = ImageIO.read(new File("fuYou.jpg"));
      int w = fuYou.getWidth();
      int h = fuYou.getHeight();
      for (int y = 0; y < YY; y++)
        for (int x = 0; x < XX; x++) {
          buttons[y][x] =
              new PuzzButton(
                  new ImageIcon(fuYou.getSubimage(x * (w / XX), y * (h / YY), w / XX, h / YY)));

          buttons[y][x].setBorder(new LineBorder(Color.BLACK, 1));
          buttons[y][x].setActionCommand("" + x + y);
          buttons[y][x].setName("" + x + y);
          buttons[y][x].setPosY(y);
          buttons[y][x].setPosX(x);
          buttons[y][x].addActionListener(this);
          jF.add(buttons[y][x]);
        }

    } catch (IOException e) {
      System.out.println("Bild nicht gefunden!");
    }

    jF.pack();
    jF.setVisible(true);
  }
  public void go() {
    picture();
    ActionListener listener = new BtListener();
    go.addActionListener(listener);
    btn_update_manual.addActionListener(listener);
    go.setForeground(Color.black);
    // rights.setFont((new Font("Arial", Font.PLAIN, 12)));
    title.setFont((new Font("Arial", Font.BOLD, 36)));
    title.setForeground(new Color(238, 253, 253));
    today.setFont((new Font("Arial", Font.BOLD, 16)));
    today.setForeground(new Color(163, 184, 204));
    frame.setLayout(new BorderLayout());
    from.setBackground(Color.white);
    to.setBackground(Color.white);
    converted.setFont(new Font("Arial", Font.BOLD, 24));
    converted.setForeground(new Color(238, 253, 253));
    Lfrom.setForeground(new Color(238, 253, 253));
    Lto.setForeground(new Color(238, 253, 253));
    quantity.setForeground(new Color(238, 253, 253));
    Lfrom.setFont(new Font("Arial", Font.BOLD, 24));
    Lto.setFont(new Font("Arial", Font.BOLD, 24));
    quantity.setFont(new Font("Arial", Font.BOLD, 24));
    north.setLayout(new FlowLayout());
    north.add(title);
    north.setBackground(new Color(59, 62, 71));
    frame.add(BorderLayout.NORTH, north);
    inner.setLayout(new BorderLayout());
    inner.add(BorderLayout.NORTH, today);
    inner.add(BorderLayout.WEST, picPanel);
    center.setLayout(new GridLayout(2, 4, 5, 5));
    center.add(Lfrom);
    center.add(from);
    center.add(Lto);
    center.add(to);
    center.add(quantity);
    center.add(amount);
    center.add(go);
    inner.setBackground(new Color(59, 62, 71));
    inner.add(BorderLayout.SOUTH, center);
    center.setBackground(new Color(59, 62, 71));
    frame.add(BorderLayout.CENTER, inner);
    south.setBackground(new Color(59, 62, 71));
    south.setLayout(new FlowLayout());
    south.add(converted);
    south.add(answer);
    south.add(btn_update_manual);
    // south.add(rights);
    frame.add(BorderLayout.SOUTH, south);
    frame.setSize(850, 700);
    frame.setVisible(true);

    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent event) {
            frame.setVisible(false);
            frame.dispose();
            System.exit(0);
          }
        });
  }
  public MenuPrincipalVista() {

    JButton btnSalir = new JButton("0. Sortir");
    JButton btnMenuParc = new JButton("1. Menú parc d'atraccions");
    JButton btnMenuAtraccions = new JButton("2. Menú atraccions");
    JButton[] arrayBotones = {btnSalir, btnMenuParc, btnMenuAtraccions};
    setMenuButtons(arrayBotones);

    GridLayout layoutGrid = new GridLayout(0, 1);
    frame = new JFrame("Menu Principal");
    frame.setLayout(layoutGrid);

    for (JButton menuButton : menuButtons) {
      frame.add(menuButton);
    }

    frame.setSize(amplada, alcada);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    /*
    Amb les propietats d'aquesta classe, heu de fer el següent (no afegiu cap listener a cap control)
        Heu de crear l'objecte JFrame amb títol "Menú Principal" i layout Grid d'una columna
        Heu de crear els botons del formulari. Cada botó serà un element de l'array de botons amb les següents etiquetes:
                    "0. Sortir"
                    "1. Menú parc d'atraccions"
                    "2. Menú atraccions"
        Heu d'afegir-ho tot al frame
        Heu de fer visible el frame amb l'amplada i alçada que proposen les propietats d'aquest nom
        Heu de fer que la finestra es tanqui quan l'usuari ho fa amb el control "X" de la finestra
    */
  }
Example #10
0
  public ObserverPattern() {
    root = null;
    // window = new JFrame();
    width = 400;
    height = 400;

    window = new JFrame("New Window");
    // controllwin =  new JFrame("Controll");
    // controllwin.setLayout(new FlowLayout());
    JButton b = new JButton("Értéket ad");
    tf = new JTextField();

    b.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // controlwindow.removeAll();
            if (!ertad()) {
              tf.setText("Nem megfelelo parameter!!");
            }
          }
        });

    /*controllwin.add(tf);
    controllwin.add(b);
    controllwin.setSize(100,50);
    controllwin.setVisible(true);
    controllwin.pack();*/

    window.setLayout(new FlowLayout());
    window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    window.setSize(width, height);
    window.setVisible(true);
  }
Example #11
0
  public static void main(String[] args) {
    if (Platform.get() != Platform.WINDOWS)
      throw new UnsupportedOperationException("This demo can only run on Windows.");

    LWJGLCanvas canvas = new LWJGLCanvas();
    canvas.setSize(640, 480);

    JFrame frame = new JFrame("JAWT Demo");

    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    frame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosed(WindowEvent e) {
            canvas.destroy();
          }
        });

    KeyboardFocusManager.getCurrentKeyboardFocusManager()
        .addKeyEventDispatcher(
            e -> {
              if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                frame.dispose();
                return true;
              }

              return false;
            });

    frame.setLayout(new BorderLayout());
    frame.add(canvas, BorderLayout.CENTER);

    frame.pack();
    frame.setVisible(true);
  }
Example #12
0
 public void editContactWindow() {
   editWindow = new JFrame("Edit Contacts");
   editWindow.setLayout(new FlowLayout());
   // Add List
   editWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
   editWindow.pack();
   editWindow.setVisible(true);
 }
Example #13
0
 /*
  * (non-Javadoc)
  *
  * @see javax.swing.JFrame#setLayout(java.awt.LayoutManager)
  */
 @Override
 public void setLayout(LayoutManager manager) {
   if (manager.getClass() != RibbonFrameLayout.class) {
     LayoutManager currManager = getLayout();
     if (currManager != null) {
       throw new IllegalArgumentException("Can't set a custom layout manager on JRibbonFrame");
     }
   }
   super.setLayout(manager);
 }
Example #14
0
 public void toSendWindow() {
   toWindow = new JFrame("Send Email To");
   toWindow.setLayout(new BorderLayout());
   contactList = new ContactListCheckBox(cList);
   toWindow.add(contactList, BorderLayout.CENTER);
   toWindow.add(addSendContacts, BorderLayout.SOUTH);
   toWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
   toWindow.pack();
   toWindow.setVisible(true);
 }
Example #15
0
  public JFrame buildFrame() {

    f = new JFrame("AMSA World");
    f.setSize(800, 600);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLayout(new GridBagLayout());

    textArea.setFocusable(false);
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    ActionListener listener =
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            checkInput();
          }
        };
    inputText.addActionListener(listener);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 5, 5, 5);
    c.weightx = 1.0;
    c.gridwidth = 3;
    c.weighty = 0.025;
    c.gridx = 0;
    c.gridy = 0;
    f.add(topPanel, c);

    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.gridwidth = 2;
    c.gridx = 0;
    c.gridy = 1;
    f.add(scrollPane, c);

    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.gridwidth = 1;
    c.gridx = 2;
    c.gridy = 1;
    f.add(sidePanel, c);
    sidePanel.setVisible(false);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weighty = 0.025;
    c.gridwidth = 3;
    c.gridx = 0;
    c.gridy = 2;
    f.add(inputText, c);

    f.setVisible(true);

    return f;
  }
  public static void main(String[] args) {
    frame.setLayout(new FlowLayout());

    final JPanel sceneHolder = new JPanel();
    initialize(sceneHolder);
    frame.add(sceneHolder);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(700, 700);
    frame.setVisible(true);
  }
 public void construirVentana() {
   jfrVentana = new JFrame("CARACETERES ESPECIALES EN EL TEXTO");
   jfrVentana.setLayout(new BoxLayout(jfrVentana.getContentPane(), BoxLayout.Y_AXIS));
   jfrVentana.add(pnlSuperior);
   jfrVentana.add(pnlInferior);
   jfrVentana.pack();
   jfrVentana.setResizable(false);
   jfrVentana.setVisible(true);
   jfrVentana.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
   jfrVentana.setBounds(4, 5, 500, 400);
 }
Example #18
0
 public void removeContactWindow() {
   removeWindow = new JFrame("Remove Contacts");
   removeWindow.setLayout(new BorderLayout());
   contactList = new ContactListCheckBox(cList);
   removeWindow.add(contactList, BorderLayout.CENTER);
   // Add List here
   removeWindow.add(deleteContact, BorderLayout.SOUTH);
   removeWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
   removeWindow.pack();
   removeWindow.setVisible(true);
 }
Example #19
0
  public void CreateFrame() throws IOException {

    makeFrame();

    JFrame f;
    f = new JFrame();
    // f.setSize(1300, 800);
    f.setLayout(new BorderLayout());
    f.add(panel);
    f.pack();
    f.setVisible(true);
  }
Example #20
0
  public void launchFrame() {
    JFrame frame = new JFrame("Mensajero");
    frame.setLayout(new BorderLayout());
    frame.add(Salida, BorderLayout.CENTER);
    frame.add(Entrada, BorderLayout.SOUTH);

    JPanel p1 = new JPanel();
    p1.setLayout(new GridLayout(2, 1));
    p1.add(Enviar);
    p1.add(Salir);

    frame.addWindowListener(new CerrarHandler());
    frame.add(p1, BorderLayout.EAST);
    frame.pack();
    frame.setVisible(true);
  }
Example #21
0
  Jf() {

    j.setBounds(500, 40, 500, 500);
    j.setVisible(true);
    j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    j.setLayout(null);
    ImageIcon image = new ImageIcon("im1.jpg");
    JLabel l = new JLabel(image);
    int m = image.getIconWidth();
    int m1 = image.getIconHeight();
    j.setResizable(false); // frame resize nahi hoga	
    l.setBounds(0, 0, m, m1);
    j.add(l);
    l.add(linfo);
    l.add(lid);
    l.add(fid);
    l.add(lpass);
    l.add(fpass);
    fpass.setEchoChar('*');

    l.add(blogin);
    l.add(bnewaccount);
    l.add(bforget);

    ImageIcon image1 = new ImageIcon("logo1.png");
    JLabel limage = new JLabel(image1);
    l.add(limage);
    limage.setBounds(10, 50, 190, 130);

    Font f = new Font("ALGERIAN", Font.BOLD, 20);
    linfo.setFont(f);
    linfo.setBounds(40, 10, 420, 30);
    lid.setBounds(210, 50, 70, 30);
    fid.setBounds(290, 50, 150, 30);
    lpass.setBounds(210, 90, 70, 30);
    fpass.setBounds(290, 90, 150, 30);
    blogin.setBounds(210, 130, 100, 50);
    bnewaccount.setBounds(320, 130, 160, 20);
    bforget.setBounds(320, 160, 160, 20);
    blogin.setBackground(Color.green);
    bnewaccount.setBackground(Color.cyan);
    bforget.setBackground(Color.pink);

    blogin.addActionListener(new Login());
    bnewaccount.addActionListener(new Account());
    bforget.addActionListener(new Forget());
  }
  public void init() {
    frame = new JFrame();
    frame.setLayout(new FlowLayout());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setTitle("PersistentFrameTest");
    frame.setSize(400, 200);

    JButton loadButton = new JButton("Load");
    frame.add(loadButton);
    loadButton.addActionListener(EventHandler.create(ActionListener.class, this, "load"));

    JButton saveButton = new JButton("Save");
    frame.add(saveButton);
    saveButton.addActionListener(EventHandler.create(ActionListener.class, this, "save"));

    frame.setVisible(true);
  }
Example #23
0
  private void mostrarGUI() {
    janela = new JFrame("Java Swing Examples");
    janela.setSize(400, 400);
    janela.setLayout(new GridLayout(3, 1));

    janela.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent windowEvent) {
            System.exit(0);
          }
        });

    statusLabel = new JLabel("", JLabel.CENTER);
    statusLabel.setSize(350, 100);

    controlPanel = new JPanel();
    controlPanel.setLayout(new FlowLayout());

    ImageIcon icon = criarImageIcon("/resources/home153.png", "Home");

    JButton okButton = new JButton("OK");
    // JButton homeButton = new JButton("Home", icon);

    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            statusLabel.setText("Clicou no Botao Ok.");
          }
        });

    /*
       homeButton.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
             statusLabel.setText("Clicou no Botao Home.");
          }
       });
    */

    controlPanel.add(okButton);
    // controlPanel.add(homeButton);

    janela.add(statusLabel);
    janela.add(controlPanel);
    janela.setVisible(true);
  }
 private void setupBoard() {
   JFrame mainBoard = new JFrame("Tic-Tac-Toe");
   mainBoard.setSize(300, 300);
   mainBoard.setLayout(new GridLayout(3, 3));
   mainBoard.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   int place = 1;
   for (int row = 0; row < 3; row++) {
     for (int column = 0; column < 3; column++) {
       button[row][column] = new JButton("");
       button[row][column].setName(Integer.toString(place));
       button[row][column].addActionListener(new ButtonListener(row, column));
       button[row][column].setFont(new Font("", Font.PLAIN, 55));
       mainBoard.add(button[row][column]);
       place += 1;
     }
   }
   mainBoard.setVisible(true);
 }
 public static void main(String[] args) {
   JLabel labelLoto = new JLabel();
   // Creation d'un bouton mettant a jour
   // le label avec un nouveau tirage de
   // loto grace au listener de classe
   // com.eteks.test.NouveauTirage
   JButton boutonLoto = new JButton("Nouveau tirage");
   boutonLoto.addActionListener(new NouveauTirage(labelLoto));
   // Affichage du bouton et du label l'un
   // sous l'autre dans une fenetre
   JFrame fenetre = new JFrame("Loto");
   fenetre.setLayout(new GridLayout(2, 1));
   fenetre.add(boutonLoto);
   fenetre.add(labelLoto);
   fenetre.pack();
   fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   fenetre.setVisible(true);
 }
Example #26
0
 // main test method
 public static void main(String[] args) {
   JFrame testFrame = new JFrame();
   testFrame.setLayout(new GridLayout(2, 2));
   MineButton button1 = new MineButton();
   MineButton button2 = new MineButton();
   MineButton button3 = new MineButton();
   MineButton button4 = new MineButton();
   button2.setType(MineButton.MINE);
   button3.setNumber(5);
   ;
   testFrame.add(button1);
   testFrame.add(button2);
   testFrame.add(button3);
   testFrame.add(button4);
   testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   testFrame.pack();
   testFrame.setLocationRelativeTo(null);
   testFrame.setVisible(true);
 }
Example #27
0
  public GridDemo() {
    _frame.setSize(WIDTH, HEIGHT);
    // Close program when window is closed
    _frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    _frame.setLayout(new GridLayout(3, 3));

    for (int j = 0; j < 9; j++) {
      _buttons[j] = new JButton("_");
      ActionListener buttonListener = new ButtonListener();
      _buttons[j].addActionListener(buttonListener);
      _buttons[j].setFont(new Font("Courier", Font.PLAIN, 48));
      _frame.add(_buttons[j]);
    }

    // Refresh window - otherwise we will not be able to see it
    // THIS IS A COMMON SOURCE OF BUGS!
    _frame.setVisible(true);
  }
Example #28
0
  public void buildmemberframe() {

    f.setSize(400, 400);
    f.setLayout(new GridLayout(9, 1));
    f.setLocationRelativeTo(null);
    f.setResizable(false);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(check);
    f.add(evaluate);
    f.add(checkgrade);
    f.add(pu);
    f.add(bandblog);
    f.add(share);
    f.add(personal);
    f.add(changepassword);
    f.add(logoff);
    f.setVisible(true);

    // 如果查看状态是1--未看,那么打开团员窗口自动弹出最新团内消息
    // 并把查看状态设为2--已看
    try {
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // 连接数据库
      Connection c = DriverManager.getConnection("jdbc:odbc:bandmanagerDatabase");
      Statement s = c.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
      ResultSet r = s.executeQuery("select * From personlist");
      r.beforeFirst();
      while (r.next()) {
        if (r.getString("username").equals(username)) {
          if (r.getInt("checkstatus") == 1) {
            JOptionPane.showMessageDialog(null, checkcontent);
            s.executeUpdate(
                "update personlist set checkstatus=2 where username=\'" + username + "\'");
          }
          break;
        }
      }
      s.close();
      c.close();
    } catch (Exception ex) {
      System.err.println("Exception :" + ex);
      ex.printStackTrace();
    }
  }
  private static void drawGUI() {
    JFrame frame = new JFrame("Week1ProgrammingAssignment ");

    frame.setLayout(new BorderLayout());
    JLabel label = new JLabel("You are successfully running a Swing applet!");
    label.setHorizontalAlignment(JLabel.CENTER);

    JTable table = new JTable(new CharTableModel(resultLetters, key));

    table.setSurrendersFocusOnKeystroke(true);
    JScrollPane pane = new JScrollPane(table);
    pane.setPreferredSize(new Dimension(1300, 300));

    frame.add(pane, BorderLayout.CENTER);

    frame.pack();
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
Example #30
0
  public void initUI() {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      JPopupMenu.setDefaultLightWeightPopupEnabled(false);
      frame = new JFrame("Project Benelux | 317 | Fullscreen - Resizeable");
      frame.setLayout(new BorderLayout());
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      gamePanel = new JPanel();
      new AutoUpdater().run();
      webclient = false;
      gamePanel.setLayout(new BorderLayout());
      gamePanel.add(this);
      JMenu fileMenu = new JMenu("File");

      String[] mainButtons = new String[] {"-", "Exit", "-"};

      for (String name : mainButtons) {
        JMenuItem menuItem = new JMenuItem(name);
        if (name.equalsIgnoreCase("-")) {
          fileMenu.addSeparator();
        } else {
          menuItem.addActionListener(this);
          fileMenu.add(menuItem);
        }
      }

      JMenuBar menuBar = new JMenuBar();
      JMenuBar jmenubar = new JMenuBar();
      Dimension dimension1 = new Dimension(765 + 16, 503 + 59);
      frame.setMinimumSize(dimension1);
      frame.add(jmenubar);
      menuBar.add(fileMenu);
      frame.getContentPane().add(menuBar, BorderLayout.NORTH);
      frame.getContentPane().add(gamePanel, BorderLayout.CENTER);
      frame.pack();

      frame.setVisible(true); // can see the client
      frame.setResizable(true); // resizeable frame
      init();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }