Exemple #1
0
  public SudokuGUI(String x) {
    setTitle(x);
    textfield1.setEditable(false);
    button5.setEnabled(false);
    button10.setEnabled(false);
    button13.setEnabled(false);
    button12.setEnabled(false);
    button15.setEnabled(false);
    button18.setEnabled(false);
    setLayout(new GridLayout(6, 4, 4, 4));
    setLocation(350, 300);

    button1.addMouseListener(this);
    button2.addMouseListener(this);
    button3.addMouseListener(this);
    button4.addMouseListener(this);
    button6.addMouseListener(this);
    button7.addMouseListener(this);
    button8.addMouseListener(this);
    button9.addMouseListener(this);
    button11.addMouseListener(this);
    button14.addMouseListener(this);
    button16.addMouseListener(this);
    button17.addMouseListener(this);
    button19.addMouseListener(this);
    button20.addMouseListener(this);
    textfield2.addMouseListener(this);

    add(button1);
    add(button2);
    add(button3);
    add(button4);
    add(button5);
    add(button6);
    add(button7);
    add(button8);
    add(button9);
    add(button10);
    add(button11);
    add(button12);
    add(button13);
    add(button14);
    add(button15);
    add(button16);
    add(button17);
    add(button18);
    add(button19);
    add(button20);
    add(textfield1);
    add(textfield2);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(700, 400);
  }
  private void jbInit() throws Exception {
    // this.setResizable(false);
    this.setSize(ancho, alto);
    this.setLocation(0, 0);

    // this.setUndecorated(true);
    // this.getContentPane().setLayout(null);

    // limites de componentes
    labelFondo.setBounds(
        new Rectangle((int) (ancho / 5), 2 * (alto / 6), (int) (ancho / 1.5), alto / 4));
    botonCancelar.setBounds(
        new Rectangle(
            (int) (2.9 * (ancho / 5)), (int) (2 * (alto / 4)), (int) (ancho / 10.2), alto / 25));
    botonCancelar.setBorder(null);
    // botonAceptar.setBounds(new Rectangle(0, 0, 100, 30));
    botonAceptar.setBounds(
        new Rectangle(
            (int) (2.15 * (ancho / 5)), (int) (2 * (alto / 4)), (int) (ancho / 10.2), alto / 25));
    botonAceptar.setBorder(null);
    textNombre.setFont(new java.awt.Font("Serif", 3, 15));
    textNombre.setBounds(
        new Rectangle((int) (2.5 * (ancho / 5)), (int) (1.5 * (alto / 4)), ancho / 5, alto / 25));
    textNombre.addKeyListener(new PanelNick_textNombre_keyAdapter(this));

    textContra.setFont(new java.awt.Font("Serif", 3, 15));
    textContra.setBounds(
        new Rectangle(
            (int) (2.9 * (ancho / 5)), (int) (1.65 * (alto / 4)) + 20, ancho / 8, alto / 25));

    // imagenes de componentes
    labelFondo.setIcon(new ImageIcon("../imagenes/introduceNick.jpg"));
    botonCancelar.setIcon(new ImageIcon("../imagenes/botoncancelar.jpg"));
    botonCancelar.addMouseListener(new PanelNick_botonCancelar_mouseAdapter(this));
    botonAceptar.setIcon(new ImageIcon("../imagenes/botonaceptar.jpg"));
    botonAceptar.addMouseListener(new PanelNick_botonAceptar_mouseAdapter(this));

    // agregar componentes al panel
    this.add(textContra, null);
    this.add(botonCancelar, null);
    this.add(botonAceptar, null);
    this.add(textNombre, null);
    this.add(labelFondo, null);

    // acciones de botones
    botonAceptar.addActionListener(new PanelNick_botonAceptar_actionAdapter(this));
    botonCancelar.addActionListener(new PanelNick_botonCancelar_actionAdapter(this));
  }
  /**
   * Description of the Method
   *
   * @exception Exception Description of Exception
   */
  private void jbInit() throws Exception {

    this.setLayout(null);
    this.setSize(700, 500);
    this.setLocation(0, 0);

    // limites de componentes
    labelFondo.setBounds(new Rectangle((int) (ancho / 3.5), 2 * (alto / 6), ancho / 2, alto / 4));

    botonAceptar.setBounds(
        new Rectangle(
            (int) (2.4 * (ancho / 5)), (int) (1.9 * (alto / 4)), (int) (ancho / 10.2), alto / 25));
    botonAceptar.setBorder(null);

    // imagenes de componentes
    labelFondo.setIcon(new ImageIcon(Imagen));

    botonAceptar.setIcon(new ImageIcon("../imagenes/botonaceptar.jpg"));
    botonAceptar.addMouseListener(new PanelGenerico_botonAceptar_mouseAdapter(this));

    // agregar componentes al panel

    this.add(botonAceptar, null);
    this.add(labelFondo, null);
    this.setBackground(SystemColor.menuText);

    // acciones de botones
    botonAceptar.addActionListener(new PanelGenerico_botonAceptar_actionAdapter(this));
  }
