Package javax.swing

Examples of javax.swing.JPanel


 
  private void addButtons() {
    JButton okBut = new JButton("OK");
    JButton cancelBut = new JButton("Cancel");
   
    JPanel butHolder = new JPanel();
    butHolder.setLayout(new GridLayout(1, 2));
    butHolder.add(okBut); butHolder.add(cancelBut);
    add(butHolder, BorderLayout.SOUTH);
   
    okBut.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {       
        if (m_modifyListener != null) {
View Full Code Here


        public void stateChanged(ChangeEvent e) {
          updateInfoForSliderValue((double)m_thresholdSlider.getValue() / 100.0);
        }
      });
     
      JPanel plotHolder = new JPanel();
      plotHolder.setLayout(new GridLayout(1,2));     
      plotHolder.add(m_performancePanel);
      plotHolder.add(m_costBenefitPanel);
      add(plotHolder, BorderLayout.CENTER);
     
      JPanel lowerPanel = new JPanel();
      lowerPanel.setLayout(new BorderLayout());
     
      ButtonGroup bGroup = new ButtonGroup();
      bGroup.add(m_percPop);
      bGroup.add(m_percOfTarget);
      bGroup.add(m_threshold);
     
      ButtonGroup bGroup2 = new ButtonGroup();
      bGroup2.add(m_costR);
      bGroup2.add(m_benefitR);
      ActionListener rl = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          if (m_costR.isSelected()) {
            m_costBenefitL.setText("Cost: ");
          } else {
            m_costBenefitL.setText("Benefit: ");
          }

          double gain = Double.parseDouble(m_gainV.getText());
          gain = -gain;
          m_gainV.setText(Utils.doubleToString(gain, 2));
        }
      };
      m_costR.addActionListener(rl);
      m_benefitR.addActionListener(rl);
      m_costR.setSelected(true);
     
      m_percPop.setSelected(true);
      JPanel threshPanel = new JPanel();
      threshPanel.setLayout(new BorderLayout());
      JPanel radioHolder = new JPanel();
      radioHolder.setLayout(new FlowLayout());
      radioHolder.add(m_percPop);
      radioHolder.add(m_percOfTarget);
      radioHolder.add(m_threshold);
      threshPanel.add(radioHolder, BorderLayout.NORTH);
      threshPanel.add(m_thresholdSlider, BorderLayout.SOUTH);
     
      JPanel threshInfoPanel = new JPanel();
      threshInfoPanel.setLayout(new GridLayout(3,2));
      threshInfoPanel.add(new JLabel("% of Population: ", SwingConstants.RIGHT));
      threshInfoPanel.add(m_percPopLab);
      threshInfoPanel.add(new JLabel("% of Target: ", SwingConstants.RIGHT));
      threshInfoPanel.add(m_percOfTargetLab);
      threshInfoPanel.add(new JLabel("Score Threshold: ", SwingConstants.RIGHT));
      threshInfoPanel.add(m_thresholdLab);
     
      JPanel threshHolder = new JPanel();
      threshHolder.setBorder(BorderFactory.createTitledBorder("Threshold"));
      threshHolder.setLayout(new BorderLayout());
      threshHolder.add(threshPanel, BorderLayout.CENTER);
      threshHolder.add(threshInfoPanel, BorderLayout.EAST);
     
      lowerPanel.add(threshHolder, BorderLayout.NORTH);
     
      // holder for the two matrixes
      JPanel matrixHolder = new JPanel();
      matrixHolder.setLayout(new GridLayout(1,2));
     
      // confusion matrix
      JPanel confusionPanel = new JPanel();
      confusionPanel.setLayout(new GridLayout(3,3));
      confusionPanel.add(m_conf_predictedA);
      confusionPanel.add(m_conf_predictedB);
      confusionPanel.add(new JLabel()); // dummy
      confusionPanel.add(m_conf_aa);
      confusionPanel.add(m_conf_ab);
      confusionPanel.add(m_conf_actualA);
      confusionPanel.add(m_conf_ba);
      confusionPanel.add(m_conf_bb);
      confusionPanel.add(m_conf_actualB);
      JPanel tempHolderCA = new JPanel();
      tempHolderCA.setLayout(new BorderLayout());
      tempHolderCA.setBorder(BorderFactory.createTitledBorder("Confusion Matrix"));
      tempHolderCA.add(confusionPanel, BorderLayout.CENTER);
     
      JPanel accHolder = new JPanel();
      accHolder.setLayout(new FlowLayout(FlowLayout.LEFT));
      accHolder.add(new JLabel("Classification Accuracy: "));
      accHolder.add(m_classificationAccV);
      tempHolderCA.add(accHolder, BorderLayout.SOUTH);
     
      matrixHolder.add(tempHolderCA);
     
      // cost matrix
      JPanel costPanel = new JPanel();
      costPanel.setBorder(BorderFactory.createTitledBorder("Cost Matrix"));
      costPanel.setLayout(new BorderLayout());
     
      JPanel cmHolder = new JPanel();
      cmHolder.setLayout(new GridLayout(3, 3));
      cmHolder.add(m_cost_predictedA);     
      cmHolder.add(m_cost_predictedB);
      cmHolder.add(new JLabel()); // dummy
      cmHolder.add(m_cost_aa);
      cmHolder.add(m_cost_ab);
      cmHolder.add(m_cost_actualA);
      cmHolder.add(m_cost_ba);
      cmHolder.add(m_cost_bb);
      cmHolder.add(m_cost_actualB);
      costPanel.add(cmHolder, BorderLayout.CENTER);
     
      FocusListener fl = new FocusListener() {
        public void focusGained(FocusEvent e) {
         
        }
       
        public void focusLost(FocusEvent e) {
          if (constructCostBenefitData()) {
            try {
              m_costBenefitPanel.setMasterPlot(m_costBenefit);
              m_costBenefitPanel.validate(); m_costBenefitPanel.repaint();
            } catch (Exception ex) {
              ex.printStackTrace();
            }
            updateCostBenefit();
          }
        }
      };
     
      ActionListener al = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          if (constructCostBenefitData()) {
            try {
              m_costBenefitPanel.setMasterPlot(m_costBenefit);
              m_costBenefitPanel.validate(); m_costBenefitPanel.repaint();
            } catch (Exception ex) {
              ex.printStackTrace();
            }
            updateCostBenefit();
          }
        }
      };
           
      m_cost_aa.addFocusListener(fl);
      m_cost_aa.addActionListener(al);
      m_cost_ab.addFocusListener(fl);
      m_cost_ab.addActionListener(al);
      m_cost_ba.addFocusListener(fl);
      m_cost_ba.addActionListener(al);
      m_cost_bb.addFocusListener(fl);
      m_cost_bb.addActionListener(al);
     
      m_totalPopField.addFocusListener(fl);
      m_totalPopField.addActionListener(al);
     
      JPanel cbHolder = new JPanel();
      cbHolder.setLayout(new BorderLayout());
      JPanel tempP = new JPanel();
      tempP.setLayout(new GridLayout(3, 2));
      tempP.add(m_costBenefitL);
      tempP.add(m_costBenefitV);
      tempP.add(new JLabel("Random: ", SwingConstants.RIGHT));
      tempP.add(m_randomV);
      tempP.add(new JLabel("Gain: ", SwingConstants.RIGHT));
      tempP.add(m_gainV);
      cbHolder.add(tempP, BorderLayout.NORTH);
      JPanel butHolder = new JPanel();
      butHolder.setLayout(new GridLayout(2, 1));
      butHolder.add(m_maximizeCB);
      butHolder.add(m_minimizeCB);
      m_maximizeCB.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          findMaxMinCB(true);
        }
      });
     
      m_minimizeCB.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          findMaxMinCB(false);
        }
      });
     
      cbHolder.add(butHolder, BorderLayout.SOUTH);
      costPanel.add(cbHolder, BorderLayout.EAST);
     
      JPanel popCBR = new JPanel();
      popCBR.setLayout(new GridLayout(1, 2));
      JPanel popHolder = new JPanel();
      popHolder.setLayout(new FlowLayout(FlowLayout.LEFT));
      popHolder.add(new JLabel("Total Population: "));
      popHolder.add(m_totalPopField);
     
      JPanel radioHolder2 = new JPanel();
      radioHolder2.setLayout(new FlowLayout(FlowLayout.RIGHT));
      radioHolder2.add(m_costR);
      radioHolder2.add(m_benefitR);
      popCBR.add(popHolder);
      popCBR.add(radioHolder2);
     
      costPanel.add(popCBR, BorderLayout.SOUTH);
     
