public static void main(String[] args) {
    ComponentFactory factory = WindowsComponentFactory.getInstance();

    CustomButton button1 = factory.createButton();
    CustomLabel label1 = factory.createLabel();

    System.out.println("Button1: " + button1.getText());
    System.out.println("Label1: " + label1.getText());

    /*
     * Output:
     * Button1: WindowsButton - Click me
     * Label1: WindowsLabel - Read me
     */

    factory = LinuxComponentFactory.getInstance();

    CustomButton button2 = factory.createButton();
    CustomLabel label2 = factory.createLabel();

    System.out.println("Button2: " + button2.getText());
    System.out.println("Label2: " + label2.getText());

    /*
     * Output:
     * Button2: LinuxButton - Click me
     * Label2: LinuxLabel - Read me
     */
  }
  @Override
  public void paint(Graphics g) {
    super.paint(g);
    connectUsers("Select * from users");
    CustomButton.setGraphics(g);
    ScaledPoint.setWindowDimensions(getWidth(), getHeight());

    if (help) // display help message
    {
      showHelp(g);
      return;
    }

    // Draw main GUI components
    drawStoreBG(g);
    drawStoreName(g);
    drawStoreImage(g);
    drawStoreMessage(g);
    drawInventory(g);
    drawBalance(g);
    drawPageIndicator(g);

    deactivateButtons();
    CustomButton.draw();
  }
Example #3
0
  /**
   * Return defined button with own click handler
   *
   * @param type selected button type
   * @param title text displayed on button hover
   * @param clickAction ClickHandler / if null it's not added
   * @return create button
   */
  public static CustomButton getPredefinedButton(
      ButtonType type, String title, ClickHandler clickAction) {

    CustomButton b = new CustomButton();

    // icon first
    b.setIcon(getButtonIconByType(type));
    // then text

    b.setText(getButtonTextByType(type));

    if (title != null && !title.isEmpty()) {
      b.setTitle(title);
    }

    if (clickAction != null) {
      b.addClickHandler(clickAction);
    }

    if (ButtonType.CONTINUE.equals(type)) {
      b.setImageAlign(true);
    }

    return b;
  }
Example #4
0
  private void addEvents() {
    confirmButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            Color color = null;
            if (redButton.isSelected()) {
              color = Color.red;
            } else if (blueButton.isSelected()) {
              color = Color.blue;
            } else if (greenButton.isSelected()) {
              color = Color.green;
            } else if (yellowButton.isSelected()) {
              color = Color.yellow;
            }
            new GameBoard(frame, color, numPlayers);
          }
        });

    redButton.addActionListener(new buttonAdapter());
    blueButton.addActionListener(new buttonAdapter());
    greenButton.addActionListener(new buttonAdapter());
    yellowButton.addActionListener(new buttonAdapter());
  }
  private void deactivateButtons()
        //  POST: Deactivates buttons that should not be pressed.
      {
    if (currentPage == 0) // if we are at the first page, disable leftTab
    {
      leftTab.deactivate();
    } else // otherwise activate it
    {
      leftTab.activate();
    }

    if (currentPage == totalPages - 1) // if we are at the last page, disable rightTab
    {
      rightTab.deactivate();
    } else // otherwise activate it
    {
      rightTab.activate();
    }

    if (itemSelected == -1) // if no item has been selected
    {
      buySellButton.deactivate();
    } else // otherwise activate it
    {
      buySellButton.activate();
    }

    if (!mode) // if we are in buying mode
    {
      buyTab.deactivate();
      sellTab.activate();
    } else // if we are in selling mode
    {
      sellTab.deactivate();
      buyTab.activate();
    }
  }
Example #6
0
  public static JButton getCustButton(String path_On, String path_Off) {
    CustomButton component = new CustomButton();
    Icon myIcon1 = new ImageIcon(path_On);
    Icon myIcon2 = new ImageIcon(path_Off);

    int height = myIcon1.getIconHeight();
    int width = myIcon1.getIconWidth();
    Dimension dim = new Dimension(height + 1, width + 1);

    component.setCursor(CURSOR);
    component.setRolloverEnabled(true);
    component.setMinimumSize(dim);
    component.setMaximumSize(dim);
    component.setPreferredSize(dim);

    component.setIcon(myIcon2);
    component.setRolloverIcon(myIcon1);
    component.setPressedIcon(myIcon1);

    // button.setBorderPainted(false);
    // button.setContentAreaFilled(false);

    return component;
  }
