Example #1
0
  public ShowComp() throws InterruptedException, IOException {
    super("CONNECTED COMPUTERS");
    int x = 0, d = 20;
    mb = new JMenuBar();
    File = new JMenu("File");
    mb.add(File);
    exit = new JMenuItem("Exit");
    exit.addActionListener(this);
    File.add(exit);
    ta = new JTextArea();
    ta.setBounds(20, 30, 315, 470);
    ta.setEditable(false);
    add(ta);

    setJMenuBar(mb);

    sel = new JLabel("The connected computers are..");
    sel.setBounds(15, 5, 300, 30);
    add(sel);
    b1 = new JButton("<< BACK");
    b1.setBounds(140, 510, 100, 30);
    b1.setToolTipText("Back to main page");
    b1.addActionListener(this);
    add(b1);
    setLayout(null);
    while (x < 360) {
      x = x + d;
      setBounds(675, 50, x, 600);
      this.show();
    }
    // setVisible(true);
    String s = "192.168.0.", temp = null;
    Printer printer = new Printer();
    printer.start();
    Connector connector = new Connector(printer);
    connector.start();

    LinkedList targets = new LinkedList();
    for (int i = 1; i <= 255; i++) {
      temp = s + Integer.toString(i);
      Target t = new Target(temp);
      targets.add(t);
      connector.add(t);
    }
    Thread.sleep(2000);
    connector.shutdown();
    connector.join();

    for (Iterator i = targets.iterator(); i.hasNext(); ) {
      Target t = (Target) i.next();
      if (!t.shown) t.show();
    }

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  }
Example #2
0
  private JPanel createTopPanel(YWorkItem item) {
    JPanel topPanel = new JPanel(new BorderLayout());
    topPanel.setBackground(YAdminGUI._apiColour);

    JPanel leftPanel = new JPanel(new BorderLayout());
    leftPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    JTextArea explanatoryText = new JTextArea();
    explanatoryText.setText(
        "The data you submitted for this work item was \n"
            + "validated against a schema (see below).  For some reason the\n"
            + "this data did not succeed in passing the constrainst set\n"
            + "inside the schema.\n"
            + "Usage Note: If this is causing problems try using the Web server\n"
            + "version of YAWL, which supports automatic forms generation.\n"
            + "Otherwise you could copy the schema from this page and use it\n "
            + "to create a valid output document using an XML development tool.");
    explanatoryText.setEditable(false);
    explanatoryText.setFont(new Font("Arial", Font.BOLD, 12));
    explanatoryText.setForeground(Color.DARK_GRAY);
    explanatoryText.setBackground(YAdminGUI._apiColour);
    leftPanel.add(explanatoryText);
    topPanel.add(leftPanel, BorderLayout.WEST);

    JPanel rightPanel = new JPanel(new GridLayout(4, 2));

    rightPanel.setBackground(YAdminGUI._apiColour);
    rightPanel.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(
                BorderFactory.createEtchedBorder(), "Work Item Details"),
            BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    YTask task =
        YEngine.getInstance().getTaskDefinition(item.getSpecificationID(), item.getTaskID());
    String taskName = task.getName();

    String[] text = {
      item.getSpecificationID().toString(), taskName, item.getIDString(), item.getStartTimeStr()
    };
    String[] labels = {"Specification ID", "Task Name", "WorkItem ID", "Task Started"};
    for (int i = 0; i < text.length; i++) {
      String s = text[i];
      rightPanel.add(new JLabel(labels[i]));
      JTextField t = new JTextField(s);
      t.setEditable(false);
      rightPanel.add(t);
    }
    topPanel.add(rightPanel, BorderLayout.CENTER);
    return topPanel;
  }
  // Constructor
  public ProcessRentalView() {
    this.f = new JFrame("Process Rental");
    f.pack();
    p = new JPanel();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int height = screenSize.height;
    int width = screenSize.width;
    f.setSize(width / 2, height / 2);

    f.setLocationRelativeTo(null);
    fl = new FlowLayout(FlowLayout.CENTER);
    idLabel = new JLabel("Item ID: ");
    idTextField = new JTextField(5);
    quantityLabel = new JLabel("Quantity: ");
    quantityTextField = new JTextField(5);
    dateLabel = new JLabel("Date(MM/DD/YYYY): ");
    dateTextField = new JTextField(8);
    dateTextField.setText("");
    totalItemsLabel = new JLabel("Items:");
    totalItems = new JTextArea("");
    totalItems.setEditable(false);
    totalItems.setColumns(10);
    totalItems.setRows(12);
    totalCostLabel = new JLabel("Total Cost:");
    totalCost = new JTextField(10);
    totalCost.setEditable(false);

    addButton = new JButton("Add Item");
    exitButton = new JButton("Exit");
    checkoutButton = new JButton("Checkout");
    p.add(idLabel);
    p.add(idTextField);
    p.add(quantityLabel);
    p.add(quantityTextField);
    p.add(dateLabel);
    p.add(dateTextField);
    p.add(addButton);
    p.add(exitButton);
    p.add(totalItemsLabel);
    p.add(totalItems);
    p.add(totalCostLabel);
    p.add(totalCost);
    p.add(checkoutButton);
    p.setLayout(fl);

    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setContentPane(p);
    f.setVisible(true);
  }
  /** Initialisation */
  private void initComponents() {
    setBackground(new java.awt.Color(114, 159, 255));
    addWindowListener(
        new java.awt.event.WindowAdapter() {
          public void windowClosing(java.awt.event.WindowEvent evt) {
            closeDialog();
          }
        });
    getContentPane().setLayout(new java.awt.BorderLayout());

    JPanel actionPanel = new JPanel();
    actionPanel.setLayout(new java.awt.GridLayout(1, 0));
    detailedArea.setEditable(false);
    detailedArea.setVisible(true);
    detailedArea.setSize(500, 300);
    detailedArea.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 11));
    StringWriter opDetail = new StringWriter();
    actionPrint(new PrintWriter(opDetail));
    detailedArea.setText(new String(opDetail.getBuffer()));
    JScrollPane scroll = new JScrollPane(detailedArea);
    actionPanel.add(scroll);
    getContentPane().add(actionPanel, "Center");

    northToolBar = new javax.swing.JToolBar();
    northToolBar.setLayout(new java.awt.FlowLayout());
    northToolBar.setFloatable(false);

    jbn_Print = new javax.swing.JButton();
    jbn_Print.setText("   Print   ");
    jbn_Print.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jbn_PrintActionPerformed();
          }
        });
    northToolBar.add(jbn_Print);

    jbn_OK = new javax.swing.JButton();
    jbn_OK.setText("   Close   ");
    jbn_OK.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jbn_OKActionPerformed();
          }
        });
    northToolBar.add(jbn_OK);

    getContentPane().add(northToolBar, "South");
  }
Example #5
0
    public HelpFrame(JFrame f) {
      super("Help menu");
      setSize(320, 240);
      setLocationRelativeTo(f);
      setResizable(false);

      JTextArea message = new JTextArea();
      message.setEditable(false);
      message.setText(
          "Default keybindings:\n     -Cmd+e to toggle terminal\n     -Cmd+k to run\n     -Cmd+/ to show help\n     -Cmd+o for options\n\n"
              + "Special keywords: \n     -'import' can be typed anywhere \n     -'method' and then a method will compile\n\n"
              + "Other: \n     -You can also use this for normal Java editing!");

      add(message, "Center");
      setVisible(true);
    }
  public PhoneBookGUI(PhoneBook pb) {
    super("PhoneBook");
    phoneBook = pb;

    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

    Locale.setDefault(new Locale("en"));
    /* To avoid hardcoded Swedish text on OptionPane dialogs */
    UIManager.put("OptionPane.cancelButtonText", "Cancel");

    setLayout(new BorderLayout());
    JMenuBar menubar = new JMenuBar();
    setJMenuBar(menubar);

    JMenu editMenu = new JMenu("Edit");
    menubar.add(editMenu);
    editMenu.add(new AddMenu(phoneBook, this));
    editMenu.add(new RemoveMenu(phoneBook, this));
    JMenu findMenu = new JMenu("Find");
    menubar.add(findMenu);
    findMenu.add(new FindNumbersMenu(phoneBook, this));
    findMenu.add(new FindNamesMenu(phoneBook, this));
    JMenu viewMenu = new JMenu("View");
    menubar.add(viewMenu);
    viewMenu.add(new ShowAllMenu(phoneBook, this));

    JPanel southPanel = new JPanel();
    messageArea = new JTextArea(4, 25);
    messageArea.setEditable(false);
    southPanel.add(new JScrollPane(messageArea));
    southPanel.add(new QuitButton(phoneBook));
    add(southPanel, BorderLayout.CENTER);

    pack();
    setVisible(true);

    String fileName = JOptionPane.showInputDialog("Enter file name");
    if (fileName != null) {
      try {
        phoneBook.readFromFile(fileName);
      } catch (Exception e) {
        setText("No such file was found");
      }
    }
  }
Example #7
0
  private void buildInterface() {

    // Panel p to hold the label and text field
    JPanel panelInput = new JPanel();
    panelInput.setLayout(new BorderLayout());
    panelInput.add(buttonSelect, BorderLayout.EAST);
    panelInput.add(textFolder, BorderLayout.CENTER);
    textFolder.setEditable(false);
    textFolder.setText(System.getProperty("user.home") + "\\"); // Set default save location

    setLayout(new BorderLayout());
    add(panelInput, BorderLayout.NORTH);
    add(new JScrollPane(textArea), BorderLayout.CENTER);
    textArea.setEditable(false);

    buttonSelect.setToolTipText(TOOL_TIP_SELECT_FOLDER);
    buttonSelect.addActionListener(new ButtonListener()); // Register listener
  }
  private void createErrorCard() {
    myErrorPanel = new JPanel(new BorderLayout());
    myErrorMessages =
        new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 10, 5, true, false));
    myErrorPanel.add(myErrorMessages, BorderLayout.PAGE_START);

    myErrorStack = new JTextArea(50, 20);
    myErrorStack.setEditable(false);

    myErrorStackLayout = new CardLayout();
    myErrorStackPanel = new JPanel(myErrorStackLayout);
    myErrorStackPanel.add(new JLabel(), ERROR_NO_STACK_CARD);
    myErrorStackPanel.add(ScrollPaneFactory.createScrollPane(myErrorStack), ERROR_STACK_CARD);

    myErrorPanel.add(myErrorStackPanel, BorderLayout.CENTER);

    add(myErrorPanel, ERROR_CARD);
  }
Example #9
0
  public DirectorySize() {
    super(new BorderLayout());

    // Create the log first, because the action listeners
    // need to refer to it.
    log = new JTextArea(50, 100);
    log.setMargin(new Insets(5, 5, 5, 5));
    log.setEditable(false);
    JScrollPane logScrollPane = new JScrollPane(log);

    // Create a file chooser
    fc = new JFileChooser();

    // Uncomment one of the following lines to try a different
    // file selection mode.  The first allows just directories
    // to be selected (and, at least in the Java look and feel,
    // shown).  The second allows both files and directories
    // to be selected.  If you leave these lines commented out,
    // then the default mode (FILES_ONLY) will be used.
    //
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    // fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);

    // Create the open button.  We use the image from the JLF
    // Graphics Repository (but we extracted it from the jar).
    openButton = new JButton("Open Folder...");
    openButton.addActionListener(this);

    // Create the save button.  We use the image from the JLF
    // Graphics Repository (but we extracted it from the jar).
    saveButton = new JButton("Clear Log...");
    saveButton.addActionListener(this);

    // For layout purposes, put the buttons in a separate panel
    JPanel buttonPanel = new JPanel(); // use FlowLayout
    buttonPanel.add(openButton);
    buttonPanel.add(saveButton);

    // Add the buttons and the log to this panel.
    add(buttonPanel, BorderLayout.PAGE_START);
    add(logScrollPane, BorderLayout.CENTER);
  }
