Exemple #1
0
  public static void main(String[] args) {

    try {
      // myFrame.add(newSubPanel);

      JTabbedPane tabbedPane = new JTabbedPane();
      isSmall = true;
      // tabbedPane.add(new JButton("asd"));
      JMenuBar menuBar = new JMenuBar();
      // menuBar.add(tabbedPane);
      menuBar.setBackground(Color.white);
      menuBar.setVisible(true);
      menuBar.add(new ResolutionButton());
      menuBar.add(new NextPanelbutton(false));
      menuBar.add(new NextPanelbutton(true));
      // menuBar.setPreferredSize(new Dimension(1024, 20));
      UpploaderView u = new UpploaderView();
      tabbedPane.addTab("Channel", u);
      tabbedPane.addTab("Videos", newSubPanel);
      //	menuBar.add(tabbedPane);
      // tabbedPane.setTabComponentAt(0,menuBar);

      // myFrame.add(u);
      // myFrame.add(tabbedPane);
      //	myFrame.setLayout(new FlowLayout());
      // Toolkit toolkit = Toolkit.getDefaultToolkit();
      // System.out.println(toolkit.getScreenSize().width+"x"+toolkit.getScreenSize().height);
      myFrame.setSize(1024, 600);
      myFrame.setJMenuBar(menuBar);
      myFrame.addWindowListener(new WindowClose());
      myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      myFrame.setVisible(true);
      Dimension panelDim = myFrame.getRootPane().getSize();
      // myFrame.add(newSubPanel);
      for (int i = 0; i < 3; i++) {
        if (i == 0) {
          newSubs = new DoublePanelStack(new NewSubVideoPanel(panelDim));
          myFrame.add(newSubs.getCurrentPanel());
          myFrame.validate();
          myFrame.repaint();
        }
        if (StatCol.newsubsStartIndex < StatCol.MAXNEWSUBVIDEOS)
          newSubs.add(new NewSubVideoPanel(panelDim));
      }
      // u.init();
      // sub2 = new NewSubVideoPanel(newSubPanel.init(),panelDim);
      myFrame.validate();
      // myFrame.pack();

    } catch (AuthenticationException e) {
      e.printStackTrace();
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (ServiceException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Exemple #2
0
  /** This function initializes and displays a Slick2D frame */
  public void showSlick() {
    try {
      if (game == null) {
        game = new TestGame();
      }
      contain = new NSlixContainer(game);
      contain.setSize(sizex, sizey);
      window.add(contain, BorderLayout.CENTER);
      window.setSize(sizex, sizey);
      window.add(textfield, BorderLayout.SOUTH);
      window.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
      window.addWindowListener(
          new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
              // SlixLibrary.removeAllScreens();
              // SlixLibrary.updateScreens();
              window.dispose();
              System.exit(0);
            }
          });
      textfield.setFocusable(true);
      window.validate();
      window.setVisible(true);
      window.pack();
      contain.start();
    } catch (SlickException ex) {
      System.err.println(ex);
    }
  }
  @Override
  public void showMenuCaja(CajaController cc, JFrame f, Usuario u) {

    usuario = u;

    System.out.println("SHOW CAJA");

    cajaController = cc;
    frame = f;

    PanelGeneral panelGeneral = new PanelGeneral(u);

    listenerCajaVolver = new ListenerCajaVolver(cc);
    listenerVerMovimientos = new ListenerVerMovimientos(cc);
    listenerVerOtrosMovimientos = new ListenerVerOtrosMovimientos(cc);

    panelCajaMenu.getBtnVolver().addActionListener(listenerCajaVolver);
    panelCajaMenu.getBtnVerMovs().addActionListener(listenerVerMovimientos);
    panelCajaMenu.getBtnVerUnDia().addActionListener(listenerVerOtrosMovimientos);

    frame.setTitle("Menu Caja");
    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    frame.getContentPane().removeAll();
    frame.getContentPane().add(panelGeneral, BorderLayout.PAGE_START);
    frame.getContentPane().add(panelCajaMenu, BorderLayout.WEST);
    frame.getContentPane().add(panelCaja, BorderLayout.LINE_END);
    frame.validate();
    frame.repaint();
  }
Exemple #4
0
  public Processing(Box root) {
    super(null);

    Log.log("startup.processing", " processing plugin is starting up ");

    frame = new JFrame("Field/Processing");
    __applet =
        new FieldProcessingApplet(
            sizeX,
            sizeY,
            queue,
            this,
            s -> {
              if (getLastErrorOutput() != null) getLastErrorOutput().accept(new Pair<>(-1, s));
            });

    __applet.init();
    __applet.loop();
    frame.add(__applet, BorderLayout.CENTER);
    frame.setSize(sizeX, sizeY);
    frame.setVisible(true);
    frame.validate();

    applet = new FieldProcessingAppletDelgate(__applet);

    this.properties.put(P, applet);

    Log.log("startup.processing", " searching for boxes that need processing support ");

    Log.log("startup.processing", " processing plugin has finished starting up ");
  }
  public static void main(String[] args) {

    JFrame frame = new WarGameGUI();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // frame.pack();
    frame.setMinimumSize(new Dimension(900, 750));
    frame.validate();
    frame.setVisible(true);
  }
Exemple #6
0
 public static void prevPanel() {
   if (currentStack.hasPrev()) {
     myFrame.remove(currentStack.getCurrentPanel());
     myFrame.add(currentStack.getPrev());
     currentStack.getCurrentPanel().setVisible(true);
     myFrame.validate();
     myFrame.repaint();
   }
 }
  public void actionPerformed(ActionEvent event) {
    Thread.currentThread().setContextClassLoader(cl);

    final JFrame frame = new JFrame("REPL connect");
    final Container cp = frame.getContentPane();
    final JLabel initLabel = new JLabel("Initializing Clojure");

    cp.add(initLabel);
    frame.setSize(200, 100);
    frame.setVisible(true);
    frame.validate();
    frame.repaint();

    final Runnable after =
        new Runnable() {
          public void run() {
            Thread.currentThread().setContextClassLoader(cl);
            Var newDialog = RT.var("protege.dialog", "new-dialog-panel");
            cp.removeAll();
            JPanel dialog = (JPanel) newDialog.invoke(getOWLEditorKit());

            cp.add(dialog);
            frame.pack();
            frame.setVisible(true);
            frame.validate();
            frame.repaint();
          }
        };

    final Runnable before =
        new Runnable() {
          public void run() {
            Thread.currentThread().setContextClassLoader(cl);
            try {
              if (!clojureInit) {
                synchronized (lock) {
                  RT.loadResourceScript("protege/dialog.clj");
                  RT.loadResourceScript("protege/nrepl.clj");
                  initLabel.setText("Reading User Init");
                  Var init = RT.var("protege.nrepl", "init");
                  init.invoke();
                  clojureInit = true;
                }
              }
              SwingUtilities.invokeAndWait(after);

            } catch (Exception exp) {
              throw new RuntimeException(exp);
            }
          }
        };

    new Thread(before).start();
  }
  /*
   * FrameSize Control
   */
  public void validate() {
    Rectangle rect = getBounds();

    super.validate();

    int width = ViewSettings.getTokuteiLoginFrameWidth();
    int height = ViewSettings.getTokuteiLoginFrameHeight();

    if (width > rect.width || height > rect.height) {
      setBounds(rect.x, rect.y, width, height);
    }
  }
Exemple #9
0
 // ****************************************
 protected void show_text(String title, String text)
       // ****************************************
     {
   JFrame help_frame = new JFrame(title);
   JTextArea ta = new JTextArea();
   ta.setText(text);
   help_frame.add(ta);
   help_frame.pack();
   help_frame.setLocationRelativeTo(null);
   help_frame.validate();
   help_frame.setVisible(true);
 }
 private void setLayout() {
   GroupLayout layout = new GroupLayout(dialog.getContentPane());
   dialog.getContentPane().setLayout(layout);
   dialog.setResizable(true);
   layout.setAutoCreateContainerGaps(true);
   layout.setHorizontalGroup(layout.createParallelGroup().addComponent(tabbedPane));
   layout.setVerticalGroup(layout.createParallelGroup().addComponent(tabbedPane));
   layout.setHonorsVisibility(tabbedPane, true);
   // TODO set color here
   dialog.getContentPane().setBackground(new Color(0x132638));
   dialog.validate();
   dialog.repaint();
 }
  /** Float cytoPanel */
  private void FloatCytoPanel() {
    // show ourselves
    showCytoPanel(CytoPanelState.FLOAT);

    if (!isFloating()) {
      // new window to place this CytoPanel
      externalWindow = new JFrame(parent.getGraphicsConfiguration());

      // add listener to handle when window is closed
      addWindowListener();

      //  Add CytoPanel to the New External Window
      Container contentPane = externalWindow.getContentPane();
      contentPane.add(this, BorderLayout.CENTER);
      final Dimension windowSize = this.getSize();

      externalWindow.setSize(windowSize);
      externalWindow.validate();

      // set proper title of window
      externalWindow.setTitle(getTitle());

      // set proper button icon/text
      floatButton.setText(ICON_THUMB_TACK);
      floatButton.setToolTipText(TOOL_TIP_DOCK);

      // set float label text
      floatLabel.setText("");

      // set location of external window
      setLocationOfExternalWindow(externalWindow);
      // lets show it
      externalWindow.setVisible(true);

      // set our new state
      this.cytoPanelState = CytoPanelState.FLOAT;

      // re-layout
      this.validate();

      // SOUTH_WEST is used for manualLayout, it is nested in WEST
      if (compassDirection == CytoPanelName.SOUTH_WEST) {
        try {
          this.getParent().getParent().validate();
        } catch (Exception e) {
        }
      }
    }
  }
 /** This method allows you to draw additional data of the individual */
 @Override
 public void showIndividual() {
   JFrame newFrame = new JFrame();
   newFrame.setTitle(this.individual.getName() + ": " + this.individual);
   newFrame.addWindowListener(
       new WindowAdapter() {
         @Override
         public void windowClosing(WindowEvent ev) {
           System.gc();
         }
       });
   newFrame.getContentPane().add(this.optimizationProblem.drawIndividual(-1, -1, this.individual));
   newFrame.setSize(200, 300);
   newFrame.pack();
   newFrame.validate();
   newFrame.setVisible(true);
 }
  /** refreshes the 4 charts and the transactionList */
  public void refresh() {

    // refresh total balance
    double balance = transactionMgr.getBalance();
    financesBalance_LBL.setText("You have $" + balance);
    if (balance < 0)
      financesBalance_LBL.setIcon(new ImageIcon(Finances.class.getResource("/img/Warning.png")));
    else financesBalance_LBL.setIcon(null);

    // refresh 4 types
    DefaultCategoryDataset AssetDataset = new DefaultCategoryDataset();
    AssetDataset = TransactionMgr.getAssetChartData();
    financesAsset_PNL.removeAll();
    financesAsset_PNL.add(renderBarChart(AssetDataset, 0));
    financesAsset_PNL.add(financesRenameAssetCat_BTN);
    financesAsset_PNL.add(financesAssetTransfer_BTN);

    DefaultCategoryDataset LiabilityDataset = new DefaultCategoryDataset();
    LiabilityDataset = TransactionMgr.getLiabilityChartData();
    financesLiability_PNL.removeAll();
    financesLiability_PNL.add(renderBarChart(LiabilityDataset, 1));
    financesLiability_PNL.add(financesRenameLiabilityCat_BTN);
    financesLiability_PNL.add(financesLiabilityTransfer_BTN);

    DefaultCategoryDataset IncomeDataset = new DefaultCategoryDataset();
    IncomeDataset = TransactionMgr.getIncomeChartData();
    financesIncome_PNL.removeAll();
    financesIncome_PNL.add(renderBarChart(IncomeDataset, 2));
    financesIncome_PNL.add(financesRenameIncomeCat_BTN);

    DefaultCategoryDataset ExpenseDataset = new DefaultCategoryDataset();
    ExpenseDataset = TransactionMgr.getExpenseChartData();
    financesExpense_PNL.removeAll();
    financesExpense_PNL.add(renderBarChart(ExpenseDataset, 3));
    financesExpense_PNL.add(financesRenameExpenseCat_BTN);

    // refresh transactionList
    financesTransactionList_PNL.removeAll();
    renderList(financesTransactionList_PNL, TransactionMgr.getTransactionList());

    // refresh line chart
    financesLineChart_PNL.add(renderLineChart(TransactionMgr.getLineChartData()));

    financesMain_FRM.validate();
  }
 @Override
 public void actionPerformed(ActionEvent event) {
   JFrame frame = new JFrame();
   frame.setTitle(
       "The current best solution for " + optimizationParameters.getProblem().getName());
   frame.setSize(400, 300);
   frame.setLocation(450, 250);
   Population pop = optimizationParameters.getOptimizer().getPopulation();
   frame
       .getContentPane()
       .add(
           optimizationParameters
               .getProblem()
               .drawIndividual(
                   pop.getGeneration(), pop.getFunctionCalls(), pop.getBestEAIndividual()));
   frame.validate();
   frame.setVisible(true);
 }
  private void refreshTable() {

    try {
      if (scrollPane.isAncestorOf(table)) {
        frame.remove(scrollPane);
        scrollPane.remove(table);
        frame.validate();
        frame.repaint();
      }
    } catch (NullPointerException e) {

    }

    DefaultTableModel dm = new DefaultTableModel();
    dm.setDataVector(getValuesArray(), new Object[] {"Name", ""});

    table = new JTable(dm);
    table.getColumn("").setMaxWidth(120);
    table.getColumn("").setCellRenderer(new ButtonRenderer());
    table.getColumn("").setCellEditor(new ButtonEditor(new JCheckBox()));

    table
        .getModel()
        .addTableModelListener(
            new TableModelListener() {

              @Override
              public void tableChanged(TableModelEvent e) {

                int row = e.getFirstRow();
                int column = e.getColumn();
                TableModel model = (TableModel) e.getSource();
                String columnName = model.getColumnName(column);
                String newValue = model.getValueAt(row, column).toString();

                eaArrayList_RenamededFolders.add(
                    new EA_Rename(EA_Utils.getColumnsArrayList().get(row), newValue, row));
              }
            });

    scrollPane = new JScrollPane(table);
    scrollPane.setBounds(10, 11, 371, 206);
    frame.getContentPane().add(scrollPane);
  }
Exemple #16
0
  private void loadGUI() {
    clientFrame = new JFrame("Client File Transfer Control Panel");
    clientFrame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            ClientMain.terminate();
          }
        });
    clientFrame.setMaximumSize(new Dimension(1920, 1080));
    buttonPanel = new JPanel();
    selectPanel = new JPanel();
    controlPanel = new JPanel();
    controlPanel.setLayout(new BorderLayout());
    displayPanel = new JPanel();
    displayPanel.setLayout(new BorderLayout());
    receivePanel = new JPanel();
    receivePanel.setLayout(new BorderLayout());
    receiveControlPanel = new JPanel();
    receiveControlPanel.setLayout(new BorderLayout());
    statusPanel = new JPanel();
    statusPanel.setLayout(new BorderLayout());

    setUpButtonPanel();
    setUpSelectBox();
    setUpDisplayPanel();
    setUpStatusPanel();
    setUpReceivePanel();

    receiveControlPanel.add(receivePanel, BorderLayout.WEST);
    receiveControlPanel.add(displayPanel, BorderLayout.CENTER);
    controlPanel.add(buttonPanel, BorderLayout.NORTH);
    controlPanel.add(receiveControlPanel, BorderLayout.CENTER);
    clientFrame.add(controlPanel, BorderLayout.CENTER);

    clientFrame.validate();
    clientFrame.pack();
    clientFrame.setVisible(true);

    // add action listener
    input.addActionListener(new InputDirectoryChooser());
    output.addActionListener(new OutputDirectoryChooser());
    receive.addActionListener(new Receive());
  }
