Example usage for javax.swing JCheckBox JCheckBox

List of usage examples for javax.swing JCheckBox JCheckBox

Introduction

In this page you can find the example usage for javax.swing JCheckBox JCheckBox.

Prototype

public JCheckBox(Action a) 

Source Link

Document

Creates a check box where properties are taken from the Action supplied.

Usage

From source file:caarray.client.test.gui.GuiMain.java

private void initializeTests() throws Exception {
    int index = 0;
    ApiFacade apiFacade = new FullApiFacade();
    List<ConfigurableTestSuite> shortTests = TestMain.getShortTestSuites(apiFacade);
    List<ConfigurableTestSuite> longTests = TestMain.getLongTestSuites(apiFacade);
    List<ConfigurableTestSuite> testSuites = new ArrayList<ConfigurableTestSuite>();
    runTests = new boolean[shortTests.size() + longTests.size()];

    for (ConfigurableTestSuite test : shortTests) {
        JCheckBox box = new JCheckBox(test.getDisplayName());
        box.addChangeListener(new SelectTestListener(index));
        box.setSelected(true);/* w  w w. j av a 2 s .  c o m*/
        testCheckBoxes.add(box);
        selectionPanel.add(box);
        testSuites.add(test);
        index++;
    }
    for (ConfigurableTestSuite test : longTests) {
        JCheckBox box = new JCheckBox(test.getDisplayName());
        box.addChangeListener(new SelectTestListener(index));
        box.setSelected(false);
        testCheckBoxes.add(box);
        selectionPanel.add(box);
        testSuites.add(test);
        index++;
    }
    testSuiteCollection.add(testSuites);
    apiFacades.add(apiFacade);
}

From source file:MyLink.java

public JPanel printableKSGenerate() {
    // create a simple graph for the demo
    graph = new SparseMultigraph<Integer, MyLink>();

    Integer[] v = createVertices(getTermNum());
    createEdges(v);/*ww  w. j a va  2s .  co m*/

    vv = new VisualizationViewer<Integer, MyLink>(new KKLayout<Integer, MyLink>(graph));
    vv.setPreferredSize(new Dimension(520, 520)); // 570, 640 | 565, 640 

    vv.getRenderContext().setVertexLabelTransformer(new UnicodeVertexStringer<Integer>(v));
    vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.magenta));
    vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.magenta));
    VertexIconShapeTransformer<Integer> vertexIconShapeFunction = new VertexIconShapeTransformer<Integer>(
            new EllipseVertexShapeTransformer<Integer>());
    DefaultVertexIconTransformer<Integer> vertexIconFunction = new DefaultVertexIconTransformer<Integer>();
    vv.getRenderContext().setVertexShapeTransformer(vertexIconShapeFunction);
    vv.getRenderContext().setVertexIconTransformer(vertexIconFunction);
    loadImages(v, vertexIconFunction.getIconMap());
    vertexIconShapeFunction.setIconMap(vertexIconFunction.getIconMap());
    vv.getRenderContext().setVertexFillPaintTransformer(new PickableVertexPaintTransformer<Integer>(
            vv.getPickedVertexState(), new Color(0, 102, 255), Color.red));
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<MyLink>(vv.getPickedEdgeState(), Color.orange, Color.cyan));
    vv.setBackground(Color.white);

    final int maxSize = findMaxSizeNumber();

    File file = new File("./output/DESC_TERM_COUNT.txt");
    String s;

    try {
        BufferedReader fis = new BufferedReader(new InputStreamReader(new FileInputStream(file)));

        s = fis.readLine();
        userSelectedTermsCount = Integer.parseInt(s);
        termIndex = new int[userSelectedTermsCount];

        int i = 0;
        while ((s = fis.readLine()) != null) {
            String[] tmp = s.split("=");
            termIndex[i] = Integer.parseInt(tmp[1].trim());
            i++;
        }

    } catch (IOException e) {
        System.out.println(e.getMessage());
    }

    Transformer<Integer, Shape> vertexSize = new Transformer<Integer, Shape>() {
        public Shape transform(Integer i) {
            double sizeInt = termIndex[i];
            sizeInt = (double) sizeInt / (double) maxSize;
            sizeInt = (double) sizeInt * (double) 30 + 10;
            Ellipse2D circle = new Ellipse2D.Double(sizeInt / 2 * (-1), sizeInt / 2 * (-1), sizeInt, sizeInt);
            return circle;
        }
    };
    vv.getRenderContext().setVertexShapeTransformer(vertexSize);
    vv.getRenderer().getVertexLabelRenderer().setPosition(Position.N);

    // add my listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<Integer>());

    // create a frome to hold the graph
    APanel = new JPanel();
    APanel.setLayout(new BoxLayout(APanel, BoxLayout.Y_AXIS));

    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);

    final ModalGraphMouse gm = new DefaultModalGraphMouse<Integer, Number>();
    vv.setGraphMouse(gm);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JCheckBox lo = new JCheckBox("Show Labels");
    lo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            showLabels = e.getStateChange() == ItemEvent.SELECTED;

            vv.repaint();
        }
    });
    lo.setSelected(true);

    JPanel controls = new JPanel();
    controls.add(plus);
    controls.add(minus);
    controls.add(lo);
    controls.add(((DefaultModalGraphMouse<Integer, Number>) gm).getModeComboBox());
    APanel.add(vv);
    APanel.add(controls);

    return APanel;
}

From source file:com.declarativa.interprolog.gui.ListenerWindow.java