Example #10
0
  /**
   * Builds the components from the file and displays it.
   *
   * @param strFile the file to be read.
   */
  public void build(int nType, String strFile, String strhelpfile) {
    m_nType = nType;
    m_strPath = (strFile != null) ? FileUtil.openPath(strFile) : "";
    m_strHelpFile = strhelpfile;
    boolean bValidate = false;
    boolean bChecksum = false;

    if (nType == CONFIG) {
      setTitle("Configuration");
      buildConfig();
    } else {
      JComponent compDisplay = null;
      if (nType == DEFAULT) {
        m_pnlAccPolicy = new AccPolicyPanel(m_strPath);
        compDisplay = m_pnlAccPolicy;
        setTitle("Password Configuration");
      } else if (nType == CHECKSUM) {
        m_pnlChecksum = new ChecksumPanel(m_strPath);
        compDisplay = m_pnlChecksum;
        setTitle("Checksum Configuration");
        bValidate = true;
        bChecksum = true;
      } else {
        setTitle("Perform System Validation");
        compDisplay = new JTextArea();
        ((JTextArea) compDisplay).setEditable(false);
        bValidate = true;
        doBlink();
      }
      m_pnlDisplay.removeAll();
      m_pnlDisplay.setLayout(new BorderLayout());
      m_pnlDisplay.add(compDisplay, BorderLayout.CENTER);
      setVisible(true);
    }
    validateButton.setVisible(bValidate);
    // abandonButton.setVisible(!bValidate);
    setAbandonEnabled(bValidate);
    m_btnChecksum.setVisible(bChecksum);
  }
  public WizStepManyTextFields(Wizard w, String instr, Vector strings) {
    // store wizard?
    _instructions.setText(instr);
    _instructions.setWrapStyleWord(true);
    _instructions.setEditable(false);
    _instructions.setBorder(null);
    _instructions.setBackground(_mainPanel.getBackground());

    _mainPanel.setBorder(new EtchedBorder());

    GridBagLayout gb = new GridBagLayout();
    _mainPanel.setLayout(gb);

    GridBagConstraints c = new GridBagConstraints();
    c.ipadx = 3;
    c.ipady = 3;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.anchor = GridBagConstraints.EAST;

    JLabel image = new JLabel("");
    // image.setMargin(new Insets(0, 0, 0, 0));
    image.setIcon(WIZ_ICON);
    image.setBorder(null);
    c.gridx = 0;
    c.gridheight = GridBagConstraints.REMAINDER;
    c.gridy = 0;
    c.anchor = GridBagConstraints.NORTH;
    gb.setConstraints(image, c);
    _mainPanel.add(image);

    c.weightx = 0.0;
    c.gridx = 2;
    c.gridheight = 1;
    c.gridwidth = 3;
    c.gridy = 0;
    c.fill = GridBagConstraints.NONE;
    gb.setConstraints(_instructions, c);
    _mainPanel.add(_instructions);

    c.gridx = 1;
    c.gridy = 1;
    c.weightx = 0.0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    SpacerPanel spacer = new SpacerPanel();
    gb.setConstraints(spacer, c);
    _mainPanel.add(spacer);

    c.gridx = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = 1;
    int size = strings.size();
    for (int i = 0; i < size; i++) {
      c.gridy = 2 + i;
      String s = (String) strings.elementAt(i);
      JTextField tf = new JTextField(s, 50);
      tf.setMinimumSize(new Dimension(200, 20));
      tf.getDocument().addDocumentListener(this);
      _fields.addElement(tf);
      gb.setConstraints(tf, c);
      _mainPanel.add(tf);
    }

    c.gridx = 1;
    c.gridy = 3 + strings.size();
    c.weightx = 0.0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    SpacerPanel spacer2 = new SpacerPanel();
    gb.setConstraints(spacer2, c);
    _mainPanel.add(spacer2);
  }
  public void setup() {
    setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    title = new JLabel(SHTML + TITLE + elem.title + EHTML);
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.gridy = 4;
    gbc.gridx = 0;
    gbc.gridwidth = 2;
    gbc.gridheight = 1;
    gbc.weighty = 1.0;
    add(title, gbc);
    donor = new JLabel(SHTML + DONOR + elem.donor + EHTML);
    gbc.gridy = 5;
    add(donor, gbc);
    subDate = new JLabel(SHTML + SUB_DATE + elem.subDate.toString() + EHTML);
    gbc.gridy = 6;
    add(subDate, gbc);
    objDate = new JLabel(SHTML + OBJ_DATE + elem.objDate.toString() + EHTML);
    gbc.gridy = 7;
    add(objDate, gbc);
    medium = new JLabel(SHTML + MEDIUM + elem.medium + EHTML);
    gbc.gridy = 8;
    add(medium, gbc);
    accNum = new JLabel(SHTML + ACC_NUM + elem.accNum + EHTML);
    gbc.gridy = 9;
    add(accNum, gbc);
    desc = new JLabel(SHTML + DESC + EHTML);
    // gbc.anchor = GridBagConstraints.PAGE_START;
    gbc.insets = new Insets(0, 50, 0, 0);
    gbc.gridy = 4;
    gbc.gridx = 2;
    add(desc, gbc);
    descView = new JTextArea();
    descView.setLineWrap(true);
    descView.setWrapStyleWord(true);
    descView.setEditable(false);
    descView.setText(elem.desc);
    descView.setFont(new Font("Times New Roman", Font.PLAIN, 13));
    JScrollPane scrollPane = new JScrollPane(descView);
    scrollPane.setPreferredSize(new Dimension(225, 100));
    // scrollPane.setBorder(null);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    descView.setCaretPosition(0);
    gbc.gridy = 5;
    gbc.gridheight = 4;
    gbc.gridx = 2;
    add(scrollPane, gbc);

    gbc.insets = null;
    gbc.gridy = 0;
    gbc.gridx = 0;
    gbc.gridwidth = 4;
    gbc.gridheight = 4;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(0, 0, 10, 0);
    vpan = new V3DPanel(elem, provider);
    vpan.setPreferredSize(new Dimension(500, 300));
    setBackground(BACKGROUND);
    add(vpan, gbc);
    validate();
  }
Example #13
0
  public void makeGUI() {
    frm = new JFrame();
    c = frm.getContentPane();

    btnImport = new JButton("Import");
    btnImport.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            secureImport();
          }
        });
    btnMove = new JButton("Move");
    btnMove.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            secureMove();
          }
        });
    btnDelete = new JButton("Delete");
    btnDelete.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            secureDelete();
          }
        });
    btnAnalyse = new JButton("Analyse");
    btnAnalyse.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            secureAnalysis();
          }
        });

    tblItems = new JTable(store);
    tblItems.setRowSorter(tableSorter);
    tblItems.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tblItems.setFillsViewportHeight(true);
    tblItems.getRowSorter().toggleSortOrder(Storage.COL_DATE);
    tblItems.addMouseListener(
        new MouseListener() {
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
              tblItems.setRowSelectionInterval(
                  e.getY() / tblItems.getRowHeight(), e.getY() / tblItems.getRowHeight());
            }
            if (e.getClickCount() > 1 || e.getButton() == MouseEvent.BUTTON3) {
              int idx = tblItems.convertRowIndexToModel(tblItems.getSelectedRow());
              secureExport(idx);
            }
          }

          public void mouseEntered(MouseEvent arg0) {}

          public void mouseExited(MouseEvent arg0) {}

          public void mousePressed(MouseEvent arg0) {}

          public void mouseReleased(MouseEvent arg0) {}
        });

    txaStatus = new JTextArea(TXA_HEIGHT, TXA_WIDTH);
    txaStatus.setEditable(false);
    txaStatus.setBorder(BorderFactory.createTitledBorder("Status"));
    txaSearch = new JTextArea(4, TXA_WIDTH);
    txaSearch.setBorder(BorderFactory.createTitledBorder("Search"));
    txaSearch.addKeyListener(
        new KeyListener() {
          public void keyPressed(KeyEvent arg0) {}

          public void keyReleased(KeyEvent arg0) {
            filterBase(txaSearch.getText());
            // EXPORT settings here, as in mass export (export everything)
            if (allowExport && txaSearch.getText().equalsIgnoreCase(CMD_EXPORT)) {
              // txaSearch.setText("");
              if (JOptionPane.showConfirmDialog(
                      frm,
                      "Do you really want to export the whole secure base?",
                      "Confirm Export",
                      JOptionPane.OK_CANCEL_OPTION)
                  == JOptionPane.OK_OPTION) {
                totalExport();
              }
            }
            // LOST X IMPORT asin look through the store for files not listed
            if (txaSearch.getText().equalsIgnoreCase(CMD_STOCKTAKE)) {
              for (int i = 0; i < storeLocs.size(); i++) {
                if (store.stockTake(i)) needsSave = true;
              }
            }
          }

          public void keyTyped(KeyEvent arg0) {}
        });

    JPanel pnlTop = new JPanel(new GridLayout(1, 4));
    JPanel pnlEast = new JPanel(new BorderLayout());
    JPanel pnlCenterEast = new JPanel(new BorderLayout());
    JScrollPane jspItems = new JScrollPane(tblItems);

    pnlTop.add(btnImport);
    pnlTop.add(btnMove);
    pnlTop.add(btnDelete);
    pnlTop.add(btnAnalyse);
    pnlCenterEast.add(txaStatus, BorderLayout.CENTER);
    pnlCenterEast.add(txaSearch, BorderLayout.NORTH);
    // pnlEast.add(pswPass, BorderLayout.NORTH);
    pnlEast.add(pnlCenterEast, BorderLayout.CENTER);
    c.setLayout(new BorderLayout());
    c.add(pnlTop, BorderLayout.NORTH);
    c.add(pnlEast, BorderLayout.EAST);
    c.add(jspItems, BorderLayout.CENTER);
    frm.setContentPane(c);
  }