Exemple #17
0
 public void actionPerformed(ActionEvent ae) {
   JButton button = (JButton) ae.getSource();
   if (button == high) {
     frame.remove(main);
     frame.setContentPane(scores);
   }
   if (button == cred) {
     frame.remove(main);
     frame.setContentPane(credits);
   }
   if (button == start) {
     frame.remove(main);
     frame.setContentPane(story);
   }
   if (button == stor) {
     frame.remove(story);
     frame.setContentPane(tutorial);
   }
   if (button == tutor) {
     frame.remove(main);
     DesktopLauncher a = new DesktopLauncher();
     a.run();
   }
   if (button == returns1) {
     frame.remove(scores);
     frame.setContentPane(main);
   }
   if (button == returns2) {
     frame.remove(credits);
     frame.setContentPane(main);
   }
   if (button == returns3) {
     frame.remove(story);
     frame.setContentPane(main);
   }
   if (button == returns4) {
     frame.remove(tutorial);
     frame.setContentPane(story);
   }
   frame.validate();
   frame.repaint();
 }
Exemple #18
0
 // ****************************************
 void show_files(List<File> ll)
       // ****************************************
     {
   if (show_files_frame != null) show_files_frame.dispose();
   show_files_frame = new JFrame("Files: ");
   JTextArea ta = new JTextArea();
   String s = "";
   if (ll.isEmpty() == true) {
     s = "No files for this session\n";
   }
   for (File f : ll) {
     s += f.getAbsolutePath() + "\n";
   }
   ta.setText(s);
   show_files_frame.add(ta);
   show_files_frame.pack();
   show_files_frame.setLocationRelativeTo(null);
   show_files_frame.validate();
   show_files_frame.setVisible(true);
 }