Example #7
0
  /**
   * Creates a new configuration method
   *
   * @param backMenu Menu instance used to control its music
   */
  public Config(Menu backMenu) {

    try {
      UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
      try (ObjectInputStream entradaObjs =
          new ObjectInputStream(new FileInputStream("Saves" + File.separator + "config.dat"))) {
        configSave = (float[]) entradaObjs.readObject();
      }
    } catch (ClassNotFoundException
        | IOException
        | InstantiationException
        | IllegalAccessException
        | UnsupportedLookAndFeelException e) {
      System.out.println(e.getMessage());
    }

    this.setSize(800, 300);
    this.add(fondo = new Fondo("fondoConfig.png"));
    this.setUndecorated(true);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.setIconImage(Toolkit.getDefaultToolkit().getImage("Images" + File.separator + "logo.png"));
    this.backMenu = backMenu;

    icon = new ImageIcon("Images/brick.png");

    fondo.setLayout(new BorderLayout());

    returns = CustomButton.createButton("Go Back", this.getGraphicsConfiguration(), 18);
    returns.addActionListener(this);

    musicSlider = new JSlider(JSlider.HORIZONTAL, -30, 0, (int) configSave[0]);
    musicSlider.setOpaque(false);
    musicSlider.setMajorTickSpacing(10);
    musicSlider.setMinorTickSpacing(2);
    musicSlider.setPaintTicks(true);

    volumeSlider = new JSlider(JSlider.HORIZONTAL, -30, 0, (int) configSave[1]);
    volumeSlider.setOpaque(false);
    volumeSlider.setMajorTickSpacing(10);
    volumeSlider.setMinorTickSpacing(2);
    volumeSlider.setPaintTicks(true);

    fondo.add(returns, BorderLayout.SOUTH);
    fondo.add(musicSlider, BorderLayout.NORTH);
    fondo.add(volumeSlider, BorderLayout.CENTER);

    try {
      this.getContentPane()
          .setCursor(
              Toolkit.getDefaultToolkit()
                  .createCustomCursor(
                      CompatibleImage.toCompatibleImage(
                          ImageIO.read(new File("Images" + File.separator + "cursor.png"))),
                      new Point(0, 0),
                      "cursor"));
    } catch (IOException ex) {
      Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
    }

    this.setVisible(true);
  }
