Search in sources :

Example 1 with CgSpinner

use of course_generator.utils.CgSpinner in project Course_Generator by patrovite.

the class FrmConfigMrb method initComponents.

private void initComponents() {
    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setAlwaysOnTop(true);
    setResizable(false);
    setType(java.awt.Window.Type.UTILITY);
    addComponentListener(new java.awt.event.ComponentAdapter() {

        public void componentShown(java.awt.event.ComponentEvent evt) {
            repaint();
        }
    });
    // -- Layout
    // ------------------------------------------------------------
    Container paneGlobal = getContentPane();
    paneGlobal.setLayout(new GridBagLayout());
    // -- Tabbed panel
    // ------------------------------------------------------
    TabbedPaneConfig = new javax.swing.JTabbedPane();
    Utils.addComponent(paneGlobal, TabbedPaneConfig, 0, 0, 1, 1, 1, 1, 10, 10, 0, 10, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // == TAB : panel general config
    panelGeneral = new JPanel();
    panelGeneral.setLayout(new GridBagLayout());
    TabbedPaneConfig.add(panelGeneral, bundle.getString("FrmConfigMrb.panelGeneral.tabTitle"));
    // -- Content of the panel
    // lbNbCharPerLine = new JLabel(bundle.getString("FrmConfigMrb.lbNbCharPerLine.text"));
    // Utils.addComponent(panelGeneral, lbNbCharPerLine,
    // 0, 0,
    // 1, 1,
    // 0, 0,
    // 10, 10, 0, 0, GridBagConstraints.WEST,
    // GridBagConstraints.BOTH);
    // 
    // spinCharPerLine = new CgSpinner(25,1,100,1);
    // Utils.addComponent(panelGeneral, spinCharPerLine,
    // 1, 0,
    // 1, 1,
    // 1, 0,
    // 10, 10, 0, 10,
    // GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // --
    lbCurveFilter = new JLabel(bundle.getString("FrmConfigMrb.lbCurveFilter.text"));
    Utils.addComponent(panelGeneral, lbCurveFilter, 0, 0, 1, 1, 0, 0, 5, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    spinCurveFilter = new CgSpinner(1, 1, 10, 1);
    Utils.addComponent(panelGeneral, spinCurveFilter, 1, 0, 1, 1, 1, 0, 5, 10, 0, 10, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // --
    lbTopSize = new JLabel(bundle.getString("FrmConfigMrb.lbTopSize.text"));
    Utils.addComponent(panelGeneral, lbTopSize, 0, 1, 1, 1, 0, 0, 5, 10, 10, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    spinTopSize = new CgSpinner(100, 1, 1000, 1);
    Utils.addComponent(panelGeneral, spinTopSize, 1, 1, 1, 1, 1, 0, 5, 10, 10, 10, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // -- Empty line for resize purpose (not the best solution but it's simple ;) )
    lbEmpty = new JLabel();
    Utils.addComponent(panelGeneral, lbEmpty, 0, 2, 1, 1, 0, 1, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // == TAB :  panel simple graph config
    panelSimple = new JPanel();
    panelSimple.setLayout(new GridBagLayout());
    TabbedPaneConfig.add(panelSimple, bundle.getString("FrmConfigMrb.panelSimple.tabTitle"));
    // -- Content of the panel
    lbSimpleFillColor = new JLabel(" " + bundle.getString("FrmConfigMrb.lbSimpleFillColor.text") + " ");
    Utils.addComponent(panelSimple, lbSimpleFillColor, 0, 0, 1, 1, 1, 0, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    lbSimpleFillColorView = new JLabel("          ");
    lbSimpleFillColorView.setBorder(BorderFactory.createLineBorder(Color.black));
    lbSimpleFillColorView.setOpaque(true);
    Utils.addComponent(panelSimple, lbSimpleFillColorView, 1, 0, 1, 1, 0, 0, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    btSimpleFillColor = new JButton(bundle.getString("FrmConfigMrb.btColor.text"));
    btSimpleFillColor.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ColorSimpleFill = FrmColorChooser.showDialog("", ColorSimpleFill);
            Refresh();
        }
    });
    Utils.addComponent(panelSimple, btSimpleFillColor, 2, 0, 1, 1, 0, 0, 10, 10, 0, 10, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // --
    lbSimplePenColor = new JLabel(" " + bundle.getString("FrmConfigMrb.lbSimplePenColor.text") + " ");
    Utils.addComponent(panelSimple, lbSimplePenColor, 0, 1, 1, 1, 1, 0, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    lbSimplePenColorView = new JLabel("          ");
    lbSimplePenColorView.setBorder(BorderFactory.createLineBorder(Color.black));
    lbSimplePenColorView.setOpaque(true);
    Utils.addComponent(panelSimple, lbSimplePenColorView, 1, 1, 1, 1, 0, 0, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    btSimplePenColor = new JButton(bundle.getString("FrmConfigMrb.btColor.text"));
    btSimplePenColor.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ColorSimpleBorder = FrmColorChooser.showDialog("", ColorSimpleBorder);
            Refresh();
        }
    });
    Utils.addComponent(panelSimple, btSimplePenColor, 2, 1, 1, 1, 0, 0, 10, 10, 0, 10, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // --
    btSimpleDefaultColor = new JButton(bundle.getString("FrmConfigMrb.btDefaultColors.text"));
    btSimpleDefaultColor.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ColorSimpleFill = CgConst.CL_PROFIL_SIMPLE_FILL;
            ColorSimpleBorder = CgConst.CL_PROFIL_SIMPLE_BORDER;
            Refresh();
        }
    });
    Utils.addComponent(panelSimple, btSimpleDefaultColor, 0, 2, GridBagConstraints.REMAINDER, 1, 0, 0, 10, 10, 0, 10, GridBagConstraints.EAST, GridBagConstraints.VERTICAL);
    // -- Empty line for resize purpose (not the best solution but it's simple ;) )
    lbSimpleEmpty = new JLabel();
    Utils.addComponent(panelSimple, lbSimpleEmpty, 0, 3, 1, 1, 0, 1, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // == TAB :  panel road/track graph config
    panelRoadTrack = new JPanel();
    panelRoadTrack.setLayout(new GridBagLayout());
    TabbedPaneConfig.add(panelRoadTrack, bundle.getString("FrmConfigMrb.panelRoadTrack.tabTitle"));
    // -- Content of the panel
    lbRTTrackFillColor = new JLabel(" " + bundle.getString("FrmConfigMrb.lbRTTrackFillColor.text") + " ");
    Utils.addComponent(panelRoadTrack, lbRTTrackFillColor, 0, 0, 1, 1, 1, 0, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    lbRTTrackFillColorView = new JLabel("          ");
    lbRTTrackFillColorView.setBorder(BorderFactory.createLineBorder(Color.black));
    lbRTTrackFillColorView.setOpaque(true);
    Utils.addComponent(panelRoadTrack, lbRTTrackFillColorView, 1, 0, 1, 1, 0, 0, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    btRTTrackFillColor = new JButton(bundle.getString("FrmConfigMrb.btColor.text"));
    btRTTrackFillColor.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ColorRSPath = FrmColorChooser.showDialog("", ColorRSPath);
            Refresh();
        }
    });
    Utils.addComponent(panelRoadTrack, btRTTrackFillColor, 2, 0, 1, 1, 0, 0, 10, 10, 0, 10, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // --
    lbRTRoadFillColor = new JLabel(" " + bundle.getString("FrmConfigMrb.lbRTRoadFillColor.text") + " ");
    Utils.addComponent(panelRoadTrack, lbRTRoadFillColor, 0, 1, 1, 1, 1, 0, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    lbRTRoadFillColorView = new JLabel("          ");
    lbRTRoadFillColorView.setBorder(BorderFactory.createLineBorder(Color.black));
    lbRTRoadFillColorView.setOpaque(true);
    Utils.addComponent(panelRoadTrack, lbRTRoadFillColorView, 1, 1, 1, 1, 0, 0, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    btRTRoadFillColor = new JButton(bundle.getString("FrmConfigMrb.btColor.text"));
    btRTRoadFillColor.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ColorRSRoad = FrmColorChooser.showDialog("", ColorRSRoad);
            Refresh();
        }
    });
    Utils.addComponent(panelRoadTrack, btRTRoadFillColor, 2, 1, 1, 1, 0, 0, 10, 10, 0, 10, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // --
    lbRTPenColor = new JLabel(" " + bundle.getString("FrmConfigMrb.lbRTPenColor.text") + " ");
    Utils.addComponent(panelRoadTrack, lbRTPenColor, 0, 2, 1, 1, 1, 0, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    lbRTPenColorView = new JLabel("          ");
    lbRTPenColorView.setBorder(BorderFactory.createLineBorder(Color.black));
    lbRTPenColorView.setOpaque(true);
    Utils.addComponent(panelRoadTrack, lbRTPenColorView, 1, 2, 1, 1, 0, 0, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    btRTPenColor = new JButton(bundle.getString("FrmConfigMrb.btColor.text"));
    btRTPenColor.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ColorRSBorder = FrmColorChooser.showDialog("", ColorRSBorder);
            Refresh();
        }
    });
    Utils.addComponent(panelRoadTrack, btRTPenColor, 2, 2, 1, 1, 0, 0, 10, 10, 0, 10, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // --
    btRTDefaultColor = new JButton(bundle.getString("FrmConfigMrb.btDefaultColors.text"));
    btRTDefaultColor.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ColorRSPath = CgConst.CL_PROFIL_RS_PATH;
            ColorRSRoad = CgConst.CL_PROFIL_RS_ROAD;
            ColorRSBorder = CgConst.CL_PROFIL_RS_BORDER;
            Refresh();
        }
    });
    Utils.addComponent(panelRoadTrack, btRTDefaultColor, 0, 3, GridBagConstraints.REMAINDER, 1, 0, 0, 10, 10, 0, 10, GridBagConstraints.EAST, GridBagConstraints.VERTICAL);
    // -- Empty line for resize purpose (not the best solution but it's simple ;) )
    lbRTEmpty = new JLabel();
    Utils.addComponent(panelRoadTrack, lbRTEmpty, 0, 4, 1, 1, 0, 1, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // == TAB :  panel slope graph config
    panelSlope = new JPanel();
    panelSlope.setLayout(new GridBagLayout());
    TabbedPaneConfig.add(panelSlope, bundle.getString("FrmConfigMrb.panelSlope.tabTitle"));
    // -- Content of the panel
    lbSlopeInf5 = new JLabel(" " + bundle.getString("FrmConfigMrb.lbSlopeInf5.text") + " ");
    Utils.addComponent(panelSlope, lbSlopeInf5, 0, 0, 1, 1, 1, 0, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    lbSlopeInf5View = new JLabel("          ");
    lbSlopeInf5View.setBorder(BorderFactory.createLineBorder(Color.black));
    lbSlopeInf5View.setOpaque(true);
    Utils.addComponent(panelSlope, lbSlopeInf5View, 1, 0, 1, 1, 0, 0, 10, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    btSlopeInf5 = new JButton(bundle.getString("FrmConfigMrb.btColor.text"));
    btSlopeInf5.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ColorSlopeInf5 = FrmColorChooser.showDialog("", ColorSlopeInf5);
            Refresh();
        }
    });
    Utils.addComponent(panelSlope, btSlopeInf5, 2, 0, 1, 1, 0, 0, 10, 10, 0, 10, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // --
    lbSlopeInf10 = new JLabel(" " + bundle.getString("FrmConfigMrb.lbSlopeInf10.text") + " ");
    Utils.addComponent(panelSlope, lbSlopeInf10, 0, 1, 1, 1, 1, 0, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    lbSlopeInf10View = new JLabel("          ");
    lbSlopeInf10View.setBorder(BorderFactory.createLineBorder(Color.black));
    lbSlopeInf10View.setOpaque(true);
    Utils.addComponent(panelSlope, lbSlopeInf10View, 1, 1, 1, 1, 0, 0, 10, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    btSlopeInf10 = new JButton(bundle.getString("FrmConfigMrb.btColor.text"));
    btSlopeInf10.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ColorSlopeInf10 = FrmColorChooser.showDialog("", ColorSlopeInf10);
            Refresh();
        }
    });
    Utils.addComponent(panelSlope, btSlopeInf10, 2, 1, 1, 1, 0, 0, 10, 10, 0, 10, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // --
    lbSlopeInf15 = new JLabel(" " + bundle.getString("FrmConfigMrb.lbSlopeInf15.text") + " ");
    Utils.addComponent(panelSlope, lbSlopeInf15, 0, 2, 1, 1, 1, 0, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    lbSlopeInf15View = new JLabel("          ");
    lbSlopeInf15View.setBorder(BorderFactory.createLineBorder(Color.black));
    lbSlopeInf15View.setOpaque(true);
    Utils.addComponent(panelSlope, lbSlopeInf15View, 1, 2, 1, 1, 0, 0, 10, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    btSlopeInf15 = new JButton(bundle.getString("FrmConfigMrb.btColor.text"));
    btSlopeInf15.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ColorSlopeInf15 = FrmColorChooser.showDialog("", ColorSlopeInf15);
            Refresh();
        }
    });
    Utils.addComponent(panelSlope, btSlopeInf15, 2, 2, 1, 1, 0, 0, 10, 10, 0, 10, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // --
    lbSlopeSup15 = new JLabel(" " + bundle.getString("FrmConfigMrb.lbSlopeSup15.text") + " ");
    Utils.addComponent(panelSlope, lbSlopeSup15, 0, 3, 1, 1, 1, 0, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    lbSlopeSup15View = new JLabel("          ");
    lbSlopeSup15View.setBorder(BorderFactory.createLineBorder(Color.black));
    lbSlopeSup15View.setOpaque(true);
    Utils.addComponent(panelSlope, lbSlopeSup15View, 1, 3, 1, 1, 0, 0, 10, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    btSlopeSup15 = new JButton(bundle.getString("FrmConfigMrb.btColor.text"));
    btSlopeSup15.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ColorSlopeSup15 = FrmColorChooser.showDialog("", ColorSlopeSup15);
            Refresh();
        }
    });
    Utils.addComponent(panelSlope, btSlopeSup15, 2, 3, 1, 1, 0, 0, 10, 10, 0, 10, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // --
    lbSlopePenColor = new JLabel(" " + bundle.getString("FrmConfigMrb.lbSlopePenColor.text") + " ");
    Utils.addComponent(panelSlope, lbSlopePenColor, 0, 4, 1, 1, 1, 0, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    lbSlopePenColorView = new JLabel("          ");
    lbSlopePenColorView.setBorder(BorderFactory.createLineBorder(Color.black));
    lbSlopePenColorView.setOpaque(true);
    Utils.addComponent(panelSlope, lbSlopePenColorView, 1, 4, 1, 1, 0, 0, 10, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    btSlopePenColor = new JButton(bundle.getString("FrmConfigMrb.btColor.text"));
    btSlopePenColor.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ColorSlopeBorder = FrmColorChooser.showDialog("", ColorSlopeBorder);
            Refresh();
        }
    });
    Utils.addComponent(panelSlope, btSlopePenColor, 2, 4, 1, 1, 0, 0, 10, 10, 0, 10, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // --
    btSlopeDefaultColor = new JButton(bundle.getString("FrmConfigMrb.btDefaultColors.text"));
    btSlopeDefaultColor.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ColorSlopeInf5 = CgConst.CL_PROFIL_SLOPE_INF5;
            ColorSlopeInf10 = CgConst.CL_PROFIL_SLOPE_INF10;
            ColorSlopeInf15 = CgConst.CL_PROFIL_SLOPE_INF15;
            ColorSlopeSup15 = CgConst.CL_PROFIL_SLOPE_SUP15;
            ColorSlopeBorder = CgConst.CL_PROFIL_SLOPE_BORDER;
            Refresh();
        }
    });
    Utils.addComponent(panelSlope, btSlopeDefaultColor, 0, 5, GridBagConstraints.REMAINDER, 1, 0, 0, 10, 10, 0, 10, GridBagConstraints.EAST, GridBagConstraints.VERTICAL);
    // -- Empty line for resize purpose (not the best solution but it's simple ;) )
    lbRTEmpty = new JLabel();
    Utils.addComponent(panelSlope, lbRTEmpty, 0, 6, 1, 1, 0, 1, 10, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // == BUTTONS
    // ===========================================================
    panelButtons = new javax.swing.JPanel();
    panelButtons.setLayout(new FlowLayout());
    Utils.addComponent(paneGlobal, panelButtons, 0, 1, 1, 1, 1, 0, 0, 10, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    btCancel = new javax.swing.JButton();
    btCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/cancel.png")));
    btCancel.setText(bundle.getString("Global.btCancel.text"));
    btCancel.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            setVisible(false);
        }
    });
    btOk = new javax.swing.JButton();
    btOk.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/valid.png")));
    btOk.setText(bundle.getString("Global.btOk.text"));
    btOk.setMinimumSize(btCancel.getMinimumSize());
    btOk.setPreferredSize(btCancel.getPreferredSize());
    btOk.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            RequestToClose();
        }
    });
    // -- Add buttons
    panelButtons.add(btOk);
    panelButtons.add(btCancel);
    // --
    pack();
    setLocationRelativeTo(null);
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JButton(javax.swing.JButton) GridBagLayout(java.awt.GridBagLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) ActionEvent(java.awt.event.ActionEvent) Container(java.awt.Container) CgSpinner(course_generator.utils.CgSpinner) JTabbedPane(javax.swing.JTabbedPane) JPanel(javax.swing.JPanel)