Exemple #19
0
 public static void openFrame(Object frame) {
   boolean packFrame = false;
   if (packFrame) {
     ((JFrame) frame).pack();
   } else {
     ((JFrame) frame).validate();
   }
   // Center the window
   Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
   Dimension frameSize = ((JFrame) frame).getSize();
   if (frameSize.height > screenSize.height) {
     frameSize.height = screenSize.height;
   }
   if (frameSize.width > screenSize.width) {
     frameSize.width = screenSize.width;
   }
   ((JFrame) frame)
       .setLocation(
           (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
   ((JFrame) frame).setVisible(true);
 }
Exemple #20
0
  private void initGUI() {
    JMenuItem close =
        new JMenuItem(
            new AbstractAction("Close") {
              @Override
              public void actionPerformed(ActionEvent e) {
                frame.dispose();
              }
            });

    JMenuBar bar = new JMenuBar();
    bar.add(close);

    frame = new JFrame();
    frame.add(new JLabel("Teste"));
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setJMenuBar(bar);
    frame.setUndecorated(true);
    frame.setSize(400, 300);
    frame.validate();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    MouseAdapter adapter =
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent ev) {
            frameMousePressed(ev);
          }

          @Override
          public void mouseDragged(MouseEvent ev) {
            frameMouseDragged(ev);
          }
        };
    frame.addMouseListener(adapter);
    frame.addMouseMotionListener(adapter);
  }