Exemple #4
0
  public JButton ButtonProperties(JButton button, String buttonText) {

    button.setFont(componentFont);
    button.setBorderPainted(false);
    button.setFocusPainted(false);
    button.setBackground(themeColor1);
    button.setForeground(themeColor4);
    button.setVerticalTextPosition(SwingConstants.BOTTOM);
    button.setHorizontalTextPosition(SwingConstants.CENTER);
    button.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseEntered(MouseEvent e) {

            button.setBackground(themeColor2);
            button.setForeground(Color.BLACK);
            button.setText(buttonText);
          }

          @Override
          public void mouseExited(MouseEvent e) {

            button.setBackground(themeColor1);
            button.setForeground(themeColor4);
            button.setText("");
          }
        });
    return button;
  }
 LookManager(JButton arrowbutton, PopupPanel popuppanel) {
   arrow = arrowbutton;
   popup = popuppanel;
   popup.addPopupMenuListener(this);
   initButton(arrow);
   arrow.addMouseListener(this);
 }
Exemple #6
0
  public JButton ButtonProperties(JButton button) {

    button.setFont(componentFont);
    button.setBorderPainted(false);
    button.setFocusPainted(false);
    button.setBackground(themeColor1);
    button.setForeground(themeColor4);
    button.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseEntered(MouseEvent e) {

            button.setBackground(themeColor2);
            button.setForeground(Color.BLACK);
          }

          @Override
          public void mouseExited(MouseEvent e) {

            button.setBackground(themeColor1);
            button.setForeground(themeColor4);
          }
        });
    return button;
  }
  /**
   * Installs a Tool in the Toolbar
   *
   * @param toolbar as JToolbar
   * @param tool, Tool to install
   */
  public void installToolInToolBar(JToolBar toolbar, final Tool tool) {
    final JButton button;
    button = new JButton();

    button.setMargin(new Insets(0, 0, 0, 0));

    if (tool.getItemType() != null) {
      button.setIcon(tool.getItemType().getIcon());
      button.setToolTipText(tool.getItemType().getDescription());

    } else {
      button.setText("Tool"); // For Debugging
    }
    toolbar.add(button);
    toolButtons.add(button);
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            WorkingView.this.setTool(tool, button);
          }
        });
    button.setContentAreaFilled(false);
    button.setBorderPainted(false);
    button.addMouseListener(
        new MouseAdapter() {
          public void mouseEntered(MouseEvent e) {
            ((JButton) e.getSource()).setBorderPainted(true);
          }

          public void mouseExited(MouseEvent e) {
            ((JButton) e.getSource()).setBorderPainted(false);
          }
        });
  }
Exemple #8
0
  /**
   * _more_
   *
   * @param initValue
   * @param min
   * @param max
   */
  public JSpinner(int initValue, int min, int max) {
    value = initValue;
    this.minValue = min;
    this.maxValue = max;

    // the value field
    tf = new JTextField(1);
    tf.setEditable(false);
    javax.swing.border.Border border = tf.getBorder();
    tf.setBorder(BorderFactory.createEmptyBorder());
    setBorder(javax.swing.border.LineBorder.createBlackLineBorder());

    setValue(initValue);

    // create up & down buttons
    JPanel udPanel = new JPanel(new GridLayout(2, 1));
    JButton up = createButton(SpinIcon.TypeUp);
    udPanel.add(up);

    JButton down = createButton(SpinIcon.TypeDown);
    udPanel.add(down);

    add(tf);
    add(udPanel);

    // listeners
    up.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (value < maxValue) {
              value++;
            }
            setValue(value);
          }
        });
    down.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (value > minValue) {
              value--;
            }
            setValue(value);
          }
        });
  }