Example #14
0
  /**
   * Inizialize frame components
   *
   * @throws CMSException
   * @throws FileNotFoundException
   * @throws IOException
   * @throws GeneralSecurityException
   */
  private void initComponents()
      throws CMSException, FileNotFoundException, IOException, GeneralSecurityException {

    // *********************************

    panel4 = new JPanel();
    label2 = new JLabel();
    textPane1 = new JTextPane();
    panel5 = new JPanel();
    textArea1 = new JTextArea();
    textArea2 = new JTextArea();

    progressBar = new JProgressBar();

    textPane2 = new JTextPane();
    textField1 = new JTextField();
    button1 = new JButton();
    panel6 = new JPanel();
    button2 = new JButton();
    button3 = new JButton();
    button4 = new JButton();
    GridBagConstraints gbc;
    // ======== this ========
    Container contentPane = getContentPane();
    contentPane.setLayout(new GridBagLayout());
    ((GridBagLayout) contentPane.getLayout()).columnWidths = new int[] {165, 0, 0};
    ((GridBagLayout) contentPane.getLayout()).rowHeights = new int[] {105, 50, 0};
    ((GridBagLayout) contentPane.getLayout()).columnWeights = new double[] {0.0, 1.0, 1.0E-4};
    ((GridBagLayout) contentPane.getLayout()).rowWeights = new double[] {1.0, 0.0, 1.0E-4};

    // ======== panel4 ========
    {
      panel4.setBackground(Color.white);
      panel4.setLayout(new GridBagLayout());
      ((GridBagLayout) panel4.getLayout()).columnWidths = new int[] {160, 0};
      ((GridBagLayout) panel4.getLayout()).rowHeights = new int[] {0, 0, 0};
      ((GridBagLayout) panel4.getLayout()).columnWeights = new double[] {0.0, 1.0E-4};
      ((GridBagLayout) panel4.getLayout()).rowWeights = new double[] {1.0, 1.0, 1.0E-4};

      // ---- label2 ----
      label2.setIcon(
          new ImageIcon(
              "images" + System.getProperty("file.separator") + "logo-freesigner-piccolo.png"));
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      gbc.insets.bottom = 5;
      panel4.add(label2, gbc);

      // ---- textPane1 ----
      textPane1.setFont(new Font("Verdana", Font.BOLD, 12));
      textPane1.setText("Lettura\ncertificati\nda token");
      textPane1.setEditable(false);
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 1;
      gbc.anchor = GridBagConstraints.NORTHWEST;
      panel4.add(textPane1, gbc);
    }
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets.bottom = 5;
    gbc.insets.right = 5;
    contentPane.add(panel4, gbc);

    // ======== panel5 ========
    {
      panel5.setBackground(Color.white);
      panel5.setLayout(new GridBagLayout());
      ((GridBagLayout) panel5.getLayout()).columnWidths = new int[] {0, 205, 0, 0};
      ((GridBagLayout) panel5.getLayout()).rowHeights = new int[] {100, 0, 30, 30, 0};
      ((GridBagLayout) panel5.getLayout()).columnWeights = new double[] {1.0, 0.0, 1.0, 1.0E-4};
      ((GridBagLayout) panel5.getLayout()).rowWeights = new double[] {0.0, 0.0, 1.0, 1.0, 1.0E-4};

      // ---- textArea1 ----
      textArea1.setFont(new Font("Verdana", Font.BOLD, 14));
      textArea1.setText("Lettura certificati da token");
      textArea1.setEditable(false);
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.gridwidth = 3;
      gbc.fill = GridBagConstraints.VERTICAL;
      gbc.insets.bottom = 5;
      panel5.add(textArea1, gbc);

      // ---- textArea2 ----
      textArea2.setFont(new Font("Verdana", Font.PLAIN, 12));
      textArea2.setText("Ricerca certificati...\n");
      textArea2.setEditable(false);
      textArea2.setColumns(30);
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 1;
      gbc.gridwidth = 3;
      gbc.fill = GridBagConstraints.BOTH;
      panel5.add(textArea2, gbc);
      progressBar.setValue(0);
      progressBar.setMaximum(1);
      progressBar.setStringPainted(true);
      progressBar.setBounds(0, 0, 300, 150);

      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 2;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      gbc.insets.bottom = 5;
      gbc.insets.right = 5;
      gbc.gridwidth = 3;
      panel5.add(progressBar, gbc);
    }
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets.bottom = 5;
    contentPane.add(panel5, gbc);

    // ======== panel6 ========
    {
      panel6.setBackground(Color.white);
      panel6.setLayout(new GridBagLayout());
      ((GridBagLayout) panel6.getLayout()).columnWidths = new int[] {0, 0, 0, 0};
      ((GridBagLayout) panel6.getLayout()).rowHeights = new int[] {0, 0};
      ((GridBagLayout) panel6.getLayout()).columnWeights = new double[] {1.0, 1.0, 1.0, 1.0E-4};
      ((GridBagLayout) panel6.getLayout()).rowWeights = new double[] {1.0, 1.0E-4};

      // ---- button2 ----
      button2.setText("Indietro");
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.insets.right = 5;
      button2.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {

              frame.hide();

              FreeSignerSignApplet nuovo = new FreeSignerSignApplet();
            }
          });

      // panel6.add(button2, gbc);

      // ---- button4 ----
      button4.setText("Annulla");
      gbc = new GridBagConstraints();
      gbc.gridx = 2;
      gbc.gridy = 0;
      // panel6.add(button4, gbc);
    }
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.BOTH;
    contentPane.add(panel6, gbc);
    contentPane.setBackground(Color.white);
    frame = new JFrame();
    frame.setContentPane(contentPane);
    frame.setTitle("Freesigner");
    frame.setSize(300, 150);
    frame.setResizable(false);
    frame.pack();
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((d.width - frame.getWidth()) / 2, (d.height - frame.getHeight()) / 2);

    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
    timer =
        new Timer(
            10,
            new ActionListener() {

              public void actionPerformed(ActionEvent evt) {
                frame.show();
                if (task.getMessage() != null) {
                  String s = new String();
                  s = task.getMessage();
                  s = s.substring(0, Math.min(60, s.length()));

                  textArea2.setText(s + " ");
                  progressBar.setValue(task.getStatus());
                }
                if (task.isDone()) {
                  timer.stop();

                  // Finalizzo la cryptoki, onde evitare
                  // successivi errori PKCS11 "cryptoki alreadi initialized"

                  if ((task != null)) task.libFinalize();

                  ArrayList slotInfos = task.getSlotInfos();
                  if ((slotInfos == null) || slotInfos.isEmpty()) {

                    frame.show();

                    JOptionPane.showMessageDialog(
                        frame,
                        "Controllare la presenza sul sistema\n"
                            + "della libreria PKCS11 impostata.",
                        "Nessun lettore rilevato",
                        JOptionPane.WARNING_MESSAGE);

                    frame.hide();

                  } else {
                    String st = task.getCRLerror();

                    if (st.length() > 0) {
                      timer.stop();

                      JOptionPane.showMessageDialog(
                          frame,
                          "C'è stato un errore nella verifica CRL.\n" + st,
                          "Errore verifica CRL",
                          JOptionPane.ERROR_MESSAGE);
                      frame.hide();
                      FreeSignerSignApplet nuovo = new FreeSignerSignApplet();
                    }
                    if (task.getDifferentCerts() == 0) {
                      if (task.getCIr() != null) {
                        JOptionPane.showMessageDialog(
                            frame,
                            "La carta "
                                + task.getCardDescription()
                                + " nel lettore "
                                + conf.getReader()
                                + " non contiene certificati",
                            "Attenzione",
                            JOptionPane.WARNING_MESSAGE);

                      } else
                        JOptionPane.showMessageDialog(
                            frame, task.getMessage(), "Errore:", JOptionPane.ERROR_MESSAGE);
                    }

                    frame.hide();

                    // confFrame.createTreeAndTokenNodes(task.getSlotInfos());

                  }
                }
              }
            });
  }