Exemple #21
0
  static void GoEnd(JFrame frame, int i) {
    Image background = new ImageIcon("image/final_" + i + ".png").getImage();
    background =
        background.getScaledInstance(frame.getWidth(), frame.getHeight(), Image.SCALE_DEFAULT);
    JLabel back = new JLabel();
    back.setBounds(0, 0, frame.getWidth(), frame.getHeight());
    back.setIcon(new ImageIcon(background));
    frame.add(back, 1);
    frame.validate();
    frame.repaint();
    if (i == 1) { // 烤好
      Talk.say("你成功的通過了這學期", 1);
      Talk.say("這次經驗也讓你對學習產生濃烈的興趣", 1);
      Talk.say("讓你大四成為了神,進而順利畢業", 1);

    } else if (i == 2) { // 系館
      Talk.say("經由你的捐贈", 1);
      Talk.say("資訊系逐漸自成一個校區", 1);
      Talk.say("而在原系館中庭擺放了一個十倍放大的銅像", 1);
      Talk.say("用來紀念資訊系傑出校友─大恩碩像", 1);

    } else if (i == 3) { // 出國
      Talk.say("你放棄了學業,踏上了桌球國手之路", 1);
      Talk.say("過五關斬六將", 1);
      Talk.say("終於成為了世界桌球王", 1);

    } else if (i == 4) { // 0分 game over
      Talk.say("輕輕的我走了", 1);
      Talk.say("正如我輕輕地來", 1);
      Talk.say("我揮一揮衣袖", 1);
      Talk.say("不帶走任何學分", 1);
    } else if (i == 5) { // final
      Talk.say("你完成了final project", 1);
      Talk.say("跟其他同學一起過了OOP", 1);
      Talk.say("不過大四還有更嚴苛的挑戰在等著你", 1);
      Talk.say("同學!加油吧!", 1);
    }
  }
  /** Method to pop the GUI in the middle of the screen */
  private void displayFrame(JFrame aFrame) {
    // first center the frame
    GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Point c = e.getCenterPoint();
    Rectangle bounds = e.getMaximumWindowBounds();

    int w = Math.max(bounds.width / 2, Math.min(aFrame.getWidth(), bounds.width));
    int h = Math.max(bounds.height / 2, Math.min(aFrame.getHeight(), bounds.height));
    int x = c.x - w / 2;
    int y = c.y - h / 2;
    aFrame.setBounds(x, y, w, h);
    if (w == bounds.width && h == bounds.height) {
      aFrame.setExtendedState(Frame.MAXIMIZED_BOTH);
    }

    aFrame.validate();

    // then show it
    aFrame.pack();
    aFrame.setVisible(true);
    aFrame.setResizable(true);
    aFrame.toFront();
  }