Exemple #9
0
  /** Constructor for allocating memory and simple initializing. */
  public GameBoard() {
    dealerPanel = new JPanel();
    playerPanel = new JPanel();
    controlPanel = new JPanel();
    money = new JLabel();
    record = new JLabel();
    inputImage = new JLabel(new ImageIcon("res/INPUT.gif"));
    moneyLabel = new JLabel(new ImageIcon("res/MONEY.gif"));
    betLabel = new JLabel(new ImageIcon("res/MAKE_YOUR_BET.gif"));
    recordLabel = new JLabel(new ImageIcon("res/BEST_SCORE.gif"));
    betButton = new JButton(new ImageIcon("res/BET.gif"));
    resultButton = new JButton(new ImageIcon("res/RESULT.gif"));
    betInput = new JTextField();

    try {
      recordReader = new BufferedReader(new FileReader("res/record"));
      bestScore = Integer.parseInt(recordReader.readLine());
      recordReader.close();
    } catch (Exception e) {
      e.printStackTrace();
    }

    inputImage.setLayout(new BorderLayout());
    controlPanel.setLayout(new FlowLayout());

    betInput.setHorizontalAlignment(JTextField.CENTER);
    betButton.setBorder(BorderFactory.createEmptyBorder());
    betButton.setContentAreaFilled(false);
    resultButton.setBorder(BorderFactory.createEmptyBorder());
    resultButton.setContentAreaFilled(false);
    resultButton.setEnabled(false);
    betButton.addMouseListener(new BetListener());
    resultButton.addMouseListener(new ResultListener());
    betInput.setOpaque(false);
    betInput.setBorder(BorderFactory.createEmptyBorder());
    money.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 30));
    record.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 30));
    setOpaque(false);

    initGame();
    initRound();
  }
Exemple #10
0
  /** Create the tabbed panels for the GUI */
  private void createTabs() {

    // Create the tabbed pane
    mainPanel = new JTabbedPane(JTabbedPane.BOTTOM);

    // Create the various panels
    workspacePanel = new JPanel(new BorderLayout());
    userListPanel = new JPanel(new BorderLayout());
    searchPanel = new JPanel(new GridLayout(0, 2));

    // Create the pieces of the workspace panel
    workspaceList.setLayoutOrientation(JList.VERTICAL_WRAP);
    workspacePanel.add(new JScrollPane(workspaceList));
    workspacePanel.add(new JLabel("Local File Listing"), BorderLayout.NORTH);

    // Create the UserList tab
    JPanel labelPanel = new JPanel(new GridLayout(0, 2));
    labelPanel.add(new JLabel("Users Connected:"));
    labelPanel.add(new JLabel("Selected User's Files:"));

    JPanel listPanel = new JPanel(new GridLayout(0, 2));
    listPanel.add(new JScrollPane(userList));
    listPanel.add(new JScrollPane(fileList));

    userList.addMouseListener(mouseHandler);
    fileList.addMouseListener(mouseHandler);

    userListPanel.add(labelPanel, BorderLayout.NORTH);
    userListPanel.add(listPanel, BorderLayout.CENTER);

    // Create Search Panel
    searchPanel = new JPanel(new BorderLayout());
    JPanel searchOpsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    searchName = new JTextField(20);
    searchInit = new JButton("Search");
    searchInit.addMouseListener(mouseHandler);
    String types[] = {"Image", "Video", "Audio", "Any"};
    searchType = new JComboBox(types);
    searchType.setSelectedIndex(3);

    searchOpsPanel.add(new JLabel("Search String"));
    searchOpsPanel.add(searchName);
    searchOpsPanel.add(new JLabel("File Type"));
    searchOpsPanel.add(searchType);
    searchOpsPanel.add(searchInit);

    searchPanel.add(new JScrollPane(searchList));
    searchPanel.add(searchOpsPanel, BorderLayout.NORTH);

    // Add panels to the tab pane
    mainPanel.addTab("Home", workspacePanel);
    mainPanel.addTab("Server", userListPanel);
    mainPanel.addTab("Search", searchPanel);
  }
  public Abschluss(String wahl, Sudoku s, Sudoku2 s2) {
    super("Sudoku-Abschluss");
    this.setSize(270, 135);
    this.setLocation(250, 300);
    this.setLayout(null);
    this.setAlwaysOnTop(true);
    this.setResizable(false);
    this.setUndecorated(true);
    if (s == null) this.setLocationRelativeTo(s2);
    else this.setLocationRelativeTo(s);

    su = s;
    su2 = s2;
    w = wahl;

    ImageIcon icon = new ImageIcon("files/minigames/Sudoku/beispiel2.jpg");
    icon.setImage(icon.getImage().getScaledInstance(290, 135, Image.SCALE_DEFAULT));

    lab = new JLabel(icon);
    lab.setSize(270, 135);
    lab.setLocation(0, 0);
    this.add(lab);

    text = new JLabel();
    text.setSize(250, 20);
    text.setLocation(10, 10);
    text.setForeground(Color.white);
    text.setHorizontalAlignment(0);
    lab.add(text);

    text2 = new JLabel();
    text2.setSize(270, 20);
    text2.setLocation(10, 30);
    text2.setForeground(Color.white);
    lab.add(text2);

    ok = new JButton("OK");
    ok.setSize(90, 30);
    ok.setLocation(80, 50);
    ok.setBorderPainted(false);
    ok.setBackground(Color.lightGray);
    ok.setForeground(Color.lightGray);
    ok.setOpaque(false);
    ok.setFont(new Font("Arial Black", 4, 20));
    ok.setContentAreaFilled(false);
    ok.setFocusPainted(false);
    ok.addActionListener(this);
    ok.addMouseListener(this);
    lab.add(ok);

    textWahl(wahl);

    this.setVisible(true);
  }