Example #8
0
  /**
   * Add search widget to tab menu
   *
   * @param searchEvent event triggered when user click on search button
   * @param title displayed on button hover
   * @return ExtendedTextBox textbox widget
   */
  public ExtendedTextBox addSearchWidget(final PerunSearchEvent searchEvent, final String title) {

    final ExtendedTextBox textBox = new ExtendedTextBox();

    final CustomButton button = getPredefinedButton(ButtonType.SEARCH, title);

    // trigger search on ENTER
    textBox
        .getTextBox()
        .addKeyUpHandler(
            new KeyUpHandler() {
              public void onKeyUp(KeyUpEvent event) {
                if (!textBox.getTextBox().getText().trim().isEmpty()) {
                  button.setEnabled(true);
                  if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                    searchEvent.searchFor(textBox.getTextBox().getText().trim());
                  }
                } else {
                  button.setEnabled(false);
                }
              }
            });
    textBox
        .getTextBox()
        .addBlurHandler(
            new BlurHandler() {
              @Override
              public void onBlur(BlurEvent event) {
                // fake some meaningless KeyUpEvent
                DomEvent.fireNativeEvent(
                    Document.get().createKeyUpEvent(false, false, false, false, KeyCodes.KEY_DOWN),
                    textBox.getTextBox());
              }
            });
    textBox
        .getTextBox()
        .addValueChangeHandler(
            new ValueChangeHandler<String>() {
              @Override
              public void onValueChange(ValueChangeEvent<String> event) {
                // fake some meaningless KeyUpEvent
                DomEvent.fireNativeEvent(
                    Document.get().createKeyUpEvent(false, false, false, false, KeyCodes.KEY_DOWN),
                    textBox.getTextBox());
              }
            });

    // button click triggers action
    button.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent clickEvent) {
            if (UiElements.searchStingCantBeEmpty(textBox.getTextBox().getText().trim())) {
              searchEvent.searchFor(textBox.getTextBox().getText().trim());
            }
          }
        });

    // button is active only if there is "search string"
    button.setEnabled(false);

    this.addWidget(textBox);
    this.addWidget(button);

    // always focus search widget
    Scheduler.get()
        .scheduleDeferred(
            new Command() {
              @Override
              public void execute() {
                textBox.getTextBox().setFocus(true);
              }
            });

    return textBox;
  }
 @Override
 public void mouseReleased(MouseEvent arg0) {
   CustomButton.depress();
   repaint();
 }
  @Override
  public void mousePressed(MouseEvent e) {
    CustomButton buttonPressed; // Button that was pressed.
    String buttonName; // The name of the button.
    int option; // Option chosen by user.
    User buyer; // User object for buyer
    User seller; // User object for seller
    Item selected_item; // Item object for selected item

    if (help) // if in help mode
    {
      help = false;
      repaint();
      return;
    }

    wasItemSelected(e.getX(), e.getY());
    buttonPressed = CustomButton.wasPressed(e.getX(), e.getY());

    if (buttonPressed == null) // if no button was pressed
    {
      return;
    }

    buttonName = buttonPressed.getName();
    playAudio(-1);

    switch (buttonName) // handle event associated with button name
    {
      case "rightTab":
        currentPage++;
        itemSelected = -1;
        break;

      case "leftTab":
        currentPage--;
        itemSelected = -1;
        break;

      case "buyTab":
        mode = false;
        break;

      case "sellTab":
        mode = true;
        break;

      case "button":
        selected_item = itemsArray[itemSelected];

        option =
            JOptionPane.showConfirmDialog(
                this, ((!mode) ? "Buy " : "Sell ") + "for " + "$" + selected_item.getPrice() + "?");

        if (option == 0 && (!mode)) // if they choose to buy
        {
          buyer = usersArray[0];
          switch (store) // change message based on value of store.
          {
            case 0:
              seller = usersArray[2];
              break;

            case 1:
              seller = usersArray[1];
              break;

            case 2:
              seller = usersArray[3];
              break;

            case 3:
              seller = usersArray[4];
              break;

            default:
              seller = usersArray[1];
          }

          buyItemFromUser(buyer, seller, selected_item);

        } else if (option == 0 && mode) // if they choose to sell
        {
          seller = usersArray[0];

          switch (store) // change message based on value of store.
          {
            case 0:
              buyer = usersArray[2];
              break;

            case 1:
              buyer = usersArray[1];
              break;

            case 2:
              buyer = usersArray[3];
              break;

            case 3:
              buyer = usersArray[4];
              break;

            default:
              buyer = usersArray[1];
          }

          buyItemFromUser(buyer, seller, selected_item);
        }

        itemSelected = -1;
        break;

      case "nextStore":
        if (++store == NUMSTORES) // if we're on the last store, loop around
        {
          store = 0;
        }

        switchStore(store);
        break;

      case "sort":
        // something
        orderToSort =
            JOptionPane.showOptionDialog(
                this,
                "Sort by:",
                "Sort",
                JOptionPane.DEFAULT_OPTION,
                JOptionPane.QUESTION_MESSAGE,
                null,
                SORTOPTIONS,
                null);

        break;

      case "help":
        help = true;
        break;

      default:
    }

    repaint();
  }
