public QuadristateCheckbox(String text, Icon icon, State state) {
   super(text, icon);
   // Add a listener for when the mouse is pressed
   super.addMouseListener(
       new MouseAdapter() {
         @Override
         public void mousePressed(MouseEvent e) {
           grabFocus();
           getModel().nextState();
         }
       });
   // Reset the keyboard action map
   ActionMap map = new ActionMapUIResource();
   map.put(
       "pressed",
       new AbstractAction() {
         public void actionPerformed(ActionEvent e) {
           grabFocus();
           getModel().nextState();
         }
       });
   map.put("released", null);
   SwingUtilities.replaceUIActionMap(this, map);
   setState(state);
 }
  public ExtendedTriStateCheckBox(String text, Icon icon, Boolean initial) {
    super(text, icon);
    // Add a listener for when the mouse is pressed
    super.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            grabFocus();
            model.nextState();
          }
        });
    // Reset the keyboard action map
    ActionMap map = new ActionMapUIResource();
    map.put(
        "pressed",
        new AbstractAction() { // NOI18N

          private static final long serialVersionUID = 0L;

          @Override
          public void actionPerformed(ActionEvent e) {
            grabFocus();
            model.nextState();
          }
        });
    map.put("released", null); // NOI18N
    SwingUtilities.replaceUIActionMap(this, map);
    // set the model to the adapted model
    model = new TristateDecorator(getModel());
    setModel(model);
    setState(initial);
  }
Ejemplo n.º 3
0
  protected void filterOpcItem() {
    opcItemsPanel.removeAll();

    List<YGOpcItem> filted = filter.doFiter(opcItemList);
    if (filted == null) {
      return;
    }

    MouseAdapter mouseAdapter =
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getSource() instanceof JCheckBox) {
              JCheckBox clickedButton = (JCheckBox) e.getSource();

              if (clickedButton.isSelected()) {
                jTextFieldForOPCItemName.setText(clickedButton.getText());
              }
            }
          }
        };

    opcItemsPanel.setLayout(new GridLayout(filted.size() < 6 ? 6 : filted.size(), 1));
    for (YGOpcItem item : filted) {
      JCheckBox checkBox = new JCheckBox(item.getItemName());
      checkBox.setBackground(Color.white);
      checkBox.addMouseListener(mouseAdapter);

      selectItemButtonGroup.add(checkBox);
      opcItemsPanel.add(checkBox);
    }
    opcItemsPanel.updateUI();
  }
Ejemplo n.º 4
0
  public void crearPropiedad(
      int min, int max, int defecto, String unidades, String nombrePropiedad) {

    final SelectorPropiedad sp = new SelectorPropiedad(min, max);
    sp.setLabelUnidades(unidades);

    if (this.selectoresPropiedad.size() == 0) {
      MouseAdapter ma =
          new MouseAdapter() {

            public void mouseClicked(MouseEvent mouseEvent) {

              if (mouseEvent.getButton() == MouseEvent.BUTTON1 && mouseEvent.isControlDown()) {
                CheckBoxMedida.super.setSelected(true);
                for (int i = 0; i < CheckBoxMedida.this.selectoresPropiedad.size(); i++) {

                  JDialog jd = CheckBoxMedida.this.getDialogoSeleccionPropiedad(i);
                  jd.setVisible(true);
                }
              }
            }
          };
      super.addMouseListener(ma);
    }

    sp.slider.setValue(defecto);
    this.selectoresPropiedad.add(sp);
    this.nombrePropiedad.add(nombrePropiedad);
    super.setToolTipText("Ctrl + click to select " + nombrePropiedad);
  }
Ejemplo n.º 5
0
  // For testing only at present
  IndeterminateCheckBox(
      final String text, final Icon icon, final SelectionState initial, final boolean original) {
    super(text, icon);

    setBorderPaintedFlat(true);

    // Set default single model
    setModel(new ButtonModelEx(initial, this, original));

    // override action behaviour
    super.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            IndeterminateCheckBox.this.iterateState();
          }
        });

    final ActionMap actions = new ActionMapUIResource();

    actions.put(
        "pressed",
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
            IndeterminateCheckBox.this.iterateState();
          }
        });
    actions.put("released", null);

    SwingUtilities.replaceUIActionMap(this, actions);
  }
