예제 #1
0
파일: My29.java 프로젝트: Buzov/Java_lesson
 public static void main(String[] args) {
   System.out.println("It is program My");
   // получение списка шрифтов
   String[] fontNames =
       GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
   for (int i = 0; i < fontNames.length; i++) System.out.println(fontNames[i]);
   MyFrame frame = new MyFrame();
   // условие закрытия окна
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.show();
 }
예제 #2
0
  /**
   * Sets the ui enable.
   *
   * @param isEnable should the UI enable?
   * @param isShutdown should the UI shutdown?
   */
  private void setUIEnable(boolean isEnable, boolean isShutdown) {
    String msg = "";
    Color screenColor = Color.RED;

    if (!isEnable) { // disable the UI
      if (isShutdown) {
        msg = "Shutdown";
        screenColor = Color.GRAY;
      } else {
        msg = "Fatal halt";
      }

      myFrame.getContentPane().removeAll(); // remove existing content

      // add new panel
      JPanel panel = new JPanel(new GridBagLayout());
      JLabel label = new JLabel(msg);
      label.setForeground(Color.WHITE);
      panel.setBackground(screenColor);
      panel.add(label, new GridBagConstraints());
      myFrame.getContentPane().add(panel);

      myFrame.getContentPane().revalidate();
      myFrame.getContentPane().repaint();
    } else {
      System.out.println("Enabling frame");
      myFrame.getContentPane().removeAll(); // remove existing content

      myFrame.getContentPane().add(myPanel);

      myFrame.getContentPane().revalidate();
      myFrame.getContentPane().repaint();
    }
  }