private void graphComponents() throws IOException {

    Forest<String, Integer> forest = new DelegateForest<>();
    Forest<String, Integer> forest2 = new DelegateForest<>();
    Forest<String, Integer> forest3 = new DelegateForest<>();
    //ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest));
    ObservableGraph g = new ObservableGraph(new GraphGenerator().createTree(forest));
    ObservableGraph g2 = new ObservableGraph(new GraphGenerator().createTree2(forest2));
    ObservableGraph g3 = new ObservableGraph(new GraphGenerator().createTree3(forest3));

    //Layout layout = new BalloonLayout(forest);
    Layout layout = new BalloonLayout(forest);
    Layout layout2 = new BalloonLayout(forest2);
    Layout layout3 = new TreeLayout(forest3, 70, 70);

    final BaseJungScene scene = new SceneImpl(g, layout);
    final BaseJungScene scene2 = new SceneImpl(g2, layout2);
    final BaseJungScene scene3 = new SceneImpl(g3, layout3);

    jLayeredPane1.setLayout(new BorderLayout());
    //jf.setLayout(new BorderLayout());

    jLayeredPane5.setLayout(new BorderLayout());
    jLayeredPane8.setLayout(new BorderLayout());

    jLayeredPane1.add(new JScrollPane(scene.createView()), BorderLayout.CENTER);
    //jf.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER);

    jLayeredPane5.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER);
    jLayeredPane8.add(new JScrollPane(scene3.createView()), BorderLayout.CENTER);

    JToolBar bar = new JToolBar();
    bar.setMargin(new Insets(5, 5, 5, 5));
    bar.setLayout(new FlowLayout(5));
    DefaultComboBoxModel<Layout> mdl = new DefaultComboBoxModel<>();
    mdl.addElement(new KKLayout(g));
    mdl.addElement(layout);/*from  w w w .  j av  a  2  s . c  o m*/
    mdl.addElement(new BalloonLayout(forest));
    mdl.addElement(new RadialTreeLayout(forest));
    mdl.addElement(new CircleLayout(g));
    mdl.addElement(new FRLayout(g));
    mdl.addElement(new FRLayout2(g));
    mdl.addElement(new ISOMLayout(g));
    mdl.addElement(new edu.uci.ics.jung.algorithms.layout.SpringLayout(g));
    mdl.addElement(new SpringLayout2(g));
    mdl.addElement(new DAGLayout(g));
    mdl.addElement(new XLayout(g));
    mdl.setSelectedItem(layout);
    final JCheckBox checkbox = new JCheckBox("Animate iterative layouts");

    scene.setLayoutAnimationFramesPerSecond(48);
    scene2.setLayoutAnimationFramesPerSecond(48);
    scene3.setLayoutAnimationFramesPerSecond(48);

    final JComboBox<Layout> layouts = new JComboBox(mdl);
    layouts.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln,
                boolean bln1) {
            o = o.getClass().getSimpleName();
            return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates.
        }
    });
    bar.add(new JLabel(" Layout Type"));
    bar.add(layouts);
    layouts.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            Layout layout = (Layout) layouts.getSelectedItem();
            // These two layouts implement IterativeContext, but they do
            // not evolve toward anything, they just randomly rearrange
            // themselves.  So disable animation for these.
            if (layout instanceof ISOMLayout || layout instanceof DAGLayout) {
                checkbox.setSelected(false);
            }
            scene.setGraphLayout(layout, true);
        }
    });

    bar.add(new JLabel(" Connection Shape"));
    DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>();
    shapes.addElement(new EdgeShape.QuadCurve<String, Number>());
    shapes.addElement(new EdgeShape.BentLine<String, Number>());
    shapes.addElement(new EdgeShape.CubicCurve<String, Number>());
    shapes.addElement(new EdgeShape.Line<String, Number>());
    shapes.addElement(new EdgeShape.Box<String, Number>());
    shapes.addElement(new EdgeShape.Orthogonal<String, Number>());
    shapes.addElement(new EdgeShape.Wedge<String, Number>(10));

    final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>(
            shapes);
    shapesBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox
                    .getSelectedItem();
            scene.setConnectionEdgeShape(xform);
        }
    });
    shapesBox.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln,
                boolean bln1) {
            o = o.getClass().getSimpleName();
            return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates.
        }
    });
    shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>());
    bar.add(shapesBox);

    //jf.add(bar, BorderLayout.NORTH);
    bar.add(new ListenerWindow.MinSizePanel(scene.createSatelliteView()));
    bar.setFloatable(false);
    bar.setRollover(true);

    final JLabel selectionLabel = new JLabel("<html>&nbsp;</html>");
    System.out.println("LOOKUP IS " + scene.getLookup());
    Lookup.Result<String> selectedNodes = scene.getLookup().lookupResult(String.class);
    LookupListener listener = new LookupListener() {
        @Override
        public void resultChanged(LookupEvent le) {
            System.out.println("RES CHANGED");
            Lookup.Result<String> res = (Lookup.Result<String>) le.getSource();
            StringBuilder sb = new StringBuilder("<html>");
            List<String> l = new ArrayList<>(res.allInstances());
            Collections.sort(l);
            for (String s : l) {
                if (sb.length() != 0) {
                    sb.append(", ");
                }
                sb.append(s);
            }
            sb.append("</html>");
            selectionLabel.setText(sb.toString());
            System.out.println("LOOKUP EVENT " + sb);
        }
    };
    selectedNodes.addLookupListener(listener);
    selectedNodes.allInstances();

    bar.add(selectionLabel);

    checkbox.setSelected(true);
    checkbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            scene.setAnimateIterativeLayouts(checkbox.isSelected());
        }
    });
    bar.add(checkbox);
    jLayeredPane3.setLayout(new BorderLayout());

    jLayeredPane6.setLayout(new BorderLayout());

    jLayeredPane3.add(bar);

    jLayeredPane6.add(bar);

    //        jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700);
    //        jf.setSize(new Dimension(1280, 720));
    //        jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent we) {
            scene.relayout(true);
            scene.validate();
            scene2.relayout(true);
            scene2.validate();
            scene3.relayout(true);
            scene3.validate();
        }
    });

}

From source file:org.esa.beam.visat.toolviews.stat.ProfilePlotPanel.java

protected JPanel createMiddlePanel(BindingContext bindingContext) {
    final JLabel boxSizeLabel = new JLabel("Box size: ");
    final JSpinner boxSizeSpinner = new JSpinner();
    final JCheckBox computeInBetweenPoints = new JCheckBox("Compute in-between points");
    final JCheckBox useCorrelativeData = new JCheckBox("Use correlative data");

    correlativeFieldSelector = new CorrelativeFieldSelector(bindingContext);
    final PropertyDescriptor boxSizeDescriptor = bindingContext.getPropertySet().getProperty("boxSize")
            .getDescriptor();/*  w ww  . j  av a  2  s  . com*/
    boxSizeDescriptor.setValueRange(new ValueRange(1, 101));
    boxSizeDescriptor.setAttribute("stepSize", 2);
    boxSizeDescriptor.setValidator(new Validator() {
        @Override
        public void validateValue(Property property, Object value) throws ValidationException {
            if (((Number) value).intValue() % 2 == 0) {
                throw new ValidationException("Only odd values allowed as box size.");
            }
        }
    });
    bindingContext.bind("boxSize", boxSizeSpinner);
    bindingContext.bind("computeInBetweenPoints", computeInBetweenPoints);
    bindingContext.bind("useCorrelativeData", useCorrelativeData);
    EnablePointDataCondition condition = new EnablePointDataCondition();
    pointDataSourceEnablement = bindingContext.bindEnabledState("pointDataSource", true, condition);
    dataFieldEnablement = bindingContext.bindEnabledState("dataField", true, condition);

    bindingContext.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            updateDataSource();
            updateDataSet();
            updateUIState();
        }
    });

    JPanel dataSourceOptionsPanel = GridBagUtils.createPanel();
    GridBagConstraints dataSourceOptionsConstraints = GridBagUtils
            .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2");
    GridBagUtils.addToPanel(dataSourceOptionsPanel, boxSizeLabel, dataSourceOptionsConstraints,
            "gridwidth=1,gridy=0,gridx=0,weightx=0,insets.left=4");
    GridBagUtils.addToPanel(dataSourceOptionsPanel, boxSizeSpinner, dataSourceOptionsConstraints,
            "gridwidth=1,gridy=0,gridx=1,weightx=1,insets.left=0");
    GridBagUtils.addToPanel(dataSourceOptionsPanel, computeInBetweenPoints, dataSourceOptionsConstraints,
            "gridwidth=2,gridy=1,gridx=0,weightx=2");
    GridBagUtils.addToPanel(dataSourceOptionsPanel, useCorrelativeData, dataSourceOptionsConstraints,
            "gridy=2,insets.top=16");
    GridBagUtils.addToPanel(dataSourceOptionsPanel, correlativeFieldSelector.pointDataSourceLabel,
            dataSourceOptionsConstraints, "gridy=3,insets.top=0,insets.left=4");
    GridBagUtils.addToPanel(dataSourceOptionsPanel, correlativeFieldSelector.pointDataSourceList,
            dataSourceOptionsConstraints, "gridy=4,insets.left=4");
    GridBagUtils.addToPanel(dataSourceOptionsPanel, correlativeFieldSelector.dataFieldLabel,
            dataSourceOptionsConstraints, "gridy=5,insets.left=4");
    GridBagUtils.addToPanel(dataSourceOptionsPanel, correlativeFieldSelector.dataFieldList,
            dataSourceOptionsConstraints, "gridy=6,insets.left=4");

    xAxisRangeControl.getBindingContext().bind(PROPERTY_NAME_MARK_SEGMENTS, new JCheckBox("Mark segments"));
    yAxisRangeControl.getBindingContext().bind(PROPERTY_NAME_LOG_SCALED, new JCheckBox("Log10 scaled"));

    JPanel displayOptionsPanel = GridBagUtils.createPanel();
    GridBagConstraints displayOptionsConstraints = GridBagUtils
            .createConstraints("anchor=SOUTH,fill=HORIZONTAL,weightx=1");
    GridBagUtils.addToPanel(displayOptionsPanel, xAxisRangeControl.getPanel(), displayOptionsConstraints,
            "gridy=0");
    GridBagUtils.addToPanel(displayOptionsPanel,
            xAxisRangeControl.getBindingContext().getBinding(PROPERTY_NAME_MARK_SEGMENTS).getComponents()[0],
            displayOptionsConstraints, "gridy=1");
    GridBagUtils.addToPanel(displayOptionsPanel, yAxisRangeControl.getPanel(), displayOptionsConstraints,
            "gridy=2");
    GridBagUtils.addToPanel(displayOptionsPanel,
            yAxisRangeControl.getBindingContext().getBinding(PROPERTY_NAME_LOG_SCALED).getComponents()[0],
            displayOptionsConstraints, "gridy=3");

    JPanel middlePanel = GridBagUtils.createPanel();
    GridBagConstraints middlePanelConstraints = GridBagUtils
            .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1");
    GridBagUtils.addToPanel(middlePanel, dataSourceOptionsPanel, middlePanelConstraints, "gridy=0");
    GridBagUtils.addToPanel(middlePanel, new JPanel(), middlePanelConstraints,
            "gridy=1,fill=VERTICAL,weighty=1");
    GridBagUtils.addToPanel(middlePanel, displayOptionsPanel, middlePanelConstraints,
            "gridy=2,fill=HORIZONTAL,weighty=0");

    return middlePanel;
}

