Examples of CardLayout


Examples of java.awt.CardLayout

            currentAction.action = cbxAction.getSelectedIndex();
            setActionProperties();
          }
        });
       
        optionPanel = new JPanel(new CardLayout());

        // ---------- Text options -----------
        Box options = Box.createVerticalBox();
        options.add(Box.createVerticalGlue());
View Full Code Here

Examples of java.awt.CardLayout

       
        // No re-entry to avoid problems, not synchronized because not necessary
        if (inAction) return;
        inAction = true;
       
        CardLayout cl = (CardLayout)(optionPanel.getLayout());
        switch (currentAction.action) {
          case AutomatonAction.MOVE_UP:
          case AutomatonAction.MOVE_RIGHT:
          case AutomatonAction.MOVE_DOWN:
          case AutomatonAction.MOVE_LEFT:
            cl.show(optionPanel, "move");
            if ((currentAction.option==null) || (!(currentAction.option instanceof Integer)))
              currentAction.option = lastMoveOp;
            lastMoveOp = (Integer)currentAction.option;
            if (currentAction.option.equals(AutomatonAction.OPTION_WRAP)) {
              rbWrap.setSelected(true);
            }
            else if (currentAction.option.equals(AutomatonAction.OPTION_EXTEND)) {
              rbExtend.setSelected(true);
            }
            else rbDoNothing.setSelected(true);
            break;
          case AutomatonAction.SET_BACKGROUND_COLOR: 
          case AutomatonAction.SET_FRAME_COLOR:
          case AutomatonAction.SET_TEXT_COLOR:
            cl.show(optionPanel, "color");
            if ((currentAction.option==null) || (!(currentAction.option instanceof Color)))
              currentAction.option = lastColor;
            lastColor = (Color)currentAction.option;
            bchoosecolor.setBackground(lastColor);
            break;
          case AutomatonAction.SET_TEXT:
            if ((currentAction.option==null) || (!(currentAction.option instanceof Object[])) || (((Object[])currentAction.option).length==0) || (!(((Object[])currentAction.option)[0] instanceof Integer))  ) {
              currentAction.option = new Object[] {new Integer(0)};
            }
            int format = ((Integer)((Object[])currentAction.option)[0]).intValue();
            if (format==6) {
              if ((((Object[])currentAction.option).length<2) || (!(((Object[])currentAction.option)[1] instanceof String))) {
                currentAction.option = new Object[] { ((Object[])currentAction.option)[6], lastString };
              }
              lastString = (String)((Object[])currentAction.option)[1];
              rbFixedText.setSelected(true);
              if (!tfFixedText.getText().equals(lastString) )
                tfFixedText.setText(lastString);
              tfFixedText.setEnabled(true);
              cbxformat.setEnabled(false);
              nfformat.setEnabled(false);
              lformatdigits.setEnabled(false);
            } else {
              rbUseSource.setSelected(true);
              tfFixedText.setEnabled(false);
              cbxformat.setEnabled(true);
              cbxformat.setSelectedIndex(format);
              if ((format==1) || (format==2)) {
                if ((((Object[])currentAction.option).length<2) || (!(((Object[])currentAction.option)[1] instanceof NumberFormat))) {
                  currentAction.option = new Object[] { ((Object[])currentAction.option)[0], NumberFormat.getNumberInstance(CustomizedLocale.get()) };
                  if ((format==2) && (((Object[])currentAction.option)[1] instanceof DecimalFormat)) {
                    ((DecimalFormat)((Object[])currentAction.option)[1]).applyPattern("0.000E0");
                  }
                }
                nfformat.setEnabled(true);
                lformatdigits.setEnabled(true);
                if (((Object[])currentAction.option)[1] instanceof DecimalFormat) {
                  DecimalFormat df = ((DecimalFormat)((Object[])currentAction.option)[1]);
                  if (format==1) nfformat.setValue(df.getMaximumFractionDigits());
                  else {
                    String pattern = df.toPattern();
                    int l =0;
                    l = pattern.indexOf('E') - pattern.indexOf('.');
                    if (l>0) l--; // number of characters between . and E
                    nfformat.setValue(l);
                  }
                }
              } else {
                nfformat.setEnabled(false);
                lformatdigits.setEnabled(false);
              }
            }
            cl.show(optionPanel, "text");
            break;
        }
        cbxAction.setSelectedIndex(currentAction.action);
        if (list!=null) list.repaint();
        inAction = false;