Example 2 with CgSpinner

use of course_generator.utils.CgSpinner in project Course_Generator by patrovite.

the class FrmMiniroadbook method Create_Toolbar.

/**
 * Create the toolbar
 */
private void Create_Toolbar() {
    int btw = 38;
    int bth = 24;
    ToolBarMRB = new javax.swing.JToolBar();
    ToolBarMRB.setFloatable(false);
    ToolBarMRB.setRollover(true);
    // -- Save as image
    btSaveAsImage = new javax.swing.JButton();
    btSaveAsImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/save.png")));
    btSaveAsImage.setToolTipText(bundle.getString("FrmMiniroadbook.btSaveAsImage.toolTipText"));
    btSaveAsImage.setPreferredSize(new Dimension(btw, bth));
    btSaveAsImage.setFocusable(false);
    btSaveAsImage.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            SaveProfile();
        }
    });
    ToolBarMRB.add(btSaveAsImage);
    // -- Separator
    ToolBarMRB.add(new javax.swing.JToolBar.Separator());
    // -- Configuration
    btConfig = new javax.swing.JButton();
    btConfig.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/settings.png")));
    btConfig.setToolTipText(bundle.getString("FrmMiniroadbook.btConfig.toolTipText"));
    btConfig.setPreferredSize(new Dimension(btw, bth));
    btConfig.setFocusable(false);
    btConfig.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            FrmConfigMrb frm = new FrmConfigMrb();
            frm.showDialog(track);
            track.isModified = true;
            pnlProfil.setTrack(track);
            pnlProfil.Refresh();
        }
    });
    ToolBarMRB.add(btConfig);
    // -- Separator
    ToolBarMRB.add(new javax.swing.JToolBar.Separator());
    // -- Copy format
    btCopyFormat = new javax.swing.JButton();
    btCopyFormat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/pipette.png")));
    btCopyFormat.setToolTipText(bundle.getString("FrmMiniroadbook.btCopyFormat.toolTipText"));
    btCopyFormat.setPreferredSize(new Dimension(btw, bth));
    btCopyFormat.setFocusable(false);
    btCopyFormat.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            CopyFormat();
        }
    });
    ToolBarMRB.add(btCopyFormat);
    // -- Paste format
    btPasteFormat = new javax.swing.JButton();
    btPasteFormat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/replicate.png")));
    btPasteFormat.setToolTipText(bundle.getString("FrmMiniroadbook.btPasteFormat.toolTipText"));
    btPasteFormat.setPreferredSize(new Dimension(btw, bth));
    btPasteFormat.setFocusable(false);
    btPasteFormat.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            PasteFormat();
        }
    });
    ToolBarMRB.add(btPasteFormat);
    // -- Config format duplication
    btPasteFormatConfig = new javax.swing.JButton();
    btPasteFormatConfig.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/replicate_config.png")));
    btPasteFormatConfig.setToolTipText(bundle.getString("FrmMiniroadbook.btPasteFormatConfig.toolTipText"));
    btPasteFormatConfig.setPreferredSize(new Dimension(btw, bth));
    btPasteFormatConfig.setFocusable(false);
    btPasteFormatConfig.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            FrmConfigMrbDuplicate frm = new FrmConfigMrbDuplicate();
            ConfigDuplication = frm.showDialog(ConfigDuplication);
        }
    });
    ToolBarMRB.add(btPasteFormatConfig);
    // -- Separator
    ToolBarMRB.add(new javax.swing.JToolBar.Separator());
    // -- Label connected to the bottom of the profil
    btLabelConnectedToBottom = new javax.swing.JButton();
    btLabelConnectedToBottom.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/label_to_bottom.png")));
    btLabelConnectedToBottom.setToolTipText(bundle.getString("FrmMiniroadbook.btLabelConnectedToBottom.toolTipText"));
    btLabelConnectedToBottom.setPreferredSize(new Dimension(btw, bth));
    btLabelConnectedToBottom.setFocusable(false);
    btLabelConnectedToBottom.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            track.LabelToBottom = true;
            track.isModified = true;
            RefreshBtLabel();
            repaint();
        }
    });
    ToolBarMRB.add(btLabelConnectedToBottom);
    // -- Label connected to the top of the profil
    btLabelConnectedToProfil = new javax.swing.JButton();
    btLabelConnectedToProfil.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/label_to_profil.png")));
    btLabelConnectedToProfil.setToolTipText(bundle.getString("FrmMiniroadbook.btLabelConnectedToProfil.toolTipText"));
    btLabelConnectedToProfil.setPreferredSize(new Dimension(btw, bth));
    btLabelConnectedToProfil.setFocusable(false);
    btLabelConnectedToProfil.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            track.LabelToBottom = false;
            track.isModified = true;
            RefreshBtLabel();
            repaint();
        }
    });
    ToolBarMRB.add(btLabelConnectedToProfil);
    // -- Separator
    ToolBarMRB.add(new javax.swing.JToolBar.Separator());
    // -- Night and day highlight
    btNightAndDayHighlight = new javax.swing.JButton();
    btNightAndDayHighlight.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/night_day.png")));
    btNightAndDayHighlight.setToolTipText(bundle.getString("FrmMiniroadbook.btNightAndDayHighlight.toolTipText"));
    btNightAndDayHighlight.setPreferredSize(new Dimension(btw, bth));
    btNightAndDayHighlight.setFocusable(false);
    btNightAndDayHighlight.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            track.bShowNightDay = !track.bShowNightDay;
            btNightAndDayHighlight.setSelected(track.bShowNightDay);
            repaint();
        }
    });
    ToolBarMRB.add(btNightAndDayHighlight);
    // -- Separator
    ToolBarMRB.add(new javax.swing.JToolBar.Separator());
    // -- Label "Profil type"
    lbProfilType = new javax.swing.JLabel(" " + bundle.getString("FrmMiniroadbook.lbProfilType.Text") + " ");
    ToolBarMRB.add(lbProfilType);
    // -- "Profil type" selection
    cbProfilType = new javax.swing.JComboBox<String>();
    String[] profiltype = { bundle.getString("FrmMiniroadbook.ProfilSimple"), bundle.getString("FrmMiniroadbook.ProfilRoadTrack"), bundle.getString("FrmMiniroadbook.ProfilSlope") };
    cbProfilType.setModel(new javax.swing.DefaultComboBoxModel<String>(profiltype));
    cbProfilType.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            pnlProfil.setProfileType(cbProfilType.getSelectedIndex());
            track.isModified = true;
        }
    });
    ToolBarMRB.add(cbProfilType);
    // -- Memory 1
    btMemory1 = new javax.swing.JButton();
    btMemory1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/favoris1.png")));
    btMemory1.setPreferredSize(new Dimension(btw, bth));
    btMemory1.setFocusable(false);
    btMemory1.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            memoFormat[0] = ManageMemories(e, memoFormat[0]);
            RefreshTooltips();
        }
    });
    ToolBarMRB.add(btMemory1);
    // -- Memory 2
    btMemory2 = new javax.swing.JButton();
    btMemory2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/favoris2.png")));
    btMemory2.setPreferredSize(new Dimension(btw, bth));
    btMemory2.setFocusable(false);
    btMemory2.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            memoFormat[1] = ManageMemories(e, memoFormat[1]);
            RefreshTooltips();
        }
    });
    ToolBarMRB.add(btMemory2);
    // -- Memory 3
    btMemory3 = new javax.swing.JButton();
    btMemory3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/favoris3.png")));
    btMemory3.setPreferredSize(new Dimension(btw, bth));
    btMemory3.setFocusable(false);
    btMemory3.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            memoFormat[2] = ManageMemories(e, memoFormat[2]);
            RefreshTooltips();
        }
    });
    ToolBarMRB.add(btMemory3);
    // -- Memory 4
    btMemory4 = new javax.swing.JButton();
    btMemory4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/favoris4.png")));
    btMemory4.setPreferredSize(new Dimension(btw, bth));
    btMemory4.setFocusable(false);
    btMemory4.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            memoFormat[3] = ManageMemories(e, memoFormat[3]);
            RefreshTooltips();
        }
    });
    ToolBarMRB.add(btMemory4);
    // -- Memory 5
    btMemory5 = new javax.swing.JButton();
    btMemory5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/favoris5.png")));
    btMemory5.setPreferredSize(new Dimension(btw, bth));
    btMemory5.setFocusable(false);
    btMemory5.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            memoFormat[4] = ManageMemories(e, memoFormat[4]);
            RefreshTooltips();
        }
    });
    ToolBarMRB.add(btMemory5);
    // -- Separator
    ToolBarMRB.add(new javax.swing.JToolBar.Separator());
    // -- Width of the mini roadbook
    lbWidth = new javax.swing.JLabel(" " + bundle.getString("FrmMiniroadbook.lbWidth.Text") + " ");
    ToolBarMRB.add(lbWidth);
    spinWidth = new CgSpinner(1000, 0, 4000, 1);
    spinWidth.setToolTipText(bundle.getString("FrmMiniroadbook.spinWidth.TooltipText"));
    spinWidth.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent arg0) {
            track.MrbSizeW = spinWidth.getValueAsInt();
            pnlProfil.setWidth(track.MrbSizeW);
            jScrollPaneProfil.repaint();
            track.isModified = true;
        }
    });
    ToolBarMRB.add(spinWidth);
    // -- Height of the mini roadbook
    lbHeight = new javax.swing.JLabel(" " + bundle.getString("FrmMiniroadbook.lbHeight.Text") + " ");
    ToolBarMRB.add(lbHeight);
    spinHeight = new CgSpinner(500, 0, 2000, 1);
    spinHeight.setToolTipText(bundle.getString("FrmMiniroadbook.spinHeight.TooltipText"));
    spinHeight.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent arg0) {
            track.MrbSizeH = spinHeight.getValueAsInt();
            pnlProfil.setHeight(track.MrbSizeH);
            jScrollPaneProfil.repaint();
            track.isModified = true;
        }
    });
    ToolBarMRB.add(spinHeight);
    RefreshTooltips();
}
Also used : ChangeListener(javax.swing.event.ChangeListener) JToolBar(javax.swing.JToolBar) JButton(javax.swing.JButton) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) Dimension(java.awt.Dimension) JToolBar(javax.swing.JToolBar) CgSpinner(course_generator.utils.CgSpinner) ChangeEvent(javax.swing.event.ChangeEvent) JLabel(javax.swing.JLabel)