Example #15
0
  // initializes the internal component of the translator
  protected void jbInit() {
    this.getContentPane().setLayout(new GridBagLayout());

    loadButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            loadButton_actionPerformed(e);
          }
        });
    loadButton.setMaximumSize(new Dimension(39, 39));
    loadButton.setMinimumSize(new Dimension(39, 39));
    loadButton.setPreferredSize(new Dimension(39, 39));
    loadButton.setSize(new Dimension(39, 39));
    loadButton.setToolTipText("Load Source File");
    loadButton.setIcon(loadIcon);

    saveButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            saveButton_actionPerformed(e);
          }
        });
    saveButton.setMaximumSize(new Dimension(39, 39));
    saveButton.setMinimumSize(new Dimension(39, 39));
    saveButton.setPreferredSize(new Dimension(39, 39));
    saveButton.setSize(new Dimension(39, 39));
    saveButton.setToolTipText("Save Destination File");
    saveButton.setIcon(saveIcon);

    singleStepButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            singleStepButton_actionPerformed(e);
          }
        });
    singleStepButton.setMaximumSize(new Dimension(39, 39));
    singleStepButton.setMinimumSize(new Dimension(39, 39));
    singleStepButton.setPreferredSize(new Dimension(39, 39));
    singleStepButton.setSize(new Dimension(39, 39));
    singleStepButton.setToolTipText("Single Step");
    singleStepButton.setIcon(singleStepIcon);

    ffwdButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ffwdButton_actionPerformed(e);
          }
        });
    ffwdButton.setMaximumSize(new Dimension(39, 39));
    ffwdButton.setMinimumSize(new Dimension(39, 39));
    ffwdButton.setPreferredSize(new Dimension(39, 39));
    ffwdButton.setSize(new Dimension(39, 39));
    ffwdButton.setToolTipText("Fast Forward");
    ffwdButton.setIcon(ffwdIcon);

    rewindButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            rewindButton_actionPerformed(e);
          }
        });
    rewindButton.setMaximumSize(new Dimension(39, 39));
    rewindButton.setMinimumSize(new Dimension(39, 39));
    rewindButton.setPreferredSize(new Dimension(39, 39));
    rewindButton.setSize(new Dimension(39, 39));
    rewindButton.setToolTipText("Rewind");
    rewindButton.setIcon(rewindIcon);

    stopButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            stopButton_actionPerformed(e);
          }
        });
    stopButton.setMaximumSize(new Dimension(39, 39));
    stopButton.setMinimumSize(new Dimension(39, 39));
    stopButton.setPreferredSize(new Dimension(39, 39));
    stopButton.setSize(new Dimension(39, 39));
    stopButton.setToolTipText("Stop");
    stopButton.setIcon(stopIcon);

    fullTranslationButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            fullTranslationButton_actionPerformed(e);
          }
        });
    fullTranslationButton.setMaximumSize(new Dimension(39, 39));
    fullTranslationButton.setMinimumSize(new Dimension(39, 39));
    fullTranslationButton.setPreferredSize(new Dimension(39, 39));
    fullTranslationButton.setSize(new Dimension(39, 39));
    fullTranslationButton.setToolTipText("Fast Translation");
    fullTranslationButton.setIcon(fullTranslationIcon);

    messageLbl.setFont(Utilities.statusLineFont);
    messageLbl.setLineWrap(true);
    messageLbl.setEditable(false);
    messageLbl.setCursor(null);
    messageLbl.setOpaque(false);
    messageLbl.setFocusable(false);
    messageLblPane.setBorder(BorderFactory.createLoweredBevelBorder());
    // messageLblPane.setBounds(new Rectangle(0, 672, TRANSLATOR_WIDTH - 8, 20));
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 3;
    c.anchor = GridBagConstraints.CENTER;
    c.gridx = 0;
    c.gridy = 2;
    this.getContentPane().add(messageLblPane, c);

    // arrowLabel.setBounds(new Rectangle(290, 324, 88, 71));
    arrowLabel.setIcon(arrowIcon);

    // source.setVisibleRows(31);
    // destination.setVisibleRows(31);
    // source.setBounds(new Rectangle(35,100,source.getWidth(),source.getHeight()));
    // destination.setBounds(new Rectangle(375,100,destination.getWidth(),destination.getHeight()));

    c.fill = GridBagConstraints.BOTH;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.CENTER;
    c.gridx = 0;
    c.gridy = 1;
    this.getContentPane().add(source, c);

    c.fill = GridBagConstraints.NONE;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.CENTER;
    c.gridx = 1;
    c.gridy = 1;
    this.getContentPane().add(arrowLabel, c);

    c.fill = GridBagConstraints.BOTH;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.CENTER;
    c.gridx = 2;
    c.gridy = 1;
    this.getContentPane().add(destination, c);

    // Adding the tool bar to this container.
    toolBar.setFloatable(false);
    toolBar.setLocation(0, 0);
    toolBar.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0));
    toolBar.setBorder(BorderFactory.createEtchedBorder());
    arrangeToolBar();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 3;
    c.anchor = GridBagConstraints.CENTER;
    c.gridx = 0;
    c.gridy = 0;
    this.getContentPane().add(toolBar, c);
    toolBar.revalidate();
    toolBar.repaint();
    repaint();

    // Creating the menu bar
    arrangeMenu();
    setJMenuBar(menuBar);

    // initializing the window size and visibility
    setDefaultCloseOperation(3);
    setSize(new Dimension(TRANSLATOR_WIDTH, TRANSLATOR_HEIGHT));
    setVisible(true);
  }
  public ListSelectionDemo() {
    super(new BorderLayout());

    String[] listData = {"one", "two", "three", "four", "five", "six", "seven"};
    String[] columnNames = {"French", "Spanish", "Italian"};
    list = new JList(listData);

    listSelectionModel = list.getSelectionModel();
    listSelectionModel.addListSelectionListener(new SharedListSelectionHandler());
    JScrollPane listPane = new JScrollPane(list);

    JPanel controlPane = new JPanel();
    String[] modes = {
      "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION"
    };

    final JComboBox comboBox = new JComboBox(modes);
    comboBox.setSelectedIndex(2);
    comboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String newMode = (String) comboBox.getSelectedItem();
            if (newMode.equals("SINGLE_SELECTION")) {
              listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) {
              listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            } else {
              listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            }
            output.append("----------" + "Mode: " + newMode + "----------" + newline);
          }
        });
    controlPane.add(new JLabel("Selection mode:"));
    controlPane.add(comboBox);

    // Build output area.
    output = new JTextArea(1, 10);
    output.setEditable(false);
    JScrollPane outputPane =
        new JScrollPane(
            output,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    // Do the layout.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    add(splitPane, BorderLayout.CENTER);

    JPanel topHalf = new JPanel();
    topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS));
    JPanel listContainer = new JPanel(new GridLayout(1, 1));
    listContainer.setBorder(BorderFactory.createTitledBorder("List"));
    listContainer.add(listPane);

    topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
    topHalf.add(listContainer);
    // topHalf.add(tableContainer);

    topHalf.setMinimumSize(new Dimension(100, 50));
    topHalf.setPreferredSize(new Dimension(100, 110));
    splitPane.add(topHalf);

    JPanel bottomHalf = new JPanel(new BorderLayout());
    bottomHalf.add(controlPane, BorderLayout.PAGE_START);
    bottomHalf.add(outputPane, BorderLayout.CENTER);
    // XXX: next line needed if bottomHalf is a scroll pane:
    // bottomHalf.setMinimumSize(new Dimension(400, 50));
    bottomHalf.setPreferredSize(new Dimension(450, 135));
    splitPane.add(bottomHalf);
  }
  /** Construct a new dialog. */
  public JExecDetailsDialog() {
    super("Execution Details");

    /* create dialog body components */
    {
      JPanel body = new JPanel();
      body.setLayout(new BoxLayout(body, BoxLayout.Y_AXIS));

      {
        JPanel panel = new JPanel();
        panel.setName("MainDialogPanel");
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

        /* working directory */
        {
          panel.add(UIFactory.createPanelLabel("Working Directory:"));

          panel.add(Box.createRigidArea(new Dimension(0, 4)));

          JTextField field = UIFactory.createTextField(null, 100, JLabel.LEFT);
          pWorkingDirField = field;

          panel.add(field);
        }

        body.add(panel);
      }

      {
        JPanel panel = new JPanel();
        panel.setName("HorizontalBar");

        Dimension size = new Dimension(100, 7);
        panel.setPreferredSize(size);
        panel.setMinimumSize(size);
        panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 7));

        body.add(panel);
      }

      /* command line */
      JPanel above = new JPanel();
      {
        above.setName("MainDialogPanel");
        above.setLayout(new BoxLayout(above, BoxLayout.Y_AXIS));

        {
          Box hbox = new Box(BoxLayout.X_AXIS);

          hbox.add(Box.createRigidArea(new Dimension(4, 0)));

          {
            JLabel label = new JLabel("X");
            pCommandLineLabel = label;

            label.setName("PanelLabel");

            hbox.add(label);
          }

          hbox.add(Box.createHorizontalGlue());

          above.add(hbox);
        }

        above.add(Box.createRigidArea(new Dimension(0, 4)));

        {
          JTextArea area = new JTextArea(null, 5, 70);
          pCommandLineArea = area;

          area.setName("CodeTextArea");
          area.setLineWrap(true);
          area.setWrapStyleWord(true);
          area.setEditable(false);
        }

        {
          JScrollPane scroll =
              UIFactory.createScrollPane(
                  pCommandLineArea,
                  ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER,
                  ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                  new Dimension(100, 27),
                  null,
                  null);

          above.add(scroll);
        }
      }

      /* environment */
      JPanel below = new JPanel();
      {
        below.setName("MainDialogPanel");
        below.setLayout(new BoxLayout(below, BoxLayout.Y_AXIS));

        {
          Box hbox = new Box(BoxLayout.X_AXIS);

          hbox.add(Box.createRigidArea(new Dimension(4, 0)));

          {
            JLabel label = new JLabel("X");
            pEnvLabel = label;

            label.setName("PanelLabel");

            hbox.add(label);
          }

          hbox.add(Box.createHorizontalGlue());

          below.add(hbox);
        }

        below.add(Box.createRigidArea(new Dimension(0, 4)));

        Component comps[] = UIFactory.createTitledPanels();
        {
          JPanel tpanel = (JPanel) comps[0];
          JPanel vpanel = (JPanel) comps[1];

          tpanel.add(Box.createRigidArea(new Dimension(sTSize, 0)));
          vpanel.add(Box.createHorizontalGlue());
        }

        {
          pEnvScroll =
              UIFactory.createScrollPane(
                  comps[2],
                  ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER,
                  ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                  new Dimension(100, 50),
                  new Dimension(100, 300),
                  null);

          below.add(pEnvScroll);
        }
      }

      {
        JVertSplitPanel split = new JVertSplitPanel(above, below);
        split.setResizeWeight(0.0);
        split.setAlignmentX(0.5f);

        body.add(split);
      }

      super.initUI("X", body, null, null, null, "Close", null);
    }
  }