Exemple #23
0
  /** Stand alone testing. */
  public static void main(String[] args) {
    try {
      JFrame frame = new JFrame("JargonTree");
      JargonTree tree = new JargonTree(args, null);

      JScrollPane pane = new JScrollPane(tree);
      pane.setPreferredSize(new Dimension(800, 600));

      frame.addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent we) {
              System.exit(0);
            }
          });
      frame.getContentPane().add(pane, BorderLayout.NORTH);
      frame.pack();
      frame.show();
      frame.validate();

    } catch (Throwable e) {
      e.printStackTrace();
      System.out.println(((SRBException) e).getStandardMessage());
    }
  }
Exemple #24
0
  public static void removeBrick(int x, int y) {
    int i = 0;
    for (Position pos : posBrick) {
      if (pos.getColumn() == y && pos.getRow() == x) {

        gamePlay.remove(jlistBrick.get(i));
        gamePlay.validate();
        jframe.validate();
        gamePlay.repaint();
        if (pos.equals(winPos)) {
          ImageIcon im = new ImageIcon("ali.png");
          JLabel jl = new JLabel(im);
          gamePlay.add(jl);
          jl.setBounds(
              pos.getRow() * BomborMan.unit,
              pos.getColumn() * BomborMan.unit,
              jl.getPreferredSize().width,
              jl.getPreferredSize().height);
          gameWin();
        }
      }
      i++;
    }
  }
  public BaseballController() {

    // Connect to Database

    try {
      dataBase = new DBWrapper();
    } catch (SQLException e) {
      e.printStackTrace();
    }

    screen = new JFrame("Math Baseball");
    screen.setExtendedState(Frame.MAXIMIZED_BOTH);
    screen.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    inputManager = new InputManager(screen);
    createGameActions();
    loginPanel = new BackGroundPanel();
    loginPanel.setPreferredSize(screen.getSize());
    loginPanel.setOpaque(false);
    loginPanel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.HORIZONTAL;

    uNameField = new JTextField();
    TextPrompt uText = new TextPrompt("Username", uNameField, TextPrompt.Show.FOCUS_LOST);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 1;
    loginPanel.add(uNameField, constraints);

    pWordField = new JPasswordField();
    TextPrompt pText = new TextPrompt("Password", pWordField, TextPrompt.Show.FOCUS_LOST);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 2;
    loginPanel.add(pWordField, constraints);

    isTeacher = new JRadioButton("Teacher");
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 3;
    loginPanel.add(isTeacher, constraints);

    loginButton = createButton("loginButton", "To Login");
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 4;
    loginPanel.add(loginButton, constraints);

    registerButton = new JButton("Register");
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 5;
    constraints.anchor = GridBagConstraints.PAGE_END;
    loginPanel.add(registerButton, constraints);

    Container contentPane = screen.getContentPane();
    // make sure the content pane is transparent
    if (contentPane instanceof JComponent) {
      ((JComponent) contentPane).setOpaque(false);
    }
    // add components to the screen's content pane
    contentPane.add(loginPanel);
    screen.setVisible(true);
    screen.validate();
    // screen.repaint();
    // add listeners
    isTeacher.addActionListener(this);
    loginButton.addActionListener(this);
    registerButton.addActionListener(this);
  }