From source file:it.ventuland.ytd.ui.GUIClient.java

private void addComponentsToPane(final Container pane) {
    this.panel = new JPanel();
    this.panel.setLayout(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(5, 5, 5, 5);
    gbc.anchor = GridBagConstraints.WEST;

    ActionManager lActionManager = new ActionManager();

    dlm = new DefaultListModel<String>();
    this.urllist = new JList<String>(dlm);
    // TODO maybe we add a button to remove added URLs from list?
    //this.userlist.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
    this.urllist.setFocusable(false);
    textarea = new JTextArea(2, 2);
    textarea.setEditable(true);//from  w ww  .  j a va  2  s  .c om
    textarea.setFocusable(false);

    JScrollPane leftscrollpane = new JScrollPane(this.urllist);
    JScrollPane rightscrollpane = new JScrollPane(textarea);
    this.middlepane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftscrollpane, rightscrollpane);
    this.middlepane.setOneTouchExpandable(true);
    this.middlepane.setDividerLocation(150);

    Dimension minimumSize = new Dimension(25, 25);
    leftscrollpane.setMinimumSize(minimumSize);
    rightscrollpane.setMinimumSize(minimumSize);

    this.directorybutton = new JButton("", createImageIcon("images/open.png", ""));
    gbc.gridx = 0;
    gbc.gridy = 0;
    this.directorybutton.addActionListener(lActionManager);
    this.panel.add(this.directorybutton, gbc);

    this.saveconfigcheckbox = new JCheckBox("Save config");
    this.saveconfigcheckbox.setSelected(false);

    this.panel.add(this.saveconfigcheckbox);

    this.saveconfigcheckbox.setEnabled(false);

    // TODO check if initial download directory exists
    // assume that at least the users homedir exists
    String shomedir = System.getProperty("user.home").concat(File.separator);

    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.gridwidth = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.directorytextfield = new JTextField(shomedir, 20 + (mIsDebug ? 48 : 0));
    this.directorytextfield.setEnabled(false);
    this.directorytextfield.setFocusable(true);
    this.directorytextfield.addActionListener(lActionManager);
    this.panel.add(this.directorytextfield, gbc);

    JLabel dirhint = new JLabel("Download to folder:");

    gbc.gridx = 0;
    gbc.gridy = 1;
    this.panel.add(dirhint, gbc);

    this.middlepane.setPreferredSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().width / 3,
            Toolkit.getDefaultToolkit().getScreenSize().height / 4 + (mIsDebug ? 200 : 0)));

    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weighty = 2;
    gbc.weightx = 2;
    gbc.gridwidth = 2;
    this.panel.add(this.middlepane, gbc);

    // radio buttons for resolution to download
    mVideoResolutionBtnGrp = new ButtonGroup();
    JPanel lRadioPanel = new JPanel(new GridLayout(1, 0));
    List<Object> lVidQ = mAppContext.getList("youtube-downloader.video-quality");
    JRadioButton lRadioButton = null;
    for (Object obj : lVidQ) {
        String lQuality = (String) obj;
        String lToolTip = mAppContext.getString("youtube-downloader.video-quality." + lQuality + ".tooltip");
        boolean lSelected = mAppContext
                .getBoolean("youtube-downloader.video-quality." + lQuality + ".selected");
        boolean lEnabled = mAppContext.getBoolean("youtube-downloader.video-quality." + lQuality + ".enabled");
        lRadioButton = new JRadioButton(lQuality);
        lRadioButton.setName(lQuality);
        lRadioButton.setActionCommand(lQuality.toLowerCase());
        lRadioButton.addActionListener(lActionManager);
        lRadioButton.setToolTipText(lToolTip);
        lRadioButton.setSelected(lSelected);
        lRadioButton.setEnabled(lEnabled);
        mVideoResolutionBtnGrp.add(lRadioButton);
        lRadioPanel.add(lRadioButton);
    }

    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.gridheight = 0;
    gbc.gridwidth = 0;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.NORTHEAST;
    this.panel.add(lRadioPanel, gbc);

    // radio buttons for video format to download
    mVideoQualityBtnGrp = new ButtonGroup();
    lRadioPanel = new JPanel(new GridLayout(1, 0));
    save3dcheckbox = new JCheckBox("3D");
    save3dcheckbox.setToolTipText("stereoscopic video");
    save3dcheckbox.setSelected(false);
    save3dcheckbox.setEnabled(true);
    lRadioPanel.add(save3dcheckbox);
    List<Object> lVidR = mAppContext.getList("youtube-downloader.video-resolution");
    lRadioButton = null;
    for (Object obj : lVidR) {
        String lResolution = (String) obj;
        String lToolTip = mAppContext
                .getString("youtube-downloader.video-resolution." + lResolution + ".tooltip");
        boolean lSelected = mAppContext
                .getBoolean("youtube-downloader.video-resolution." + lResolution + ".selected");
        boolean lEnabled = mAppContext
                .getBoolean("youtube-downloader.video-resolution." + lResolution + ".enabled");
        lRadioButton = new JRadioButton(lResolution);
        lRadioButton.setName(lResolution);
        lRadioButton.setActionCommand(lResolution.toLowerCase());
        lRadioButton.addActionListener(lActionManager);
        lRadioButton.setToolTipText(lToolTip);
        lRadioButton.setSelected(lSelected);
        lRadioButton.setEnabled(lEnabled);
        mVideoQualityBtnGrp.add(lRadioButton);
        lRadioPanel.add(lRadioButton);
    }

    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.gridheight = 0;
    gbc.gridwidth = 0;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.NORTHEAST;
    this.panel.add(lRadioPanel, gbc);

    JLabel hint = new JLabel("Type, paste or drag'n drop a YouTube video address:");

    gbc.fill = 0;
    gbc.gridwidth = 0;
    gbc.gridheight = 1;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.anchor = GridBagConstraints.WEST;
    this.panel.add(hint, gbc);

    textinputfield = new JTextField(20);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.gridwidth = 2;
    textinputfield.setEnabled(true);
    textinputfield.setFocusable(true);
    textinputfield.addActionListener(lActionManager);
    textinputfield.getDocument().addDocumentListener(new UrlInsertListener());
    this.panel.add(textinputfield, gbc);

    this.quitbutton = new JButton("", createImageIcon("images/exit.png", ""));
    gbc.gridx = 2;
    gbc.gridy = 5;
    gbc.gridwidth = 0;
    this.quitbutton.addActionListener(lActionManager);
    this.quitbutton.setActionCommand("quit");
    this.quitbutton.setToolTipText("Exit.");

    this.panel.add(this.quitbutton, gbc);

    pane.add(this.panel);
    addWindowListener(new GUIWindowAdapter());

    this.setDropTarget(new DropTarget(this, new DragDropListener()));
    textarea.setTransferHandler(null); // otherwise the dropped text would be inserted

}

From source file:econtroller.gui.ControllerGUI.java

private void createSamplingAndNodeOrderingSection() {
    orderedEnabled = new JCheckBox("Ordering enabled");
    orderedEnabled.setSelected(true);// w  ww.ja v a  2 s .  c  o m
    samplingOrderLbl = new JLabel("Sampling & Ordering (s)");
    samplingText = new IntegerTextField("10");
    orderingText = new IntegerTextField("90");
    sampleOrderLayout = new Container();
    sampleOrderLayout.setLayout(new GridLayout(1, 2));
    sampleOrderLayout.add(samplingText);
    sampleOrderLayout.add(orderingText);
}