Ejemplo n.º 6
0
 /**
  * Constructs a new {@code QuadStateCheckBox}.
  *
  * @param text the text of the check box
  * @param icon the Icon image to display
  * @param initial The initial state
  * @param allowed The allowed states
  */
 public QuadStateCheckBox(String text, Icon icon, State initial, State[] allowed) {
   super(text, icon);
   this.allowed = Utils.copyArray(allowed);
   // Add a listener for when the mouse is pressed
   super.addMouseListener(
       new MouseAdapter() {
         @Override
         public void mousePressed(MouseEvent e) {
           grabFocus();
           model.nextState();
         }
       });
   // Reset the keyboard action map
   ActionMap map = new ActionMapUIResource();
   map.put(
       "pressed",
       new AbstractAction() {
         @Override
         public void actionPerformed(ActionEvent e) {
           grabFocus();
           model.nextState();
         }
       });
   map.put("released", null);
   SwingUtilities.replaceUIActionMap(this, map);
   // set the model to the adapted model
   model = new QuadStateDecorator(getModel());
   setModel(model);
   setState(initial);
 }
Ejemplo n.º 7
0
 public void setJCheckbox(JCheckBox jcb) {
   jcb.setOpaque(false);
   jcb.setBorder(null);
   jcb.setBorderPainted(false);
   jcb.setMargin(new Insets(0, 0, 0, 0));
   jcb.setContentAreaFilled(false);
   jcb.setFocusable(false);
   jcb.setFont(new Font("ËÎÌå", 0, 12));
   jcb.addMouseListener(new ButtonListener());
 }
Ejemplo n.º 8
0
  public IECheckBoxWidgetView(
      IEController ieController,
      IECheckBoxWidget model,
      boolean addDnDSupport,
      IEWOComponentView view) {
    super(ieController, model, addDnDSupport, view);
    FlowLayout layout = new FlowLayout(FlowLayout.LEFT, 0, 0);
    setLayout(layout);
    _jCheckBox = new JCheckBox();
    _jCheckBox.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            isUpdatingModel = true;
            getCheckBoxModel().setValue(((JCheckBox) e.getSource()).isSelected());
            isUpdatingModel = false;
          }
        });
    _jCheckBox.setFont(TEXTFIELD_FONT);
    container = new JPanel(new FlowLayout(FlowLayout.CENTER, 4, 4));
    container.setOpaque(false);
    container.add(_jCheckBox);
    add(container);
    _jCheckBox.setEnabled(true);
    _jCheckBox.setFocusable(false);
    _jCheckBox.setOpaque(false);
    if (getCheckBoxModel().getDescription() != null) {
      _jCheckBox.setToolTipText(getCheckBoxModel().getDescription());
    }
    TransparentMouseListener tml = new TransparentMouseListener(_jCheckBox, this);
    _jCheckBox.addMouseListener(tml);
    _jCheckBox.addMouseMotionListener(tml);
    _jCheckBox.setSelected(getCheckBoxModel().getValue());
    _jCheckBox.setBackground(getBackgroundColor());
    setBackground(getBackgroundColor());
    revalidate();
  }
