예제 #1
0
 private JRadioButton getRegionButton(
     JRadioButton button, int x, int y, int w, int h, String tip) {
   button.setBounds(new Rectangle(x, y, w, h));
   button.setBorder(BorderFactory.createLoweredBevelBorder());
   button.setToolTipText(Messages.getString(tip));
   button.addActionListener(alRegion);
   regionButtons.add(button);
   return button;
 }
예제 #2
0
 private JRadioButton getShapeButton(
     JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj obj) {
   button.setBounds(new Rectangle(x, y, w, h));
   button.setBorder(BorderFactory.createLoweredBevelBorder());
   button.setToolTipText(Messages.getString(tip));
   button.addActionListener(alShape);
   shapeButtons.add(button);
   shapes.put(shp, button);
   objects.put(shp, obj);
   return button;
 }
예제 #3
0
  private void updateBorder() {
    // Preserve old borders
    if (SwingUtils.isPreserveBorders(radioButton)) {
      return;
    }

    // Actual margin
    final boolean ltr = radioButton.getComponentOrientation().isLeftToRight();
    final Insets m =
        new Insets(
            margin.top,
            ltr ? margin.left : margin.right,
            margin.bottom,
            ltr ? margin.right : margin.left);

    // Installing border
    radioButton.setBorder(LafUtils.createWebBorder(m));
  }
  /** Creates the And/Or radio buttons, their button group and a panel for them */
  private JComponent createLogicalButtons() {

    andButton = new JRadioButton(I18N.getString("AttributeResearchPanel.logicalAnd"));
    andButton.setBorder(BorderFactory.createEmptyBorder(2, 10, 2, 10));
    andButton.setActionCommand(logicalRelationships[0]);
    andButton.doClick();

    orButton = new JRadioButton(I18N.getString("AttributeResearchPanel.logicalOr"));
    orButton.setBorder(BorderFactory.createEmptyBorder(2, 10, 5, 10));
    orButton.setActionCommand(logicalRelationships[1]);

    ActionListener bal =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JRadioButton rb = (JRadioButton) e.getSource();
            currentRelationship = rb.getActionCommand();
          }
        };
    andButton.addActionListener(bal);
    orButton.addActionListener(bal);

    ButtonGroup bg = new ButtonGroup();
    bg.add(andButton);
    bg.add(orButton);
    JPanel b = new JPanel();
    LayoutManager lm = new BoxLayout(b, BoxLayout.PAGE_AXIS);
    b.setLayout(lm);
    b.setAlignmentX(Component.LEFT_ALIGNMENT);
    b.setBorder(
        BorderFactory.createTitledBorder(I18N.getString("AttributeResearchPanel.logicalLink")));

    // add a bit of space
    b.add(Box.createRigidArea(new Dimension(20, 10)));
    b.add(andButton);
    b.add(Box.createRigidArea(new Dimension(20, 10)));
    b.add(orButton);
    b.setPreferredSize(new Dimension(150, 100));

    return b;
  }
  private void initComponents() { // GEN-BEGIN:initComponents

    // COMPONENTES DE LA PESTAÑA 1
    jPanel1 = new javax.swing.JPanel();
    PanelP = new javax.swing.JPanel();

    jButton1 = new javax.swing.JButton(); // linea 2
    jButton2 = new javax.swing.JButton();

    jEtiq1 = new javax.swing.JLabel();
    jEtiq2 = new javax.swing.JLabel();
    jEtiq3 = new javax.swing.JLabel();
    jEtiq4 = new javax.swing.JLabel();
    jEtiq5 = new javax.swing.JLabel();

    // Se crea el scroll para el área de texto de los vectores
    vectores = new javax.swing.JTextArea(null, 0, 0);
    help = new javax.swing.JEditorPane();
    help.setEditable(false);

    scroll = new javax.swing.JScrollPane(vectores);
    scroll2 = new javax.swing.JScrollPane(help);

    tvariables = new javax.swing.JTextField();
    texpresion = new javax.swing.JTextField();
    tconstantes = new javax.swing.JTextField();

    TabFolders = new javax.swing.JTabbedPane();

    // COMPONENTES DE LA PESTAÑA 2
    buttonGroup1 = new javax.swing.ButtonGroup();
    buttonGroup2 = new javax.swing.ButtonGroup();
    PanelP = new javax.swing.JPanel();
    Label1 = new javax.swing.JLabel();
    Label2 = new javax.swing.JLabel();
    Label3 = new javax.swing.JLabel();
    tConstantes = new javax.swing.JTextField();
    tVariables = new javax.swing.JTextField();
    tExpresion = new javax.swing.JTextField();
    Panel2 = new javax.swing.JPanel();
    Label4 = new javax.swing.JLabel();
    Etiq = new javax.swing.JLabel();
    Label5 = new javax.swing.JLabel();
    Label6 = new javax.swing.JLabel();
    Label7 = new javax.swing.JLabel();
    rECM = new javax.swing.JRadioButton();
    rKS = new javax.swing.JRadioButton();
    Label8 = new javax.swing.JLabel();
    Label9 = new javax.swing.JLabel();
    Label10 = new javax.swing.JLabel();
    Label11 = new javax.swing.JLabel();
    Label12 = new javax.swing.JLabel();
    Label13 = new javax.swing.JLabel();
    Label14 = new javax.swing.JLabel();
    rAutomatico = new javax.swing.JRadioButton();
    rArchivo = new javax.swing.JRadioButton();
    Label15 = new javax.swing.JLabel();
    Label16 = new javax.swing.JLabel();
    tCruce = new javax.swing.JTextField();
    tMutacion = new javax.swing.JTextField();
    tPoblacion = new javax.swing.JTextField();
    tGeneraciones = new javax.swing.JTextField();
    tEntrada = new javax.swing.JTextField();
    tSalida = new javax.swing.JTextField();
    tValmin = new javax.swing.JTextField();
    tValmax = new javax.swing.JTextField();
    tValarchivo = new javax.swing.JTextField();
    Label17 = new javax.swing.JLabel();
    tErrormin = new javax.swing.JTextField();
    tErrormax = new javax.swing.JTextField();
    tDelta = new javax.swing.JTextField();
    tKS = new javax.swing.JTextField();
    bEvolucion = new javax.swing.JButton();
    barra = new javax.swing.JProgressBar();

    // UBICACION DE LOS COMPONENTES DE LA PRIMERA PESTAÑA
    getContentPane().setLayout(null);
    // getContentPane().setBackground(new java.awt.Color(255,195,140));

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Parámetros de Entrada Para el Simulador");
    setResizable(false);

    jPanel1.setLayout(null);

    jPanel1.setBackground(new java.awt.Color(240, 240, 240));
    jPanel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(100, 100, 100)));
    jEtiq1.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12));
    jEtiq1.setText("Función :");
    jPanel1.add(jEtiq1);
    jEtiq1.setBounds(30, 45, 70, 13);

    jEtiq2.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12));
    jEtiq2.setText("Variables: ");
    jPanel1.add(jEtiq2);
    jEtiq2.setBounds(30, 79, 70, 13);

    jEtiq3.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 11));
    jEtiq3.setText("Constantes: ");
    jPanel1.add(jEtiq3);
    jEtiq3.setBounds(25, 109, 72, 19);

    jEtiq4.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12));
    jEtiq4.setText("  Vectores");
    jPanel1.add(jEtiq4);
    jEtiq4.setBounds(30, 145, 80, 13);

    jEtiq5.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12));
    jEtiq5.setText("  Iniciales:");
    jPanel1.add(jEtiq5);
    jEtiq5.setBounds(30, 165, 80, 13);

    tconstantes.setFont(new java.awt.Font("Arial", 1, 13));
    tconstantes.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    jPanel1.add(tconstantes);
    tconstantes.setBounds(100, 110, 240, 23);
    tconstantes.setText("");

    tvariables.setFont(new java.awt.Font("Arial", 1, 13));
    tvariables.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    jPanel1.add(tvariables);
    tvariables.setBounds(100, 75, 240, 23);
    tvariables.setText("");

    texpresion.setFont(new java.awt.Font("Arial", 1, 11));
    texpresion.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    jPanel1.add(texpresion);
    texpresion.setBounds(100, 40, 240, 23);
    texpresion.setText("");

    vectores.setFont(new java.awt.Font("Arial", 1, 14));
    scroll.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    jPanel1.add(scroll);
    scroll.setBounds(100, 145, 240, 193);
    vectores.setText("");

    // AREA DONDE SE LE MUESTRAN LOS COMENTARIOS DE AYUDA AL USUARIO
    help.setFont(new java.awt.Font("Times New Roman", 2, 13));
    help.setBackground(new java.awt.Color(240, 240, 240));
    help.setBounds(390, 52, 204, 294);
    scroll2.setBackground(new java.awt.Color(240, 240, 240));
    scroll2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    scroll2.setAutoscrolls(true);
    //        scroll2.setCorner(this,1);
    jPanel1.add(scroll2);
    scroll2.setBounds(360, 40, 206, 298);
    letrero_inicial();

    // getContentPane().add(jPanel1);

    // DEFINE LAS DIMENSIONES DEL PANEL: x,y,ancho,altura
    // jPanel1.setBounds(40, 20, 340, 320);

    TabFolders.setBackground(new java.awt.Color(225, 225, 225));
    TabFolders.add(" Parámetros de Entrada ", jPanel1);

    // UBICACION DE LOS COMPONENTES DE LA SEGUNDA PESTAÑA
    // getContentPane().setLayout(null);
    PanelP.setLayout(null);
    PanelP.setBackground(new java.awt.Color(240, 240, 240));
    PanelP.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(100, 100, 100)));

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle(
        "Estimador de parámetros para funciones no lineales por simulación de algoritmos evolutivos");
    setResizable(false);

    Label4.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label4.setText("Probabilidad Cruce:");
    PanelP.add(Label4);
    Label4.setBounds(40, 20, 110, 13);

    Label5.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label5.setText("Probabilidad de mutaci\u00f3n:");
    PanelP.add(Label5);
    Label5.setBounds(40, 50, 130, 13);

    Label6.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label6.setText("Cantidad de poblaci\u00f3n:");
    PanelP.add(Label6);
    Label6.setBounds(40, 80, 120, 13);

    Label7.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label7.setText("N\u00famero de generaciones:");
    PanelP.add(Label7);
    Label7.setBounds(40, 110, 130, 13);

    rECM.setBackground(new java.awt.Color(240, 240, 240));
    rECM.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    rECM.setText("ECM");
    rECM.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            RECMActionPerformed(evt);
          }
        });

    PanelP.add(rECM);
    rECM.setBounds(312, 40, 49, 21);

    rKS.setBackground(new java.awt.Color(240, 240, 240));
    rKS.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    rKS.setText("Kolmogorov - Smirnov");
    rKS.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            RKSActionPerformed(evt);
          }
        });

    PanelP.add(rKS);
    rKS.setBounds(310, 60, 130, 21);

    Label8.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label8.setText("Error m\u00ednimo:");
    PanelP.add(Label8);
    Label8.setBounds(300, 120, 80, 13);

    Label9.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label9.setText("Error m\u00e1ximo:");
    PanelP.add(Label9);
    Label9.setBounds(300, 150, 70, 13);

    Label9.setVisible(false);

    Label10.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label10.setText("Delta de error:");
    PanelP.add(Label10);
    Label10.setBounds(300, 180, 80, 13);

    Label10.setVisible(false);

    Label11.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label11.setText("Porcentaje de puntos (K-S):");
    PanelP.add(Label11);
    Label11.setBounds(300, 150, 130, 13);

    /*Label12.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label12.setText("Archivo de entrada:");
    PanelP.add(Label12);
    Label12.setBounds(40, 140, 92, 13);*/

    Label13.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label13.setText("Archivo de salida:");
    PanelP.add(Label13);
    Label13.setBounds(40, 140, 100, 13);

    Label14.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 10));
    Label14.setText("Calcular pobaci\u00f3n inicial ");
    PanelP.add(Label14);
    Label14.setBounds(20, 210, 220, 13);

    rAutomatico.setBackground(new java.awt.Color(240, 240, 240));
    rAutomatico.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    rAutomatico.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    rAutomatico.setText("Autom\u00e1ticamente:");
    PanelP.add(rAutomatico);
    rAutomatico.setBounds(50, 230, 130, 21);

    rArchivo.setBackground(new java.awt.Color(240, 240, 240));
    rArchivo.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    rArchivo.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    rArchivo.setText("Valores dados de archivo:");
    PanelP.add(rArchivo);
    rArchivo.setBounds(50, 300, 150, 21);

    Label15.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label15.setText("Valores entre:");
    PanelP.add(Label15);
    Label15.setBounds(60, 260, 80, 13);

    Label16.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label16.setText("y");
    PanelP.add(Label16);
    Label16.setBounds(210, 260, 20, 13);

    tCruce.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tCruce.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tCruce);
    tCruce.setBounds(140, 20, 110, 18);
    tCruce.setText("0.5");

    tMutacion.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tMutacion.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tMutacion);
    tMutacion.setBounds(170, 50, 80, 18);
    tMutacion.setText("0.025");

    tPoblacion.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tPoblacion.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tPoblacion);
    tPoblacion.setBounds(160, 80, 90, 18);
    tPoblacion.setText("200");

    tGeneraciones.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tGeneraciones.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tGeneraciones);
    tGeneraciones.setBounds(170, 110, 80, 18);
    tGeneraciones.setText("100");

    tEntrada.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    PanelP.add(tEntrada);
    tEntrada.setBounds(240, 140, 110, 18);
    tEntrada.setText("Entrada.txt");
    tEntrada.setVisible(false);

    tSalida.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tSalida.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tSalida);
    tSalida.setBounds(130, 140, 120, 18);
    tSalida.setText("Salida.txt");

    tValmin.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tValmin.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tValmin);
    tValmin.setBounds(140, 260, 60, 18);
    tValmin.setText("-100.0");

    tValmax.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tValmax.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tValmax);
    tValmax.setBounds(230, 260, 60, 18);
    tValmax.setText("100.0");

    tDelta.setVisible(false);

    tValarchivo.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tValarchivo.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tValarchivo);
    tValarchivo.setBounds(70, 330, 220, 18);
    tValarchivo.setText("dataDefault.txt");

    Label17.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 10));
    Label17.setText("C\u00e1lculo del error:");
    PanelP.add(Label17);
    Label17.setBounds(300, 20, 100, 13);

    tErrormin.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tErrormin.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tErrormin);
    tErrormin.setBounds(440, 120, 80, 18);
    tErrormin.setText("0.0");

    tErrormax.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tErrormax.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tErrormax);
    tErrormax.setBounds(390, 150, 80, 18);
    tErrormax.setText("0.01");

    tErrormax.setVisible(false);

    tDelta.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    PanelP.add(tDelta);
    tDelta.setBounds(390, 180, 80, 18);
    tDelta.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    tDelta.setText("0.1");

    tKS.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tKS.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tKS);
    tKS.setBounds(440, 150, 80, 18);
    tKS.setText("0.8");

    bEvolucion.setText("Iniciar!");
    bEvolucion.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 20));
    bEvolucion.setBackground(new java.awt.Color(210, 210, 210));
    bEvolucion.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(100, 100, 100)));

    bEvolucion.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            BEvolucionActionPerformed(evt);
          }
        });

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

    PanelP.add(bEvolucion);
    bEvolucion.setBounds(370, 280, 150, 70);

    Etiq.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 10));
    Etiq.setBounds(345, 183, 190, 70);
    Etiq.setText("Evolución de las Generaciones:");
    PanelP.add(Etiq);
    Etiq.setVisible(false);

    barra.setBounds(370, 240, 150, 20);

    barra.setMinimum(0);
    barra.setMaximum(100);
    barra.setVisible(false);
    barra.setBackground(new java.awt.Color(240, 240, 240));
    barra.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0)));
    PanelP.add(barra);

    buttonGroup1.add(rECM);
    buttonGroup1.add(rKS);
    rECM.setSelected(true);
    rECM.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));

    buttonGroup2.add(rArchivo);
    buttonGroup2.add(rAutomatico);
    rAutomatico.setSelected(true);

    TabFolders.setEnabled(true);
    TabFolders.add(" Ejecución de la Simulación ", PanelP);
    TabFolders.setBounds(40, 20, 600, 400);
    getContentPane().add(TabFolders, java.awt.BorderLayout.CENTER);

    // Se adicionan los "escuchadores" de foco a los campos de texto de la primera pestaña

    SymFocus aSymFocus = new SymFocus(this);
    texpresion.addFocusListener(aSymFocus);
    tconstantes.addFocusListener(aSymFocus);
    tvariables.addFocusListener(aSymFocus);
    vectores.addFocusListener(aSymFocus);

    pack();

    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 925) / 2, (screenSize.height - 582) / 2, 675, 482);
  }