Exemple #12
0
    /**
     * Constructor.
     *
     * @param title the title of the tab component
     * @param editor the editor of the tab (used to close the tab)
     */
    public TabComponent(final AbstractEditorPanel editor) {

      setLayout(new BorderLayout());
      setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0));
      setOpaque(false);

      // title
      title = new JLabel(editor.getTitle());
      title.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
      add(title, BorderLayout.WEST);

      // close
      final JButton close = new JButton(Project.getEditorImageIconOrEmpty("icon_cross.png"));
      close.setPreferredSize(new Dimension(16, 16));
      close.setUI(new BasicButtonUI());
      close.setBorderPainted(false);
      close.setOpaque(false);
      close.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
              removeEditor(editor, true);
            }
          });
      close.addMouseListener(
          new MouseListener() {

            @Override
            public void mouseClicked(MouseEvent me) {}

            @Override
            public void mousePressed(MouseEvent me) {}

            @Override
            public void mouseReleased(MouseEvent me) {}

            @Override
            public void mouseEntered(MouseEvent me) {

              close.setBorderPainted(true);
            }

            @Override
            public void mouseExited(MouseEvent me) {

              close.setBorderPainted(false);
            }
          });
      add(close, BorderLayout.EAST);
    }
Exemple #13
0
  /* Create a component that will replace the spinner models value
   * with the object returned by <code>spinner.getPreviousValue</code>.
   * By default the <code>previousButton</code> is a JButton
   * who's <code>ActionListener</code> updates it's <code>JSpinner</code>
   * ancestors model.  If a previousButton isn't needed (in a subclass)
   * then override this method to return null.
   *
   * @return a component that will replace the spinners model with the
   *     next value in the sequence, or null
   * @see #installUI
   * @see #createNextButton
   */
  protected Component createPreviousButton() {
    Component tmpButton = super.createPreviousButton();

    if (tmpButton instanceof JButton) {
      JButton result = new ArrowButton(SwingConstants.SOUTH);
      ActionListener al[] = ((JButton) tmpButton).getActionListeners();
      for (int i = 0; i < al.length; i++) result.addActionListener(al[i]);

      MouseListener ml[] = ((JButton) tmpButton).getMouseListeners();
      for (int i = 0; i < ml.length; i++) result.addMouseListener(ml[i]);

      return result;
    } else return tmpButton;
  }