View Full Code Here

Examples of java.awt.CardLayout

        cbxformat.addItem(resources.getString("PrintfFormat"));
        cbxformat.addItem(resources.getString("UseDataSourceFormat"));
        cbxformat.setEditable(false);
        // CARD PANEL
        cards = new JPanel();
        cards.setLayout(new CardLayout());
        // JSYnoptic formater
        lformatdigits = new JLabel(resources.getString("DecimalDigits:"));
        nfformat = new NumberField(0, 3);
        nfformat.setColumns(10);
        nfformat.setHorizontalAlignment(SwingConstants.RIGHT);
        GridBagPanel digitsPanel = new GridBagPanel();
        digitsPanel.addOnCurrentRow(lformatdigits);
        digitsPanel.addOnCurrentRow(nfformat);
        digitsPanel.carriageReturn();
        cards.add(digitsPanel, "jsynopticFormat");
        // Printf Formater
        GridBagPanel printfPanel = new GridBagPanel();
        lPrintfFormat = new JLabel(resources.getString("PrintfFormat"));
        tfPrintfFormat = new JTextField(10);
        printfPanel.addOnCurrentRow(lPrintfFormat);
        printfPanel.addOnCurrentRow(tfPrintfFormat);
        printfPanel.carriageReturn();
        cards.add(printfPanel, "printfFormat");
        cards.add(new GridBagPanel(), "noAttributes");
        // Mapper
        cbxmapper = new JComboBox();
        cbxmapper.addItem(resources.getString("=======NONE======="));
        int idx = 0;
        if (TextMapper.textMappers != null) {
            for (int i = 0; i < TextMapper.textMappers.size(); ++i) {
                TextMapper tm = (TextMapper) TextMapper.textMappers.get(i);
                if (tm.equals(mapper)) {
                    idx = i + 1;
                }
                cbxmapper.addItem(tm);
            }
        }
        cbxmapper.setEditable(false);
        cbxmapper.setSelectedIndex(idx);
        beditmapper = new JButton(resources.getString("Edit"));
        bnewmapper = new JButton(resources.getString("New"));
        bdelmapper = new JButton(resources.getString("Delete"));
        bduplicateMapper = new JButton(resources.getString("Duplicate"));
        if (idx == 0) {
            beditmapper.setEnabled(false);
            bdelmapper.setEnabled(false);
            bduplicateMapper.setEnabled(false);
        }
        cbxmapper.setRenderer(new ListCellRenderer() {
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                    boolean cellHasFocus) {
                String s = value.toString();
                if (s.length() > 18) {
                    s = s.substring(0, 15) + "...";
                }
                return new JLabel(s);
            }
        });
        beditmapper.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (mapper == null) {
                    return;
                }
                mapper.editDialog(TextPropertiesPanel.this.getOwner());
                cbxmapper.repaint(); // in case of name change
            }
        });
        bnewmapper.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                mapper = TextMapper.createTextMapperDialog(TextPropertiesPanel.this.getOwner());
                if (TextMapper.textMappers == null) {
                    TextMapper.textMappers = new Vector();
                }
                TextMapper.textMappers.add(mapper);
                cbxmapper.addItem(mapper);
                cbxmapper.setSelectedItem(mapper);
                cards.revalidate();
            }
        });
        bdelmapper.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (mapper == null) {
                    return;
                }
                if (TextMapper.textMappers != null) {
                    TextMapper.textMappers.remove(mapper);
                }
                cbxmapper.removeItem(mapper);
                cbxmapper.setSelectedIndex(0);
                mapper = null;
                bdelmapper.setEnabled(false);
                bduplicateMapper.setEnabled(false);
                beditmapper.setEnabled(false);
            }
        });
       
        bduplicateMapper.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (mapper == null) {
                    return;
                }
                try {
                    TextMapper tm =  (TextMapper)((TextMapper)mapper).clone();
                    if (TextMapper.textMappers != null) {
                        TextMapper.textMappers.add(tm);
                    }
                    mapper = tm;
                    cbxmapper.addItem(mapper);
                    cbxmapper.setSelectedItem(mapper);
                   
                }catch (CloneNotSupportedException cnse){
                }
            }
        });
       
        cbxmapper.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                int idx = cbxmapper.getSelectedIndex();
                if (idx == 0) {
                    beditmapper.setEnabled(false);
                    bdelmapper.setEnabled(false);
                    bduplicateMapper.setEnabled(false);
                    mapper = null;
                } else {
                    mapper = (TextMapper) cbxmapper.getItemAt(idx);
                    beditmapper.setEnabled(true);
                    bdelmapper.setEnabled(true);
                    bduplicateMapper.setEnabled(true);
                }
            }
        });
        GridBagPanel mapperPanel = new GridBagPanel();
        mapperPanel.addOnCurrentRow(cbxmapper, 2);
        mapperPanel.addOnCurrentRow(beditmapper);
        mapperPanel.addOnCurrentRow(bnewmapper);
        mapperPanel.addOnCurrentRow(bdelmapper);
        mapperPanel.addOnCurrentRow(bduplicateMapper);
        mapperPanel.carriageReturn();
        cards.add(mapperPanel, "mapper");
        CardLayout cl = (CardLayout) (cards.getLayout());
        if (cbxformat.getSelectedIndex() == TextShape.FORMAT_MAPPER) {
            cl.show(cards, "mapper");
        } else {
            cl.show(cards, "bounds");
        }
        tfText.getDocument().addDocumentListener(new DocumentListener() {
            public void insertUpdate(DocumentEvent e) {
                updateName();
            }

            public void removeUpdate(DocumentEvent e) {
                updateName();
            }

            public void changedUpdate(DocumentEvent e) {
                updateName();
            }

            private void updateName() {
                TextPropertiesPanel.this.setName(tfText.getText());
            }
        });
        setName(tfText.getText());
        cbxformat.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if ((cbxformat.getSelectedIndex() == TextShape.FORMAT_DECIMAL)
                        || (cbxformat.getSelectedIndex() == TextShape.FORMAT_SCIENTIFIC)) {
                    nfformat.setEnabled(true);
                    lformatdigits.setEnabled(true);
                } else {
                    nfformat.setEnabled(false);
                    lformatdigits.setEnabled(false);
                }
                if (cbxformat.getSelectedIndex() == TextShape.FORMAT_USE_DATA_SOURCE) {
                    if (DataInfo.getPrintfFormat(source) != null) {
                        tfPrintfFormat.setText(DataInfo.getPrintfFormat(source));
                    } else {
                        tfPrintfFormat.setText("");
                        if (JSynoptic.gui != null) {
                            JSynoptic.gui.setStatus(resources.getString("NoDataSourceFormat"));
                        } else {
                            System.err.println(resources.getString("NoDataSourceFormat"));
                        }
                    }
                    tfPrintfFormat.setEditable(false);
                } else if (cbxformat.getSelectedIndex() == TextShape.FORMAT_PRINTF) {
                    tfPrintfFormat.setEditable(true);
                }
                CardLayout cl = (CardLayout) (cards.getLayout());
                if (cbxformat.getSelectedIndex() == TextShape.FORMAT_MAPPER) {
                    cl.show(cards, "mapper");
                } else if ((cbxformat.getSelectedIndex() == TextShape.FORMAT_DATE)
                        || (cbxformat.getSelectedIndex() == TextShape.FORMAT_TIME)
                        || (cbxformat.getSelectedIndex() == TextShape.FORMAT_DATE_TIME)) {
                    cl.show(cards, "noAttributes");
                } else if ((cbxformat.getSelectedIndex() == TextShape.FORMAT_USE_DATA_SOURCE)
                        || (cbxformat.getSelectedIndex() == TextShape.FORMAT_PRINTF)
                        || (cbxformat.getSelectedIndex() == TextShape.FORMAT_DATE_TIME)) {
                    cl.show(cards, "printfFormat");
                } else {
                    cl.show(cards, "jsynopticFormat");
                }
            }
        });
        dstree.getSourceTree().addTreeSelectionListener(new TreeSelectionListener() {
            public void valueChanged(TreeSelectionEvent e) {
View Full Code Here

Examples of java.awt.CardLayout

        bcelldelete = resources.getButton("deleteCellButton", null);
        cbx = new JComboBox();
        cbx.setEditable(false);
        cbx.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                CardLayout cl = (CardLayout) (cards.getLayout());
                int index = cbx.getSelectedIndex();
                if (index >= 0) {
                    TextPropertiesPanel tpp = (TextPropertiesPanel) TextArrayPropertiesPanel.this.textPanels.get(index);
                    tpp.updateSourceTree();
                    cl.show(cards, Integer.toString(index));
                }
            }
        });
        bcelldelete.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                int index = cbx.getSelectedIndex();
                textPanels.remove(index);
                updateCells();
                // Disable delete button in case there is only one cell.
                bcelldelete.setEnabled(textPanels.size() > 1);
                if (index > (textPanels.size() - 1)) {
                    index = textPanels.size() - 1;
                }
                TextPropertiesPanel tpp = (TextPropertiesPanel) TextArrayPropertiesPanel.this.textPanels.get(index);
                tpp.updateSourceTree();
                ((CardLayout) (cards.getLayout())).show(cards, Integer.toString(index));
            }
        });
        bcelladd.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                JPropertiesPanel textPanel = createTextPropertiesPanel(false,Builtin.resources.getString("TextArray") );
                // New cell has same properties as the last cell created
                JPropertiesPanel textPanelModel = (JPropertiesPanel) textPanels.get(textPanels.size() - 1);
                String[] props = textPanelModel.getPropertyNames();
                if (props != null) {
                    for (int j = 0; j < props.length; j++) {
                        String pname = props[j];
                        textPanel.setPropertyValue(pname, textPanelModel.getPropertyValue(pname));
                    }
                }
                // fin test
                // Set new panel owner
                textPanel.setOwner(TextArrayPropertiesPanel.this.getOwner());
                // Add to the list of text cells panels
                textPanels.add(textPanel);
                // Disable delete button in case there is only one cell.
                bcelldelete.setEnabled(textPanels.size() > 1);
                updateCells();
                int index = textPanels.size() - 1;
                cbx.setSelectedIndex(index);
                TextPropertiesPanel tpp = (TextPropertiesPanel) TextArrayPropertiesPanel.this.textPanels.get(index);
                tpp.updateSourceTree();
                ((CardLayout) (cards.getLayout())).show(cards, Integer.toString(index));
                enableFontChoosers(!cbSameFont.isSelected());
            }
        });
        cards = new JPanel();
        cards.setLayout(new CardLayout());
        cbSameFont = new ActionCheckBox(resources.getString("UseAUniqueFontForTheWholeArray"), true) {
            public void actionPerformed(ActionEvent e) {
                if (cbSameFont.isSelected()) {
                    JPropertiesPanel jp = (JPropertiesPanel) TextArrayPropertiesPanel.this.textPanels.get(cbx
                            .getSelectedIndex());
View Full Code Here

Examples of java.awt.CardLayout

   * @param e
   */
  public static void showQuickErrorDialog(JFrame parent, String title, Exception e) {
    // create and configure a text area - fill it with exception text.
    final JPanel pan = new JPanel(), details = new JPanel();
    final CardLayout crd = new CardLayout();
    pan.setLayout(crd);
    final JTextArea textArea = new JTextArea();
    textArea.setFont(new Font("Sans-Serif", Font.PLAIN, 10));
    textArea.setEditable(false);
    StringWriter writer = new StringWriter();
    e.printStackTrace(new PrintWriter(writer));
    textArea.setText(writer.toString());
    JLabel lab = new JLabel(e.getMessage());
    JButton flip = new JButton(Globals.lang("Details"));

    FormLayout layout = new FormLayout("left:pref", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.append(lab);
    builder.nextLine();
    builder.append(Box.createVerticalGlue());
    builder.nextLine();
    builder.append(flip);
    final JPanel simple = builder.getPanel();

    // stuff it in a scrollpane with a controlled size.
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setPreferredSize(new Dimension(350, 150));
    details.setLayout(new BorderLayout());
    details.add(scrollPane, BorderLayout.CENTER);

    flip.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent event) {
        crd.show(pan, "details");
      }
    });
    pan.add(simple, "simple");
    pan.add(details, "details");
    // pass the scrollpane to the joptionpane.
View Full Code Here

Examples of java.awt.CardLayout

        Box buttonBox = new Box(BoxLayout.X_AXIS);

        cardPanel = new JPanel();
        cardPanel.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));      

        cardLayout = new CardLayout();
        cardPanel.setLayout(cardLayout);
       
        backButton = new JButton();
        nextButton = new JButton();
        cancelButton = new JButton();