예제 #6
0
  private void buildDialog() {
    Window window = SwingUtilities.windowForComponent(target.getEditComponent());

    dialog = new JDialog(window, "Find / Replace");
    dialog.setModal(false);

    JPanel panel = new JPanel(new BorderLayout());
    findCombo = new JComboBox();
    findCombo.setEditable(true);
    replaceCombo = new JComboBox();
    replaceCombo.setEditable(true);

    // create inputs
    GridLayout gridLayout = new GridLayout(2, 2);
    gridLayout.setVgap(5);
    JPanel inputPanel = new JPanel(gridLayout);
    inputPanel.add(new JLabel("Find:"));
    inputPanel.add(findCombo);
    inputPanel.add(new JLabel("Replace with:"));
    inputPanel.add(replaceCombo);
    inputPanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));

    // create direction panel
    ButtonGroup directionGroup = new ButtonGroup();
    forwardButton = new JRadioButton("Forward", true);
    forwardButton.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    directionGroup.add(forwardButton);
    backwardButton = new JRadioButton("Backward");
    backwardButton.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    directionGroup.add(backwardButton);

    JPanel directionPanel = new JPanel(new GridLayout(2, 1));
    directionPanel.add(forwardButton);
    directionPanel.add(backwardButton);
    directionPanel.setBorder(BorderFactory.createTitledBorder("Direction"));

    // create scope panel
    ButtonGroup scopeGroup = new ButtonGroup();
    allButton = new JRadioButton("All", true);
    allButton.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    selectedLinesButton = new JRadioButton("Selected Lines");
    selectedLinesButton.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    scopeGroup.add(allButton);
    scopeGroup.add(selectedLinesButton);

    JPanel scopePanel = new JPanel(new GridLayout(2, 1));
    scopePanel.add(allButton);
    scopePanel.add(selectedLinesButton);
    scopePanel.setBorder(BorderFactory.createTitledBorder("Scope"));

    // create options
    caseCheck = new JCheckBox("Case Sensitive");
    caseCheck.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    wholeWordCheck = new JCheckBox("Whole Word");
    wholeWordCheck.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    wrapCheck = new JCheckBox("Wrap Search");
    wrapCheck.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    JPanel optionsPanel = new JPanel(new GridLayout(3, 1));
    optionsPanel.add(caseCheck);
    optionsPanel.add(wholeWordCheck);
    optionsPanel.add(wrapCheck);
    optionsPanel.setBorder(BorderFactory.createTitledBorder("Options"));

    // create panel with options
    JPanel options = new JPanel(new GridLayout(1, 2));

    JPanel radios = new JPanel(new GridLayout(2, 1));
    radios.add(directionPanel);
    radios.add(scopePanel);

    options.add(optionsPanel);
    options.add(radios);
    options.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));

    // create buttons
    ButtonBarBuilder builder = new ButtonBarBuilder();
    findButton = new JButton(new FindAction());
    builder.addFixed(findButton);
    builder.addRelatedGap();
    replaceButton = new JButton(new ReplaceAction());
    builder.addFixed(replaceButton);
    builder.addRelatedGap();
    replaceAllButton = new JButton(new ReplaceAllAction());
    builder.addFixed(replaceAllButton);
    builder.addUnrelatedGap();
    builder.addFixed(new JButton(new CloseAction()));
    builder.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));

    // tie it up!
    panel.add(inputPanel, BorderLayout.NORTH);
    panel.add(options, BorderLayout.CENTER);
    panel.add(builder.getPanel(), BorderLayout.SOUTH);

    dialog.getContentPane().add(panel);
    dialog.pack();
    UISupport.initDialogActions(dialog, null, findButton);
  }
  // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
  private void initComponents() {
    final javax.swing.ButtonGroup acceptOrDeclineButtonGroup = new javax.swing.ButtonGroup();
    final javax.swing.JLabel explanationJLabel = new javax.swing.JLabel();

    setOpaque(false);
    explanationJLabel.setFont(Fonts.DialogFont);
    explanationJLabel.setText(
        java.util.ResourceBundle.getBundle("localization/Browser_Messages")
            .getString("UpgradeAccountAvatar.Agreement.Explanation"));

    licenseAgreementJTextArea.setColumns(20);
    licenseAgreementJTextArea.setEditable(false);
    licenseAgreementJTextArea.setFont(Fonts.DialogTextEntryFont);
    licenseAgreementJTextArea.setRows(5);
    licenseAgreementJTextArea.setTabSize(4);
    licenseAgreementJTextArea.setFocusable(false);
    licenseAgreementJScrollPane.setViewportView(licenseAgreementJTextArea);

    acceptOrDeclineButtonGroup.add(acceptJRadioButton);
    acceptJRadioButton.setFont(Fonts.DialogFont);
    acceptJRadioButton.setText(
        java.util.ResourceBundle.getBundle("localization/Browser_Messages")
            .getString("UpgradeAccountAvatar.Agreement.AcceptLicenseAgreement"));
    acceptJRadioButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    acceptJRadioButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
    acceptJRadioButton.setOpaque(false);
    acceptJRadioButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            acceptJRadioButtonActionPerformed(evt);
          }
        });

    acceptOrDeclineButtonGroup.add(declineJRadioButton);
    declineJRadioButton.setFont(Fonts.DialogFont);
    declineJRadioButton.setText(
        java.util.ResourceBundle.getBundle("localization/Browser_Messages")
            .getString("UpgradeAccountAvatar.Agreement.DeclineLicenseAgreement"));
    declineJRadioButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    declineJRadioButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
    declineJRadioButton.setOpaque(false);
    declineJRadioButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            declineJRadioButtonActionPerformed(evt);
          }
        });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(
                                licenseAgreementJScrollPane,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                455,
                                Short.MAX_VALUE)
                            .addComponent(explanationJLabel)
                            .addComponent(acceptJRadioButton)
                            .addComponent(declineJRadioButton))
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addGap(100, 100, 100)
                    .addComponent(explanationJLabel)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        licenseAgreementJScrollPane,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        214,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(19, 19, 19)
                    .addComponent(acceptJRadioButton)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(declineJRadioButton)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
  } // </editor-fold>//GEN-END:initComponents
  @SuppressWarnings("static-access")
  public editSalary(SalaryVO vo, JFrame main, LoginPO loginPO) {
    editSalary editSalary = this;
    setBounds(100, 100, 750, 600);
    setLayout(null);
    this.setVisible(true);
    // first
    rdbtnNewRadioButton = new JRadioButton("\u6309\u6708");
    rdbtnNewRadioButton.setOpaque(false);
    rdbtnNewRadioButton.setBorder(null);
    rdbtnNewRadioButton.setBounds(371, 290, 83, 23);
    rdbtnNewRadioButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            salaryModel = SalaryModel.ByMonth;
          }
        });
    add(rdbtnNewRadioButton);

    // second
    radioButton = new JRadioButton("\u6309\u6B21");
    radioButton.setBounds(371, 326, 83, 23);
    radioButton.setOpaque(false);
    radioButton.setBorder(null);
    radioButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            salaryModel = salaryModel.ByTimes;
          }
        });
    add(radioButton);

    // third
    radioButton_1 = new JRadioButton("\u6309\u63D0\u6210");
    radioButton_1.setBounds(371, 366, 100, 23);
    radioButton_1.setOpaque(false);
    radioButton_1.setBorder(null);
    radioButton_1.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            salaryModel = salaryModel.ByBenefit;
          }
        });
    add(radioButton_1);

    buttonGroup = new ButtonGroup();
    buttonGroup.add(rdbtnNewRadioButton);
    buttonGroup.add(radioButton);
    buttonGroup.add(radioButton_1);

    if (vo.getTypeOfStrategy() == SalaryModel.ByMonth) {
      rdbtnNewRadioButton.setSelected(true);
      salaryModel = SalaryModel.ByMonth;
    } else if (vo.getTypeOfStrategy() == salaryModel.ByTimes) {
      radioButton.setSelected(true);
      salaryModel = salaryModel.ByTimes;
    } else {
      radioButton_1.setSelected(true);
      salaryModel = salaryModel.ByBenefit;
    }

    JButton btnNewButton = new JButton("\u786E\u5B9A");
    btnNewButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            int n = JOptionPane.showConfirmDialog(null, "确认修改?", "no", JOptionPane.YES_NO_OPTION);
            if (n == JOptionPane.YES_OPTION) {
              if (textField_1.getText().equals("")) {
                label_4.setText("请输入价格");
                Thread thread = new Thread(editSalary);
                thread.start();
              } else {
                SalaryVO salaryVO =
                    new SalaryVO(
                        textField.getText(),
                        Double.parseDouble(textField_1.getText()),
                        salaryModel);
                SalaryPolicybl salaryPolicybl = new SalaryPolicybl();
                salaryPolicybl.editSalary(salaryVO);
                Salary salary = new Salary(salaryVO, main, loginPO);
                main.remove(editSalary);
                main.getContentPane().add(salary);
                main.invalidate();
                main.repaint();
                main.setVisible(true);
              }
            }
          }
        });
    btnNewButton.setBounds(283, 419, 52, 52);
    ImageIcon image1 = new ImageIcon("image/transparent_circle.png");
    Image temp1 =
        image1
            .getImage()
            .getScaledInstance(
                btnNewButton.getWidth(), btnNewButton.getHeight(), image1.getImage().SCALE_DEFAULT);
    image1 = new ImageIcon(temp1);
    btnNewButton.setIcon(image1);
    btnNewButton.setContentAreaFilled(false);
    btnNewButton.setBorderPainted(false);
    add(btnNewButton);

    JButton button = new JButton("");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Salary salary = new Salary(vo, main, loginPO);
            main.remove(editSalary);
            main.getContentPane().add(salary);
            main.invalidate();
            main.repaint();
            main.setVisible(true);
          }
        });
    button.setBounds(13, -9, 63, 63);
    button.setContentAreaFilled(false);
    button.setBorderPainted(false);
    button.setIcon(new ImageIcon("image/transparent_circle.png"));
    button.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            button.setIcon(new ImageIcon("image/mask_circle.png"));
          }
        });

    add(button);

    textField = new JTextField();
    textField.setColumns(10);
    textField.setBounds(373, 189, 108, 21);
    textField.setText(vo.getTypeOfStaff());
    textField.setEnabled(false);
    textField.setForeground(new Color(88, 93, 103));
    textField.setCaretColor(new Color(88, 93, 103));
    textField.setOpaque(false);
    textField.setBorder(null);
    add(textField);

    textField_1 = new JTextField();
    textField_1.setColumns(10);
    textField_1.setDocument(new JTextFieldLimit(7));
    textField_1.setBounds(373, 239, 108, 21);
    textField_1.addKeyListener(new InputNumber());
    textField_1.setText(vo.getSalary() + "");
    textField_1.setForeground(new Color(88, 93, 103));
    textField_1.setCaretColor(new Color(88, 93, 103));
    textField_1.setOpaque(false);
    textField_1.setBorder(null);
    add(textField_1);

    JToolBar toolBar = new JToolBar();
    toolBar.setBounds(8, 541, 750, 35);
    toolBar.setOpaque(false);
    toolBar.setBorder(null);
    add(toolBar);

    label_4 = new JLabel("\u72B6\u6001\u680F");
    label_4.setForeground(Color.WHITE);
    toolBar.add(label_4);

    JButton button2 = new JButton("取消");
    button2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            editSalary neweditSalary = new editSalary(vo, main, loginPO);
            main.remove(editSalary);
            main.getContentPane().add(neweditSalary);
            main.invalidate();
            main.repaint();
            main.setVisible(true);
          }
        });

    button2.setBounds(416, 418, 52, 52);
    ImageIcon image2 = new ImageIcon("image/transparent_circle.png");
    Image temp2 =
        image2
            .getImage()
            .getScaledInstance(
                button2.getWidth(), button2.getHeight(), image2.getImage().SCALE_DEFAULT);
    image2 = new ImageIcon(temp2);
    button2.setIcon(image2);
    button2.setContentAreaFilled(false);
    button2.setBorderPainted(false);
    add(button2);
  }