From source file:SoundPlayer.java

void addMidiControls() {
    // Add a slider to control the tempo
    final JSlider tempo = new JSlider(50, 200);
    tempo.setValue((int) (sequencer.getTempoFactor() * 100));
    tempo.setBorder(new TitledBorder("Tempo Adjustment (%)"));
    java.util.Hashtable labels = new java.util.Hashtable();
    labels.put(new Integer(50), new JLabel("50%"));
    labels.put(new Integer(100), new JLabel("100%"));
    labels.put(new Integer(200), new JLabel("200%"));
    tempo.setLabelTable(labels);/*from w ww .  ja v  a  2 s .c  o  m*/
    tempo.setPaintLabels(true);
    // The event listener actually changes the tmpo
    tempo.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            sequencer.setTempoFactor(tempo.getValue() / 100.0f);
        }
    });

    this.add(tempo);

    // Create rows of solo and checkboxes for each track
    Track[] tracks = sequence.getTracks();
    for (int i = 0; i < tracks.length; i++) {
        final int tracknum = i;
        // Two checkboxes per track
        final JCheckBox solo = new JCheckBox("solo");
        final JCheckBox mute = new JCheckBox("mute");
        // The listeners solo or mute the track
        solo.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                sequencer.setTrackSolo(tracknum, solo.isSelected());
            }
        });
        mute.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                sequencer.setTrackMute(tracknum, mute.isSelected());
            }
        });

        // Build up a row
        Box box = Box.createHorizontalBox();
        box.add(new JLabel("Track " + tracknum));
        box.add(Box.createHorizontalStrut(10));
        box.add(solo);
        box.add(Box.createHorizontalStrut(10));
        box.add(mute);
        box.add(Box.createHorizontalGlue());
        // And add it to this component
        this.add(box);
    }
}

From source file:cl.uai.webcursos.emarking.desktop.OptionsDialog.java

/**
 * Create the dialog.//from   w w w . j ava 2 s . c  o m
 */