View Full Code Here

  /**
   * Create the GUI
   */
  private void initGui() {
    UiUtilities.registerForClosing(this);
    JPanel panel = (JPanel) getContentPane();
    panel.setBorder(Borders.DLU4_BORDER);
    panel.setLayout(new FormLayout("fill:default:grow, default", "fill:default:grow, 3dlu, default"));

    CellConstraints cc = new CellConstraints();

    final JEditorPane infoPanel = new JEditorPane();

    infoPanel.setEditorKit(new ExtendedHTMLEditorKit());

    ExtendedHTMLDocument doc = (ExtendedHTMLDocument) infoPanel.getDocument();

    infoPanel.setEditable(false);
    infoPanel.setText(generateHtml(doc));

    infoPanel.addHyperlinkListener(new HyperlinkListener() {
      public void hyperlinkUpdate(HyperlinkEvent evt) {
        if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
          URL url = evt.getURL();
          if (url != null) {
              Launch.openURL(url.toString());
          }
        }
      }
    });

    final JScrollPane scrollPane = new JScrollPane(infoPanel);
    panel.add(scrollPane, cc.xyw(1,1,2));

    JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK));

    ok.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        setVisible(false);
      }
    });

    SwingUtilities.invokeLater(new Runnable(){
      public void run() {
        infoPanel.scrollRectToVisible(new Rectangle(0,0));
      }
    });

    panel.add(ok, cc.xy(2,3));

    setSize(500, 350);
  }