Example 3 with CgSpinner

use of course_generator.utils.CgSpinner in project Course_Generator by patrovite.

the class frmFillCoeff method initComponents.

private void initComponents() {
    int line = 0;
    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle(bundle.getString("frmFillCoeff.title"));
    setAlwaysOnTop(true);
    setResizable(false);
    setMinimumSize(new Dimension(300, 400));
    setType(java.awt.Window.Type.UTILITY);
    // -- Layout
    // ------------------------------------------------------------
    Container paneGlobal = getContentPane();
    paneGlobal.setLayout(new GridBagLayout());
    // == Panel start
    panelStart = new JPanel();
    panelStart.setLayout(new GridBagLayout());
    // Start
    panelStart.setBorder(BorderFactory.createTitledBorder(bundle.getString("frmFillCoeff.panelStart.Title")));
    panelStart.setLayout(new GridBagLayout());
    Utils.addComponent(paneGlobal, panelStart, 0, 0, 1, 1, 0, 0, 10, 10, 0, 10, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
    // From the start
    rbFromStart = new JRadioButton(bundle.getString("frmFillCoeff.rbFromStart.Text"));
    rbFromStart.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Refresh();
        }
    });
    Utils.addComponent(panelStart, rbFromStart, 0, 0, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // From line
    rbFromLine = new JRadioButton(bundle.getString("frmFillCoeff.rbFromLine.Text"));
    rbFromLine.setSelected(true);
    rbFromLine.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Refresh();
        }
    });
    Utils.addComponent(panelStart, rbFromLine, 0, 1, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    groupStart = new ButtonGroup();
    groupStart.add(rbFromStart);
    groupStart.add(rbFromLine);
    spinFromLine = new CgSpinner(100, 1, 100, 1);
    Utils.addComponent(panelStart, spinFromLine, 1, 1, 1, 1, 1, 0, 5, 5, 0, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    lbFromValue = new JLabel(bundle.getString("frmFillCoeff.lbFromValue.Text"));
    Utils.addComponent(panelStart, lbFromValue, 0, 2, 1, 1, 1, 0, 5, 5, 5, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.NONE);
    spinFromValue = new CgSpinnerDouble(100.0, 0.1, 200.0, 0.1);
    Utils.addComponent(panelStart, spinFromValue, 1, 2, 1, 1, 1, 0, 5, 5, 5, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // == Panel end
    panelEnd = new JPanel();
    panelEnd.setLayout(new GridBagLayout());
    // End
    panelEnd.setBorder(BorderFactory.createTitledBorder(bundle.getString("frmFillCoeff.panelEnd.Title")));
    panelEnd.setLayout(new GridBagLayout());
    Utils.addComponent(paneGlobal, panelEnd, 0, 1, 1, 1, 0, 0, 10, 10, 0, 10, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
    // To the end
    rbToEnd = new JRadioButton(bundle.getString("frmFillCoeff.rbToEnd.Text"));
    rbToEnd.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Refresh();
        }
    });
    Utils.addComponent(panelEnd, rbToEnd, 0, 0, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // To line
    rbToLine = new JRadioButton(bundle.getString("frmFillCoeff.rbToLine.Text"));
    rbToLine.setSelected(true);
    rbToLine.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Refresh();
        }
    });
    Utils.addComponent(panelEnd, rbToLine, 0, 1, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    groupEnd = new ButtonGroup();
    groupEnd.add(rbToEnd);
    groupEnd.add(rbToLine);
    spinToLine = new CgSpinner(100, 1, 100, 1);
    Utils.addComponent(panelEnd, spinToLine, 1, 1, 1, 1, 1, 0, 5, 5, 0, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    lbToValue = new JLabel(bundle.getString("frmFillCoeff.lbToValue.Text"));
    Utils.addComponent(panelEnd, lbToValue, 0, 2, 1, 1, 1, 0, 5, 5, 5, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.NONE);
    spinToValue = new CgSpinnerDouble(100.0, 0.1, 200.0, 0.1);
    Utils.addComponent(panelEnd, spinToValue, 1, 2, 1, 1, 1, 0, 5, 5, 5, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // == Panel help
    panelHelp = new JPanel();
    panelHelp.setLayout(new GridBagLayout());
    // Difficulty
    panelHelp.setBorder(BorderFactory.createTitledBorder(bundle.getString("frmFillCoeff.panelHelp.Title")));
    Utils.addComponent(paneGlobal, panelHelp, 0, 2, 1, 1, 1, 1, 10, 10, 0, 10, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
    panelEstimateTime = new JPanel();
    panelEstimateTime.setLayout(new GridBagLayout());
    Utils.addComponent(panelHelp, panelEstimateTime, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
    lbEstimateTime = new JLabel(bundle.getString("frmFillCoeff.lbEstimateTime.Text"));
    Utils.addComponent(panelEstimateTime, lbEstimateTime, 0, 0, GridBagConstraints.REMAINDER, 1, 1, 0, 5, 5, 0, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.NONE);
    lbHour = new JLabel(bundle.getString("frmFillCoeff.lbHour.Text"));
    Utils.addComponent(panelEstimateTime, lbHour, 0, 1, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.NONE);
    spinHour = new CgSpinner(0, 0, 999, 1);
    Utils.addComponent(panelEstimateTime, spinHour, 1, 1, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    lbMinute = new JLabel(bundle.getString("frmFillCoeff.lbMinute.Text"));
    Utils.addComponent(panelEstimateTime, lbMinute, 2, 1, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.NONE);
    spinMinute = new CgSpinner(0, 0, 59, 1);
    Utils.addComponent(panelEstimateTime, spinMinute, 3, 1, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    btCalc = new javax.swing.JButton(bundle.getString("frmFillCoeff.btCalc.text"));
    btCalc.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Calc();
            Refresh();
        }
    });
    Utils.addComponent(panelEstimateTime, btCalc, 4, 1, 1, 1, 1, 0, 5, 5, 0, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.NONE);
    // --
    panelResult = new JPanel();
    panelResult.setLayout(new GridBagLayout());
    Utils.addComponent(panelHelp, panelResult, 0, 1, 1, 1, 1, 1, 10, 0, 10, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
    lbResultCoeff = new JLabel(bundle.getString("frmFillCoeff.lbResultCoeff.Text"));
    Utils.addComponent(panelResult, lbResultCoeff, 0, 1, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.NONE);
    lbResultCoeffVal = new JLabel("0.0", JLabel.CENTER);
    lbResultCoeffVal.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    lbResultCoeffVal.setOpaque(true);
    lbResultCoeffVal.setBackground(Color.WHITE);
    lbResultCoeffVal.setPreferredSize(new Dimension(60, 20));
    Utils.addComponent(panelResult, lbResultCoeffVal, 1, 1, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    btCopyToStart = new javax.swing.JButton(bundle.getString("frmFillCoeff.btCopyToStart.text"));
    btCopyToStart.setToolTipText(bundle.getString("frmFillCoeff.btCopyToStart.toolTipText"));
    btCopyToStart.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            spinFromValue.setValue(estimatedCoeff);
        }
    });
    Utils.addComponent(panelResult, btCopyToStart, 2, 1, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    btCopyToEnd = new javax.swing.JButton(bundle.getString("frmFillCoeff.btCopyToEnd.text"));
    btCopyToEnd.setToolTipText(bundle.getString("frmFillCoeff.btCopyToEnd.toolTipText"));
    btCopyToEnd.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            spinToValue.setValue(estimatedCoeff);
        }
    });
    Utils.addComponent(panelResult, btCopyToEnd, 3, 1, 1, 1, 0, 0, 5, 5, 0, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // == BUTTONS
    // ===========================================================
    jPanelButtons = new javax.swing.JPanel();
    jPanelButtons.setLayout(new FlowLayout());
    Utils.addComponent(paneGlobal, jPanelButtons, 0, 3, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL);
    btCancel = new javax.swing.JButton();
    btCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/cancel.png")));
    btCancel.setText(bundle.getString("Global.btCancel.text"));
    btCancel.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            setVisible(false);
        }
    });
    btOk = new javax.swing.JButton();
    btOk.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/valid.png")));
    btOk.setText(bundle.getString("Global.btOk.text"));
    btOk.setMinimumSize(btCancel.getMinimumSize());
    btOk.setPreferredSize(btCancel.getPreferredSize());
    btOk.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            RequestToClose();
        }
    });
    // -- Add buttons
    jPanelButtons.add(btOk);
    jPanelButtons.add(btCancel);
    // --
    pack();
    setLocationRelativeTo(null);
}
Also used : JPanel(javax.swing.JPanel) JRadioButton(javax.swing.JRadioButton) JButton(javax.swing.JButton) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) ActionEvent(java.awt.event.ActionEvent) Container(java.awt.Container) CgSpinner(course_generator.utils.CgSpinner) ButtonGroup(javax.swing.ButtonGroup) JPanel(javax.swing.JPanel) CgSpinnerDouble(course_generator.utils.CgSpinnerDouble)