public OptionsDialog(Moodle _moodle) {
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            cancelled = true;
        }
    });
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    setIconImage(Toolkit.getDefaultToolkit().getImage(OptionsDialog.class
            .getResource("/cl/uai/webcursos/emarking/desktop/resources/glyphicons_439_wrench.png")));
    setTitle(EmarkingDesktop.lang.getString("emarkingoptions"));
    setModal(true);
    setBounds(100, 100, 707, 444);
    this.moodle = _moodle;
    this.moodle.loadProperties();
    getContentPane().setLayout(new BorderLayout());
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            okButton = new JButton(EmarkingDesktop.lang.getString("ok"));
            okButton.setEnabled(false);
            okButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    try {
                        UrlValidator validator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS);
                        if (!validator.isValid(moodleurl.getText())) {
                            throw new Exception(EmarkingDesktop.lang.getString("invalidmoodleurl") + " "
                                    + moodleurl.getText());
                        }
                        File f = new File(filename.getText());
                        if (!f.exists() || f.isDirectory()
                                || (!f.getPath().endsWith(".pdf") && !f.getPath().endsWith(".zip"))) {
                            throw new Exception(EmarkingDesktop.lang.getString("invalidpdffile") + " "
                                    + filename.getText());
                        }
                        if (omrtemplate.getText().trim().length() > 0) {
                            File omrf = new File(omrtemplate.getText());
                            if (!omrf.exists() || omrf.isDirectory() || (!omrf.getPath().endsWith(".xtmpl"))) {
                                throw new Exception(EmarkingDesktop.lang.getString("invalidomrfile") + " "
                                        + omrtemplate.getText());
                            }
                        }
                        moodle.setLastfile(filename.getText());
                        moodle.getQrExtractor().setDoubleside(chckbxDoubleSide.isSelected());
                        moodle.setMaxthreads(Integer.parseInt(getMaxThreads().getSelectedItem().toString()));
                        moodle.setResolution(Integer.parseInt(getResolution().getSelectedItem().toString()));
                        moodle.setMaxzipsize(getMaxZipSize().getSelectedItem().toString());
                        moodle.setOMRTemplate(omrtemplate.getText());
                        moodle.setThreshold(Integer.parseInt(spinnerOMRthreshold.getValue().toString()));
                        moodle.setDensity(Integer.parseInt(spinnerOMRdensity.getValue().toString()));
                        moodle.setShapeSize(Integer.parseInt(spinnerOMRshapeSize.getValue().toString()));
                        moodle.setAnonymousPercentage(
                                Integer.parseInt(spinnerAnonymousPercentage.getValue().toString()));
                        moodle.setAnonymousPercentageCustomPage(
                                Integer.parseInt(spinnerAnonymousPercentageCustomPage.getValue().toString()));
                        moodle.setFakeStudents(chckbxMarkersTraining.isSelected());
                        moodle.saveProperties();
                        cancelled = false;
                        setVisible(false);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                        JOptionPane.showMessageDialog(panel,
                                EmarkingDesktop.lang.getString("invaliddatainform"));
                    }
                }
            });
            okButton.setActionCommand("OK");
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton(EmarkingDesktop.lang.getString("cancel"));
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    cancelled = true;
                    setVisible(false);
                }
            });
            cancelButton.setActionCommand("Cancel");
            buttonPane.add(cancelButton);
        }
    }

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    getContentPane().add(tabbedPane, BorderLayout.CENTER);

    panel = new JPanel();
    tabbedPane.addTab(EmarkingDesktop.lang.getString("general"), null, panel, null);
    panel.setLayout(null);

    JPanel panel_2 = new JPanel();
    panel_2.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
    panel_2.setBounds(10, 11, 665, 131);
    panel.add(panel_2);
    panel_2.setLayout(null);

    JLabel lblPassword = new JLabel(EmarkingDesktop.lang.getString("password"));
    lblPassword.setBounds(10, 99, 109, 14);
    panel_2.add(lblPassword);
    lblPassword.setHorizontalAlignment(SwingConstants.RIGHT);

    password = new JPasswordField();
    password.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            testConnection();
        }
    });
    password.setBounds(129, 96, 329, 20);
    panel_2.add(password);
    this.password.setText(this.moodle.getPassword());

    btnTestConnection = new JButton(EmarkingDesktop.lang.getString("connect"));
    btnTestConnection.setEnabled(false);
    btnTestConnection.setBounds(468, 93, 172, 27);
    panel_2.add(btnTestConnection);

    username = new JTextField();
    username.setBounds(129, 65, 329, 20);
    panel_2.add(username);
    username.setColumns(10);
    this.username.setText(this.moodle.getUsername());

    moodleurl = new JTextField();
    moodleurl.setBounds(129, 34, 329, 20);
    panel_2.add(moodleurl);
    moodleurl.setColumns(10);
    moodleurl.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            warn();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            warn();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            warn();
        }

        private void warn() {
            UrlValidator validator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS);
            if (!validator.isValid(moodleurl.getText()) || !moodleurl.getText().endsWith("/")) {
                moodleurl.setForeground(Color.RED);
                btnTestConnection.setEnabled(false);
            } else {
                moodleurl.setForeground(Color.BLACK);
                btnTestConnection.setEnabled(true);
            }
        }
    });

    // Initializing values from moodle configuration
    this.moodleurl.setText(this.moodle.getUrl());

    JLabel lblMoodleUrl = new JLabel(EmarkingDesktop.lang.getString("moodleurl"));
    lblMoodleUrl.setBounds(10, 37, 109, 14);
    panel_2.add(lblMoodleUrl);
    lblMoodleUrl.setHorizontalAlignment(SwingConstants.RIGHT);

    JLabel lblUsername = new JLabel(EmarkingDesktop.lang.getString("username"));
    lblUsername.setBounds(10, 68, 109, 14);
    panel_2.add(lblUsername);
    lblUsername.setHorizontalAlignment(SwingConstants.RIGHT);

    JLabel lblMoodleSettings = new JLabel(EmarkingDesktop.lang.getString("moodlesettings"));
    lblMoodleSettings.setBounds(10, 11, 230, 14);
    panel_2.add(lblMoodleSettings);
    btnTestConnection.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            testConnection();
        }
    });

    JPanel panel_3 = new JPanel();
    panel_3.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
    panel_3.setBounds(10, 159, 666, 174);
    panel.add(panel_3);
    panel_3.setLayout(null);

    JLabel lblPdfFile = new JLabel(EmarkingDesktop.lang.getString("pdffile"));
    lblPdfFile.setBounds(0, 39, 119, 14);
    panel_3.add(lblPdfFile);
    lblPdfFile.setHorizontalAlignment(SwingConstants.RIGHT);

    JLabel lblScanned = new JLabel(EmarkingDesktop.lang.getString("scanned"));
    lblScanned.setBounds(0, 64, 119, 14);
    panel_3.add(lblScanned);
    lblScanned.setHorizontalAlignment(SwingConstants.RIGHT);

    chckbxDoubleSide = new JCheckBox(EmarkingDesktop.lang.getString("doubleside"));
    chckbxDoubleSide.setEnabled(false);
    chckbxDoubleSide.setBounds(125, 60, 333, 23);
    panel_3.add(chckbxDoubleSide);
    chckbxDoubleSide.setToolTipText(EmarkingDesktop.lang.getString("doublesidetooltip"));
    this.chckbxDoubleSide.setSelected(this.moodle.getQrExtractor().isDoubleside());

    filename = new JTextField();
    filename.setEnabled(false);
    filename.setBounds(129, 36, 329, 20);
    panel_3.add(filename);
    filename.setColumns(10);
    filename.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            warn();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            warn();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            warn();
        }

        private void warn() {
            validateFileForProcessing(!btnTestConnection.isEnabled());
        }
    });
    this.filename.setText(this.moodle.getLastfile());

    btnOpenPdfFile = new JButton(EmarkingDesktop.lang.getString("openfile"));
    btnOpenPdfFile.setEnabled(false);
    btnOpenPdfFile.setBounds(468, 33, 172, 27);
    panel_3.add(btnOpenPdfFile);

    JLabel lblPdfFileSettings = new JLabel(EmarkingDesktop.lang.getString("filesettings"));
    lblPdfFileSettings.setBounds(10, 11, 230, 14);
    panel_3.add(lblPdfFileSettings);

    JLabel lblOMRtemplate = new JLabel(EmarkingDesktop.lang.getString("omrfile"));
    lblOMRtemplate.setHorizontalAlignment(SwingConstants.RIGHT);
    lblOMRtemplate.setBounds(0, 142, 119, 14);
    panel_3.add(lblOMRtemplate);

    omrtemplate = new JTextField();
    omrtemplate.setEnabled(false);
    omrtemplate.setText((String) null);
    omrtemplate.setColumns(10);
    omrtemplate.setBounds(129, 139, 329, 20);
    panel_3.add(omrtemplate);
    omrtemplate.setText(this.moodle.getOMRTemplate());

    btnOpenOMRTemplate = new JButton(EmarkingDesktop.lang.getString("openomrfile"));
    btnOpenOMRTemplate.setEnabled(false);
    btnOpenOMRTemplate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            JFileChooser chooser = new JFileChooser();
            chooser.setDialogTitle(EmarkingDesktop.lang.getString("openfiletitle"));
            chooser.setDialogType(JFileChooser.OPEN_DIALOG);
            chooser.setFileFilter(new FileFilter() {
                @Override
                public String getDescription() {
                    return "*.xtmpl";
                }

                @Override
                public boolean accept(File arg0) {
                    if (arg0.getName().endsWith(".xtmpl") || arg0.isDirectory())
                        return true;
                    return false;
                }
            });
            int retval = chooser.showOpenDialog(panel);
            if (retval == JFileChooser.APPROVE_OPTION) {
                omrtemplate.setText(chooser.getSelectedFile().getAbsolutePath());
            } else {
                return;
            }
        }
    });
    btnOpenOMRTemplate.setBounds(468, 136, 172, 27);
    panel_3.add(btnOpenOMRTemplate);

    lblMarkersTraining = new JLabel((String) EmarkingDesktop.lang.getString("markerstraining"));
    lblMarkersTraining.setHorizontalAlignment(SwingConstants.RIGHT);
    lblMarkersTraining.setBounds(0, 89, 119, 14);
    panel_3.add(lblMarkersTraining);

    chckbxMarkersTraining = new JCheckBox(EmarkingDesktop.lang.getString("markerstrainingfakestudents"));
    chckbxMarkersTraining.setBounds(125, 87, 333, 23);
    panel_3.add(chckbxMarkersTraining);
    btnOpenPdfFile.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            okButton.setEnabled(false);
            JFileChooser chooser = new JFileChooser();
            chooser.setDialogTitle(EmarkingDesktop.lang.getString("openfiletitle"));
            chooser.setDialogType(JFileChooser.OPEN_DIALOG);
            chooser.setFileFilter(new FileFilter() {
                @Override
                public String getDescription() {
                    return "*.pdf, *.zip";
                }

                @Override
                public boolean accept(File arg0) {
                    if (arg0.getName().endsWith(".zip") || arg0.getName().endsWith(".pdf")
                            || arg0.isDirectory())
                        return true;
                    return false;
                }
            });
            int retval = chooser.showOpenDialog(panel);
            if (retval == JFileChooser.APPROVE_OPTION) {
                filename.setText(chooser.getSelectedFile().getAbsolutePath());
                okButton.setEnabled(true);
            } else {
                return;
            }
        }
    });

    JPanel panel_1 = new JPanel();
    tabbedPane.addTab(EmarkingDesktop.lang.getString("advanced"), null, panel_1, null);
    panel_1.setLayout(null);

    JPanel panel_4 = new JPanel();
    panel_4.setLayout(null);
    panel_4.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
    panel_4.setBounds(10, 11, 665, 131);
    panel_1.add(panel_4);

    JLabel lblAdvancedOptions = new JLabel(EmarkingDesktop.lang.getString("advancedoptions"));
    lblAdvancedOptions.setBounds(10, 11, 233, 14);
    panel_4.add(lblAdvancedOptions);

    JLabel lblThreads = new JLabel(EmarkingDesktop.lang.getString("maxthreads"));
    lblThreads.setBounds(10, 38, 130, 14);
    panel_4.add(lblThreads);
    lblThreads.setHorizontalAlignment(SwingConstants.RIGHT);

    JLabel lblSomething = new JLabel(EmarkingDesktop.lang.getString("separatezipfiles"));
    lblSomething.setBounds(10, 73, 130, 14);
    panel_4.add(lblSomething);
    lblSomething.setHorizontalAlignment(SwingConstants.RIGHT);

    JLabel label = new JLabel(EmarkingDesktop.lang.getString("resolution"));
    label.setBounds(10, 105, 130, 14);
    panel_4.add(label);
    label.setHorizontalAlignment(SwingConstants.RIGHT);

    resolution = new JComboBox<Integer>();
    resolution.setBounds(150, 99, 169, 27);
    panel_4.add(resolution);
    resolution.setModel(new DefaultComboBoxModel<Integer>(new Integer[] { 75, 100, 150, 300, 400, 500, 600 }));
    resolution.setSelectedIndex(2);
    this.resolution.setSelectedItem(this.moodle.getQrExtractor().getResolution());

    maxZipSize = new JComboBox<String>();
    maxZipSize.setBounds(150, 67, 169, 27);
    panel_4.add(maxZipSize);
    maxZipSize.setModel(new DefaultComboBoxModel<String>(new String[] { "<dynamic>", "2Mb", "4Mb", "8Mb",
            "16Mb", "32Mb", "64Mb", "128Mb", "256Mb", "512Mb", "1024Mb" }));
    maxZipSize.setSelectedIndex(6);
    this.maxZipSize.setSelectedItem(this.moodle.getMaxZipSizeString());

    maxThreads = new JComboBox<Integer>();
    maxThreads.setBounds(150, 32, 169, 27);
    panel_4.add(maxThreads);
    maxThreads.setModel(new DefaultComboBoxModel<Integer>(new Integer[] { 2, 4, 8, 16 }));
    maxThreads.setSelectedIndex(1);
    this.maxThreads.setSelectedItem(this.moodle.getQrExtractor().getMaxThreads());

    JPanel panel_5 = new JPanel();
    panel_5.setLayout(null);
    panel_5.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
    panel_5.setBounds(10, 153, 665, 131);
    panel_1.add(panel_5);

    JLabel lblOMRoptions = new JLabel(EmarkingDesktop.lang.getString("omroptions"));
    lblOMRoptions.setBounds(10, 11, 233, 14);
    panel_5.add(lblOMRoptions);

    JLabel lblOMRthreshold = new JLabel(EmarkingDesktop.lang.getString("omrthreshold"));
    lblOMRthreshold.setHorizontalAlignment(SwingConstants.RIGHT);
    lblOMRthreshold.setBounds(10, 32, 130, 14);
    panel_5.add(lblOMRthreshold);

    JLabel lblShapeSize = new JLabel(EmarkingDesktop.lang.getString("omrshapesize"));
    lblShapeSize.setHorizontalAlignment(SwingConstants.RIGHT);
    lblShapeSize.setBounds(10, 99, 130, 14);
    panel_5.add(lblShapeSize);

    JLabel lblDensity = new JLabel(EmarkingDesktop.lang.getString("omrdensity"));
    lblDensity.setHorizontalAlignment(SwingConstants.RIGHT);
    lblDensity.setBounds(10, 70, 130, 14);
    panel_5.add(lblDensity);

    spinnerOMRthreshold = new JSpinner();
    spinnerOMRthreshold.setBounds(150, 32, 169, 20);
    panel_5.add(spinnerOMRthreshold);
    spinnerOMRthreshold.setValue(this.moodle.getOMRthreshold());

    spinnerOMRdensity = new JSpinner();
    spinnerOMRdensity.setBounds(150, 67, 169, 20);
    panel_5.add(spinnerOMRdensity);
    spinnerOMRdensity.setValue(this.moodle.getOMRdensity());

    spinnerOMRshapeSize = new JSpinner();
    spinnerOMRshapeSize.setBounds(150, 99, 169, 20);
    panel_5.add(spinnerOMRshapeSize);
    spinnerOMRshapeSize.setValue(this.moodle.getOMRshapeSize());

    JLabel lblAnonymousPercentage = new JLabel(
            "<html>" + EmarkingDesktop.lang.getString("anonymouspercentage") + "</html>");
    lblAnonymousPercentage.setHorizontalAlignment(SwingConstants.RIGHT);
    lblAnonymousPercentage.setBounds(329, 32, 130, 27);
    panel_5.add(lblAnonymousPercentage);

    spinnerAnonymousPercentage = new JSpinner();
    spinnerAnonymousPercentage.setBounds(469, 32, 169, 20);
    panel_5.add(spinnerAnonymousPercentage);
    spinnerAnonymousPercentage.setValue(this.moodle.getAnonymousPercentage());

    JLabel lblAnonymousPercentageCustomPage = new JLabel(
            "<html>" + EmarkingDesktop.lang.getString("anonymouspercentagecustompage") + "</html>");
    lblAnonymousPercentageCustomPage.setHorizontalAlignment(SwingConstants.RIGHT);
    lblAnonymousPercentageCustomPage.setBounds(329, 70, 130, 27);
    panel_5.add(lblAnonymousPercentageCustomPage);

    spinnerAnonymousPercentageCustomPage = new JSpinner();
    spinnerAnonymousPercentageCustomPage.setBounds(469, 70, 169, 20);
    panel_5.add(spinnerAnonymousPercentageCustomPage);
    spinnerAnonymousPercentageCustomPage.setValue(this.moodle.getAnonymousPercentageCustomPage());

    JLabel lblCustomPage = new JLabel(
            "<html>" + EmarkingDesktop.lang.getString("anonymouscustompage") + "</html>");
    lblCustomPage.setHorizontalAlignment(SwingConstants.RIGHT);
    lblCustomPage.setBounds(329, 99, 130, 27);
    panel_5.add(lblCustomPage);

    spinnerCustomPage = new JSpinner();
    spinnerCustomPage.setBounds(469, 99, 169, 20);
    panel_5.add(spinnerCustomPage);
    spinnerCustomPage.setValue(this.moodle.getAnonymousCustomPage());
}