View Full Code Here

  /**
   * Create the GUI
   */
  private void createDialog() {
    UiUtilities.registerForClosing(this);
    JPanel panel = (JPanel) getContentPane();

    panel.setLayout(new FormLayout("default, 3dlu, fill:default:grow",
        "default, 3dlu, default, 3dlu:grow, default, 3dlu"));

    CellConstraints cc = new CellConstraints();

    panel.setBorder(Borders.DLU4_BORDER);

    panel.add(new JLabel(mLocalizer.msg("time", "Time zone correction")), cc.xy(1, 1));

    mCorrectionCB = new JComboBox(new String[] { "-1:00", "-0:45", "-0:30", "-0:15", "0:00", "+0:15", "+0:30", "+0:45", "+1:00" });
    mCorrectionCB.setSelectedIndex(mChannel[0].getTimeZoneCorrectionMinutes() / 15 + 4);

    panel.add(mCorrectionCB, cc.xy(3, 1));

    JTextArea txt = UiUtilities.createHelpTextArea(mLocalizer.msg("DLSTNote", ""));
    // Hack because of growing JTextArea in FormLayout
    txt.setMinimumSize(new Dimension(200, 20));
    panel.add(txt, cc.xyw(1, 3, 3));

    ButtonBarBuilder2 builder = new ButtonBarBuilder2();
   
    JButton defaultButton = new JButton(Localizer.getLocalization(Localizer.I18N_DEFAULT));
   
    defaultButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        resetToDefaults();
      }

    });
   
    builder.addButton(defaultButton);
    builder.addRelatedGap();
    builder.addGlue();

    mOKBt = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
    mOKBt.addActionListener(this);
    getRootPane().setDefaultButton(mOKBt);
   
    mCloseBt = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL));
    mCloseBt.addActionListener(this);

    builder.addButton(new JButton[] { mOKBt, mCloseBt });

    panel.add(builder.getPanel(), cc.xyw(1, 5, 3));

    pack();

    if (getWidth() < 400) {
      setSize(400, getHeight());
View Full Code Here

    // create content
    jcontentPane = (JPanel) getContentPane();
    jcontentPane.setLayout(new BorderLayout());

    JPanel skinPanel = new JPanel();
    skinPanel.setLayout(new BorderLayout());

    JPanel centerPanel = new JPanel(new BorderLayout());
    centerPanel.setOpaque(false);
    centerPanel.setBorder(BorderFactory.createEmptyBorder());

    mFilterPanel = new FilterPanel();
    mFilterPanel.setVisible(false);

    mTimeChooserPanel = new TimeChooserPanel(this);

    centerPanel.add(mFilterPanel, BorderLayout.NORTH);

    Channel[] channelArr = ChannelList.getSubscribedChannels();
    int startOfDay = Settings.propProgramTableStartOfDay.getInt();
    int endOfDay = Settings.propProgramTableEndOfDay.getInt();
    mProgramTableModel = new DefaultProgramTableModel(channelArr, startOfDay,
        endOfDay);
    mProgramTableScrollPane = new ProgramTableScrollPane(mProgramTableModel);
    centerPanel.add(mProgramTableScrollPane);

    createDateSelector();

    skinPanel.add(centerPanel, BorderLayout.CENTER);
View Full Code Here

        }
    }

    @Override
    protected JComponent doBindControl() {
        JPanel panel = new JPanel();

        panel.add(createLabelFor("day", dayCombo));
        panel.add(dayCombo);
        panel.add(createLabelFor("slot", slotCombo));
        panel.add(slotCombo);
        panel.add(dateLabel);
        return panel;
    }
View Full Code Here

    protected JComponent createControl() {
        @SuppressWarnings("unchecked")
        PoolDescriptor<T> tableDescriptor = (PoolDescriptor<T>) getDescriptor();
        settings = tableDescriptor.getSettings();

        JPanel panel = new JPanel(new BorderLayout());
        mdForm = createForm(tableDescriptor.getDao(), Helper.convert(String.class,
                tableDescriptor.getObjectDescriptor().getUiProperties(UiShow.OVERVIEW)));

        panel.add(mdForm.getControl(), BorderLayout.CENTER);
        return panel;
    }