Ejemplo n.º 9
0
  public SpecialsGUI(String usersID, int bookingid) {
    setLayout(null);
    specials = new JPanel();
    specials.setBounds(125, 210, 743, 288);
    add(specials);
    specials.setLayout(null);
    font = new Font("Veranda", font.PLAIN, 18);
    this.bookingid = bookingid;
    this.usersID = usersID;

    addSomething =
        new JLabel(
            "Add something extra to your stay with us,"
                + " by selecting from our range of available specials");
    addSomething.setFont(font);
    addSomething.setBounds(10, 0, 760, 36);
    specials.add(addSomething);

    golf = new JCheckBox("Golf");
    golf.setFont(font);
    golf.setBounds(323, 165, 160, 23);
    golf.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (golf.isSelected()) {
              priceField = priceField + 100;
              price.setText("Price: €" + priceField);
              numGolf++;
            } else {
              priceField = priceField - 100;
              price.setText("Price: €" + priceField);
              numGolf--;
            }
          }
        });
    specials.add(golf);

    spa = new JCheckBox("Spa Treatment");
    spa.setFont(font);
    spa.setBounds(323, 87, 160, 23);
    spa.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (spa.isSelected()) {
              priceField = priceField + 150;
              price.setText("Price: €" + priceField);
              numSpa++;
            } else {
              priceField = priceField - 150;
              price.setText("Price: €" + priceField);
              numSpa--;
            }
          }
        });
    specials.add(spa);

    breaky = new JCheckBox("Breakfast");
    breaky.setFont(font);
    breaky.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (breaky.isSelected()) {
              priceField = priceField + 20;
              price.setText("Price: €" + priceField);
              numBreaky++;
            } else {
              priceField = priceField - 20;
              price.setText("Price: €" + priceField);
              numBreaky--;
            }
          }
        });
    breaky.setBounds(323, 139, 160, 23);
    specials.add(breaky);

    karting = new JCheckBox("Go-karting");
    karting.setFont(font);
    karting.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (karting.isSelected()) {
              priceField = priceField + 50;
              price.setText("Price: €" + priceField);
              numKarting++;
            } else {
              priceField = priceField - 50;
              price.setText("Price: €" + priceField);
              numKarting--;
            }
          }
        });
    karting.setBounds(323, 113, 160, 23);
    specials.add(karting);

    price = new JLabel("Price: €" + priceField);
    price.setFont(font);
    price.setBounds(317, 205, 140, 14);
    specials.add(price);

    addSpecials = new JButton("Add Specials");
    addSpecials.setFont(font);
    addSpecials.setBackground(color);
    addSpecials.addActionListener(this);
    addSpecials.setBounds(206, 230, 150, 23);
    specials.add(addSpecials);

    back = new JButton("Back");
    back.setFont(font);
    back.setBackground(color);
    back.addActionListener(this);
    back.setBounds(386, 230, 150, 23);
    specials.add(back);
  }