From source file:net.pandoragames.far.ui.swing.FindFilePanel.java

private void initContentSearchPanel(SwingConfig config, ComponentRepository componentRepository) {

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));

    String title = localizer.localize("label.content-pattern");
    contentSearchPanel = new ContentSearchPanel(title, dataModel, config, componentRepository);
    contentSearchPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    browseButtonListener.addComponentToBeDisabledForSingleFiles(contentSearchPanel);
    componentRepository.getSearchBaseListener().addToBeEnabled(contentSearchPanel);
    componentRepository.getResetDispatcher().addToBeEnabled(contentSearchPanel);
    this.add(contentSearchPanel);

    inversionFlag = new JCheckBox(localizer.localize("label.exclude-matches"));
    inversionFlag.setAlignmentX(Component.LEFT_ALIGNMENT);
    inversionFlag.setSelected(dataModel.isInvertContentFilter());
    inversionFlag.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setInvertContentFilter((ItemEvent.SELECTED == event.getStateChange()));
        }//from w ww  .  j  a v a 2 s. c  om
    });
    browseButtonListener.addComponentToBeDisabledForSingleFiles(inversionFlag);
    componentRepository.getSearchBaseListener().addToBeEnabled(inversionFlag);
    componentRepository.getResetDispatcher().addToBeEnabled(inversionFlag);
    contentSearchPanel.addFlag(inversionFlag);

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));
    this.add(Box.createVerticalGlue());

}

From source file:net.sf.taverna.t2.activities.spreadsheet.views.SpreadsheetImportConfigView.java