Example #18
0
  public RegistryUi() {
    myContent.setLayout(new BorderLayout(UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP));

    myModel = new MyTableModel();
    myTable = new JBTable(myModel);
    myTable.setCellSelectionEnabled(true);
    myTable.setEnableAntialiasing(true);
    final MyRenderer r = new MyRenderer();

    final TableColumn c0 = myTable.getColumnModel().getColumn(0);
    c0.setCellRenderer(r);
    c0.setMaxWidth(RESTART_ICON.getIconWidth() + 12);
    c0.setMinWidth(RESTART_ICON.getIconWidth() + 12);
    c0.setHeaderValue(null);

    final TableColumn c1 = myTable.getColumnModel().getColumn(1);
    c1.setCellRenderer(r);
    c1.setHeaderValue("Key");

    final TableColumn c2 = myTable.getColumnModel().getColumn(2);
    c2.setCellRenderer(r);
    c2.setHeaderValue("Value");
    c2.setCellEditor(new MyEditor());
    myTable.setStriped(true);

    myDescriptionLabel = new JTextArea(3, 50);
    myDescriptionLabel.setEditable(false);
    final JScrollPane label = ScrollPaneFactory.createScrollPane(myDescriptionLabel);
    final JPanel descriptionPanel = new JPanel(new BorderLayout());
    descriptionPanel.add(label, BorderLayout.CENTER);
    descriptionPanel.setBorder(
        IdeBorderFactory.createTitledBorder("Description", false, false, true));

    myContent.add(ScrollPaneFactory.createScrollPane(myTable), BorderLayout.CENTER);
    myContent.add(descriptionPanel, BorderLayout.SOUTH);

    myTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                if (e.getValueIsAdjusting()) return;

                final int selected = myTable.getSelectedRow();
                if (selected != -1) {
                  final RegistryValue value = myModel.getRegistryValue(selected);
                  String desc = value.getDescription();
                  if (value.isRestartRequired()) {
                    String required = "Requires IDE restart.";
                    if (desc.endsWith(".")) {
                      desc += required;
                    } else {
                      desc += (". " + required);
                    }
                  }
                  myDescriptionLabel.setText(desc);
                } else {
                  myDescriptionLabel.setText(null);
                }
              }
            });

    myRestoreDefaultsAction = new RestoreDefaultsAction();

    final DefaultActionGroup tbGroup = new DefaultActionGroup();
    tbGroup.add(new EditAction());
    tbGroup.add(new RevertAction());

    final ActionToolbar tb =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, tbGroup, true);
    tb.setTargetComponent(myTable);

    myContent.add(tb.getComponent(), BorderLayout.NORTH);
    new TableSpeedSearch(myTable).setComparator(new SpeedSearchComparator(false));
  }
  private void jbInit() throws Exception {
    titledBorder1 = new TitledBorder("");
    this.setLayout(baseLayout);

    double[][] lower_size = {
      {TableLayout.PREFERRED, TableLayout.FILL, 25}, {25, 25, TableLayout.FILL}
    };
    mLowerPanelLayout = new TableLayout(lower_size);

    mLowerPanel.setLayout(mLowerPanelLayout);

    double[][] dir_size = {
      {TableLayout.FILL, TableLayout.PREFERRED}, {TableLayout.PREFERRED, TableLayout.FILL}
    };
    mDirectionsPanelLayout = new TableLayout(dir_size);
    mDirectionsPanel.setLayout(mDirectionsPanelLayout);

    // Try to get icons for the toolbar buttons
    try {
      ClassLoader loader = getClass().getClassLoader();
      mAddIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/add.gif"));
      mRemoveIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/remove.gif"));
      mDisabledRemoveIcon =
          new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/remove_disabled.gif"));

      mAddNodeBtn.setIcon(mAddIcon);
      mRemoveNodeBtn.setIcon(mRemoveIcon);
      mRemoveNodeBtn.setDisabledIcon(mDisabledRemoveIcon);
    } catch (Exception e) {
      // Ack! No icons. Use text labels instead
      mAddNodeBtn.setText("Add");
      mRemoveNodeBtn.setText("Remove");
    }

    /*
    mAddNodeBtn.setMaximumSize(new Dimension(130, 33));
    mAddNodeBtn.setMinimumSize(new Dimension(130, 33));
    mAddNodeBtn.setPreferredSize(new Dimension(130, 33));
    mAddNodeBtn.setText("Add Node");
    */
    mAddNodeBtn.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mAddNodeBtn_actionPerformed(e);
          }
        });
    /*
    mRemoveNodeBtn.setMaximumSize(new Dimension(130, 33));
    mRemoveNodeBtn.setMinimumSize(new Dimension(130, 33));
    mRemoveNodeBtn.setPreferredSize(new Dimension(130, 33));
    mRemoveNodeBtn.setText("Remove Node");
    */
    mRemoveNodeBtn.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mRemoveNode();
          }
        });
    mHostnameLabel.setHorizontalAlignment(SwingConstants.TRAILING);
    mHostnameLabel.setLabelFor(mHostnameField);
    mHostnameLabel.setText("Hostname:");

    mHostnameField.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mAddNodeBtn_actionPerformed(e);
          }
        });
    mDirectionsPanel.setBorder(BorderFactory.createEtchedBorder());
    mTitleLabel.setFont(new java.awt.Font("Serif", 1, 20));
    mTitleLabel.setHorizontalAlignment(SwingConstants.CENTER);
    mTitleLabel.setText("Add Cluster Nodes");
    mDirectionsLabel.setText("Click on the add button to add nodes to your cluster configuration.");
    mDirectionsLabel.setLineWrap(true);
    mDirectionsLabel.setEditable(false);
    mDirectionsLabel.setBackground(mTitleLabel.getBackground());

    baseLayout.setHgap(5);
    baseLayout.setVgap(5);
    mLowerPanel.add(
        mHostnameLabel, new TableLayoutConstraints(0, 0, 0, 0, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mHostnameField, new TableLayoutConstraints(1, 0, 1, 0, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mListScrollPane1,
        new TableLayoutConstraints(0, 1, 1, 2, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mAddNodeBtn, new TableLayoutConstraints(2, 0, 2, 0, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mRemoveNodeBtn, new TableLayoutConstraints(2, 1, 2, 1, TableLayout.FULL, TableLayout.FULL));
    this.add(mLowerPanel, BorderLayout.CENTER);
    mListScrollPane1.getViewport().add(lstNodes, null);
    mDirectionsPanel.add(
        mTitleLabel, new TableLayoutConstraints(0, 0, 0, 0, TableLayout.FULL, TableLayout.FULL));
    mDirectionsPanel.add(
        mDirectionsLabel,
        new TableLayoutConstraints(0, 1, 0, 1, TableLayout.FULL, TableLayout.FULL));
    mDirectionsPanel.add(
        mIconLabel, new TableLayoutConstraints(1, 0, 1, 1, TableLayout.FULL, TableLayout.FULL));
    this.add(mDirectionsPanel, BorderLayout.NORTH);
  }
Example #20
0
  public QueryDBFrame() {
    setTitle("QueryDB");
    setSize(400, 300);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    getContentPane().setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    authors = new JComboBox();
    authors.setEditable(false);
    authors.addItem("Any");

    publishers = new JComboBox();
    publishers.setEditable(false);
    publishers.addItem("Any");

    result = new JTextArea(4, 50);
    result.setEditable(false);

    priceChange = new JTextField(8);
    priceChange.setText("-5.00");

    try {
      //  连接数据库
      con = getConnection();
      stmt = con.createStatement();

      // 将数据库中的作者名添加到组合框
      String query = "SELECT Name FROM Authors";
      ResultSet rs = stmt.executeQuery(query);
      while (rs.next()) authors.addItem(rs.getString(1));

      //  将出版社名添加到组合框
      query = "SELECT Name FROM Publishers";
      rs = stmt.executeQuery(query);
      while (rs.next()) publishers.addItem(rs.getString(1));
    } catch (Exception e) {
      result.setText("Error " + e);
    }

    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 100;
    gbc.weighty = 100;
    add(authors, gbc, 0, 0, 2, 1);

    add(publishers, gbc, 2, 0, 2, 1);

    gbc.fill = GridBagConstraints.NONE;
    JButton queryButton = new JButton("Query");
    queryButton.addActionListener(this);
    add(queryButton, gbc, 0, 1, 1, 1);

    JButton changeButton = new JButton("Change prices");
    changeButton.addActionListener(this);
    add(changeButton, gbc, 2, 1, 1, 1);

    gbc.fill = GridBagConstraints.HORIZONTAL;
    add(priceChange, gbc, 3, 1, 1, 1);

    gbc.fill = GridBagConstraints.BOTH;
    add(result, gbc, 0, 2, 4, 1);
  }
  public CAStatic(int size) {

    // size is the size of the area containing cells
    dsize = size;
    gSize = size + 2 * maxit;
    int wscale = 6; // scale for main panel
    int btnHeight = 480 - 384; // found by trial and error - must be a better way!

    // experiment = new CAGridStatic(size, maxC);
    // int tint = (int)Math.ceil((double)(400*maxit)/(double)gSize)+(480-384);
    // int tint = (int)Math.ceil((double)(400*(50+maxit))/(double)gSize)+(480-384);
    int tint = (maxit + rowstoDraw) * wscale + btnHeight;
    // only going to show up to 50 dots in lower panel
    // add 20 to x and 60 to y bcos not printing onto the full frame
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container mainWindow = getContentPane();
    mainWindow.setLayout(new BorderLayout());
    setSize(gSize * wscale, tint);

    buttonHolder = new JPanel();
    buttonHolder.setLayout(new GridLayout(2, 2));

    SpinnerNumberModel model3 = new SpinnerNumberModel(50, 0, 100, 5);
    JSpinner spinner3 = new JSpinner(model3);
    writeBtn = new JButton("Output Results to file");
    writeBtn.addActionListener(this);

    startBtn = new JButton("Start");
    startBtn.addActionListener(this);

    paramsBtn = new JButton("Set Probabilities");
    paramsBtn.addActionListener(this);

    wrapBtn = new JButton("Toggle wrap");
    wrapBtn.addActionListener(this);

    buttonHolder.add(writeBtn);
    writeBtn.setVisible(false);
    buttonHolder.add(paramsBtn);
    buttonHolder.add(wrapBtn);
    buttonHolder.add(startBtn);

    mainWindow.add(buttonHolder, BorderLayout.SOUTH);

    msgBtn = new JTextArea(" Default Parameter Values: " + CAGridStatic.params);
    msgBtn.setEditable(false);

    mainWindow.add(msgBtn, BorderLayout.NORTH);

    CApicture = new CAImagePanel();
    CApicture.rowstoShow = rowstoDraw;
    mainWindow.add(CApicture, BorderLayout.CENTER);

    // not here - doesn't work: CApicture.setScale(gSize,maxit,scale);

    // pack();

    setVisible(true);
    setpalette();
    iterations = 0;
    savedvals = new int[maxRun][maxit];
    outPrinter = new ResultsPrinter(this);
  }
Example #22
0
  private void jbInit() throws Exception {

    saveButton.setText("Save");
    saveButton.addActionListener(new PrintfTemplateEditor_saveButton_actionAdapter(this));
    cancelButton.setText("Cancel");
    cancelButton.addActionListener(new PrintfTemplateEditor_cancelButton_actionAdapter(this));
    this.setTitle(this.getTitle() + " Template Editor");
    printfPanel.setLayout(gridBagLayout1);
    formatLabel.setFont(new java.awt.Font("DialogInput", 0, 12));
    formatLabel.setText("Format String:");
    buttonPanel.setLayout(flowLayout1);
    printfPanel.setBorder(BorderFactory.createEtchedBorder());
    printfPanel.setMinimumSize(new Dimension(100, 160));
    printfPanel.setPreferredSize(new Dimension(380, 160));
    parameterPanel.setLayout(gridBagLayout2);
    parameterLabel.setText("Parameters:");
    parameterLabel.setFont(new java.awt.Font("DialogInput", 0, 12));
    parameterTextArea.setMinimumSize(new Dimension(100, 25));
    parameterTextArea.setPreferredSize(new Dimension(200, 25));
    parameterTextArea.setEditable(true);
    parameterTextArea.setText("");
    insertButton.setMaximumSize(new Dimension(136, 20));
    insertButton.setMinimumSize(new Dimension(136, 20));
    insertButton.setPreferredSize(new Dimension(136, 20));
    insertButton.setToolTipText(
        "insert the format in the format string and add parameter to list.");
    insertButton.setText("Insert Parameter");
    insertButton.addActionListener(new PrintfTemplateEditor_insertButton_actionAdapter(this));
    formatTextArea.setMinimumSize(new Dimension(100, 25));
    formatTextArea.setPreferredSize(new Dimension(200, 15));
    formatTextArea.setText("");
    parameterPanel.setBorder(null);
    parameterPanel.setMinimumSize(new Dimension(60, 40));
    parameterPanel.setPreferredSize(new Dimension(300, 40));
    insertMatchButton.addActionListener(
        new PrintfTemplateEditor_insertMatchButton_actionAdapter(this));
    insertMatchButton.setText("Insert Match");
    insertMatchButton.setToolTipText(
        "insert the match in the format string and add parameter to list.");
    insertMatchButton.setPreferredSize(new Dimension(136, 20));
    insertMatchButton.setMinimumSize(new Dimension(136, 20));
    insertMatchButton.setMaximumSize(new Dimension(136, 20));
    matchPanel.setPreferredSize(new Dimension(300, 40));
    matchPanel.setBorder(null);
    matchPanel.setMinimumSize(new Dimension(60, 60));
    matchPanel.setLayout(gridBagLayout3);
    InsertPanel.setLayout(gridLayout1);
    gridLayout1.setColumns(1);
    gridLayout1.setRows(2);
    gridLayout1.setVgap(0);
    InsertPanel.setBorder(BorderFactory.createEtchedBorder());
    InsertPanel.setMinimumSize(new Dimension(100, 100));
    InsertPanel.setPreferredSize(new Dimension(380, 120));
    editorPane.setText("");
    editorPane.addKeyListener(new PrintfEditor_editorPane_keyAdapter(this));
    printfTabPane.addChangeListener(new PrintfEditor_printfTabPane_changeAdapter(this));
    parameterPanel.add(
        insertButton,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(8, 6, 13, 8),
            0,
            10));
    parameterPanel.add(
        paramComboBox,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(8, 8, 13, 0),
            258,
            11));
    paramComboBox.setRenderer(new MyCellRenderer());
    InsertPanel.add(matchPanel, null);
    InsertPanel.add(parameterPanel, null);
    buttonPanel.add(cancelButton, null);
    buttonPanel.add(saveButton, null);
    this.getContentPane().add(printfTabPane, BorderLayout.NORTH);
    this.getContentPane().add(InsertPanel, BorderLayout.CENTER);
    matchPanel.add(
        insertMatchButton,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(8, 6, 13, 8),
            0,
            10));
    matchPanel.add(
        matchComboBox,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(8, 8, 13, 0),
            258,
            11));
    printfPanel.add(
        parameterLabel,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(7, 5, 0, 5),
            309,
            0));
    printfPanel.add(
        formatLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(4, 5, 0, 5),
            288,
            0));
    printfPanel.add(
        formatTextArea,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(6, 5, 0, 5),
            300,
            34));
    printfPanel.add(
        parameterTextArea,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(6, 5, 6, 5),
            300,
            34));
    printfTabPane.addTab("Editor View", null, editorPanel, "View in Editor");
    printfTabPane.addTab("Printf View", null, printfPanel, "Vies as Printf");
    editorPane.setCharacterAttributes(PLAIN_ATTR, true);
    editorPane.addStyle("PLAIN", editorPane.getLogicalStyle());
    editorPanel.getViewport().add(editorPane, null);
    this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    buttonGroup.add(cancelButton);
  }
  public MavenArchetypesStep(MavenModuleBuilder builder, @Nullable StepAdapter step) {
    myBuilder = builder;
    myStep = step;
    Disposer.register(this, myLoadingIcon);

    myArchetypesTree = new Tree();
    myArchetypesTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode()));
    JScrollPane archetypesScrollPane = ScrollPaneFactory.createScrollPane(myArchetypesTree);

    myArchetypesPanel.add(archetypesScrollPane, "archetypes");

    JPanel loadingPanel = new JPanel(new GridBagLayout());
    JPanel bp = new JPanel(new BorderLayout(10, 10));
    bp.add(new JLabel("Loading archetype list..."), BorderLayout.NORTH);
    bp.add(myLoadingIcon, BorderLayout.CENTER);

    loadingPanel.add(bp, new GridBagConstraints());

    myArchetypesPanel.add(ScrollPaneFactory.createScrollPane(loadingPanel), "loading");
    ((CardLayout) myArchetypesPanel.getLayout()).show(myArchetypesPanel, "archetypes");

    myUseArchetypeCheckBox.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            updateComponents();
            archetypeMayBeChanged();
          }
        });

    myAddArchetypeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doAddArchetype();
          }
        });

    myArchetypesTree.setRootVisible(false);
    myArchetypesTree.setShowsRootHandles(true);
    myArchetypesTree.setCellRenderer(new MyRenderer());
    myArchetypesTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    myArchetypesTree
        .getSelectionModel()
        .addTreeSelectionListener(
            new TreeSelectionListener() {
              public void valueChanged(TreeSelectionEvent e) {
                updateArchetypeDescription();
                archetypeMayBeChanged();
              }
            });

    new TreeSpeedSearch(
            myArchetypesTree,
            new Convertor<TreePath, String>() {
              public String convert(TreePath path) {
                MavenArchetype info =
                    getArchetypeInfoFromPathComponent(path.getLastPathComponent());
                return info.groupId + ":" + info.artifactId + ":" + info.version;
              }
            })
        .setComparator(new SpeedSearchComparator(false));

    myArchetypeDescriptionField.setEditable(false);
    myArchetypeDescriptionField.setBackground(UIUtil.getPanelBackground());

    requestUpdate();
    updateComponents();
  }