Example #11
0
	public PostCheckWidget(HashSet<String> p, CustomRequestCallback cb) {
		callback = cb;
		procs = p;
		vPanel = new VerticalPanel();
		vPanel.setSpacing(10);
		initWidget(vPanel);
		postCheckInfoFlexTable = new FlexTable();
		// postCheckInfoFlexTable.setWidth("100%");
		// Label payerLb = new Label("Payer");
		// payerWidget = new CustomModuleWidget(
		// "api.ClaimLog.RebillDistinctPayers");
		Label checkNumberLb = new Label(_("Check Number"));
		tbCheckNo = new TextBox();
		Label totalAmountLb = new Label(_("Total Amount"));
		tbTotalAmount = new TextBox();

		// postCheckInfoFlexTable.setWidget(0, 0, payerLb);
		// postCheckInfoFlexTable.setWidget(0, 1, payerWidget);
		postCheckInfoFlexTable.setWidget(1, 0, checkNumberLb);
		postCheckInfoFlexTable.setWidget(1, 1, tbCheckNo);
		postCheckInfoFlexTable.setWidget(2, 0, totalAmountLb);
		postCheckInfoFlexTable.setWidget(2, 1, tbTotalAmount);

		proceduresInfoTable = new CustomTable();
		proceduresInfoTable.setAllowSelection(false);
		proceduresInfoTable.setSize("100%", "100%");
		proceduresInfoTable.setIndexName("id");
		proceduresInfoTable.addColumn(_("Patient"), "pt_name");
		proceduresInfoTable.addColumn(_("Claim"), "clm");
		proceduresInfoTable.addColumn(_("CPT"), "cpt");
		proceduresInfoTable.addColumn(_("Service Date"), "ser_date");
		proceduresInfoTable.addColumn(_("Paid"), "paid");
		proceduresInfoTable.addColumn(_("Amount Billed"), "amnt_bill");
		proceduresInfoTable.addColumn(_("Amount Allowed"), "balance");
		proceduresInfoTable.addColumn(_("Adustment Balance"), "adj_bal");
		proceduresInfoTable.addColumn(_("Payment"), "pay");
		proceduresInfoTable.addColumn(_("Copay"), "copay");
		proceduresInfoTable.addColumn(_("Left Over"), "left");
		proceduresInfoTable
				.setTableWidgetColumnSetInterface(new TableWidgetColumnSetInterface() {

					@SuppressWarnings("unchecked")
					@Override
					public Widget setColumn(String columnName,
							final HashMap<String, String> data) {

						final int actionRow = proceduresInfoTable
								.getActionRow();
						if (columnName.compareTo("balance") == 0) {
							int row = proceduresInfoTable.getActionRow();
							proceduresInfoTable.getFlexTable()
									.getFlexCellFormatter().setWidth(row, 6,
											"10%");
							pids.add(data.get("id"));
							final TextBox tbAllowedAmount = new TextBox();
							tbAllowedAmount.setWidth("100%");
							tbAllowedAmount.setText(data.get("balance"));
							tbAllowedAmount
									.addChangeHandler(new ChangeHandler() {

										@Override
										public void onChange(ChangeEvent arg0) {
											float all_amnt = 0;
											float pay = 0;
											float copay = 0;
											if (!(tbAllowedAmount.getText()
													.equals("0") || tbAllowedAmount
													.getText().equals(""))) {
												all_amnt = Float
														.parseFloat(tbAllowedAmount
																.getText()
																.trim());
											}
											TextBox tb1 = (TextBox) proceduresInfoTable
													.getWidget(8);
											TextBox tb2 = (TextBox) proceduresInfoTable
													.getWidget(9);
											if (!(tb1.getText().equals("0") || tb1
													.getText().equals(""))) {
												pay = Float.parseFloat(tb1
														.getText().trim());
											}
											if (!(tb2.getText().equals("0") || tb2
													.getText().equals(""))) {
												copay = Float.parseFloat(tb2
														.getText().trim());
											}
											Label left = (Label) proceduresInfoTable
													.getWidget(10);
											left.setText(""
													+ (all_amnt - pay - copay));
										}

									});
							return tbAllowedAmount;
						} else if (columnName.compareTo("pay") == 0) {
							int row = proceduresInfoTable.getActionRow();
							proceduresInfoTable.getFlexTable()
									.getFlexCellFormatter().setWidth(row, 8,
											"10%");
							final TextBox tbPayment = new TextBox();
							tbPayment.setWidth("100%");
							tbPayment.setText("0");
							tbPayment.addChangeHandler(new ChangeHandler() {

								@Override
								public void onChange(ChangeEvent arg0) {
									float all_amnt = 0;
									float pay = 0;
									float copay = 0;
									if (!(tbPayment.getText().equals("0") || tbPayment
											.getText().equals(""))) {
										pay = Float.parseFloat(tbPayment
												.getText().trim());
									}
									TextBox tb1 = (TextBox) proceduresInfoTable
											.getWidget(6);
									TextBox tb2 = (TextBox) proceduresInfoTable
											.getWidget(9);
									if (!(tb1.getText().equals("0") || tb1
											.getText().equals(""))) {
										all_amnt = Float.parseFloat(tb1
												.getText().trim());
									}
									if (!(tb2.getText().equals("0") || tb2
											.getText().equals(""))) {
										copay = Float.parseFloat(tb2.getText()
												.trim());
									}
									Label left = (Label) proceduresInfoTable
											.getWidget(10);
									left.setText("" + (all_amnt - pay - copay));
								}

							});
							return tbPayment;
						} else if (columnName.compareTo("copay") == 0) {
							int row = proceduresInfoTable.getActionRow();
							proceduresInfoTable.getFlexTable()
									.getFlexCellFormatter().setWidth(row, 9,
											"10%");
							final TextBox tbCopay = new TextBox();
							tbCopay.setWidth("100%");
							tbCopay.setText("0");
							@SuppressWarnings("rawtypes")
							ArrayList params = new ArrayList();
							tbCopay.addChangeHandler(new ChangeHandler() {

								@Override
								public void onChange(ChangeEvent arg0) {
									float all_amnt = 0;
									float pay = 0;
									float copay = 0;
									if (!(tbCopay.getText().equals("0") || tbCopay
											.getText().equals(""))) {
										copay = Float.parseFloat(tbCopay
												.getText().trim());
									}
									TextBox tb1 = (TextBox) proceduresInfoTable
											.getWidget(6);
									TextBox tb2 = (TextBox) proceduresInfoTable
											.getWidget(8);
									if (!(tb1.getText().equals("0") || tb1
											.getText().equals(""))) {
										all_amnt = Float.parseFloat(tb1
												.getText().trim());
									}
									if (!(tb2.getText().equals("0") || tb2
											.getText().equals(""))) {
										pay = Float.parseFloat(tb2.getText()
												.trim());
									}
									Label left = (Label) proceduresInfoTable
											.getWidget(10);
									left.setText("" + (all_amnt - pay - copay));
								}

							});
							params.add(data.get("pt_id"));
							params.add(data.get("id"));

							Util.callApiMethod("Ledger",
									"getCoveragesCopayInfo", params,
									new CustomRequestCallback() {
										@Override
										public void onError() {
										}

										@Override
										public void jsonifiedData(Object d) {
											if (data != null) {
												HashMap<String, String> result = (HashMap<String, String>) d;
												// tbAmount.setEnabled(false);
												if (result != null) {
													tbCopay.setText(result
															.get("copay"));
													try {
														Label lbLeft = new Label();
														float left = 0;
														float copay = Float
																.parseFloat(result
																		.get("copay"));
														left = Float
																.parseFloat(data
																		.get("left"));
														lbLeft
																.setText(""
																		+ (left - copay));
														proceduresInfoTable
																.getFlexTable()
																.setWidget(
																		actionRow,
																		10,
																		lbLeft);
													} catch (Exception e) {
														Window.alert("aaaa");
													}
													// tbAmount.setEnabled(false);
												}
											}
										}
									}, "HashMap<String,String>");
							return tbCopay;
						} else if (columnName.compareTo("left") == 0) {
							int row = proceduresInfoTable.getActionRow();
							proceduresInfoTable.getFlexTable()
									.getFlexCellFormatter().setWidth(row, 10,
											"10%");
							try {
								Label lb = (Label) proceduresInfoTable
										.getWidget(10);
								return lb;
							} catch (Exception e) {
								return new Label();
							}
						} else if (columnName.compareTo("adj_bal") == 0) {
							int row = proceduresInfoTable.getActionRow();
							proceduresInfoTable.getFlexTable()
									.getFlexCellFormatter().setWidth(row, 7,
											"10%");
							Label adjbal = new Label();
							adjbal.setText(data.get("adj_bal"));
							return adjbal;
						} else if (columnName.compareTo("amnt_bill") == 0) {
							int row = proceduresInfoTable.getActionRow();
							proceduresInfoTable.getFlexTable()
									.getFlexCellFormatter().setWidth(row, 5,
											"10%");
							Label amntbill = new Label();
							amntbill.setText(data.get("amnt_bill"));
							return amntbill;
						}

						else {
							return (Widget) null;
						}

					}
				});
		HorizontalPanel actionPanel = new HorizontalPanel();
		actionPanel.setSpacing(5);
		// actionPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);

		CustomButton postBtn = new CustomButton(_("Post"), AppConstants.ICON_ADD);
		postBtn.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				prepareDataForPostCheck();
			}

		});
		CustomButton cancelBtn = new CustomButton(_("Cancel"),
				AppConstants.ICON_CANCEL);
		final PostCheckWidget pcw = this;
		cancelBtn.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				pcw.removeFromParent();
				callback.jsonifiedData("cancel");
			}

		});
		actionPanel.add(postBtn);
		actionPanel.add(cancelBtn);
		vPanel.add(postCheckInfoFlexTable);
		vPanel.add(proceduresInfoTable);
		vPanel.add(actionPanel);
		vPanel.setCellHorizontalAlignment(actionPanel,
				HasHorizontalAlignment.ALIGN_RIGHT);
		pids = new ArrayList<String>();
		loadSelectedProcedureInfo();
	}