@Override
protected void initialise() {
    super.initialise();
    newConfiguration = getJson().deepCopy();

    // title/*from w ww  . java2  s. co m*/
    titlePanel = new JPanel(new BorderLayout());
    titlePanel.setBackground(Color.WHITE);
    addDivider(titlePanel, SwingConstants.BOTTOM, true);

    titleLabel = new JLabel(SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.panelTitle"));
    titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 13.5f));
    titleIcon = new JLabel("");
    titleMessage = new DialogTextArea(DEFAULT_MESSAGE);
    titleMessage.setMargin(new Insets(5, 10, 10, 10));
    // titleMessage.setMinimumSize(new Dimension(0, 30));
    titleMessage.setFont(titleMessage.getFont().deriveFont(11f));
    titleMessage.setEditable(false);
    titleMessage.setFocusable(false);
    // titleMessage.setFont(titleLabel.getFont().deriveFont(Font.PLAIN,
    // 12f));

    // column range
    columnLabel = new JLabel(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.columnSectionLabel"));

    JsonNode columnRange = newConfiguration.get("columnRange");
    columnFromValue = new JTextField(new UpperCaseDocument(),
            SpreadsheetUtils.getColumnLabel(columnRange.get("start").intValue()), 4);
    columnFromValue.setMinimumSize(columnFromValue.getPreferredSize());
    columnToValue = new JTextField(new UpperCaseDocument(),
            SpreadsheetUtils.getColumnLabel(columnRange.get("end").intValue()), 4);
    columnToValue.setMinimumSize(columnToValue.getPreferredSize());

    columnFromValue.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
        }

        public void insertUpdate(DocumentEvent e) {
            checkValue(columnFromValue.getText());
        }

        public void removeUpdate(DocumentEvent e) {
            checkValue(columnFromValue.getText());
        }

        private void checkValue(String text) {
            if (text.trim().equals("")) {
                addErrorMessage(EMPTY_FROM_COLUMN_ERROR_MESSAGE);
            } else if (text.trim().matches("[A-Za-z]+")) {
                String fromColumn = columnFromValue.getText().toUpperCase();
                String toColumn = columnToValue.getText().toUpperCase();
                int fromColumnIndex = SpreadsheetUtils.getColumnIndex(fromColumn);
                int toColumnIndex = SpreadsheetUtils.getColumnIndex(toColumn);
                if (checkColumnRange(fromColumnIndex, toColumnIndex)) {
                    columnMappingTableModel.setFromColumn(fromColumnIndex);
                    columnMappingTableModel.setToColumn(toColumnIndex);
                    newConfiguration.set("columnRange", newConfiguration.objectNode()
                            .put("start", fromColumnIndex).put("end", toColumnIndex));
                    validatePortNames();
                }
                removeErrorMessage(FROM_COLUMN_ERROR_MESSAGE);
                removeErrorMessage(EMPTY_FROM_COLUMN_ERROR_MESSAGE);
            } else {
                addErrorMessage(FROM_COLUMN_ERROR_MESSAGE);
                removeErrorMessage(EMPTY_FROM_COLUMN_ERROR_MESSAGE);
            }
        }

    });

    columnToValue.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
        }

        public void insertUpdate(DocumentEvent e) {
            checkValue(columnToValue.getText());
        }

        public void removeUpdate(DocumentEvent e) {
            checkValue(columnToValue.getText());
        }

        private void checkValue(String text) {
            if (text.trim().equals("")) {
                addErrorMessage(EMPTY_TO_COLUMN_ERROR_MESSAGE);
            } else if (text.trim().matches("[A-Za-z]+")) {
                String fromColumn = columnFromValue.getText().toUpperCase();
                String toColumn = columnToValue.getText().toUpperCase();
                int fromColumnIndex = SpreadsheetUtils.getColumnIndex(fromColumn);
                int toColumnIndex = SpreadsheetUtils.getColumnIndex(toColumn);
                if (checkColumnRange(fromColumnIndex, toColumnIndex)) {
                    columnMappingTableModel.setFromColumn(fromColumnIndex);
                    columnMappingTableModel.setToColumn(toColumnIndex);
                    newConfiguration.set("columnRange", newConfiguration.objectNode()
                            .put("start", fromColumnIndex).put("end", toColumnIndex));
                    validatePortNames();
                }
                removeErrorMessage(TO_COLUMN_ERROR_MESSAGE);
                removeErrorMessage(EMPTY_TO_COLUMN_ERROR_MESSAGE);

            } else {
                addErrorMessage(TO_COLUMN_ERROR_MESSAGE);
                removeErrorMessage(EMPTY_TO_COLUMN_ERROR_MESSAGE);
            }
        }
    });

    // row range
    rowLabel = new JLabel(SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.rowSectionLabel"));
    addDivider(rowLabel, SwingConstants.TOP, false);

    rowSelectAllOption = new JCheckBox(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.selectAllRowsOption"));
    rowExcludeFirstOption = new JCheckBox(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.excludeHeaderRowOption"));
    rowIgnoreBlankRows = new JCheckBox(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.ignoreBlankRowsOption"));
    rowSelectAllOption.setFocusable(false);
    rowExcludeFirstOption.setFocusable(false);

    JsonNode rowRange = newConfiguration.get("rowRange");
    rowFromValue = new JTextField(new NumericDocument(), String.valueOf(rowRange.get("start").intValue() + 1),
            4);
    if (rowRange.get("end").intValue() == -1) {
        rowToValue = new JTextField(new NumericDocument(), "", 4);
    } else {
        rowToValue = new JTextField(new NumericDocument(), String.valueOf(rowRange.get("end").intValue() + 1),
                4);
    }
    rowFromValue.setMinimumSize(rowFromValue.getPreferredSize());
    rowToValue.setMinimumSize(rowToValue.getPreferredSize());

    if (newConfiguration.get("allRows").booleanValue()) {
        rowSelectAllOption.setSelected(true);
        rowFromValue.setEditable(false);
        rowFromValue.setEnabled(false);
        rowToValue.setEditable(false);
        rowToValue.setEnabled(false);
    } else {
        rowExcludeFirstOption.setEnabled(false);
    }
    rowExcludeFirstOption.setSelected(newConfiguration.get("excludeFirstRow").booleanValue());
    rowIgnoreBlankRows.setSelected(newConfiguration.get("ignoreBlankRows").booleanValue());

    rowFromValue.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
        }

        public void insertUpdate(DocumentEvent e) {
            checkValue(rowFromValue.getText());
        }

        public void removeUpdate(DocumentEvent e) {
            checkValue(rowFromValue.getText());
        }

        private void checkValue(String text) {
            if (text.trim().equals("")) {
                addErrorMessage(EMPTY_FROM_ROW_ERROR_MESSAGE);
            } else if (text.trim().matches("[1-9][0-9]*")) {
                checkRowRange(rowFromValue.getText(), rowToValue.getText());
                int fromRow = Integer.parseInt(rowFromValue.getText());
                ((ObjectNode) newConfiguration.get("rowRange")).put("start", fromRow - 1);
                removeErrorMessage(FROM_ROW_ERROR_MESSAGE);
                removeErrorMessage(EMPTY_FROM_ROW_ERROR_MESSAGE);
            } else {
                addErrorMessage(FROM_ROW_ERROR_MESSAGE);
                removeErrorMessage(EMPTY_FROM_ROW_ERROR_MESSAGE);
            }
        }
    });

    rowToValue.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
        }

        public void insertUpdate(DocumentEvent e) {
            checkValue(rowToValue.getText());
        }

        public void removeUpdate(DocumentEvent e) {
            checkValue(rowToValue.getText());
        }

        private void checkValue(String text) {
            if (text.trim().equals("")) {
                ((ObjectNode) newConfiguration.get("rowRange")).put("end", -1);
                removeErrorMessage(TO_ROW_ERROR_MESSAGE);
                removeErrorMessage(INCONSISTENT_ROW_MESSAGE);
            } else if (text.trim().matches("[0-9]+")) {
                checkRowRange(rowFromValue.getText(), rowToValue.getText());
                int toRow = Integer.parseInt(rowToValue.getText());
                ((ObjectNode) newConfiguration.get("rowRange")).put("end", toRow - 1);
                removeErrorMessage(TO_ROW_ERROR_MESSAGE);
            } else {
                addErrorMessage(TO_ROW_ERROR_MESSAGE);
            }
        }
    });

    rowSelectAllOption.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                newConfiguration.put("allRows", true);
                rowExcludeFirstOption.setEnabled(true);
                if (rowExcludeFirstOption.isSelected()) {
                    rowFromValue.setText("2");
                } else {
                    rowFromValue.setText("1");
                }
                rowToValue.setText("");
                rowFromValue.setEditable(false);
                rowFromValue.setEnabled(false);
                rowToValue.setEditable(false);
                rowToValue.setEnabled(false);
            } else {
                newConfiguration.put("allRows", false);
                rowExcludeFirstOption.setEnabled(false);
                rowFromValue.setEditable(true);
                rowFromValue.setEnabled(true);
                rowToValue.setEditable(true);
                rowToValue.setEnabled(true);
            }
        }
    });

    rowExcludeFirstOption.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                newConfiguration.put("excludeFirstRow", true);
                rowFromValue.setText("2");
                ((ObjectNode) newConfiguration.get("rowRange")).put("start", 1);
            } else {
                newConfiguration.put("excludeFirstRow", false);
                rowFromValue.setText("1");
                ((ObjectNode) newConfiguration.get("rowRange")).put("start", 0);
            }
        }
    });

    rowIgnoreBlankRows.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            newConfiguration.put("ignoreBlankRows", e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    // empty cells
    emptyCellLabel = new JLabel(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.emptyCellSectionLabel"));
    addDivider(emptyCellLabel, SwingConstants.TOP, false);

    emptyCellButtonGroup = new ButtonGroup();
    emptyCellEmptyStringOption = new JRadioButton(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.emptyStringOption"));
    emptyCellUserDefinedOption = new JRadioButton(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.userDefinedOption"));
    emptyCellErrorValueOption = new JRadioButton(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.generateErrorOption"));
    emptyCellEmptyStringOption.setFocusable(false);
    emptyCellUserDefinedOption.setFocusable(false);
    emptyCellErrorValueOption.setFocusable(false);

    emptyCellUserDefinedValue = new JTextField(newConfiguration.get("emptyCellValue").textValue());

    emptyCellButtonGroup.add(emptyCellEmptyStringOption);
    emptyCellButtonGroup.add(emptyCellUserDefinedOption);
    emptyCellButtonGroup.add(emptyCellErrorValueOption);

    if (newConfiguration.get("emptyCellPolicy").textValue().equals("GENERATE_ERROR")) {
        emptyCellErrorValueOption.setSelected(true);
        emptyCellUserDefinedValue.setEnabled(false);
        emptyCellUserDefinedValue.setEditable(false);
    } else if (newConfiguration.get("emptyCellPolicy").textValue().equals("EMPTY_STRING")) {
        emptyCellEmptyStringOption.setSelected(true);
        emptyCellUserDefinedValue.setEnabled(false);
        emptyCellUserDefinedValue.setEditable(false);
    } else {
        emptyCellUserDefinedOption.setSelected(true);
        emptyCellUserDefinedValue.setText(newConfiguration.get("emptyCellValue").textValue());
        emptyCellUserDefinedValue.setEnabled(true);
        emptyCellUserDefinedValue.setEditable(true);
    }

    emptyCellEmptyStringOption.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            newConfiguration.put("emptyCellPolicy", "EMPTY_STRING");
            emptyCellUserDefinedValue.setEnabled(false);
            emptyCellUserDefinedValue.setEditable(false);
        }
    });
    emptyCellUserDefinedOption.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            newConfiguration.put("emptyCellPolicy", "USER_DEFINED");
            emptyCellUserDefinedValue.setEnabled(true);
            emptyCellUserDefinedValue.setEditable(true);
            emptyCellUserDefinedValue.requestFocusInWindow();
        }
    });
    emptyCellErrorValueOption.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            newConfiguration.put("emptyCellPolicy", "GENERATE_ERROR");
            emptyCellUserDefinedValue.setEnabled(false);
            emptyCellUserDefinedValue.setEditable(false);
        }
    });

    emptyCellUserDefinedValue.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            newConfiguration.put("emptyCellValue", emptyCellUserDefinedValue.getText());
        }

        public void insertUpdate(DocumentEvent e) {
            newConfiguration.put("emptyCellValue", emptyCellUserDefinedValue.getText());
        }

        public void removeUpdate(DocumentEvent e) {
            newConfiguration.put("emptyCellValue", emptyCellUserDefinedValue.getText());
        }
    });

    // column mappings
    columnMappingLabel = new JLabel(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.columnMappingSectionLabel"));
    addDivider(columnMappingLabel, SwingConstants.TOP, false);

    Map<String, String> columnToPortMapping = new HashMap<>();
    if (newConfiguration.has("columnNames")) {
        for (JsonNode columnName : newConfiguration.get("columnNames")) {
            columnToPortMapping.put(columnName.get("column").textValue(), columnName.get("port").textValue());
        }
    }
    columnMappingTableModel = new SpreadsheetImportConfigTableModel(columnFromValue.getText(),
            columnToValue.getText(), columnToPortMapping);

    columnMappingTable = new JTable();
    columnMappingTable.setRowSelectionAllowed(false);
    columnMappingTable.getTableHeader().setReorderingAllowed(false);
    columnMappingTable.setGridColor(Color.LIGHT_GRAY);
    // columnMappingTable.setFocusable(false);

    columnMappingTable.setColumnModel(new DefaultTableColumnModel() {
        public TableColumn getColumn(int columnIndex) {
            TableColumn column = super.getColumn(columnIndex);
            if (columnIndex == 0) {
                column.setMaxWidth(100);
            }
            return column;
        }
    });

    TableCellEditor defaultEditor = columnMappingTable.getDefaultEditor(String.class);
    if (defaultEditor instanceof DefaultCellEditor) {
        DefaultCellEditor defaultCellEditor = (DefaultCellEditor) defaultEditor;
        defaultCellEditor.setClickCountToStart(1);
        Component editorComponent = defaultCellEditor.getComponent();
        if (editorComponent instanceof JTextComponent) {
            final JTextComponent textField = (JTextComponent) editorComponent;
            textField.getDocument().addDocumentListener(new DocumentListener() {
                public void changedUpdate(DocumentEvent e) {
                    updateModel(textField.getText());
                }

                public void insertUpdate(DocumentEvent e) {
                    updateModel(textField.getText());
                }

                public void removeUpdate(DocumentEvent e) {
                    updateModel(textField.getText());
                }

                private void updateModel(String text) {
                    int row = columnMappingTable.getEditingRow();
                    int column = columnMappingTable.getEditingColumn();
                    columnMappingTableModel.setValueAt(text, row, column);

                    ArrayNode columnNames = newConfiguration.arrayNode();
                    Map<String, String> columnToPortMapping = columnMappingTableModel.getColumnToPortMapping();
                    for (Entry<String, String> entry : columnToPortMapping.entrySet()) {
                        columnNames.add(newConfiguration.objectNode().put("column", entry.getKey()).put("port",
                                entry.getValue()));
                    }
                    newConfiguration.put("columnNames", columnNames);
                    validatePortNames();
                }

            });
        }
    }

    columnMappingTable.setModel(columnMappingTableModel);

    // output format
    outputFormatLabel = new JLabel(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.outputFormatSectionLabel"));

    outputFormatMultiplePort = new JRadioButton(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.multiplePortOption"));
    outputFormatSinglePort = new JRadioButton(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.singlePortOption"));
    outputFormatMultiplePort.setFocusable(false);
    outputFormatSinglePort.setFocusable(false);

    outputFormatDelimiterLabel = new JLabel(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.userDefinedCsvDelimiter"));
    outputFormatDelimiter = new JTextField(newConfiguration.get("csvDelimiter").textValue(), 5);

    outputFormatButtonGroup = new ButtonGroup();
    outputFormatButtonGroup.add(outputFormatMultiplePort);
    outputFormatButtonGroup.add(outputFormatSinglePort);

    if (newConfiguration.get("outputFormat").textValue().equals("PORT_PER_COLUMN")) {
        outputFormatMultiplePort.setSelected(true);
        outputFormatDelimiterLabel.setEnabled(false);
        outputFormatDelimiter.setEnabled(false);
    } else {
        outputFormatSinglePort.setSelected(true);
        columnMappingLabel.setEnabled(false);
        enableTable(columnMappingTable, false);
    }

    outputFormatMultiplePort.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            outputFormatDelimiterLabel.setEnabled(false);
            outputFormatDelimiter.setEnabled(false);
            columnMappingLabel.setEnabled(true);
            enableTable(columnMappingTable, true);
            newConfiguration.put("outputFormat", "PORT_PER_COLUMN");
        }
    });
    outputFormatSinglePort.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            outputFormatDelimiterLabel.setEnabled(true);
            outputFormatDelimiter.setEnabled(true);
            columnMappingLabel.setEnabled(false);
            enableTable(columnMappingTable, false);
            newConfiguration.put("outputFormat", "SINGLE_PORT");
        }

    });
    outputFormatDelimiter.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            handleUpdate();
        }

        public void insertUpdate(DocumentEvent e) {
            handleUpdate();
        }

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

        private void handleUpdate() {
            String text = null;
            try {
                text = StringEscapeUtils.unescapeJava(outputFormatDelimiter.getText());
            } catch (RuntimeException re) {
            }
            if (text == null || text.length() == 0) {
                newConfiguration.put("csvDelimiter", ",");
            } else {
                newConfiguration.put("csvDelimiter", text.substring(0, 1));
            }
        }

    });

    // buttons
    nextButton = new JButton(SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.nextButton"));
    nextButton.setFocusable(false);
    nextButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            backButton.setVisible(true);
            nextButton.setVisible(false);
            cardLayout.last(contentPanel);
        }
    });

    backButton = new JButton(SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.backButton"));
    backButton.setFocusable(false);
    backButton.setVisible(false);
    backButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            nextButton.setVisible(true);
            backButton.setVisible(false);
            cardLayout.first(contentPanel);
        }
    });

    buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    addDivider(buttonPanel, SwingConstants.TOP, true);

    removeAll();
    layoutPanel();
}