예제 #1
0
 /*
  *Creates the JTextField for the GUI.
  */
 private JTextField inputField() {
   inputField = new JTextField();
   Border inputBorder = BorderFactory.createEtchedBorder();
   inputBorder = BorderFactory.createTitledBorder(inputBorder, "Please type your words here:");
   inputField.setBorder(inputBorder);
   inputField.addActionListener(new ActionListenerField());
   return inputField;
 }
예제 #2
0
  @SuppressWarnings("OverridableMethodCallInConstructor")
  Notepad() {
    super(true);

    // Trying to set Nimbus look and feel
    try {
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (Exception ignored) {
    }

    setBorder(BorderFactory.createEtchedBorder());
    setLayout(new BorderLayout());

    // create the embedded JTextComponent
    editor = createEditor();
    // Add this as a listener for undoable edits.
    editor.getDocument().addUndoableEditListener(undoHandler);

    // install the command table
    commands = new HashMap<Object, Action>();
    Action[] actions = getActions();
    for (Action a : actions) {
      commands.put(a.getValue(Action.NAME), a);
    }

    JScrollPane scroller = new JScrollPane();
    JViewport port = scroller.getViewport();
    port.add(editor);

    String vpFlag = getProperty("ViewportBackingStore");
    if (vpFlag != null) {
      Boolean bs = Boolean.valueOf(vpFlag);
      port.setScrollMode(bs ? JViewport.BACKINGSTORE_SCROLL_MODE : JViewport.BLIT_SCROLL_MODE);
    }

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add("North", createToolbar());
    panel.add("Center", scroller);
    add("Center", panel);
    add("South", createStatusbar());
  }
  public NewTypePanelContinuous(Type.Continuous t) {
    super();
    hasLWBGroup.add(unspecifiedLWB);
    hasLWBGroup.add(yesLWB);
    hasLWBGroup.add(noLWB);
    hasUPBGroup.add(unspecifiedUPB);
    hasUPBGroup.add(yesUPB);
    hasUPBGroup.add(noUPB);
    cyclicGroup.add(unspecifiedCyclic);
    cyclicGroup.add(yesCyclic);
    cyclicGroup.add(noCyclic);
    UPBDetailGroup.add(incUPBButton);
    UPBDetailGroup.add(excUPBButton);
    LWBDetailGroup.add(incLWBButton);
    LWBDetailGroup.add(excLWBButton);

    UPBPanel.setLayout(new GridLayout(6, 1));
    UPBPanel.add(UPBExistsLabel);
    UPBPanel.add(yesUPB);
    UPBPanel.add(noUPB);
    UPBPanel.add(unspecifiedUPB);
    UPBPanel.add(specifyUPB);
    UPBPanel.add(UPBLabel);

    LWBPanel.setLayout(new GridLayout(6, 1));
    LWBPanel.add(LWBExistsLabel);
    LWBPanel.add(yesLWB);
    LWBPanel.add(noLWB);
    LWBPanel.add(unspecifiedLWB);
    LWBPanel.add(specifyLWB);
    LWBPanel.add(LWBLabel);

    UPBDetailPanel.setLayout(new GridLayout(4, 1));
    UPBDetailPanel.add(UPBDetailLabel);
    UPBDetailPanel.add(excUPBButton);
    UPBDetailPanel.add(incUPBButton);

    LWBDetailPanel.setLayout(new GridLayout(4, 1));
    LWBDetailPanel.add(LWBDetailLabel);
    LWBDetailPanel.add(excLWBButton);
    LWBDetailPanel.add(incLWBButton);

    cyclicPanel.setLayout(new GridLayout(4, 1));
    cyclicPanel.add(cyclicLabel);
    cyclicPanel.add(yesCyclic);
    cyclicPanel.add(noCyclic);
    cyclicPanel.add(unspecifiedCyclic);

    UPBPanel.setBorder(BorderFactory.createEtchedBorder());
    LWBPanel.setBorder(BorderFactory.createEtchedBorder());
    UPBDetailPanel.setBorder(BorderFactory.createEtchedBorder());
    LWBDetailPanel.setBorder(BorderFactory.createEtchedBorder());
    cyclicPanel.setBorder(BorderFactory.createEtchedBorder());

    mainPanel.setLayout(new GridLayout(2, 2));
    mainPanel.add(LWBPanel);
    mainPanel.add(UPBPanel);
    mainPanel.add(LWBDetailPanel);
    mainPanel.add(UPBDetailPanel);
    setLayout(new BorderLayout());
    add(mainPanel, BorderLayout.CENTER);
    add(cyclicPanel, BorderLayout.EAST);

    listener =
        new KeyListener() {
          public void keyPressed(KeyEvent e) {}

          public void keyTyped(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            checkBoundsFields();
          }
        };

    specifyUPBListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            UPBLabel.setText("0");
            if (specifyUPB.isSelected()) {
              UPBLabel.setVisible(true);
            } else {
              UPBLabel.setVisible(false);
            }
            checkBoundsFields();
          }
        };

    specifyLWBListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            LWBLabel.setText("0");
            if (specifyLWB.isSelected()) {
              LWBLabel.setVisible(true);
            } else {
              LWBLabel.setVisible(false);
            }
            checkBoundsFields();
          }
        };
    setupTypeInfo(t);
    setupEvents();
  }
  // Initializes this component.
  private void jbInit() {
    fileChooser.setFileFilter(new ScriptFileFilter());
    this.getContentPane().setLayout(null);

    Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();

    JLabel slowLabel = new JLabel("Slow");
    slowLabel.setFont(Utilities.thinLabelsFont);
    JLabel fastLabel = new JLabel("Fast");
    fastLabel.setFont(Utilities.thinLabelsFont);
    labelTable.put(1, slowLabel);
    labelTable.put(5, fastLabel);

    speedSlider.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            SpeedSlider_stateChanged(e);
          }
        });
    speedSlider.setLabelTable(labelTable);
    speedSlider.setMajorTickSpacing(1);
    speedSlider.setPaintTicks(true);
    speedSlider.setPaintLabels(true);
    speedSlider.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
    speedSlider.setPreferredSize(new Dimension(95, 50));
    speedSlider.setMinimumSize(new Dimension(95, 50));
    speedSlider.setToolTipText("Speed");
    speedSlider.setMaximumSize(new Dimension(95, 50));

    final Dimension buttonSize = new Dimension(39, 39);

    loadProgramButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            loadProgramButton_actionPerformed();
          }
        });
    loadProgramButton.setMaximumSize(buttonSize);
    loadProgramButton.setMinimumSize(buttonSize);
    loadProgramButton.setPreferredSize(buttonSize);
    loadProgramButton.setSize(buttonSize);
    loadProgramButton.setToolTipText("Load Program");
    loadProgramButton.setIcon(loadProgramIcon);

    ffwdButton.setMaximumSize(buttonSize);
    ffwdButton.setMinimumSize(buttonSize);
    ffwdButton.setPreferredSize(buttonSize);
    ffwdButton.setToolTipText("Run");
    ffwdButton.setIcon(ffwdIcon);
    ffwdButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ffwdButton_actionPerformed();
          }
        });

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

    rewindButton.setMaximumSize(buttonSize);
    rewindButton.setMinimumSize(buttonSize);
    rewindButton.setPreferredSize(buttonSize);
    rewindButton.setToolTipText("Reset");
    rewindButton.setIcon(rewindIcon);
    rewindButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            rewindButton_actionPerformed();
          }
        });

    scriptButton.setMaximumSize(buttonSize);
    scriptButton.setMinimumSize(buttonSize);
    scriptButton.setPreferredSize(buttonSize);
    scriptButton.setToolTipText("Load Script");
    scriptButton.setIcon(scriptIcon);
    scriptButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            scriptButton_actionPerformed();
          }
        });

    breakButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            breakButton_actionPerformed();
          }
        });
    breakButton.setMaximumSize(buttonSize);
    breakButton.setMinimumSize(buttonSize);
    breakButton.setPreferredSize(buttonSize);
    breakButton.setToolTipText("Open breakpoint panel");
    breakButton.setIcon(breakIcon);

    breakpointWindow.addBreakpointListener(this);

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

    stepOverButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            stepOverButton_actionPerformed();
          }
        });
    stepOverButton.setMaximumSize(buttonSize);
    stepOverButton.setMinimumSize(buttonSize);
    stepOverButton.setPreferredSize(buttonSize);
    stepOverButton.setSize(buttonSize);
    stepOverButton.setToolTipText("Step Over");
    stepOverButton.setIcon(stepOverIcon);

    animationCombo.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            animationCombo_actionPerformed();
          }
        });

    formatCombo.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            formatCombo_actionPerformed();
          }
        });

    additionalDisplayCombo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            additionalDisplayCombo_actionPerformed();
          }
        });

    messageLbl.setFont(Utilities.statusLineFont);
    messageLbl.setBorder(BorderFactory.createLoweredBevelBorder());
    messageLbl.setBounds(new Rectangle(0, 667, CONTROLLER_WIDTH - 8, 25));

    toolBar = new JToolBar();
    toolBar.setSize(new Dimension(TOOLBAR_WIDTH, TOOLBAR_HEIGHT));
    toolBar.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0));
    toolBar.setFloatable(false);
    toolBar.setLocation(0, 0);
    toolBar.setBorder(BorderFactory.createEtchedBorder());
    arrangeToolBar();
    this.getContentPane().add(toolBar, null);
    toolBar.revalidate();
    toolBar.repaint();
    repaint();

    // Creating the menu bar
    menuBar = new JMenuBar();
    arrangeMenu();
    setJMenuBar(menuBar);

    this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    this.getContentPane().add(messageLbl, null);

    setControllerSize();

    // sets the frame to be visible.
    setVisible(true);
  }