Example #24
0
  /**
   * The constructor creates the NodeTable and DirectedGraph taken the information from files
   * lines-gbg.txt and stops-gbg.txt and makes itself visible.
   */
  public ShortRoute(String file) {

    // try to convert to UTF-8 across plattforms to make Swedish chars work
    // System.out.println("charset = " + java.nio.charset.Charset.defaultCharset());
    // MacRoman macintosh  Windows-1252 ISO 8859-1 UTF-8
    try {
      // convert whatever this file is encoded in to UTF-8,
      // kill the exception (can't happen)
      introText =
          new String(
              introText.getBytes(java.nio.charset.Charset.defaultCharset().toString()), "UTF-8");
      felTextStart =
          new String(
              felTextStart.getBytes(java.nio.charset.Charset.defaultCharset().toString()), "UTF-8");
      felTextSlut =
          new String(
              felTextSlut.getBytes(java.nio.charset.Charset.defaultCharset().toString()), "UTF-8");
      frome =
          new String(frome.getBytes(java.nio.charset.Charset.defaultCharset().toString()), "UTF-8");
    } catch (UnsupportedEncodingException e) {
      System.exit(0);
    }

    // read the graph and draw it in a separate window
    // creates the graph and fills the p-queue "names"
    karta.setLocation(50, 250);
    if (file == null) {
      readAndDrawGraph();
    } else {
      readAndDrawBIGGraph(file);
    }
    System.out.println("Version with sorting fixed"); // debug
    // now to the graphics in the Frame
    // Left part
    // select is a panel for structuring the left part
    // i.e label, textfield for "from", label, textfield for "to"
    JPanel select = new JPanel(new GridLayout(4, 1));
    select.setBackground(Color.yellow);
    select.add(new JLabel("Ange startpunkt !", JLabel.CENTER));
    select.add(from);
    select.add(new JLabel("Ange slutpunkt !", JLabel.CENTER));
    select.add(to);
    from.setBackground(Color.white);
    from.setForeground(Color.blue);
    to.setBackground(Color.white);
    to.setForeground(Color.blue);
    from.addActionListener(this);
    to.addActionListener(this);

    // Middle part
    // route is the middle text area part where messages are displayed
    // give the middle text area a scrollbar to the right
    route = new JTextArea(introText, 12, 40);
    route.setEditable(false);
    JScrollPane routeScrollPane = new JScrollPane(route);
    routeScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    route.setBackground(Color.white);
    route.setForeground(Color.blue);

    // Rigth part
    JLabel head = new JLabel("   ****        Alternativ     *****     ");
    head.setForeground(Color.red);

    // add all stations to the right scrollpane
    // tanken är att dom skall vara valbara men det fungerar inte än
    // En JList vill ha en ListModel som parameter
    // En ListModel är ett interface som implementeras av klassen AbstractListModel
    // DefaultListModel ärver AbstractListModel
    DefaultListModel<String> valList = new DefaultListModel<String>();
    JList<String> alternativ = new JList<String>(valList);
    alternativ.setBackground(Color.white);
    alternativ.setForeground(Color.blue);
    // add a scroll pane to the station list in alternativ
    stationList = new JScrollPane(alternativ);
    // read names from p-queue and load them into the list
    while (!names.isEmpty()) valList.addElement(names.poll());

    // panel for structure
    JPanel valPanel = new JPanel(new BorderLayout());
    valPanel.setBackground(Color.white);
    valPanel.add(head, "North");
    valPanel.add(stationList, "Center");

    // put it all together in the frame
    add(select, "West");
    add(routeScrollPane, "Center");
    add(valPanel, "East");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
    setVisible(true);
  } // end ShortRoute