View Full Code Here

                appendLiteral(" - ").
                appendDayOfMonth(2).
                appendLiteral(". ").
                appendMonthOfYearText().toFormatter();

        columnHeader = new JPanel() {

            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);

                Shape oldClip = g.getClip();
                DateTime tempDateTime = settings.getStartDate();
                for (int x = 0; x < visibleDays; x++) {
                    g.setClip(new Rectangle2D.Double(x * dayWidth, 0,
                            dayWidth, columnHeaderHeight));
                    g.drawString(fmt.print(tempDateTime),
                            xTextOffset + x * dayWidth, yHeaderTextOffset);
                    tempDateTime = tempDateTime.plusDays(1);
                }
                g.setClip(oldClip);
            }
        };

        rowHeader = new JPanel() {

            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                for (int y = 0; y < getHoursPerDay(); y++) {
                    g.drawString(String.format("%1$02d", y + getHourOffset()) + ":00",
                            xTextOffset, yHeaderTextOffset + y * hourWidth);
                }
            }
        };

        scroll = new JScrollPane();
        scroll.setRowHeaderView(rowHeader);

//        scroll.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, new JLabel() {
//
//            @Override
//            public String getText() {
//                return "no:" + getCurrentIntervals().size();
//            }
//        });

        scroll.setColumnHeaderView(columnHeader);

        JPanel timeNorthPanel = new JPanel();
        calendarDateField = CalendarFactory.createDateField();
        calendarDateField.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                // get the date only - not the time
                DateTime val = new DateTime(((Date) calendarDateField.getValue()).getTime());
                DateTime start = settings.getStartDate();
                setStartDate(start.withYear(val.getYear()).
                        withMonthOfYear(val.getMonthOfYear()).withDayOfMonth(val.getDayOfMonth()));
            }
        });
        timeNorthPanel.add(calendarDateField);
        timeNorthPanel.add(prevDaysButton = new SmallButton("<"));
        timeNorthPanel.add(nextDaysButton = new SmallButton(">"));
        prevDaysButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                setStartDate(settings.getStartDate().minusDays(settings.getNumberOfDays()));
            }
        });
        nextDaysButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                setStartDate(settings.getStartDate().plusDays(settings.getNumberOfDays()));
            }
        });

        scroll.setViewportView(timetableGrid);

        JPanel southPanel = new JPanel(new GridLayout(1, 0));
        eventJList.setVisibleRowCount(3);
        taskJList.setVisibleRowCount(3);
        southPanel.add(new JScrollPane(eventJList));
        southPanel.add(new JScrollPane(taskJList));

        listener = new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
View Full Code Here

    @Override
    protected JComponent createFormControl() {       
        Assert.notNull(dao);
        addTabs();

        JPanel mainPanel = new JPanel(new BorderLayout());
        if (allTabs.isEmpty()) {
            mainPanel.add(getFormBuilder().getForm(), BorderLayout.CENTER);
        } else {
            pane = new ExtTabbedPane();
            pane.addTab(new Tab("Properties", getFormBuilder().getForm()));
            for (Entry<String, TableFormBuilder> entry : allTabs.entrySet()) {
                pane.addTab(new Tab(entry.getKey(), entry.getValue().getForm()));
            }

            mainPanel.add(pane.getControl(), BorderLayout.CENTER);
        }
        mainPanel.add(createButtonBar(), BorderLayout.SOUTH);
        updateControlsForState();

        return mainPanel;
    }
View Full Code Here

        /**
         * Construct the main dialog pane.
         * @return Constructed component
         */
        protected JComponent createDialogContentPane() {
            JPanel dialogPanel = new JPanel(new BorderLayout());           

            // If a text file resource has been specified, then construct the
            // scroller to show it.
            if( aboutTextPath != null ) {
                // Add in the application descriptor data, if available
                dialogPanel.add(createApplicationDescriptorComponent(), BorderLayout.NORTH);
                try {
                    scroller = new HtmlScroller(false, 2000, 15, 10);
                    String text = FileCopyUtils.copyToString(new BufferedReader(new InputStreamReader(aboutTextPath
                            .getInputStream())));
                    scroller.setHtml(text);
                } catch( IOException e ) {
                    final IllegalStateException exp = new IllegalStateException("About text not accessible: "
                            + e.getMessage());
                    exp.setStackTrace(e.getStackTrace());
                    throw exp;
                }
                dialogPanel.add(scroller, BorderLayout.CENTER);
                dialogPanel.setPreferredSize(new Dimension(scroller.getPreferredSize().width, 300));
            } else {
                /** CHANGED **/
                dialogPanel.add(createApplicationDescriptorComponent(), BorderLayout.CENTER);
                // Set the preferred size
                dialogPanel.setPreferredSize(new Dimension( 300, 200));
            }
            dialogPanel.add(new JSeparator(), BorderLayout.SOUTH);
            return dialogPanel;
        }
View Full Code Here

TOP

Related Classes of javax.swing.JPanel

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.