예제 #5
0
  public ImageLabFrame() {

    // Set up menus
    JMenuBar menuBar = new JMenuBar();

    JMenu imageLabMenu = new JMenu("imageLab");
    menuBar.add(imageLabMenu);

    aboutItem = new JMenuItem("About imageLab");
    imageLabMenu.add(aboutItem);
    quitItem = new JMenuItem("Quit");
    imageLabMenu.add(quitItem);

    JMenu fileMenu = new JMenu("File");
    menuBar.add(fileMenu);
    openItem = new JMenuItem("Open File...");
    fileMenu.add(openItem);
    saveItem = new JMenuItem("Save As...");
    fileMenu.add(saveItem);

    JMenu imageMenu = new JMenu("Images");
    menuBar.add(imageMenu);
    addPictureGenerator(imageMenu, new Stripe());

    JMenu filterMenu = new JMenu("Filters");
    menuBar.add(filterMenu);
    addFilter(filterMenu, new BWFilter());
    filterMenu.addSeparator();
    addScalableFilter(filterMenu, new SwirlFilter());

    // Listeners for filters are added in addScalableFilter
    aboutItem.addActionListener(this);
    quitItem.addActionListener(this);
    openItem.addActionListener(this);
    saveItem.addActionListener(this);

    // Set up rest of GUI

    lab = initialImage().getJLabel();

    slider = new JSlider(0, 100);
    sliderPanel = new JPanel();
    sliderPanel.add(slider);
    sliderPanel.setVisible(false);
    Border b1 = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    border = BorderFactory.createTitledBorder(b1, "");
    sliderPanel.setBorder(border);
    slider.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            double scale = (slider.getValue() - 50) / 50.0;
            currentFilter.apply(pic1, pic2, scale);
            lab.setIcon(pic2.getJLabel().getIcon());
            repaint();
          }
        });

    JPanel panel = new JPanel(new BorderLayout());
    getContentPane().add(panel);
    panel.add(lab, BorderLayout.NORTH);
    panel.add(sliderPanel, BorderLayout.SOUTH);
    setJMenuBar(menuBar);
    pack();
    setTitle("imageLab");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Prepare file chooser
    chooser = new JFileChooser(new File("."));
    FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG Images", "jpg");
    chooser.setFileFilter(filter);
  }
