Package java.awt

Examples of java.awt.CardLayout


           
            ButtonGroup bg = new ButtonGroup();
            bg.add(rbStatic);
            bg.add(rbDynamic);
           
            final JPanel cardPane = new JPanel(new CardLayout());
           
            Box vbox = Box.createVerticalBox();
           
            box = Box.createHorizontalBox();
            box.add(new JLabel(" "));
View Full Code Here


    public StackPanel(PageListModel model){
        this.model =  model;
      
   
        // content
        content = new JPanel(new CardLayout());

        // tabs
        tabsPanel = new GridBagPanel();
        tabs = new ArrayList();
View Full Code Here

            selectedPage.setBorder(pm.getPageTitle());
        }
      

        // Update content
        CardLayout cl = (CardLayout) (content.getLayout());
       
        if (pm != null){
            cl.show(content, pm.getPageTitle());
        } else {
            cl.show(content, "emptyPanel");
        }

        // Update tags status
        for(int i=0;i<tabs.size();i++){
            ((JButton)tabs.get(i)).setBackground(null);
View Full Code Here

        content.add(inner, BorderLayout.CENTER);

        // template card panel
        templatesPanels = new JPanel();
        templatesPanels.setLayout(new CardLayout());

        inner.add(templatesPanels, BorderLayout.CENTER);
       
      
        tlist = new JList(new TemplateListModel());
View Full Code Here

   
   
    private void displayTemplate(Template t) {
        if (t != null){
            CardLayout cl = (CardLayout) (templatesPanels.getLayout());

            if ( t.getOptionPanelForTemplate() != null ){
                cl.show(templatesPanels, t.getName());
            } else {
                cl.show(templatesPanels,"emptyPanel");
            }

            headerPanel.setTitle(t.getName());
            headerPanel.displayInfo(t.getTemplateInformation());
        }
View Full Code Here

      CyclicNumberAxis cna = null;
      if (plot.getDomainAxis() instanceof CyclicNumberAxis) cna = (CyclicNumberAxis)plot.getDomainAxis();
     
      panel.add(cbcyclex = new ActionCheckBox(resources.getString("CyclicAxis"), cna!=null) {
        public void actionPerformed(ActionEvent e) {
          CardLayout cl = (CardLayout)(xcards.getLayout());
          if (isSelected()) cl.show(xcards, "cyclic");
          else cl.show(xcards, "normal");
        }
      });
      panel.add(cbinvertx = new ActionCheckBox(resources.getString("Inverted"), plot.getDomainAxis().isInverted()) {
        public void actionPerformed(ActionEvent e) {
        }
      });
      section.add(panel);
     
      xcards = new JPanel();
      xcards.setLayout(new CardLayout());
     
      Box hbox = Box.createHorizontalBox();
      hbox.add(new JLabel(resources.getString("Period")));
      hbox.add(nfperiodx = new NumberField(cna==null ? 0 : cna.getPeriod()));
      hbox.add(Box.createHorizontalGlue());
      hbox.add(new JLabel(resources.getString("Offset")));
      hbox.add(nfoffsetx = new NumberField(cna==null ? 0 : cna.getOffset()));
      xcards.add(hbox,"cyclic");
     
      panel = new JPanel();
      panel.setLayout(new FlowLayout(FlowLayout.LEFT));
      double autorange = plot.getDomainAxis().getFixedAutoRange();
      panel.add(cbfixedautox = new ActionCheckBox(resources.getString("FixedRange"),autorange!=0) {
        public void actionPerformed(ActionEvent e) {
          nffixedautox.setEnabled(isSelected() && isEnabled());
        }
      });
      panel.add(nffixedautox = new NumberField(autorange,10));
      xcards.add(panel,"normal");

      section.add(xcards);
     
      panel = new JPanel();
      panel.setLayout(new FlowLayout(FlowLayout.LEFT));
      panel.add(cbautox = new ActionCheckBox(resources.getString("Auto-update"), plot.getDomainAxis().isAutoRange()) {
        public void actionPerformed(ActionEvent e) {
          cbfixedautox.setEnabled(isSelected());
          cbfixedautox.apply();
          lpxmin.setEnabled(!isSelected());
          lpxmax.setEnabled(!isSelected());
          tfpxmin.setEnabled(!isSelected());
          tfpxmax.setEnabled(!isSelected());
        }
      });
      panel.add(lpxmin = new JLabel(resources.getString("minLabel")));
      panel.add(tfpxmin = new NumberField(10));
      tfpxmin.setValue(plot.getDomainAxis().getLowerBound());
      panel.add(lpxmax = new JLabel(resources.getString("maxLabel")));
      panel.add(tfpxmax = new NumberField(10));
      tfpxmax.setValue(plot.getDomainAxis().getUpperBound());
      cbautox.apply();
      section.add(panel);
     
      content.add(section);

     
      // Now handle Y axis
      section = new Box(BoxLayout.Y_AXIS);
      section.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),resources.getString("YAxis")));

      panel = new JPanel();
      panel.setLayout(new FlowLayout(FlowLayout.LEFT));
     
      cna = null;
      if (plot.getRangeAxis() instanceof CyclicNumberAxis) cna = (CyclicNumberAxis)plot.getRangeAxis();
     
      panel.add(cbcycley = new ActionCheckBox(resources.getString("CyclicAxis"), cna!=null) {
        public void actionPerformed(ActionEvent e) {
          CardLayout cl = (CardLayout)(ycards.getLayout());
          if (isSelected()) cl.show(ycards, "cyclic");
          else cl.show(ycards, "normal");
        }
      });
      panel.add(cbinverty = new ActionCheckBox(resources.getString("Inverted"), plot.getRangeAxis().isInverted()) {
        public void actionPerformed(ActionEvent e) {
        }
      });
      section.add(panel);
     
      ycards = new JPanel();
      ycards.setLayout(new CardLayout());
     
      hbox = Box.createHorizontalBox();
      hbox.add(new JLabel(resources.getString("Period")));
      hbox.add(nfperiody = new NumberField(cna==null ? 0 : cna.getPeriod()));
      hbox.add(Box.createHorizontalGlue());
View Full Code Here

           
            ButtonGroup bg = new ButtonGroup();
            bg.add(rbStatic);
            bg.add(rbDynamic);
           
            final JPanel cardPane = new JPanel(new CardLayout());
           
            box = Box.createHorizontalBox();
            box.add(bufferLabel = new JLabel(resources.getString("staticBufferLabel")));
            box.add(Box.createHorizontalGlue());
            box.add(nfSize = new NumberField(100,5));
View Full Code Here

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

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

       
        // 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

        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

TOP

Related Classes of java.awt.CardLayout

Copyright © 2018 www.massapicom. 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.