예제 #1
0
  private static void createText(final Group group) {
    group.setLayout(new GridLayout(2, false));
    group.setText("Text widget");

    final Label lbl0 = new Label(group, SWT.NONE);
    lbl0.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    lbl0.setText("No prompt :");

    final Text txt0 = new Text(group, SWT.BORDER);
    txt0.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));

    final Label lbl1 = new Label(group, SWT.NONE);
    lbl1.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    lbl1.setText("Simple text prompt :");

    final Text txt1 = new Text(group, SWT.BORDER);
    txt1.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    PromptSupport.setPrompt("Type anything you want", txt1);

    final Label lbl2 = new Label(group, SWT.NONE);
    lbl2.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    lbl2.setText("Other style (bold) :");

    final Text txt2 = new Text(group, SWT.BORDER);
    txt2.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    PromptSupport.setPrompt("Type anything you want in bold", txt2);
    PromptSupport.setFontStyle(SWT.BOLD, txt2);

    final Label lbl3 = new Label(group, SWT.NONE);
    lbl3.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    lbl3.setText("Behaviour highlight :");

    final Text txt3 = new Text(group, SWT.BORDER);
    txt3.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    PromptSupport.setPrompt("Type anything you want", txt3);
    PromptSupport.setFocusBehavior(FocusBehavior.HIGHLIGHT_PROMPT, txt3);

    final Label lbl4 = new Label(group, SWT.NONE);
    lbl4.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    lbl4.setText("Change colors :");

    final Text txt4 = new Text(group, SWT.BORDER);
    txt4.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    PromptSupport.setPrompt("Type anything you want", txt4);
    PromptSupport.setForeground(txt4.getDisplay().getSystemColor(SWT.COLOR_YELLOW), txt4);
    PromptSupport.setBackground(txt4.getDisplay().getSystemColor(SWT.COLOR_BLACK), txt4);

    final Label lbl5 = new Label(group, SWT.NONE);
    lbl5.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    lbl5.setText("Change when widget is initialized :");

    final Text txt5 = new Text(group, SWT.BORDER);
    txt5.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    txt5.setText("Remove what is typed...");
    txt5.setBackground(txt4.getDisplay().getSystemColor(SWT.COLOR_BLACK));
    txt5.setForeground(txt4.getDisplay().getSystemColor(SWT.COLOR_YELLOW));

    PromptSupport.setPrompt("Type anything you want", txt5);
    PromptSupport.setForeground(txt4.getDisplay().getSystemColor(SWT.COLOR_DARK_BLUE), txt5);
    PromptSupport.setBackground(txt4.getDisplay().getSystemColor(SWT.COLOR_WHITE), txt5);
  }
예제 #2
0
  @SuppressWarnings({"rawtypes", "unchecked"})
  public BookView() {
    setLayout(new BorderLayout(5, 5));

    lbISBN = new JLabel("ISBN");
    lbISBN.setForeground(Color.blue);
    lbTitle = new JLabel("Title");
    lbTitle.setForeground(Color.blue);
    lbAuthor = new JLabel("Author");
    lbAuthor.setForeground(Color.blue);
    lbCategory = new JLabel("Category");
    lbCategory.setForeground(Color.blue);
    lbPrice = new JLabel("Price");
    lbPrice.setForeground(Color.blue);
    lbQuantity = new JLabel("Quantity");
    lbQuantity.setForeground(Color.blue);

    tfISBN = new JTextField(36);
    tfTitle = new JTextField(36);
    tfPrice = new JTextField(36);
    tfAuthor = new JTextField(36);
    tfCategory = new JTextField(36);
    tfQuantity = new JTextField(36);
    PromptSupport.setPrompt("Only for button ADD", tfQuantity);

    panel1 = new JPanel();
    panel1.setLayout(new GridLayout(3, 6, 5, 10));
    panel1.add(lbISBN);
    panel1.add(tfISBN);
    panel1.add(lbTitle);
    panel1.add(tfTitle);
    panel1.add(lbPrice);
    panel1.add(tfPrice);
    panel1.add(lbAuthor);
    panel1.add(tfAuthor);
    panel1.add(lbCategory);
    panel1.add(tfCategory);
    panel1.add(lbQuantity);
    panel1.add(tfQuantity);
    panel1.add(new JLabel());
    panel1.add(new JLabel());
    panel1.add(new JLabel());
    panel1.add(new JLabel());
    panel1.add(new JLabel());
    panel1.add(new JLabel());

    add(panel1, BorderLayout.NORTH);

    Vector colsName = new Vector();
    colsName.addElement("ISBN");
    colsName.addElement("Tittle");
    colsName.addElement("Author");
    colsName.addElement("Category");
    colsName.addElement("Price");
    colsName.addElement("Total Book");
    colsName.addElement("Remain Book");
    Vector data = new Vector();

    bookDetails = new JTable(data, colsName);
    bookDetails.setPreferredScrollableViewportSize(new Dimension(500, 100));
    bookDetails.setFillsViewportHeight(true);
    bookDetails.setAutoCreateRowSorter(true);
    scrollPanel = new JScrollPane(bookDetails);
    add(scrollPanel, BorderLayout.CENTER);

    panel3 = new JPanel();
    panel3.setLayout(new GridLayout(1, 3, 5, 10));
    btnAdd = new JButton("Add");
    btnAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icon/btnAdd.png")));
    btnEdit = new JButton("Edit");
    btnEdit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icon/btnEdit.png")));
    btnDelete = new JButton("Delete");
    btnDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icon/btnDelete.png")));
    panel3.add(btnAdd);
    panel3.add(btnEdit);
    panel3.add(btnDelete);
    add(panel3, BorderLayout.SOUTH);

    setTitle("BOOK MANAGEMENT");
    setIconImage(
        Toolkit.getDefaultToolkit().getImage(getClass().getResource("/Icon/bookView.png")));
    setSize(970, 600);
    setLocationRelativeTo(null);
    setVisible(true);
  }