Exemple #14
0
  /** Create the entire GUI from scratch */
  private void createGUI() {

    clientFrame = new JFrame("LeetFTP");

    // Allow program to exit gracefully

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

    createTabs();
    createMenu();

    // Top Options Bar
    connectButton = new JButton("Connect");
    connectButton.addMouseListener(mouseHandler);

    optionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));

    optionPanel.add(connectButton);
    optionPanel.add(new JLabel("Name Server Hostname"));
    optionPanel.add(serverTextField);
    optionPanel.add(new JLabel("Port #"));
    optionPanel.add(portTextField);
    optionPanel.add(new JLabel("UserName"));
    optionPanel.add(nameTextField);

    // Bottom Transfer Table

    transferTable = new JTable();
    transferPanel = new JPanel(new BorderLayout());
    transferPanel.add(new JLabel("Current Transfers:"), BorderLayout.NORTH);
    transferPanel.add(transferTable);

    // Make the tab pane the GUI pane
    clientFrame.getContentPane().setLayout(new BorderLayout());
    clientFrame.getContentPane().add(mainPanel);
    clientFrame.getContentPane().add(optionPanel, BorderLayout.NORTH);
    clientFrame.getContentPane().add(transferPanel, BorderLayout.SOUTH);

    // Set Client Window Properties
    clientFrame.setSize(800, 600);
    // clientFrame.setResizable(false);
    clientFrame.setLocationRelativeTo(null);
    clientFrame.setVisible(true);
  }
  public CustomizableComboBox() {
    super(new BorderLayout());

    myThemedCombo.setEditable(true);

    PopupMouseListener listener = new PopupMouseListener();
    // GTK always draws a border on the textbox.  It cannot be removed,
    // so to compensate, we remove our own border so we don't have a double border.
    if (UIUtil.isUnderGTKLookAndFeel()) {
      this.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    } else {
      this.setBorder(
          BorderFactory.createCompoundBorder(
              BorderFactory.createEmptyBorder(2, 2, 2, 2),
              BorderFactory.createLineBorder(getBorderColor(), 1)));
    }

    // Try to turn off the border on the JTextField.
    myTextField =
        new JBTextField() {
          @Override
          public void setBorder(Border border) {
            super.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
          }
        };
    myTextField.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
    myTextField.addMouseListener(listener);
    myTextField.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {
            myTextField.selectAll();
          }

          @Override
          public void focusLost(FocusEvent e) {
            // no-op
          }
        });

    JButton popupButton = createArrowButton();
    popupButton.addMouseListener(listener);

    this.add(popupButton, BorderLayout.EAST);
    this.add(myTextField, BorderLayout.CENTER);
  }
Exemple #16
0
 public static void main(String[] args) {
   Frame f = new Frame();
   f.setLocation(300, 200);
   f.setSize(200, 200);
   f.setLayout(null); // 取消布局管理器
   bt.addMouseListener(new MouseMove()); // 注册鼠标事件监听器
   bt.setBackground(Color.cyan);
   bt.setBounds(new Rectangle(45, 100, 90, 30));
   f.add(bt);
   f.pack();
   f.addWindowListener(
       new WindowAdapter() { // 关闭窗口
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   f.setVisible(true); // 设置窗体可见
 }
Exemple #17
0
  /**
   * Create a component that will replace the spinner models value with the object returned by
   * <code>spinner.getNextValue</code>. By default the <code>nextButton</code> is a JButton who's
   * <code>ActionListener</code> updates it's <code>JSpinner</code> ancestors model. If a nextButton
   * isn't needed (in a subclass) then override this method to return null.
   *
   * @return a component that will replace the spinners model with the next value in the sequence,
   *     or null
   * @see #installUI
   * @see #createPreviousButton
   */
  protected Component createNextButton() {
    Component tmpButton = super.createNextButton();

    if (tmpButton instanceof JButton) {
      JButton result = new ArrowButton(SwingConstants.NORTH);
      ((ArrowButton) result).setDrawBottomBorder(false);

      result.setBorder(
          BorderFactory.createMatteBorder(1, 1, 0, 1, UIManager.getColor("Button.borderColor")));
      ActionListener al[] = ((JButton) tmpButton).getActionListeners();
      for (int i = 0; i < al.length; i++) result.addActionListener(al[i]);

      MouseListener ml[] = ((JButton) tmpButton).getMouseListeners();
      for (int i = 0; i < ml.length; i++) result.addMouseListener(ml[i]);

      return result;
    } else return tmpButton;
  }
 public ComboBox(final ComboBoxModel model, final int width) {
   super(model);
   myMinimumAndPreferredWidth = width;
   registerCancelOnEscape();
   UIUtil.installComboBoxCopyAction(this);
   final JButton arrowButton = UIUtil.findComponentOfType(this, JButton.class);
   if (arrowButton != null) {
     arrowButton.addMouseListener(
         new MouseAdapter() {
           @Override
           public void mousePressed(MouseEvent e) {
             if (!mySwingPopup) {
               e.consume();
               setPopupVisible(true);
             }
           }
         });
   }
 }
  public void setUseFlatUI(boolean b) {
    main.setContentAreaFilled(!b);
    main.setFocusPainted(!b);
    main.setBorderPainted(!b);
    main.setMargin(new Insets(1, 1, 1, 1));

    popper.setContentAreaFilled(!b);
    popper.setFocusPainted(!b);
    popper.setBorderPainted(!b);
    popper.setMargin(new Insets(1, 1, 1, 1));

    setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    setOpaque(false);

    MouseAdapter ma =
        new MouseAdapter() {
          public void mouseEntered(MouseEvent e) {
            main.setContentAreaFilled(true);
            main.setBackground(new Color(216, 240, 254));
            // m.getMainButton().setForeground( Color.black );
            setBorder(new LineBorder(new Color(200, 200, 200), 1));
            setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

            popper.setBackground(new Color(242, 242, 242));
            popper.setContentAreaFilled(true);
            popper.setBorder(menu.getBorder());
          }

          public void mouseExited(MouseEvent e) {
            main.setContentAreaFilled(false);
            //	c.setForeground( Color.black );
            setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
            setCursor(Cursor.getDefaultCursor());

            popper.setContentAreaFilled(false);
            popper.setBorder(null);
          }
        };

    main.addMouseListener(ma);
    popper.addMouseListener(ma);
  }
Exemple #20
0
    private void initButton() {
      int actionCommandId = 1;
      for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 7; j++) {
          JButton numberButton = new JButton();
          numberButton.setBorder(BorderFactory.createEmptyBorder());
          numberButton.setHorizontalAlignment(SwingConstants.CENTER);
          numberButton.setActionCommand(String.valueOf(actionCommandId));

          numberButton.addMouseListener(this);

          numberButton.setBackground(palletTableColor);
          numberButton.setForeground(dateFontColor);
          numberButton.setText(String.valueOf(actionCommandId));
          numberButton.setPreferredSize(new Dimension(25, 25));
          daysButton[i][j] = numberButton;
          actionCommandId++;
        }
      }
    }