예제 #6
0
  private void setupUI() {
    JPanel batchInputPanel = new JPanel();
    batchInputPanel.setLayout(new GridLayoutManager(7, 2, new Insets(0, 0, 0, 0), -1, -1));
    batchInputPanel.setEnabled(true);
    this.add(
        batchInputPanel,
        new GridConstraints(
            2,
            0,
            1,
            1,
            GridConstraints.ANCHOR_CENTER,
            GridConstraints.FILL_BOTH,
            GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
            GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
            null,
            null,
            null,
            0,
            false));
    batchInputPanel.setBorder(
        BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), null));
    final Spacer spacer3 = new Spacer();
    batchInputPanel.add(
        spacer3,
        new GridConstraints(
            6,
            0,
            1,
            1,
            GridConstraints.ANCHOR_CENTER,
            GridConstraints.FILL_VERTICAL,
            1,
            GridConstraints.SIZEPOLICY_WANT_GROW,
            null,
            new Dimension(195, 14),
            null,
            0,
            false));
    dpiXLabel = new JLabel("DPI X: ");
    batchInputPanel.add(
        dpiXLabel,
        new GridConstraints(
            2,
            0,
            1,
            1,
            GridConstraints.ANCHOR_WEST,
            GridConstraints.FILL_NONE,
            GridConstraints.SIZEPOLICY_FIXED,
            GridConstraints.SIZEPOLICY_FIXED,
            null,
            new Dimension(195, 16),
            null,
            0,
            false));
    dpiYLabel = new JLabel("DPI Y: ");
    batchInputPanel.add(
        dpiYLabel,
        new GridConstraints(
            3,
            0,
            1,
            1,
            GridConstraints.ANCHOR_WEST,
            GridConstraints.FILL_NONE,
            GridConstraints.SIZEPOLICY_FIXED,
            GridConstraints.SIZEPOLICY_FIXED,
            null,
            new Dimension(195, 16),
            null,
            0,
            false));
    startDepthLabel = new JLabel("Start Depth (meter): ");
    batchInputPanel.add(
        startDepthLabel,
        new GridConstraints(
            4,
            0,
            1,
            1,
            GridConstraints.ANCHOR_WEST,
            GridConstraints.FILL_NONE,
            GridConstraints.SIZEPOLICY_FIXED,
            GridConstraints.SIZEPOLICY_FIXED,
            null,
            new Dimension(195, 16),
            null,
            0,
            false));
    depthIncLabel = new JLabel("Depth Increment (meter): ");
    batchInputPanel.add(
        depthIncLabel,
        new GridConstraints(
            5,
            0,
            1,
            1,
            GridConstraints.ANCHOR_WEST,
            GridConstraints.FILL_NONE,
            GridConstraints.SIZEPOLICY_FIXED,
            GridConstraints.SIZEPOLICY_FIXED,
            null,
            new Dimension(195, 16),
            null,
            0,
            false));

    dpiXField = new JTextField();
    dpiXField.setEnabled(false);
    dpiXField.setHorizontalAlignment(11);

    dpiYField = new JTextField();
    dpiYField.setEnabled(false);
    dpiYField.setHorizontalAlignment(11);

    batchInputPanel.add(
        dpiXField,
        new GridConstraints(
            2,
            1,
            1,
            1,
            GridConstraints.ANCHOR_WEST,
            GridConstraints.FILL_HORIZONTAL,
            GridConstraints.SIZEPOLICY_WANT_GROW,
            GridConstraints.SIZEPOLICY_FIXED,
            null,
            new Dimension(100, -1),
            null,
            0,
            false));

    batchInputPanel.add(
        dpiYField,
        new GridConstraints(
            3,
            1,
            1,
            1,
            GridConstraints.ANCHOR_WEST,
            GridConstraints.FILL_HORIZONTAL,
            GridConstraints.SIZEPOLICY_WANT_GROW,
            GridConstraints.SIZEPOLICY_FIXED,
            null,
            new Dimension(100, -1),
            null,
            0,
            false));

    startDepthField = new JTextField();
    startDepthField.setEnabled(false);
    startDepthField.setHorizontalAlignment(11);

    batchInputPanel.add(
        startDepthField,
        new GridConstraints(
            4,
            1,
            1,
            1,
            GridConstraints.ANCHOR_WEST,
            GridConstraints.FILL_HORIZONTAL,
            GridConstraints.SIZEPOLICY_WANT_GROW,
            GridConstraints.SIZEPOLICY_FIXED,
            null,
            new Dimension(100, -1),
            null,
            0,
            false));
    depthIncField = new JTextField();
    depthIncField.setEnabled(false);
    depthIncField.setHorizontalAlignment(11);

    batchInputPanel.add(
        depthIncField,
        new GridConstraints(
            5,
            1,
            1,
            1,
            GridConstraints.ANCHOR_WEST,
            GridConstraints.FILL_HORIZONTAL,
            GridConstraints.SIZEPOLICY_WANT_GROW,
            GridConstraints.SIZEPOLICY_FIXED,
            null,
            new Dimension(100, -1),
            null,
            0,
            false));
    final JPanel applyPanel = new JPanel();
    applyPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
    batchInputPanel.add(
        applyPanel,
        new GridConstraints(
            6,
            0,
            1,
            2,
            GridConstraints.ANCHOR_CENTER,
            GridConstraints.FILL_BOTH,
            GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
            GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
            null,
            null,
            null,
            0,
            false));
    applyToAllButton = new JButton("Apply to All Rows");
    applyToAllButton.setEnabled(false);
    applyPanel.add(
        applyToAllButton,
        new GridConstraints(
            0,
            1,
            1,
            1,
            GridConstraints.ANCHOR_CENTER,
            GridConstraints.FILL_HORIZONTAL,
            GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
            GridConstraints.SIZEPOLICY_FIXED,
            null,
            null,
            null,
            0,
            false));
    applyToSelectedButton = new JButton("Apply to Selected Rows");
    applyToSelectedButton.setEnabled(false);
    applyPanel.add(
        applyToSelectedButton,
        new GridConstraints(
            0,
            0,
            1,
            1,
            GridConstraints.ANCHOR_CENTER,
            GridConstraints.FILL_HORIZONTAL,
            GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
            GridConstraints.SIZEPOLICY_FIXED,
            null,
            null,
            null,
            0,
            false));
    //		final Spacer spacer4 = new Spacer();
    //		applyPanel.add(spacer4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER,
    // GridConstraints.FILL_HORIZONTAL,
    //				GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
    orientationComboBox = new JComboBox();
    orientationComboBox.setEnabled(false);
    final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel();
    defaultComboBoxModel1.addElement("Horizontal");
    defaultComboBoxModel1.addElement("Vertical");
    defaultComboBoxModel1.addElement("[Blank]");
    orientationComboBox.setModel(defaultComboBoxModel1);
    orientationComboBox.setSelectedIndex(2); // [Blank]

    batchInputPanel.add(
        orientationComboBox,
        new GridConstraints(
            0,
            1,
            1,
            1,
            GridConstraints.ANCHOR_WEST,
            GridConstraints.FILL_HORIZONTAL,
            GridConstraints.SIZEPOLICY_CAN_GROW,
            GridConstraints.SIZEPOLICY_FIXED,
            null,
            null,
            null,
            0,
            false));
    lengthLabel = new JLabel("Length (meter): ");
    batchInputPanel.add(
        lengthLabel,
        new GridConstraints(
            1,
            0,
            1,
            1,
            GridConstraints.ANCHOR_WEST,
            GridConstraints.FILL_NONE,
            GridConstraints.SIZEPOLICY_FIXED,
            GridConstraints.SIZEPOLICY_FIXED,
            null,
            null,
            null,
            0,
            false));
    lengthField = new JTextField();
    lengthField.setEnabled(false);
    lengthField.setHorizontalAlignment(11);

    batchInputPanel.add(
        lengthField,
        new GridConstraints(
            1,
            1,
            1,
            1,
            GridConstraints.ANCHOR_WEST,
            GridConstraints.FILL_HORIZONTAL,
            GridConstraints.SIZEPOLICY_WANT_GROW,
            GridConstraints.SIZEPOLICY_FIXED,
            null,
            new Dimension(150, -1),
            null,
            0,
            false));
    orientationLabel = new JLabel("Orientation: ");
    batchInputPanel.add(
        orientationLabel,
        new GridConstraints(
            0,
            0,
            1,
            1,
            GridConstraints.ANCHOR_WEST,
            GridConstraints.FILL_NONE,
            GridConstraints.SIZEPOLICY_FIXED,
            GridConstraints.SIZEPOLICY_FIXED,
            null,
            new Dimension(195, 16),
            null,
            0,
            false));
    useBatchInputCheckbox = new JCheckBox();
    useBatchInputCheckbox.setText("Batch input: blank fields will not be applied");
    this.add(
        useBatchInputCheckbox,
        new GridConstraints(
            1,
            0,
            1,
            1,
            GridConstraints.ANCHOR_WEST,
            GridConstraints.FILL_NONE,
            GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
            GridConstraints.SIZEPOLICY_FIXED,
            null,
            null,
            null,
            0,
            false));

    onBatch();
  }