View Full Code Here

Examples of java.awt.CardLayout

    scroller = new JScrollPane(textPane) ; //, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS) ;
    scroller.setPreferredSize( about.getSize());

    // overlapped animated/scrollable area
    infoPanel = new JPanel() ;
    cards = new CardLayout() ;
    infoPanel.setLayout( cards);

    infoPanel.add(about, "ani") ;
    infoPanel.add(scroller, "inf") ;
View Full Code Here

Examples of java.awt.CardLayout

    public WizardImpl(UIFacade uiFacade, String title) {
        // super(frame, title, true);
        myUIFacade = uiFacade;
        myTitle = title;
        myCardLayout = new CardLayout();
        myPagesContainer = new JPanel(myCardLayout);
        myNextAction = new NextAction();
        myBackAction = new BackAction();
    }
View Full Code Here

Examples of java.awt.CardLayout

            constraints.gridy = 0;
            panelDouble.add(fieldDouble, constraints);
        }
        {
            panelDate = builder.createStandaloneOptionPanel(myDate);
            cardLayoutDefaultValue = new CardLayout();
            panelDefaultValue = new JPanel(cardLayoutDefaultValue);
            panelDefaultValue.add(cardText, panelText);
            panelDefaultValue.add(cardBoolean, panelBoolean);
            panelDefaultValue.add(cardInteger, panelInteger);
            panelDefaultValue.add(cardDouble, panelDouble);
View Full Code Here

Examples of java.awt.CardLayout

            panelDouble = new JPanel(new BorderLayout());
            panelDouble.add(fieldDouble, BorderLayout.NORTH);
        }
        {
            panelDate = builder.createStandaloneOptionPanel(myDate);
            cardLayoutDefaultValue = new CardLayout();
            panelDefaultValue = new JPanel(cardLayoutDefaultValue);
            panelDefaultValue.add(cardText, panelText);
            panelDefaultValue.add(cardBoolean, panelBoolean);
            panelDefaultValue.add(cardInteger, panelInteger);
            panelDefaultValue.add(cardDouble, panelDouble);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.