Exemple #21
0
  public BookMain() {
    String[] col = {"번호", "제목", "저자"};
    String[][] row = new String[0][3];
    model =
        new DefaultTableModel(row, col) {
          // 익명의 클래스 : 변경,추가
          public boolean isCellEditable(int r, int c) {
            return false;
          }
        };
    table = new JTable(model);
    JScrollPane js = new JScrollPane(table);
    la1 = new JLabel("번호:");
    la2 = new JLabel("제목:");
    la3 = new JLabel("저자:");
    la4 = new JLabel("출판사:");
    la5 = new JLabel("가격:");

    la6 = new JLabel("Search");
    box = new JComboBox();
    box.addItem("위키북스");
    box.addItem("한빛미디어");
    box.addItem("영진출판사");
    box.addItem("대림출판사");
    tf = new JTextField(20);
    tf.setEditable(false);
    b = new JButton("전체목록");
    // <input type=text readonly>
    JPanel p = new JPanel();
    p.add(la6);
    p.add(box);
    p.add(tf);
    p.add(b);
    // 배치
    setLayout(null);
    p.setBounds(10, 15, 620, 35);
    js.setBounds(10, 55, 620, 245);
    bp.setBounds(10, 320, 300, 170);
    la1.setBounds(320, 320, 300, 30);
    la2.setBounds(320, 355, 300, 30);
    la3.setBounds(320, 390, 300, 30);
    la4.setBounds(320, 425, 300, 30);
    la5.setBounds(320, 460, 300, 30);
    add(p);
    add(js);
    add(bp);
    add(la1);
    add(la2);
    add(la3);
    add(la4);
    add(la5);

    setSize(640, 550);
    setVisible(true);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    getData();
    getData();
    table.addMouseListener(this);
    box.addItemListener(this);
    b.addMouseListener(this);
  }
  public JMovieControlAqua() {
    // Set the background color to the border color of the buttons.
    // This way the toolbar won't look too ugly when the buttons
    // are displayed before they have been loaded completely.
    // setBackground(new Color(118, 118, 118));
    setBackground(Color.WHITE);

    Dimension buttonSize = new Dimension(16, 16);
    GridBagLayout gridbag = new GridBagLayout();
    Insets margin = new Insets(0, 0, 0, 0);
    setLayout(gridbag);
    GridBagConstraints c;

    ResourceBundle labels = ResourceBundle.getBundle("org.monte.media.Labels");
    colorCyclingButton = new JToggleButton();
    colorCyclingButton.setToolTipText(labels.getString("colorCycling.toolTipText"));
    colorCyclingButton.addActionListener(this);
    colorCyclingButton.setPreferredSize(buttonSize);
    colorCyclingButton.setMinimumSize(buttonSize);
    colorCyclingButton.setVisible(false);
    colorCyclingButton.setMargin(margin);
    c = new GridBagConstraints();
    // c.gridx = 0;
    // c.gridy = 0;
    gridbag.setConstraints(colorCyclingButton, c);
    add(colorCyclingButton);

    audioButton = new JToggleButton();
    audioButton.setToolTipText(labels.getString("audio.toolTipText"));
    audioButton.addActionListener(this);
    audioButton.setPreferredSize(buttonSize);
    audioButton.setMinimumSize(buttonSize);
    audioButton.setVisible(false);
    audioButton.setMargin(margin);
    c = new GridBagConstraints();
    // c.gridx = 0;
    // c.gridy = 0;
    gridbag.setConstraints(audioButton, c);
    add(audioButton);

    startButton = new JToggleButton();
    startButton.setToolTipText(labels.getString("play.toolTipText"));
    startButton.addActionListener(this);
    startButton.setPreferredSize(buttonSize);
    startButton.setMinimumSize(buttonSize);
    startButton.setMargin(margin);
    c = new GridBagConstraints();
    // c.gridx = 1;
    // c.gridy = 0;
    gridbag.setConstraints(startButton, c);
    add(startButton);

    slider = new JMovieSliderAqua();
    c = new GridBagConstraints();
    // c.gridx = 2;
    // c.gridy = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    gridbag.setConstraints(slider, c);
    add(slider);

    rewindButton = new JButton();
    rewindButton.setToolTipText(labels.getString("previous.toolTipText"));
    rewindButton.setPreferredSize(buttonSize);
    rewindButton.setMinimumSize(buttonSize);
    rewindButton.setMargin(margin);
    c = new GridBagConstraints();
    // c.gridx = 3;
    // c.gridy = 0;

    gridbag.setConstraints(rewindButton, c);
    add(rewindButton);
    rewindButton.addActionListener(this);

    forwardButton = new JButton();
    forwardButton.setToolTipText(labels.getString("next.toolTipText"));
    buttonSize = new Dimension(17, 16);
    forwardButton.setPreferredSize(buttonSize);
    forwardButton.setMinimumSize(buttonSize);
    forwardButton.setMargin(margin);
    c = new GridBagConstraints();
    // c.gridx = 4;
    // c.gridy = 0;
    gridbag.setConstraints(forwardButton, c);
    add(forwardButton);
    forwardButton.addActionListener(this);

    // The spacer is used when the play controls are hidden
    spacer = new JPanel(new BorderLayout());
    spacer.setVisible(false);
    spacer.setPreferredSize(new Dimension(16, 16));
    spacer.setMinimumSize(new Dimension(16, 16));
    spacer.setOpaque(false);
    c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    gridbag.setConstraints(spacer, c);
    add(spacer);

    Border border =
        new BackdropBorder(
            new ButtonStateBorder(
                new ImageBevelBorder(
                    Images.createImage(getClass(), "images/Player.border.png"),
                    new Insets(1, 1, 1, 1),
                    new Insets(0, 4, 1, 4)),
                new ImageBevelBorder(
                    Images.createImage(getClass(), "images/Player.borderP.png"),
                    new Insets(1, 1, 1, 1),
                    new Insets(0, 4, 1, 4))));

    Border westBorder =
        new BackdropBorder(
            new ButtonStateBorder(
                new ImageBevelBorder(
                    Images.createImage(getClass(), "images/Player.borderWest.png"),
                    new Insets(1, 1, 1, 0),
                    new Insets(0, 4, 1, 4)),
                new ImageBevelBorder(
                    Images.createImage(getClass(), "images/Player.borderWestP.png"),
                    new Insets(1, 1, 1, 0),
                    new Insets(0, 4, 1, 4))));

    startButton.setBorder(westBorder);
    colorCyclingButton.setBorder(westBorder);
    audioButton.setBorder(westBorder);
    rewindButton.setBorder(westBorder);
    forwardButton.setBorder(border);
    startButton.setUI((ButtonUI) CustomButtonUI.createUI(startButton));
    colorCyclingButton.setUI((ButtonUI) CustomButtonUI.createUI(audioButton));
    audioButton.setUI((ButtonUI) CustomButtonUI.createUI(audioButton));
    rewindButton.setUI((ButtonUI) CustomButtonUI.createUI(rewindButton));
    forwardButton.setUI((ButtonUI) CustomButtonUI.createUI(forwardButton));

    colorCyclingButton.setIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStartColorCycling.png")));
    colorCyclingButton.setSelectedIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStartColorCycling.png")));
    colorCyclingButton.setDisabledIcon(
        new ImageIcon(
            Images.createImage(getClass(), "images/PlayerStartColorCycling.disabled.png")));
    audioButton.setIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStartAudio.png")));
    audioButton.setSelectedIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStopAudio.png")));
    audioButton.setDisabledIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStartAudio.disabled.png")));
    startButton.setIcon(new ImageIcon(Images.createImage(getClass(), "images/PlayerStart.png")));
    startButton.setSelectedIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStop.png")));
    startButton.setDisabledIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStart.disabled.png")));
    rewindButton.setIcon(new ImageIcon(Images.createImage(getClass(), "images/PlayerBack.png")));
    rewindButton.setDisabledIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerBack.disabled.png")));
    forwardButton.setIcon(new ImageIcon(Images.createImage(getClass(), "images/PlayerNext.png")));
    forwardButton.setDisabledIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerNext.disabled.png")));

    // Automatic scrolling
    scrollHandler = new ScrollHandler();
    scrollTimer = new Timer(60, scrollHandler);
    scrollTimer.setInitialDelay(300); // default InitialDelay?
    forwardButton.addMouseListener(scrollHandler);
    rewindButton.addMouseListener(scrollHandler);
  }
  public VentanaGuardado(JFrame padre, boolean esModal, GestorMapas gestor, char c) {
    super(padre, esModal);
    gest = gestor;
    setSize(new Dimension(600, 300));
    Container cp = getContentPane();
    setResizable(true);
    cp.setLayout(null);
    JLabel lblIngreseElNombre = new JLabel("Ingrese el nombre del archivo:");
    lblIngreseElNombre.setHorizontalAlignment(SwingConstants.CENTER);
    lblIngreseElNombre.setBounds(222, 99, 178, 14);
    cp.add(lblIngreseElNombre);
    textField = new JTextField();
    textField.setBounds(222, 124, 195, 20);
    cp.add(textField);
    if (c == 'G') texto = "Guardar juego";
    else texto = "Cargar juego";
    JButton btnGuardarArchivo = new JButton(texto);
    btnGuardarArchivo.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {
            if (textField.getText().equals("") != true) {
              String nombarchivo = textField.getText();
              if (c == 'G') { // Guardando
                XStream xs = new XStream(new DomDriver());
                xs.omitField(Celda.class, "img");
                xs.omitField(GestorMapas.class, "mapas");
                xs.omitField(Objeto.class, "img");
                // 1. Escribir el archivoFileWriter
                FileWriter fw = null;
                try {
                  fw = new FileWriter(nombarchivo + ".xml");
                  fw.write(xs.toXML(gest));
                  fw.close();
                } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                }
                JOptionPane.showMessageDialog(
                    null, "Juego Guardado", "Título del Mensaje", JOptionPane.INFORMATION_MESSAGE);

              } else { // Caso de carga
                try {
                  XStream xs = new XStream(new DomDriver());
                  Ventana.gestor =
                      (GestorMapas) xs.fromXML(new FileInputStream(nombarchivo + ".xml"));

                } catch (IOException i) {
                  JOptionPane.showMessageDialog(
                      null,
                      "No se encontró el archivo",
                      "Título del Mensaje",
                      JOptionPane.INFORMATION_MESSAGE);
                  Ventana.cargoCorrectamente = false;
                }
              }
              dispose();
            } else {
              JOptionPane.showMessageDialog(
                  null,
                  "Ingrese todos los datos",
                  "Título del Mensaje",
                  JOptionPane.INFORMATION_MESSAGE);
            }
          }
        });
    btnGuardarArchivo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {}
        });
    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            Ventana.cargoCorrectamente = false;
          }
        });

    btnGuardarArchivo.setBounds(247, 171, 134, 23);
    cp.add(btnGuardarArchivo);
  }