예제 #9
0
  public CommonPanel(JFrame ownerFrame, IFileSelector fileSelectionPanel) {
    //		try {
    //			FileHandler fh = new FileHandler("log.txt");
    //			Logger.getLogger(CommonPanel.class.getName()).addHandler(fh);
    //		}catch(IOException ex) {
    //			Logger.getLogger(CommonPanel.class.getName()).log(Level.SEVERE, null, ex);
    //		}catch(SecurityException ex) {
    //			Logger.getLogger(CommonPanel.class.getName()).log(Level.SEVERE, null, ex);
    //		}
    this.ownerFrame = ownerFrame;
    this.fileSelectionPanel = fileSelectionPanel;
    this.fontSizeTF = new JTextField(4);
    fontSizeTF.setToolTipText("Enter the font size, e.g. 12, 10.5, 22.7");
    fontSizeTF.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (!fontSizeSpecRB.isSelected()) fontSizeSpecRB.setSelected(true);
          }
        });
    fontSizeTF.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            super.mousePressed(e);
            if (!fontSizeSpecRB.isSelected()) fontSizeSpecRB.setSelected(true);
            System.out.println("fontSizeTF mousePressed");
          }

          @Override
          public void mouseExited(MouseEvent e) {
            MouseEvent event =
                new MouseEvent(
                    fontSizeSpecRB,
                    e.getID(),
                    e.getWhen(),
                    e.getModifiers(),
                    1,
                    1,
                    1,
                    e.isPopupTrigger(),
                    e.getButton());
            fontSizeSpecRB.dispatchEvent(event);
          }

          @Override
          public void mouseEntered(MouseEvent e) {
            MouseEvent event =
                new MouseEvent(
                    fontSizeSpecRB,
                    e.getID(),
                    e.getWhen(),
                    e.getModifiers(),
                    1,
                    1,
                    1,
                    e.isPopupTrigger(),
                    e.getButton());
            fontSizeSpecRB.dispatchEvent(event);
          }
        });
    String fontSizeRBToolTip =
        "<html>When this option is selected it enforces that"
            + "<br> the entered font size is used when creating the output file.";
    this.fontSizeSpecRB = new JRadioButton("Use the font size ");
    fontSizeSpecRB.setOpaque(false);
    fontSizeSpecRB.setToolTipText(fontSizeRBToolTip);
    JPanel fontSizeSpecPanel = new JPanel();
    fontSizeSpecPanel.setToolTipText(fontSizeRBToolTip);
    // pass events to radiobutton
    fontSizeSpecPanel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            MouseEvent event =
                new MouseEvent(
                    fontSizeSpecRB,
                    e.getID(),
                    e.getWhen(),
                    e.getModifiers(),
                    1,
                    1,
                    1,
                    e.isPopupTrigger(),
                    e.getButton());
            fontSizeSpecRB.dispatchEvent(event);
          }

          @Override
          public void mouseReleased(MouseEvent e) {
            MouseEvent event =
                new MouseEvent(
                    fontSizeSpecRB,
                    e.getID(),
                    e.getWhen(),
                    e.getModifiers(),
                    1,
                    1,
                    e.getClickCount(),
                    e.isPopupTrigger(),
                    e.getButton());
            fontSizeSpecRB.dispatchEvent(event);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            MouseEvent event =
                new MouseEvent(
                    fontSizeSpecRB,
                    e.getID(),
                    e.getWhen(),
                    e.getModifiers(),
                    1,
                    1,
                    e.getClickCount(),
                    e.isPopupTrigger(),
                    e.getButton());
            fontSizeSpecRB.dispatchEvent(event);
          }

          @Override
          public void mouseEntered(MouseEvent e) {
            MouseEvent event =
                new MouseEvent(
                    fontSizeSpecRB,
                    e.getID(),
                    e.getWhen(),
                    e.getModifiers(),
                    1,
                    1,
                    e.getClickCount(),
                    e.isPopupTrigger(),
                    e.getButton());
            fontSizeSpecRB.dispatchEvent(event);
          }
        });
    fontSizeSpecPanel.add(fontSizeSpecRB);
    fontSizeSpecPanel.add(fontSizeTF);
    fontSizeSpecPanel.setBorder(BorderFactory.createEtchedBorder());
    fontSizeSpecPanel.setOpaque(false);
    this.fitTextToWidthRB = new JRadioButton("Fit text to page width ");
    fitTextToWidthRB.setBorder(BorderFactory.createEtchedBorder());
    fitTextToWidthRB.setBorderPainted(true);
    fitTextToWidthRB.setOpaque(false);
    fitTextToWidthRB.setToolTipText(
        "<html>Don't care about the font size, but make sure"
            + "<br> the width of input file content will fit into "
            + "<br>a whole width of a 'pdf' page.");

    ButtonGroup fontBG = new ButtonGroup();
    fontBG.add(fontSizeSpecRB);
    fontBG.add(fitTextToWidthRB);
    fitTextToWidthRB.setSelected(true);

    double p = TableLayout.PREFERRED;
    TableLayout fontSelectPL =
        new TableLayout(new double[] {.5, p, p, p, .5}, new double[] {.5, p, .5});
    JPanel fontSelectP = new JPanel(fontSelectPL);
    fontSelectP.setOpaque(false);
    fontSelectP.add(fontSizeSpecPanel, "1,1,L,C");
    fontSelectP.add(new JLabel(" or "), "2,1,C,C");
    fontSelectP.add(fitTextToWidthRB, "3,1,R,F");

    String[] fonts = {
      BaseFont.COURIER,
      BaseFont.HELVETICA,
      BaseFont.SYMBOL,
      BaseFont.TIMES_ROMAN,
      BaseFont.ZAPFDINGBATS
    }; // , "fonts/lucon.ttf"};
    // load font files from the fonts folder
    String fontFolder = "fonts";
    String[] fontFileNames = new String[0];
    //		Logger.getLogger(CommonPanel.class.getName()).log(Level.INFO,
    //				"ownerFrame must be instanceof Txt2PDFConverterIN is it?="
    //				+(ownerFrame instanceof Txt2PDFConverterIN)
    //				+"; ownerFrame.getClass().getName()="+ownerFrame.getClass().getName());
    if (ownerFrame instanceof Txt2PDFConverterIN)
      try {
        fontFileNames = getResourceListing(this.getClass(), fontFolder + "/");
      } catch (Exception ex) {
        // ignore, it could happen when fonts folder doesn't exist, it does
        // happen when debugging since the folder doesn't exist.
        // But the folder always is packed in the compact(IN) version of the program.
      }
    else {
      fontFileNames = new File(fontFolder).list();
    }
    //		Logger.getLogger(CommonPanel.class.getName()).log(Level.INFO,
    //				"fontFileNames=" + Arrays.toString(fontFileNames));
    int initialFontsSize = fonts.length;
    if (fontFileNames.length > 0) {
      int newFontsSize = initialFontsSize + fontFileNames.length;
      fonts = Arrays.copyOf(fonts, newFontsSize);
      for (int i = initialFontsSize; i < newFontsSize; i++)
        fonts[i] = fontFolder + "/" + fontFileNames[i - initialFontsSize];
    }
    this.fontCB = new JComboBox(fonts);
    fontCB.setBorder(BorderFactory.createEtchedBorder());
    fontCB.setToolTipText("Select the font to use for output.");
    String[] encodings = {BaseFont.CP1252, BaseFont.CP1250, BaseFont.CP1257, BaseFont.MACROMAN};
    this.encodingCB = new JComboBox(encodings);
    encodingCB.setBorder(BorderFactory.createEtchedBorder());
    encodingCB.setToolTipText("Select encoding used by the input file.");
    this.portraitRB = new JRadioButton("Portrait ");
    portraitRB.setBorder(BorderFactory.createEtchedBorder());
    portraitRB.setBorderPainted(true);
    portraitRB.setOpaque(false);
    portraitRB.setToolTipText("The output file will have pages in portrait orientation.");
    this.landscapeRB = new JRadioButton("Landscape ");
    landscapeRB.setBorder(BorderFactory.createEtchedBorder());
    landscapeRB.setBorderPainted(true);
    landscapeRB.setOpaque(false);
    landscapeRB.setToolTipText("The output file will have pages in landscape orientation.");
    ButtonGroup pageOrientBG = new ButtonGroup();
    pageOrientBG.add(portraitRB);
    pageOrientBG.add(landscapeRB);
    portraitRB.setSelected(true);

    // panel with page orientation settings
    TableLayout pageOrientPL =
        new TableLayout(new double[] {5, p, p, p, 5}, new double[] {TableLayout.FILL});
    JPanel pageOrientP = new JPanel(pageOrientPL);
    pageOrientP.setOpaque(false);
    pageOrientP.add(portraitRB, "1,0,L,F");
    pageOrientP.add(new JLabel(" or "), "2,0,C,C");
    pageOrientP.add(landscapeRB, "3,0,R,F");
    pageOrientP.setBorder(BorderFactory.createEtchedBorder());

    TableLayout encodeOrientPL =
        new TableLayout(
            new double[] {10, p, 5, p, TableLayout.FILL, p, 10}, new double[] {.5, p, .5});
    JPanel fontEncodeOrientP = new JPanel(encodeOrientPL);
    fontEncodeOrientP.setOpaque(false);
    fontEncodeOrientP.add(fontCB, "1,1,L,F");
    fontEncodeOrientP.add(encodingCB, "3,1,L,F");
    fontEncodeOrientP.add(pageOrientP, "5,1,R,F");

    this.overwriteOutputFileChB = new JCheckBox("Overwrite output file ");
    overwriteOutputFileChB.setToolTipText(
        "When selected it will overwrite the output file if it exists.");
    overwriteOutputFileChB.setBorder(BorderFactory.createEtchedBorder());
    overwriteOutputFileChB.setBorderPainted(true);
    overwriteOutputFileChB.setOpaque(false);
    int bW = 80;
    int bH = 30;
    this.convertB = new JButton(copnvertAction);
    convertB.setPreferredSize(new Dimension(bW, bH));
    convertB.setToolTipText("Convert the input 'txt' file applying all the selected settings.");
    this.exitB = new JButton(exitAction);
    exitB.setPreferredSize(new Dimension(bW, bH));
    exitB.setToolTipText("Exit the program.");
    TableLayout buttonPL =
        new TableLayout(new double[] {.25, p, .5, p, .25}, new double[] {5, p, 5});
    JPanel buttonP = new JPanel(buttonPL);
    buttonP.setOpaque(false);
    buttonP.add(convertB, "1,1,C,C");
    buttonP.add(exitB, "3,1,C,C");

    JLabel infoL = new JLabel("<html><p>&nbsp Select conversion settings.</p>");
    TableLayout layout =
        new TableLayout(
            new double[] {.5, p, .5}, new double[] {.5, p, 5, p, 5, p, 5, p, 10, p, .5});
    setLayout(layout);
    add(infoL, "1,1,L,C");
    add(fontSelectP, "1,3,F,C");
    add(fontEncodeOrientP, "1,5,F,C");
    add(overwriteOutputFileChB, "1,7,C,F");
    add(buttonP, "1,9,F,C");
  }