Exemple #26
0
 /** Ustawia ponownie elementy w oknie(najlepiej używać przy dodaniu/usuwaniu kontaktów). */
 public void validate() {
   window.validate();
 }
 @Override
 protected void validateTree() {
   super.validateTree();
   if (target instanceof JFrame) ((JFrame) target).getRootPane().validate();
   else if (target instanceof JDialog) ((JDialog) target).getRootPane().validate();
 }
Exemple #28
0
 /** shows the JFrame and re-validates repaints the JFrame if need be */
 protected static void setVisible() {
   window.validate();
   window.repaint();
   window.setVisible(true);
 }
Exemple #29
0
  public void setFrame() {
    f = new JFrame("数据通讯参数设置");
    // 获取屏幕分辨率的工具集
    Toolkit tool = Toolkit.getDefaultToolkit();
    // 利用工具集获取屏幕的分辨率
    Dimension dim = tool.getScreenSize();
    // 获取屏幕分辨率的高度
    int height = (int) dim.getHeight();
    // 获取屏幕分辨率的宽度
    int width = (int) dim.getWidth();
    // 设置位置
    f.setLocation((width - 300) / 2, (height - 400) / 2);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
    f.setContentPane(this);
    f.setSize(320, 260);
    f.setResizable(false);

    lblIP = new JLabel("主机名");
    txtIp = new JTextField(20);
    try {
      InetAddress addr = InetAddress.getLocalHost();
      txtIp.setText(addr.getHostAddress().toString());
    } catch (Exception ex) {
    }

    lblNo = new JLabel("端口号");
    cmbNo = new JComboBox();
    cmbNo.setEditable(true);
    cmbNo.addPopupMenuListener(
        new PopupMenuListener() {
          @Override
          public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            cmbNo.removeAllItems();
            CommPortIdentifier portId = null;
            Enumeration portList;
            portList = CommPortIdentifier.getPortIdentifiers();
            while (portList.hasMoreElements()) {
              portId = (CommPortIdentifier) portList.nextElement();
              cmbNo.addItem(portId.getName());
            }
          }

          @Override
          public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            // To change body of implemented methods use File | Settings | File Templates.
          }

          @Override
          public void popupMenuCanceled(PopupMenuEvent e) {
            // To change body of implemented methods use File | Settings | File Templates.
          }
        });

    lblName = new JLabel("工程名");
    txtProjectName = new JComboBox();
    txtProjectName.setEditable(true);
    txtProjectName.addPopupMenuListener(
        new PopupMenuListener() {
          @Override
          public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            txtProjectName.removeAllItems();
            Mongo m1 = null;
            try {
              m1 = new Mongo(txtIp.getText().toString(), 27017);
            } catch (UnknownHostException ex) {
              ex.printStackTrace();
            }
            for (String name : m1.getDatabaseNames()) {
              txtProjectName.addItem(name);
            }
            m1.close();
          }

          @Override
          public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            // To change body of implemented methods use File | Settings | File Templates.
          }

          @Override
          public void popupMenuCanceled(PopupMenuEvent e) {
            // To change body of implemented methods use File | Settings | File Templates.
          }
        });

    lblBote = new JLabel("波特率");
    cmbBote = new JComboBox();
    cmbBote.addItem(9600);
    cmbBote.addItem(19200);
    cmbBote.addItem(57600);
    cmbBote.addItem(115200);

    lblLength = new JLabel("数据长度");
    cmbLength = new JComboBox();
    cmbLength.addItem(8);
    cmbLength.addItem(7);

    lblParity = new JLabel("校验");
    cmbParity = new JComboBox();
    cmbParity.addItem("None");
    cmbParity.addItem("Odd");
    cmbParity.addItem("Even");

    lblStopBit = new JLabel("停止位");
    cmbStopBit = new JComboBox();
    cmbStopBit.addItem(1);
    cmbStopBit.addItem(2);

    lblDelay = new JLabel("刷新");
    txtDelay = new JTextField(20);

    btnOk = new JButton("确定");
    btnOk.addActionListener(
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
            paramIp = txtIp.getText().toString();
            paramName = txtProjectName.getSelectedItem().toString();
            paramNo = cmbNo.getSelectedItem().toString();
            paramBote = Integer.parseInt(cmbBote.getSelectedItem().toString());
            parmLength = Integer.parseInt(cmbLength.getSelectedItem().toString());
            parmParity = cmbParity.getSelectedIndex();
            parmStopBit = Integer.parseInt(cmbStopBit.getSelectedItem().toString());
            parmDelay = Integer.parseInt(txtDelay.getText().toString());

            if (!paramName.equals("") && !paramNo.equals("")) {
              receiveData(
                  paramIp,
                  paramName,
                  paramNo,
                  paramBote,
                  parmLength,
                  parmParity,
                  parmStopBit,
                  parmDelay);
            } else {

            }
          }
        });
    btnCancel = new JButton("取消");
    btnCancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });

    JPanel p1 = new JPanel();
    p1.setLayout(new GridLayout(9, 2));

    p1.add(lblIP);
    p1.add(txtIp);

    p1.add(lblNo);
    p1.add(cmbNo);

    p1.add(lblName);
    p1.add(txtProjectName);

    p1.add(lblBote);
    p1.add(cmbBote);

    p1.add(lblLength);
    p1.add(cmbLength);

    p1.add(lblParity);
    p1.add(cmbParity);

    p1.add(lblStopBit);
    p1.add(cmbStopBit);

    p1.add(lblDelay);
    p1.add(txtDelay);
    txtDelay.setText("500");

    p1.add(btnOk);
    p1.add(btnCancel);

    p1.validate();

    f.add(p1);
    f.validate();
  }
Exemple #30
0
 public static void main(String[] args) {
   JFrame frame = SwingFacade.launch(new MoveATub(), "Move a Tub");
   frame.setSize(600, 250);
   frame.validate();
 }