예제 #7
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 Design() throws Exception {
    super.setBackground(Color.BLACK);
    this.setTitle("");
    con = getContentPane();
    con.setLayout(null);
    dim = tk.getDefaultToolkit().getScreenSize();
    this.setTitle("Customer Peer Login");

    l1 = new JLabel(new ImageIcon("plain.jpg"));
    l1.setBounds(0, 0, 400, 400);
    con.add(l1);
    l1.setBorder(BorderFactory.createEtchedBorder(5, Color.black, Color.black));

    title = new JLabel("CUSTOMER PEER LOGIN ");
    title.setFont(new Font("Bookman Old Style", Font.ROMAN_BASELINE, 20));
    title.setForeground(Color.red);
    title.setBounds(80, 30, 300, 30);
    l1.add(title);

    l4 = new JLabel("CMACHINE NAME");
    l4.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
    l4.setForeground(Color.BLUE);
    l4.setBounds(70, 100, 160, 20);
    //	l4.setBorder(BorderFactory.createEtchedBorder(5,Color.green,Color.green));

    l1.add(l4);
    jtf2 = new JTextField();
    jtf2.setBounds(250, 100, 100, 20);
    jtf2.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green));

    l1.add(jtf2);

    l2 = new JLabel("CUSER LOGIN");
    l2.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
    l2.setForeground(Color.blue);
    l2.setBounds(70, 150, 120, 20);
    l1.add(l2);

    jtf1 = new JTextField();
    jtf1.setBounds(250, 150, 100, 20);
    jtf1.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green));

    l1.add(jtf1);

    l3 = new JLabel("CPASSWORD");
    l3.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
    l3.setForeground(Color.blue);
    l3.setBounds(70, 200, 120, 20);
    l1.add(l3);

    jptf1 = new JPasswordField();
    jptf1.setBounds(250, 200, 100, 20);
    jptf1.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green));

    l1.add(jptf1);

    JLabel l4 = new JLabel("DAgent");
    l4.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
    l4.setForeground(Color.blue);
    l4.setBounds(70, 250, 120, 20);
    l1.add(l4);

    box = new JComboBox();
    box.setBounds(250, 250, 100, 20);
    box.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green));
    l1.add(box);

    b2 = new JButton("Register");
    b2.setBounds(50, 300, 100, 20);
    l1.add(b2);
    b2.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE));

    b3 = new JButton("Login");
    b3.setBounds(150, 300, 100, 20);
    b3.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE));
    l1.add(b3);

    b1 = new JButton("Cancel");
    b1.setBounds(250, 300, 100, 20);
    b1.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE));

    l1.add(b1);

    b1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent we) {

            dispose();
          }
        });

    try {

      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      conn = DriverManager.getConnection("jdbc:odbc:agent");

    } catch (Exception exp) {

    }

    try {
      Statement satem = conn.createStatement();
      ResultSet rsatem = satem.executeQuery("select * from Dagent");
      while (rsatem.next()) {
        String namem = rsatem.getString("uname");
        box.addItem(namem);
      }

    } catch (Exception expo1) {

    }

    b2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent we) {

            String username = jtf1.getText().trim();
            String password = jptf1.getText().trim();
            String mechine = jtf2.getText().trim();
            String dname = box.getSelectedItem().toString();
            int porte = 0;

            try {
              Statement sate = conn.createStatement();
              ResultSet rsate =
                  sate.executeQuery("select * from Dagent where uname='" + dname + "'");
              if (rsate.next()) {
                servermachine = rsate.getString("umechine");
                porte = rsate.getInt("ulistport");
                System.out.println(servermachine);
              }
              System.out.println(servermachine);

            } catch (Exception exp) {
              exp.printStackTrace();
            }

            try {
              packet p = new packet();
              p.setaction("Creg");
              p.setCuser(username);
              p.setCpass(password);
              p.setCmname(mechine);
              p.setCDpeer(dname);
              Socket soc = new Socket(servermachine, porte);
              ObjectOutputStream out = new ObjectOutputStream(soc.getOutputStream());
              out.writeObject(p);
              ObjectInputStream in = new ObjectInputStream(soc.getInputStream());
              packet rpac = (packet) in.readObject();
              if (rpac.getaction().equals("ok")) {

                JOptionPane.showMessageDialog(null, "Sucessfully Registered");

                jtf2.setText("");
                jtf1.setText("");
                jptf1.setText("");

              } else {

                JOptionPane.showMessageDialog(null, "Already Registered");
                jtf2.setText("");
                jtf1.setText("");
                jptf1.setText("");
              }

            } catch (Exception exp) {
            }
          }
        });

    b3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent we) {

            String username = jtf1.getText().trim();
            String password = jptf1.getText().trim();
            String mechine = jtf2.getText().trim();
            String Dname = box.getSelectedItem().toString();

            int porte = 0;

            try {
              Statement sate = conn.createStatement();
              ResultSet rsate =
                  sate.executeQuery("select * from Dagent where uname='" + Dname + "'");
              if (rsate.next()) {
                servermachine = rsate.getString("umechine");
                porte = rsate.getInt("ulistport");
                System.out.println(servermachine);
              }
              System.out.println(servermachine);

            } catch (Exception exp) {

            }

            try {

              packet p1 = new packet();
              p1.setaction("clogin");
              p1.setCuser(username);
              p1.setCpass(password);
              p1.setCmname(mechine);
              p1.setCDpeer(Dname);
              Socket soc1 = new Socket(servermachine, porte);
              ObjectOutputStream out1 = new ObjectOutputStream(soc1.getOutputStream());
              out1.writeObject(p1);
              ObjectInputStream in1 = new ObjectInputStream(soc1.getInputStream());
              packet rpac1 = (packet) in1.readObject();
              if (rpac1.getaction().equals("ok")) {
                int port1 = 0;
                try {

                  int portm = rpac1.getCport();
                  System.out.println("XXXXXXX" + portm);
                  //	JOptionPane.showMessageDialog(null,"Sucessfully Started");

                  new Listen(portm);
                  new process(username, portm);
                  dispose();
                } catch (Exception exp) {
                }
              } else {
                JOptionPane.showMessageDialog(
                    null, "Enter valid username and password", "Server reply", 2);
                jtf1.setText("");
                jtf2.setText("");
                jptf1.setText("");
              }

            } catch (Exception exp) {
            }
          }
        });

    setSize(400, 400);
    show();
    setLocation(150, 100);
    setResizable(false);
  }