Example #25
0
  /** Creates the GUI. */
  public void majorLayout() {
    //
    // Setup Menu
    //
    JMenuBar menuBar = new JMenuBar();
    JMenu file = new JMenu(ResourceHandler.getMessage("menu.file"));
    file.setMnemonic(ResourceHandler.getAcceleratorKey("menu.file"));

    file.add(exitMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.exit")));
    exitMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.exit"));
    exitMenuItem.addActionListener(this);
    menuBar.add(file);

    JMenu edit = new JMenu(ResourceHandler.getMessage("menu.edit"));
    edit.setMnemonic(ResourceHandler.getAcceleratorKey("menu.edit"));

    edit.add(optionMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.option")));
    optionMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.option"));
    optionMenuItem.addActionListener(this);
    menuBar.add(edit);

    JMenu help = new JMenu(ResourceHandler.getMessage("menu.help"));
    help.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help"));

    help.add(helpMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.help")));
    helpMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help"));

    help.add(new JSeparator());
    help.add(aboutMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.about")));
    aboutMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.about"));
    helpMenuItem.addActionListener(this);
    aboutMenuItem.addActionListener(this);
    menuBar.add(help);

    setJMenuBar(menuBar);

    //
    // Setup main GUI
    //

    dirLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel0"));
    dirTF = new JTextField();
    dirBttn = new JButton(ResourceHandler.getMessage("button.browse.dir"));
    dirBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.dir"));

    matchingLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel1"));
    matchingTF = new JTextField(ResourceHandler.getMessage("converter_gui.lablel2"));
    recursiveCheckBox = new JCheckBox(ResourceHandler.getMessage("converter_gui.lablel3"));
    recursiveCheckBox.setMnemonic(ResourceHandler.getAcceleratorKey("converter_gui.lablel3"));

    backupLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel5"));
    backupTF = new JTextField();
    backupBttn = new JButton(ResourceHandler.getMessage("button.browse.backup"));
    backupBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.backup"));

    templateLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel7"));
    templateCh = new TemplateFileChoice();

    staticVersioningLabel = new JLabel(ResourceHandler.getMessage("static.versioning.label"));
    String version = System.getProperty("java.version");
    if (version.indexOf("-") > 0) {
      version = version.substring(0, version.indexOf("-"));
    }
    int dotIndex = version.indexOf(".");
    dotIndex = version.indexOf(".", dotIndex + 1);
    String familyVersion = version.substring(0, dotIndex);

    MessageFormat formatter =
        new MessageFormat(ResourceHandler.getMessage("static.versioning.radio.button"));
    staticVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {version}));
    staticVersioningRadioButton.setMnemonic(
        ResourceHandler.getAcceleratorKey("static.versioning.radio.button"));

    formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.radio.button"));
    dynamicVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {familyVersion}));
    dynamicVersioningRadioButton.setMnemonic(
        ResourceHandler.getAcceleratorKey("dynamic.versioning.radio.button"));

    staticVersioningTextArea = new JTextArea(ResourceHandler.getMessage("static.versioning.text"));

    formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.text"));
    dynamicVersioningTextArea = new JTextArea(formatter.format(new Object[] {familyVersion}));

    ButtonGroup versioningButtonGroup = new ButtonGroup();
    versioningButtonGroup.add(staticVersioningRadioButton);
    versioningButtonGroup.add(dynamicVersioningRadioButton);

    runBttn = new JButton(ResourceHandler.getMessage("button.convert"));
    runBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.convert"));

    recursiveCheckBox.setOpaque(false);
    staticVersioningRadioButton.setOpaque(false);
    dynamicVersioningRadioButton.setOpaque(false);

    staticVersioningTextArea.setEditable(false);
    staticVersioningTextArea.setLineWrap(true);
    staticVersioningTextArea.setWrapStyleWord(true);
    dynamicVersioningTextArea.setEditable(false);
    dynamicVersioningTextArea.setLineWrap(true);
    dynamicVersioningTextArea.setWrapStyleWord(true);

    staticVersioningPanel.setLayout(new BorderLayout());
    staticVersioningPanel.add(staticVersioningTextArea, "Center");
    staticVersioningPanel.setBorder(new LineBorder(Color.black));

    dynamicVersioningPanel.setLayout(new BorderLayout());
    dynamicVersioningPanel.add(dynamicVersioningTextArea, "Center");
    dynamicVersioningPanel.setBorder(new LineBorder(Color.black));

    if (converter.isStaticVersioning()) {
      staticVersioningRadioButton.setSelected(true);
    } else {
      dynamicVersioningRadioButton.setSelected(true);
    }

    addListeners();

    final int buf = 10, // Buffer (between components and form)
        sp = 10, // Space between components
        vsp = 5, // Vertical space
        indent = 20; // Indent between form (left edge) and component

    GridBagConstraints gbc = new GridBagConstraints();
    GridBagLayout gbl = new GridBagLayout();
    getContentPane().setLayout(gbl);

    //
    // Setup top panel
    //
    GridBagLayout topLayout = new GridBagLayout();
    JPanel topPanel = new JPanel();
    topPanel.setOpaque(false);
    topPanel.setLayout(topLayout);

    topLayout.setConstraints(
        dirLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dirTF,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dirBttn,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(10, sp, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        matchingLabel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        matchingTF,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        recursiveCheckBox,
        new GridBagConstraints(
            2,
            1,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupLabel,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupTF,
        new GridBagConstraints(
            1,
            3,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupBttn,
        new GridBagConstraints(
            2,
            3,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(10, sp, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        templateLabel,
        new GridBagConstraints(
            0,
            4,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        templateCh,
        new GridBagConstraints(
            1,
            4,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        sep1,
        new GridBagConstraints(
            0,
            5,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(10, 10, 10, 10),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningLabel,
        new GridBagConstraints(
            0,
            6,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningRadioButton,
        new GridBagConstraints(
            0,
            7,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningPanel,
        new GridBagConstraints(
            0,
            8,
            GridBagConstraints.REMAINDER,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(vsp, 25, 10, 0),
            0,
            0));
    topLayout.setConstraints(
        dynamicVersioningRadioButton,
        new GridBagConstraints(
            0,
            9,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dynamicVersioningPanel,
        new GridBagConstraints(
            0,
            10,
            GridBagConstraints.REMAINDER,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(vsp, 25, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        sep2,
        new GridBagConstraints(
            0,
            11,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(10, 10, 0, 10),
            0,
            0));

    invisibleBttn = new JButton();
    invisibleBttn.setVisible(false);
    topLayout.setConstraints(
        invisibleBttn,
        new GridBagConstraints(
            2,
            6,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.CENTER,
            new Insets(indent, sp, 0, 0),
            0,
            0));

    topPanel.add(dirLabel);
    topPanel.add(dirTF);
    topPanel.add(dirBttn);
    topPanel.add(matchingLabel);
    topPanel.add(matchingTF);
    topPanel.add(recursiveCheckBox);
    topPanel.add(backupLabel);
    topPanel.add(backupTF);
    topPanel.add(backupBttn);
    topPanel.add(templateLabel);
    topPanel.add(templateCh);
    topPanel.add(sep1);
    topPanel.add(staticVersioningLabel);
    topPanel.add(staticVersioningRadioButton);
    topPanel.add(staticVersioningPanel);
    topPanel.add(dynamicVersioningRadioButton);
    topPanel.add(dynamicVersioningPanel);
    topPanel.add(sep2);
    topPanel.add(invisibleBttn);

    //
    // Setup bottom panel
    //
    GridBagLayout buttomLayout = new GridBagLayout();
    JPanel buttomPanel = new JPanel();
    buttomPanel.setOpaque(false);
    buttomPanel.setLayout(buttomLayout);

    buttomLayout.setConstraints(
        runBttn,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(sp, 0, 0, 0),
            0,
            0));
    buttomPanel.add(runBttn);

    //
    // Setup main panel
    //
    GridBagLayout mainLayout = new GridBagLayout();
    JPanel mainPanel = new JPanel();

    mainPanel.setOpaque(false);
    mainPanel.setLayout(mainLayout);

    mainLayout.setConstraints(
        topPanel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(buf, buf, 0, buf),
            0,
            0));
    mainLayout.setConstraints(
        buttomPanel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1,
            1,
            GridBagConstraints.SOUTH,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, buf, buf, buf),
            0,
            0));
    mainPanel.add(topPanel);
    mainPanel.add(buttomPanel);

    Border border = BorderFactory.createEtchedBorder();
    mainPanel.setBorder(border);

    GridBagLayout layout = new GridBagLayout();
    getContentPane().setLayout(layout);

    layout.setConstraints(
        mainPanel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    getContentPane().add(mainPanel);

    pack();
    setResizable(false);
  }
Example #26
0
  public CellarGUI(Cellar model) {
    this.model = model;
    setTitle("Cellar");
    setSize(new Dimension(1000, 600));
    setResizable(false);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setLayout(new BorderLayout());
    health.setPreferredSize(new Dimension(200, 10));
    exp.setPreferredSize(new Dimension(200, 10));
    currentRoom.setPreferredSize(new Dimension(200, 10));
    spacer.setPreferredSize(new Dimension(200, 115));
    magicLabel.setPreferredSize(new Dimension(200, 10));
    magicLabel.setHorizontalAlignment(JLabel.CENTER);
    playerItemLabel.setText("Player's Items (Max 1)");
    setLabels();

    JScrollPane playerItemsPane = new JScrollPane();
    playerItemsList.setListData(model.getPlayer().getItemList().toArray());
    playerItemsPane.setViewportView(playerItemsList);
    playerItemsPane.setPreferredSize(new Dimension(200, 125));
    JButton drop = new JButton("Drop Item");
    drop.addActionListener(this);
    drop.setPreferredSize(new Dimension(200, 25));

    JScrollPane roomItemsPane = new JScrollPane();
    roomItemsList = new JList(getRoomItems());
    roomItemsPane.setViewportView(roomItemsList);
    roomItemsPane.setPreferredSize(new Dimension(200, 125));
    JButton pickUp = new JButton("Pick Up");
    pickUp.addActionListener(this);
    pickUp.setPreferredSize(new Dimension(200, 25));

    JScrollPane hallsPane = new JScrollPane();
    hallList = new JList(getHalls());
    hallsPane.setViewportView(hallList);
    hallsPane.setPreferredSize(new Dimension(200, 200));
    JButton enterHall = new JButton("Enter Hallway");
    enterHall.setPreferredSize(new Dimension(200, 25));
    enterHall.addActionListener(this);

    JScrollPane outputPane = new JScrollPane();
    output = new JTextArea();
    outputPane.setPreferredSize(new Dimension(550, 550));
    output.setEditable(false);
    output.setBorder(BorderFactory.createLineBorder(Color.black));
    outputPane.setViewportView(output);

    JLabel roomItemLabel = new JLabel("Items in the Room");
    JLabel hallsLabel = new JLabel("Hallways");
    JPanel rightPanel = new JPanel();
    JPanel leftPanel = new JPanel();
    rightPanel.add(playerItemLabel);
    rightPanel.add(playerItemsPane);
    rightPanel.add(drop);
    rightPanel.add(roomItemLabel);
    rightPanel.add(roomItemsPane);
    rightPanel.add(pickUp);
    rightPanel.add(magicLabel);
    rightPanel.add(magic);
    rightPanel.add(spacer);
    rightPanel.add(health);
    rightPanel.add(exp);
    rightPanel.add(currentRoom);
    rightPanel.setPreferredSize(new Dimension(200, 600));
    rightPanel.setBackground(Color.WHITE);
    leftPanel.add(hallsLabel);
    leftPanel.add(hallsPane);
    leftPanel.add(enterHall);
    leftPanel.setPreferredSize(new Dimension(200, 600));
    leftPanel.setBackground(Color.WHITE);
    add(outputPane, BorderLayout.CENTER);
    add(rightPanel, BorderLayout.WEST);
    add(leftPanel, BorderLayout.EAST);
  }
  // Constructor connection receiving a socket number
  public ClientGUI(String host, int port, int udpPort) {

    super("Clash of Clans");
    defaultPort = port;
    defaultUDPPort = udpPort;
    defaultHost = host;

    // the server name and the port number
    JPanel serverAndPort = new JPanel(new GridLayout(1, 5, 1, 3));
    tfServer = new JTextField(host);
    tfPort = new JTextField("" + port);
    tfPort.setHorizontalAlignment(SwingConstants.RIGHT);

    // CHAT COMPONENTS
    chatStatus = new JLabel("Please login first", SwingConstants.LEFT);
    chatField = new JTextField(18);
    chatField.setBackground(Color.WHITE);

    JPanel chatControls = new JPanel();
    chatControls.add(chatStatus);
    chatControls.add(chatField);
    chatControls.setBounds(0, 0, 200, 50);

    chatArea = new JTextArea("Welcome to the Chat room\n", 80, 80);
    chatArea.setEditable(false);
    JScrollPane jsp = new JScrollPane(chatArea);
    jsp.setBounds(0, 50, 200, 550);

    JPanel chatPanel = new JPanel(null);
    chatPanel.setSize(1000, 600);
    chatPanel.add(chatControls);
    chatPanel.add(jsp);

    // LOGIN COMPONENTS
    mainLogin = new MainPanel();
    mainLogin.add(new JLabel("Main Login"));

    usernameField = new JTextField("user", 15);
    passwordField = new JTextField("password", 15);
    login = new CButton("Login");
    login.addActionListener(this);

    sideLogin = new SidePanel(new FlowLayout(FlowLayout.LEFT));
    sideLogin.add(usernameField);
    sideLogin.add(passwordField);
    sideLogin.add(login);

    // MAIN MENU COMPONENTS
    mainMenu = new MainPanel();
    mmLabel = new JLabel("Main Menu");
    timer = new javax.swing.Timer(1000, this);
    mainMenu.add(mmLabel);

    sideMenu = new SidePanel(new FlowLayout(FlowLayout.LEFT));
    cmButton = new CButton("Customize Map");
    tmButton = new CButton("Troop Movement");
    gsButton = new CButton("Game Start");
    logout = new CButton("Logout");
    cmButton.addActionListener(this);
    tmButton.addActionListener(this);
    gsButton.addActionListener(this);
    logout.addActionListener(this);
    sideMenu.add(cmButton);
    // sideMenu.add(tmButton);
    sideMenu.add(gsButton);
    sideMenu.add(logout);

    // CM COMPONENTS
    mainCM = new MainPanel(new GridLayout(mapSize, mapSize));
    tiles = new Tile[mapSize][mapSize];
    int tileSize = mainCM.getWidth() / mapSize;
    for (int i = 0; i < mapSize; i++) {
      tiles[i] = new Tile[mapSize];
      for (int j = 0; j < mapSize; j++) {
        tiles[i][j] = new Tile(i, j);
        tiles[i][j].setPreferredSize(new Dimension(tileSize, tileSize));
        tiles[i][j].setSize(tileSize, tileSize);
        tiles[i][j].addActionListener(this);

        if ((i + j) % 2 == 0) tiles[i][j].setBackground(new Color(102, 255, 51));
        else tiles[i][j].setBackground(new Color(51, 204, 51));

        mainCM.add(tiles[i][j]);
      }
    }

    sideCM = new SidePanel(new FlowLayout(FlowLayout.LEFT));
    cmBack = new CButton("Main Menu");
    cmBack.setSize(150, 30);
    cmBack.setPreferredSize(new Dimension(150, 30));
    cmBack.addActionListener(this);
    sideCM.add(cmBack);

    // TM COMPONENTS
    mainTM = new MainPanel(null);
    mapTM = new Map(600);
    mapTM.setPreferredSize(new Dimension(600, 600));
    mapTM.setSize(600, 600);
    mapTM.setBounds(0, 0, 600, 600);
    mainTM.add(mapTM);

    sideTM = new SidePanel(new FlowLayout(FlowLayout.LEFT));
    tmBack = new CButton("Main Menu");
    tmBack.setSize(150, 30);
    tmBack.setPreferredSize(new Dimension(150, 30));
    tmBack.addActionListener(this);
    sideTM.add(tmBack);

    JRadioButton button;
    ButtonGroup group;

    ub = new ArrayList<JRadioButton>();
    group = new ButtonGroup();

    button = new JRadioButton("Barbarian");
    button.addActionListener(this);
    ub.add(button);
    sideTM.add(button);
    group.add(button);

    button = new JRadioButton("Archer");
    button.addActionListener(this);
    ub.add(button);
    sideTM.add(button);
    group.add(button);

    createBuildings();
    bb = new ArrayList<JRadioButton>();

    group = new ButtonGroup();

    JRadioButton removeButton = new JRadioButton("Remove Building");
    bb.add(removeButton);
    sideCM.add(removeButton);
    group.add(removeButton);

    for (int i = 0; i < bList.size(); i++) {
      button = new JRadioButton(bList.get(i).getName() + '-' + bList.get(i).getQuantity());
      bb.add(button);
      sideCM.add(button);
      group.add(button);
    }

    mainPanels = new MainPanel(new CardLayout());
    mainPanels.add(mainLogin, "Login");
    mainPanels.add(mainMenu, "Menu");
    mainPanels.add(mainCM, "CM");
    mainPanels.add(mainTM, "TM");

    sidePanels = new SidePanel(new CardLayout());
    sidePanels.add(sideLogin, "Login");
    sidePanels.add(sideMenu, "Menu");
    sidePanels.add(sideCM, "CM");
    sidePanels.add(sideTM, "TM");

    JPanel mainPanel = new JPanel(null);
    mainPanel.setSize(1000, 600);
    mainPanel.add(sidePanels);
    mainPanel.add(mainPanels);
    mainPanel.add(chatPanel);

    add(mainPanel, BorderLayout.CENTER);

    try {
      setIconImage(ImageIO.read(new File("images/logo.png")));
    } catch (IOException exc) {
      exc.printStackTrace();
    }

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(1000, 600);
    setVisible(true);
    setResizable(false);
    chatField.requestFocus();
  }
 public void run() {
   WindowBlocker blocker = new WindowBlocker(NearInfinity.getInstance());
   blocker.setBlocked(true);
   List<ResourceEntry> files = new ArrayList<ResourceEntry>();
   for (final String fileType : FILETYPES)
     files.addAll(ResourceFactory.getInstance().getResources(fileType));
   ProgressMonitor progress =
       new ProgressMonitor(NearInfinity.getInstance(), "Searching...", null, 0, files.size());
   table =
       new SortableTable(
           new String[] {"String", "StrRef"},
           new Class[] {Object.class, Integer.class},
           new int[] {450, 20});
   StringResource.getStringRef(0);
   strUsed = new boolean[StringResource.getMaxIndex() + 1];
   for (int i = 0; i < files.size(); i++) {
     ResourceEntry entry = files.get(i);
     Resource resource = ResourceFactory.getResource(entry);
     if (resource instanceof DlgResource) checkDialog((DlgResource) resource);
     else if (resource instanceof BcsResource) checkScript((BcsResource) resource);
     else if (resource instanceof PlainTextResource) checkTextfile((PlainTextResource) resource);
     else if (resource != null) checkStruct((AbstractStruct) resource);
     progress.setProgress(i + 1);
     if (progress.isCanceled()) {
       JOptionPane.showMessageDialog(
           NearInfinity.getInstance(),
           "Operation canceled",
           "Info",
           JOptionPane.INFORMATION_MESSAGE);
       blocker.setBlocked(false);
       return;
     }
   }
   for (int i = 0; i < strUsed.length; i++)
     if (!strUsed[i]) table.addTableItem(new UnusedStringTableItem(new Integer(i)));
   if (table.getRowCount() == 0)
     JOptionPane.showMessageDialog(
         NearInfinity.getInstance(),
         "No unused strings found",
         "Info",
         JOptionPane.INFORMATION_MESSAGE);
   else {
     table.tableComplete(1);
     textArea = new JTextArea(10, 40);
     textArea.setEditable(false);
     textArea.setWrapStyleWord(true);
     textArea.setLineWrap(true);
     JScrollPane scrollText = new JScrollPane(textArea);
     resultFrame = new ChildFrame("Result", true);
     save = new JMenuItem("Save");
     save.addActionListener(this);
     JMenu fileMenu = new JMenu("File");
     fileMenu.add(save);
     JMenuBar menuBar = new JMenuBar();
     menuBar.add(fileMenu);
     resultFrame.setJMenuBar(menuBar);
     resultFrame.setIconImage(Icons.getIcon("Find16.gif").getImage());
     JLabel count = new JLabel(table.getRowCount() + " unused string(s) found", JLabel.CENTER);
     count.setFont(count.getFont().deriveFont((float) count.getFont().getSize() + 2.0f));
     JScrollPane scrollTable = new JScrollPane(table);
     scrollTable.getViewport().setBackground(table.getBackground());
     JPanel pane = (JPanel) resultFrame.getContentPane();
     pane.setLayout(new BorderLayout(0, 3));
     pane.add(count, BorderLayout.NORTH);
     pane.add(scrollTable, BorderLayout.CENTER);
     JPanel bottomPanel = new JPanel(new BorderLayout());
     JPanel searchPanel = SearchMaster.createAsPanel(this, resultFrame);
     bottomPanel.add(scrollText, BorderLayout.CENTER);
     bottomPanel.add(searchPanel, BorderLayout.EAST);
     pane.add(bottomPanel, BorderLayout.SOUTH);
     table.setFont(BrowserMenuBar.getInstance().getScriptFont());
     pane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
     table.getSelectionModel().addListSelectionListener(this);
     resultFrame.pack();
     Center.center(resultFrame, NearInfinity.getInstance().getBounds());
     resultFrame.setVisible(true);
   }
   blocker.setBlocked(false);
 }
Example #29
0
  public void launchChess() {

    mainWindow = new JFrame("网络黑白棋	作者:张炀");
    jpWest = new JPanel();
    jpEast = new JPanel();
    jpNorth = new JPanel();
    jpSouth = new JPanel();
    jpCenter = new JPanel();

    turnLabel = new JLabel();
    blackNumberLabel = new JLabel("黑棋:\n" + black + "		");
    whiteNumberLabel = new JLabel("白棋:\n" + white + "		");
    timeLabel = new JLabel("时间:  " + time + "		s");
    noticeLabel = new JLabel();

    noticeLabel = new JLabel("请选择:");
    numberPane = new JPanel();
    readyPane = new JPanel();
    jt1 = new JTextField(18); // 发送信息框
    jt2 = new JTextArea(3, 30); // 显示信息框
    js = new JScrollPane(jt2);
    jt2.setLineWrap(true);
    jt2.setEditable(false);
    //		jt1.setLineWrap(true);

    send = new JButton("发送");
    cancel = new JButton("取消");
    regret = new JButton("悔棋");
    submit = new JButton("退出");
    begin = new JButton("开始");
    save = new JButton("存盘");

    save.setEnabled(true);
    begin.setEnabled(true);

    fighter = new JRadioButton("下棋");
    audience = new JRadioButton("观看");
    group = new ButtonGroup();
    group.add(audience);
    group.add(fighter);
    group.add(AIPlayer);

    submit.addActionListener(this);
    begin.addActionListener(this);
    save.addActionListener(this);
    send.addActionListener(this);
    cancel.addActionListener(this);
    regret.addActionListener(this);
    fighter.addActionListener(this);
    audience.addActionListener(this);

    jpNorth.setLayout(new BorderLayout());
    jpNorth.add(turnLabel, BorderLayout.NORTH);
    jpNorth.add(jpCenter, BorderLayout.CENTER);
    jpSouth.add(js);
    jpSouth.add(jt1);
    jpSouth.add(send);
    jpSouth.add(cancel);
    jpEast.setLayout(new GridLayout(3, 1));
    submit.setBackground(new Color(130, 251, 241));
    panel x = new panel();
    jpEast.add(x);
    jpEast.add(numberPane);
    jpEast.add(readyPane);

    numberPane.add(blackNumberLabel);
    numberPane.add(whiteNumberLabel);
    numberPane.add(timeLabel);
    numberPane.add(submit);
    numberPane.add(begin);
    numberPane.add(save);
    numberPane.add(regret);

    readyPane.add(noticeLabel);
    readyPane.add(fighter);
    readyPane.add(audience);
    //		readyPane.add(save);
    //		readyPane.add(regret);

    jpCenter.setSize(400, 400);
    jmb = new JMenuBar();
    document = new JMenu("游戏		");
    edit = new JMenu("设置		");
    insert = new JMenu("棋盘			");
    help = new JMenu("帮助		");
    jmb.add(document);
    jmb.add(edit);
    jmb.add(insert);
    jmb.add(help);
    // mainWindow.setJMenuBar(jmb);

    mainWindow.setBounds(80, 80, 600, 600);
    mainWindow.setResizable(false);

    jsLeft = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, jpNorth, jpSouth);
    jsBase = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, jsLeft, jpEast);

    mainWindow.add(jsBase);
    mainWindow.setVisible(true);
    mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    jsBase.setDividerLocation(0.7);
    jsLeft.setDividerLocation(0.78);

    jpCenter.setLayout(new GridLayout(8, 8, 0, 0));
    ImageIcon key = new ImageIcon("chess1.jpg");
    for (int i = 0; i < cell.length; i++)
      for (int j = 0; j < cell.length; j++) {
        cell[i][j] = new ChessBoard(i, j);
        cell[i][j].addMouseListener(this);
        jpCenter.add(cell[i][j]);
      }

    cell[3][3].state = cell[4][4].state = '黑';
    cell[4][3].state = cell[3][4].state = '白';
    cell[3][3].taken = cell[4][4].taken = true;
    cell[4][3].taken = cell[3][4].taken = true;

    RememberState();

    new Thread(new TurnLabel(this)).start();

    file = new File("D:/" + myRole);
    try {
      fout = new FileOutputStream(file);
      out = new ObjectOutputStream(fout);
    } catch (IOException e1) {
      e1.printStackTrace();
    }

    Connect();

    try {
      out99 = new ObjectOutputStream(socket99.getOutputStream());
      in99 = new ObjectInputStream(socket99.getInputStream());

      out66 = new ObjectOutputStream(socket66.getOutputStream());
      in66 = new ObjectInputStream(socket66.getInputStream());

      out88 = new DataOutputStream(socket88.getOutputStream());
    } catch (IOException e) {
      e.printStackTrace();
    }

    new Thread(new Client9999(this)).start();
    new Thread(new Client6666(this)).start();
  }
  public void go() {
    frame = new JFrame("Quiz Card Player");
    JPanel mainPanel = new JPanel();
    Font bigFont = new Font("sanserif", Font.BOLD, 24);

    display = new JTextArea(10, 20);
    display.setFont(bigFont);
    display.setLineWrap(true);
    display.setEditable(false);

    JScrollPane qScroller = new JScrollPane(display);
    qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    nextButton = new JButton("Show Questions");
    nextButton.addActionListener(new NextCardListener());

    mainPanel.add(qScroller);
    mainPanel.add(nextButton);

    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    JMenuItem loadMenuItem = new JMenuItem("Load Card Set");
    loadMenuItem.addActionListener(new OpenMenuListener());
    fileMenu.add(loadMenuItem);
    menuBar.add(fileMenu);

    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
    frame.setSize(640, 500);
    frame.setVisible(true);
  }