Example 4 with CgSpinner

use of course_generator.utils.CgSpinner in project Course_Generator by patrovite.

the class frmFillDiff method initComponents.

private void initComponents() {
    int line = 0;
    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle(bundle.getString("frmFillDiff.title"));
    setAlwaysOnTop(true);
    setResizable(false);
    setMinimumSize(new Dimension(300, 400));
    setType(java.awt.Window.Type.UTILITY);
    // -- Layout
    // ------------------------------------------------------------
    Container paneGlobal = getContentPane();
    paneGlobal.setLayout(new GridBagLayout());
    // == Panel start
    panelStart = new JPanel();
    panelStart.setLayout(new GridBagLayout());
    // Start
    panelStart.setBorder(BorderFactory.createTitledBorder(bundle.getString("frmFillDiff.panelStart.Title")));
    panelStart.setLayout(new GridBagLayout());
    Utils.addComponent(paneGlobal, panelStart, 0, 0, 1, 1, 0, 0, 10, 10, 0, 10, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
    // From the start
    rbFromStart = new JRadioButton(bundle.getString("frmFillDiff.rbFromStart.Text"));
    rbFromStart.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Refresh();
        }
    });
    Utils.addComponent(panelStart, rbFromStart, 0, 0, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // From line
    rbFromLine = new JRadioButton(bundle.getString("frmFillDiff.rbFromLine.Text"));
    rbFromLine.setSelected(true);
    rbFromLine.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Refresh();
        }
    });
    Utils.addComponent(panelStart, rbFromLine, 0, 1, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    groupStart = new ButtonGroup();
    groupStart.add(rbFromStart);
    groupStart.add(rbFromLine);
    spinFromLine = new CgSpinner(100, 1, 100, 1);
    Utils.addComponent(panelStart, spinFromLine, 1, 1, 1, 1, 1, 0, 5, 5, 5, 5, GridBagConstraints.EAST, GridBagConstraints.NONE);
    // == Panel end
    panelEnd = new JPanel();
    panelEnd.setLayout(new GridBagLayout());
    // End
    panelEnd.setBorder(BorderFactory.createTitledBorder(bundle.getString("frmFillDiff.panelEnd.Title")));
    panelEnd.setLayout(new GridBagLayout());
    Utils.addComponent(paneGlobal, panelEnd, 0, 1, 1, 1, 0, 0, 10, 10, 0, 10, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
    // To the end
    rbToEnd = new JRadioButton(bundle.getString("frmFillDiff.rbToEnd.Text"));
    rbToEnd.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Refresh();
        }
    });
    Utils.addComponent(panelEnd, rbToEnd, 0, 0, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // To line
    rbToLine = new JRadioButton(bundle.getString("frmFillDiff.rbToLine.Text"));
    rbToLine.setSelected(true);
    rbToLine.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Refresh();
        }
    });
    Utils.addComponent(panelEnd, rbToLine, 0, 1, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    groupEnd = new ButtonGroup();
    groupEnd.add(rbToEnd);
    groupEnd.add(rbToLine);
    spinToLine = new CgSpinner(100, 1, 100, 1);
    Utils.addComponent(panelEnd, spinToLine, 1, 1, 1, 1, 1, 0, 5, 5, 5, 5, GridBagConstraints.EAST, GridBagConstraints.NONE);
    // == Panel difficulty
    panelDiff = new JPanel();
    panelDiff.setLayout(new GridBagLayout());
    // Difficulty
    panelDiff.setBorder(BorderFactory.createTitledBorder(bundle.getString("frmFillDiff.panelDiff.Title")));
    panelDiff.setLayout(new GridBagLayout());
    Utils.addComponent(paneGlobal, panelDiff, 0, 2, 1, 1, 1, 1, 10, 10, 0, 10, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
    // Very easy
    rbVeryEasy = new JRadioButton(bundle.getString("frmFillDiff.rbVeryEasy.Text"));
    rbVeryEasy.setOpaque(true);
    rbVeryEasy.setBackground(CgConst.CL_DIFF_VERYEASY);
    rbVeryEasy.setSelected(true);
    rbVeryEasy.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Refresh();
        }
    });
    Utils.addComponent(panelDiff, rbVeryEasy, 0, 0, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // Easy
    rbEasy = new JRadioButton(bundle.getString("frmFillDiff.rbEasy.Text"));
    rbEasy.setOpaque(true);
    rbEasy.setBackground(CgConst.CL_DIFF_EASY);
    rbEasy.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Refresh();
        }
    });
    Utils.addComponent(panelDiff, rbEasy, 0, 1, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // Average
    rbAverage = new JRadioButton(bundle.getString("frmFillDiff.rbAverage.Text"));
    rbAverage.setOpaque(true);
    rbAverage.setBackground(CgConst.CL_DIFF_AVERAGE);
    rbAverage.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Refresh();
        }
    });
    Utils.addComponent(panelDiff, rbAverage, 0, 2, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // Hard
    rbHard = new JRadioButton(bundle.getString("frmFillDiff.rbHard.Text"));
    rbHard.setOpaque(true);
    rbHard.setBackground(CgConst.CL_DIFF_HARD);
    rbHard.setForeground(Color.WHITE);
    rbHard.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Refresh();
        }
    });
    Utils.addComponent(panelDiff, rbHard, 0, 3, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // Very hard
    rbVeryHard = new JRadioButton(bundle.getString("frmFillDiff.rbVeryHard.Text"));
    rbVeryHard.setOpaque(true);
    rbVeryHard.setBackground(CgConst.CL_DIFF_VERYHARD);
    rbVeryHard.setForeground(Color.WHITE);
    rbVeryHard.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Refresh();
        }
    });
    Utils.addComponent(panelDiff, rbVeryHard, 0, 4, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // Other
    rbOther = new JRadioButton(bundle.getString("frmFillDiff.rbOther.Text"));
    rbOther.setOpaque(true);
    rbOther.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Refresh();
        }
    });
    Utils.addComponent(panelDiff, rbOther, 0, 5, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    groupDiff = new ButtonGroup();
    groupDiff.add(rbVeryEasy);
    groupDiff.add(rbEasy);
    groupDiff.add(rbAverage);
    groupDiff.add(rbHard);
    groupDiff.add(rbVeryHard);
    groupDiff.add(rbOther);
    spinDiff = new CgSpinner(100, 1, 100, 1);
    Utils.addComponent(panelDiff, spinDiff, 1, 5, 1, 1, 1, 0, 5, 5, 5, 5, GridBagConstraints.EAST, GridBagConstraints.NONE);
    // == BUTTONS
    // ===========================================================
    jPanelButtons = new javax.swing.JPanel();
    jPanelButtons.setLayout(new FlowLayout());
    Utils.addComponent(paneGlobal, jPanelButtons, 0, 3, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL);
    btCancel = new javax.swing.JButton();
    btCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/cancel.png")));
    btCancel.setText(bundle.getString("Global.btCancel.text"));
    btCancel.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            setVisible(false);
        }
    });
    btOk = new javax.swing.JButton();
    btOk.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/valid.png")));
    btOk.setText(bundle.getString("Global.btOk.text"));
    btOk.setMinimumSize(btCancel.getMinimumSize());
    btOk.setPreferredSize(btCancel.getPreferredSize());
    btOk.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            RequestToClose();
        }
    });
    // -- Add buttons
    jPanelButtons.add(btOk);
    jPanelButtons.add(btCancel);
    // --
    pack();
    setLocationRelativeTo(null);
}
Also used : JPanel(javax.swing.JPanel) JRadioButton(javax.swing.JRadioButton) FlowLayout(java.awt.FlowLayout) JButton(javax.swing.JButton) GridBagLayout(java.awt.GridBagLayout) Dimension(java.awt.Dimension) ActionEvent(java.awt.event.ActionEvent) Container(java.awt.Container) CgSpinner(course_generator.utils.CgSpinner) ButtonGroup(javax.swing.ButtonGroup) JPanel(javax.swing.JPanel)