Ejemplo n.º 10
0
  public void initComponents() {
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    setBounds(100, 100, 902, 597);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    panel_4 = new JPanel();
    panel_4.setBorder(
        new TitledBorder(
            new LineBorder(new Color(0, 0, 0)),
            "Geral",
            TitledBorder.LEFT,
            TitledBorder.TOP,
            null,
            null));
    panel_4.setBounds(10, 11, 426, 236);
    contentPane.add(panel_4);
    panel_4.setLayout(null);

    lblModeloDoAutomato = new JLabel("Defini\u00E7\u00E3o do Automato:");
    lblModeloDoAutomato.setBounds(10, 47, 125, 14);
    panel_4.add(lblModeloDoAutomato);

    JScrollPane scrollPane_2 = new JScrollPane();
    scrollPane_2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane_2.setBounds(10, 72, 406, 124);
    panel_4.add(scrollPane_2);

    textArea = new JTextArea();
    textArea.setColumns(100);
    scrollPane_2.setColumnHeaderView(textArea);
    textArea.setAutoscrolls(true);
    textArea.setRows(9);

    JButton btnMinimizar = new JButton("Minimizar");
    btnMinimizar.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            minimizarAutomato();
          }
        });
    btnMinimizar.setBounds(10, 207, 104, 23);
    panel_4.add(btnMinimizar);

    JPanel panel = new JPanel();
    panel.setBounds(10, 15, 250, 25);
    panel_4.add(panel);
    panel.setBorder(null);
    panel.setLayout(null);

    JLabel lblNome = new JLabel("Criar estado:");
    lblNome.setBounds(10, 5, 82, 14);
    panel.add(lblNome);
    lblNome.setHorizontalAlignment(SwingConstants.CENTER);

    isfinal = new JCheckBox("Final");
    isfinal.setBounds(98, 1, 56, 23);
    panel.add(isfinal);

    btnNovo = new JButton("Novo");
    btnNovo.setBounds(160, 1, 73, 23);
    panel.add(btnNovo);
    btnNovo.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            novoEstado();
          }
        });

    JPanel panel_5 = new JPanel();
    panel_5.setBorder(
        new TitledBorder(
            new LineBorder(new Color(0, 0, 0)),
            "Visualiza\u00E7\u00E3o",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    panel_5.setBounds(10, 258, 1310, 390);
    contentPane.add(panel_5);
    panel_5.setLayout(null);

    painelView = new JPanelVisualizacao(this);
    painelView.setBounds(10, 22, 1290, 357);
    panel_5.add(painelView);

    JPanel panel_2 = new JPanel();
    panel_2.setBounds(558, 11, 314, 251);
    contentPane.add(panel_2);
    panel_2.setLayout(null);

    lblNewLabel = new JLabel("Detalhes de ");
    lblNewLabel.setBounds(10, 11, 152, 14);
    panel_2.add(lblNewLabel);

    cbisFinal = new JCheckBox("Final");
    cbisFinal.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseClicked(MouseEvent arg0) {
            turnFinal();
          }
        });
    cbisFinal.setBounds(168, 7, 60, 23);
    panel_2.add(cbisFinal);

    btnExcluir = new JButton("Excluir");
    btnExcluir.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            excluirEstado();
          }
        });
    btnExcluir.setBounds(231, 7, 73, 23);
    panel_2.add(btnExcluir);

    panel_3 = new JPanel();
    panel_3.setBorder(
        new TitledBorder(
            new LineBorder(new Color(0, 0, 0)),
            "Transi\u00E7\u00F5es",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    panel_3.setBounds(10, 36, 294, 204);
    panel_2.add(panel_3);
    panel_3.setLayout(null);

    JLabel lblSimbolo = new JLabel("Simbolo:");
    lblSimbolo.setBounds(10, 29, 96, 14);
    panel_3.add(lblSimbolo);

    cbAlfabeto = new JComboBox();
    cbAlfabeto.setBounds(122, 26, 49, 20);
    panel_3.add(cbAlfabeto);

    JLabel lblEstadosDestinos = new JLabel("Estados Destinos:");
    lblEstadosDestinos.setBounds(10, 57, 96, 14);
    panel_3.add(lblEstadosDestinos);

    cbEstadosDestinos = new JComboBox();
    cbEstadosDestinos.setBounds(122, 54, 49, 20);
    panel_3.add(cbEstadosDestinos);

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setBounds(10, 82, 274, 111);
    panel_3.add(scrollPane_1);

    tblTrans = new JTable();
    scrollPane_1.setViewportView(tblTrans);

    btnNova = new JButton("Nova");
    btnNova.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            novaTransicao();
          }
        });
    btnNova.setBounds(181, 25, 89, 23);
    panel_3.add(btnNova);

    btnRemover = new JButton("Remover");
    btnRemover.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            removerTransicao();
          }
        });
    btnRemover.setBounds(181, 53, 89, 23);
    panel_3.add(btnRemover);

    JPanel panel_1 = new JPanel();
    panel_1.setBorder(
        new TitledBorder(
            new LineBorder(new Color(0, 0, 0)),
            "Estados",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    panel_1.setBounds(446, 11, 102, 236);
    contentPane.add(panel_1);
    panel_1.setLayout(null);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(10, 26, 82, 199);
    panel_1.add(scrollPane);

    tblEstados = new JTable();
    scrollPane.setViewportView(tblEstados);
    tblEstados.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseClicked(MouseEvent arg0) {
            selecionaEstadoAtual(a.getEstados().get(tblEstados.getSelectedRow()));
          }
        });
    tblEstados.setAutoscrolls(true);
    tblEstados.add(new Scrollbar());
  }