Example 5 with CgSpinner

use of course_generator.utils.CgSpinner in project Course_Generator by patrovite.

the class FrmCalcSunriseSunset method initComponents.

private void initComponents() {
    int line = 0;
    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle(bundle.getString("FrmCalcSunriseSunset.title"));
    setAlwaysOnTop(true);
    setResizable(false);
    setMinimumSize(new Dimension(300, 200));
    setType(java.awt.Window.Type.UTILITY);
    addComponentListener(new java.awt.event.ComponentAdapter() {

        public void componentShown(java.awt.event.ComponentEvent evt) {
            formComponentShown(evt);
        }
    });
    // -- Layout
    // ------------------------------------------------------------
    Container paneGlobal = getContentPane();
    paneGlobal.setLayout(new GridBagLayout());
    // == Date
    lbDate = new JLabel(bundle.getString("FrmCalcSunriseSunset.lbDate.Text"));
    Utils.addComponent(paneGlobal, lbDate, 0, line, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    lbDateVal = new JLabel("", JLabel.CENTER);
    lbDateVal.setOpaque(true);
    lbDateVal.setBackground(Color.WHITE);
    lbDateVal.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    Utils.addComponent(paneGlobal, lbDateVal, 1, line++, 1, 1, 1, 0, 5, 5, 0, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // == Longitude
    lbLongitude = new JLabel(bundle.getString("FrmCalcSunriseSunset.lbLongitude.Text"));
    Utils.addComponent(paneGlobal, lbLongitude, 0, line, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    lbLongitudeVal = new JLabel("", JLabel.CENTER);
    lbLongitudeVal.setOpaque(true);
    lbLongitudeVal.setBackground(Color.WHITE);
    lbLongitudeVal.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    Utils.addComponent(paneGlobal, lbLongitudeVal, 1, line++, 1, 1, 1, 0, 5, 5, 0, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // == Latitude
    lbLatitude = new JLabel(bundle.getString("FrmCalcSunriseSunset.lbLatitude.Text"));
    Utils.addComponent(paneGlobal, lbLatitude, 0, line, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    lbLatitudeVal = new JLabel("", JLabel.CENTER);
    lbLatitudeVal.setOpaque(true);
    lbLatitudeVal.setBackground(Color.WHITE);
    lbLatitudeVal.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    Utils.addComponent(paneGlobal, lbLatitudeVal, 1, line++, 1, 1, 1, 0, 5, 5, 0, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // Time zone
    lbTimeZone = new JLabel(bundle.getString("FrmCalcSunriseSunset.lbTimeZone.Text"));
    Utils.addComponent(paneGlobal, lbTimeZone, 0, line, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    spinTimeZone = new CgSpinner(0, -12, 12, 1);
    spinTimeZone.addChangeListener(new javax.swing.event.ChangeListener() {

        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            Calc();
            Refresh();
        }
    });
    Utils.addComponent(paneGlobal, spinTimeZone, 1, line++, 1, 1, 1, 0, 5, 5, 0, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // == Sunrise
    lbSunrise = new JLabel(bundle.getString("FrmCalcSunriseSunset.lbSunrise.Text"));
    Utils.addComponent(paneGlobal, lbSunrise, 0, line, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    lbSunriseVal = new JLabel("", JLabel.CENTER);
    lbSunriseVal.setOpaque(true);
    lbSunriseVal.setBackground(Color.WHITE);
    lbSunriseVal.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    Utils.addComponent(paneGlobal, lbSunriseVal, 1, line++, 1, 1, 1, 0, 5, 5, 0, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // == Sunset
    lbSunset = new JLabel(bundle.getString("FrmCalcSunsetSunset.lbSunset.Text"));
    Utils.addComponent(paneGlobal, lbSunset, 0, line, 1, 1, 0, 0, 5, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    lbSunsetVal = new JLabel("", JLabel.CENTER);
    lbSunsetVal.setOpaque(true);
    lbSunsetVal.setBackground(Color.WHITE);
    lbSunsetVal.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    Utils.addComponent(paneGlobal, lbSunsetVal, 1, line++, 1, 1, 1, 0, 5, 5, 0, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // == Summer time
    chkSummerTime = new JCheckBox(bundle.getString("FrmCalcSunsetSunset.chkSummerTime.Text"));
    chkSummerTime.setPreferredSize(new Dimension(50, 25));
    chkSummerTime.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Calc();
            Refresh();
        }
    });
    Utils.addComponent(paneGlobal, chkSummerTime, 1, line++, 1, 1, 1, 1, 5, 5, 0, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.NONE);
    // == BUTTONS
    // ===========================================================
    jPanelButtons = new javax.swing.JPanel();
    jPanelButtons.setLayout(new FlowLayout());
    Utils.addComponent(paneGlobal, jPanelButtons, 0, line, GridBagConstraints.REMAINDER, 1, 1, 0, 10, 0, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL);
    btOk = new javax.swing.JButton();
    btOk.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/valid.png")));
    btOk.setText(bundle.getString("Global.btOk.text"));
    btOk.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            RequestToClose();
        }
    });
    btCancel = new javax.swing.JButton();
    btCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/cancel.png")));
    btCancel.setText(bundle.getString("Global.btCancel.text"));
    btCancel.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            setVisible(false);
        }
    });
    // -- Add buttons
    jPanelButtons.add(btOk);
    jPanelButtons.add(btCancel);
    // --
    pack();
    setLocationRelativeTo(null);
}
Also used : FlowLayout(java.awt.FlowLayout) JButton(javax.swing.JButton) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) ComponentEvent(java.awt.event.ComponentEvent) ActionEvent(java.awt.event.ActionEvent) JCheckBox(javax.swing.JCheckBox) Container(java.awt.Container) CgSpinner(course_generator.utils.CgSpinner) JPanel(javax.swing.JPanel)

Aggregations

CgSpinner (course_generator.utils.CgSpinner)7 JButton (javax.swing.JButton)7 Container (java.awt.Container)6 Dimension (java.awt.Dimension)6 GridBagLayout (java.awt.GridBagLayout)6 JLabel (javax.swing.JLabel)6 JPanel (javax.swing.JPanel)6 FlowLayout (java.awt.FlowLayout)5 ActionEvent (java.awt.event.ActionEvent)5 JCheckBox (javax.swing.JCheckBox)3 CgSpinnerDouble (course_generator.utils.CgSpinnerDouble)2 JTextFieldLimit (course_generator.utils.JTextFieldLimit)2 MouseAdapter (java.awt.event.MouseAdapter)2 MouseEvent (java.awt.event.MouseEvent)2 ButtonGroup (javax.swing.ButtonGroup)2 JRadioButton (javax.swing.JRadioButton)2 ChangeEvent (javax.swing.event.ChangeEvent)2 ChangeListener (javax.swing.event.ChangeListener)2 JTimeSetting (course_generator.utils.JTimeSetting)1 BorderLayout (java.awt.BorderLayout)1