List of usage examples for javax.swing Box add
public Component add(Component comp)
From source file:econtroller.gui.ControllerGUI.java
private void createActSlider() { Box hbox = Box.createHorizontalBox(); actLabel = new JLabel("Act every ", JLabel.CENTER); actValueLabel = new JLabel(String.valueOf(ACT_INIT), JLabel.CENTER); actSecondLabel = new JLabel(" (s)", JLabel.CENTER); actSlider = new JSlider(); actSlider = new JSlider(JSlider.HORIZONTAL, ACT_MIN, ACT_MAX, ACT_INIT); actSlider.setMajorTickSpacing(20);/*from w ww . j a v a2 s. c o m*/ actSlider.setMinorTickSpacing(5); actSlider.setPaintLabels(true); actSlider.setPaintTicks(true); actSlider.setPaintTrack(true); actSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent changeEvent) { JSlider source = (JSlider) changeEvent.getSource(); int value = source.getValue(); actValueLabel.setText(String.valueOf(value)); } }); hbox.add(actLabel); hbox.add(actValueLabel); hbox.add(actSecondLabel); controllerDesignPanel.add(hbox); controllerDesignPanel.add(actSlider); }
From source file:com.diversityarrays.kdxplore.trialmgr.trait.TraitExplorerPanel.java
public void removeTraits(Collection<Trait> traitsToCheck) { KDSmartDatabase kdsDb = offlineData.getKdxploreDatabase().getKDXploreKSmartDatabase(); List<Trait> okToDelete = new ArrayList<>(); Map<Trait, List<Trial>> dontDelete = new TreeMap<>(); try {// w w w . j ava2s .co m checkOnTraitUsage(kdsDb, traitsToCheck, okToDelete, dontDelete); Function<Trait, Integer> dontDeleteNamer = new Function<Trait, Integer>() { @Override public Integer apply(Trait t) { List<Trial> list = dontDelete.get(t); return list == null ? 0 : list.size(); } }; if (okToDelete.isEmpty()) { Object msg; if (dontDelete.size() == 1) { String s = ""; for (Trait t : dontDelete.keySet()) { s = t.getTraitName() + ": used by " + dontDelete.get(t).size() + " Trials"; break; } msg = s; } else { msg = HelpUtils.makeTableInScrollPane("Trait", "# Trials", dontDelete.keySet(), dontDeleteNamer); // msg = HelpUtils.makeListInScrollPane(dontDelete.entrySet(), namer); } JOptionPane.showMessageDialog(TraitExplorerPanel.this, msg, "None of the selected Traits may be removed", JOptionPane.WARNING_MESSAGE); } else { Collections.sort(okToDelete); Box box = Box.createVerticalBox(); box.add(GuiUtil.createLabelSeparator("Traits to Remove")); box.add(HelpUtils.makeListInScrollPane(okToDelete, Trait::getTraitName)); if (!dontDelete.isEmpty()) { if (dontDelete.size() == 1) { // box.add(GuiUtil.createLabelSeparator("These will not be removed")); for (Trait t : dontDelete.keySet()) { box.add(new JLabel("Will not be removed: " + t.getTraitName())); } } else { JScrollPane sp = HelpUtils.makeTableInScrollPane("Trait", "# Trials", dontDelete.keySet(), dontDeleteNamer); box.add(GuiUtil.createLabelSeparator("These will not be removed")); box.add(sp); } } if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(TraitExplorerPanel.this, box, "Confirm Trait Removal", JOptionPane.YES_NO_OPTION)) { int[] traitIds = new int[okToDelete.size()]; for (int index = okToDelete.size(); --index >= 0;) { traitIds[index] = okToDelete.get(index).getTraitId(); } kdsDb.removeTraits(traitIds); } } } catch (IOException e1) { MsgBox.error(TraitExplorerPanel.this, e1, "Error Removing Traits"); } }
From source file:TransformExplorer.java
Box scalePanel() { Box panel = new Box(BoxLayout.Y_AXIS); // Uniform Scale JLabel uniform = new JLabel("Uniform Scale"); panel.add(new LeftAlignComponent(uniform)); FloatLabelJSlider coneScaleSlider = new FloatLabelJSlider("S:", 0.1f, 0.0f, 3.0f, coneScale); coneScaleSlider.setMajorTickSpacing(1.0f); coneScaleSlider.setPaintTicks(true); coneScaleSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { coneScale = e.getValue();//from w ww . j av a 2 s .c o m useUniformScale = true; if (useCompoundTransform) { updateUsingCompoundTransform(); } else { setConeUScale(); } } }); panel.add(coneScaleSlider); JLabel nonUniform = new JLabel("Non-Uniform Scale"); panel.add(new LeftAlignComponent(nonUniform)); // Non-Uniform Scale FloatLabelJSlider coneNUScaleXSlider = new FloatLabelJSlider("X: ", 0.1f, 0.0f, 3.0f, (float) coneNUScale.x); coneNUScaleXSlider.setMajorTickSpacing(1.0f); coneNUScaleXSlider.setPaintTicks(true); coneNUScaleXSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { coneNUScale.x = (double) e.getValue(); useUniformScale = false; if (useCompoundTransform) { updateUsingCompoundTransform(); } else { setConeNUScale(); } } }); panel.add(coneNUScaleXSlider); FloatLabelJSlider coneNUScaleYSlider = new FloatLabelJSlider("Y: ", 0.1f, 0.0f, 3.0f, (float) coneNUScale.y); coneNUScaleYSlider.setMajorTickSpacing(1.0f); coneNUScaleYSlider.setPaintTicks(true); coneNUScaleYSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { coneNUScale.y = (double) e.getValue(); useUniformScale = false; if (useCompoundTransform) { updateUsingCompoundTransform(); } else { setConeNUScale(); } } }); panel.add(coneNUScaleYSlider); FloatLabelJSlider coneNUScaleZSlider = new FloatLabelJSlider("Z: ", 0.1f, 0.0f, 3.0f, (float) coneNUScale.z); coneNUScaleZSlider.setMajorTickSpacing(1.0f); coneNUScaleZSlider.setPaintTicks(true); coneNUScaleZSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { coneNUScale.z = (double) e.getValue(); useUniformScale = false; if (useCompoundTransform) { updateUsingCompoundTransform(); } else { setConeNUScale(); } } }); panel.add(coneNUScaleZSlider); return panel; }
From source file:jchrest.gui.VisualSearchPane.java
private JPanel constructButtons() { Box buttons = Box.createVerticalBox(); JSpinner numFixations = new JSpinner(new SpinnerNumberModel(20, 1, 1000, 1)); JPanel labelledSpinner = new JPanel(); labelledSpinner.setLayout(new GridLayout(1, 2)); labelledSpinner.add(new JLabel("Number of fixations: ")); labelledSpinner.add(numFixations);/* w w w . j a v a 2 s .c om*/ JButton recallButton = new JButton(new RecallAction(numFixations)); recallButton.setToolTipText("Scan shown scene and display results"); final JCheckBox showFixations = new JCheckBox("Show fixations", false); showFixations.setToolTipText("Show fixations for recalled scene"); showFixations.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { _sceneDisplay.setShowFixations(showFixations.isSelected()); } }); buttons.add(Box.createRigidArea(new Dimension(0, 20))); buttons.add(labelledSpinner); buttons.add(recallButton); buttons.add(Box.createRigidArea(new Dimension(0, 20))); buttons.add(showFixations); buttons.add(Box.createRigidArea(new Dimension(0, 20))); // TODO: There must be a better solution to this problem! JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(buttons, BorderLayout.NORTH); return panel; }
From source file:visolate.Visolate.java
private Box getTopologyBox() { Dimension d;/* w w w. j a v a 2 s . c o m*/ Box topologyBox = Box.createHorizontalBox(); topologyButton = new JButton("Fix Topology"); topologyButton.setBackground(Color.WHITE); topologyButton.setVerticalAlignment(AbstractButton.CENTER); topologyButton.setHorizontalAlignment(AbstractButton.CENTER); d = topologyButton.getPreferredSize(); topologyButton.setMaximumSize(new Dimension(d.width, d.height)); topologyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { fixTopology(); } }); topologyBox.add(topologyButton); // topologyBox.add(Box.createHorizontalStrut(16)); manualTopology = new JCheckBox("manual"); manualTopology.setBackground(Color.WHITE); manualTopology.setSelected(false); topologyBox.add(manualTopology); return topologyBox; }
From source file:org.biojava.bio.view.MotifAnalyzer.java
private Box getControlBox(SequencePanel seqPanel, String seqName) { JSlider scale;/*from w w w .j a v a 2 s . c o m*/ Box controlBox = null; if (controlBox == null) { controlBox = Box.createHorizontalBox(); scale = new JSlider(SwingConstants.HORIZONTAL, 1, 100, INITIAL_SCALE); controlBox.add(new JLabel(seqName)); controlBox.add(Box.createHorizontalGlue()); controlBox.add(Box.createHorizontalStrut(10)); controlBox.add(Box.createHorizontalGlue()); controlBox.add(new JLabel("Scale")); controlBox.add(Box.createHorizontalStrut(5)); controlBox.add(scale); controlBox.add(Box.createHorizontalGlue()); scale.addChangeListener(new SliderListener(seqPanel)); } return controlBox; }
From source file:visolate.Visolate.java
private Box getToolpathBox() { Dimension d;/*from w w w . j av a 2 s . c o m*/ Box toolpathsBox = Box.createHorizontalBox(); toolpathsButton = new JButton("Make Toolpaths"); toolpathsButton.setBackground(Color.WHITE); toolpathsButton.setVerticalAlignment(AbstractButton.CENTER); toolpathsButton.setHorizontalAlignment(AbstractButton.CENTER); d = toolpathsButton.getPreferredSize(); toolpathsButton.setMaximumSize(new Dimension(d.width, d.height)); toolpathsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { computeToolpaths(); } }); toolpathsBox.add(toolpathsButton); // toolpathsBox.add(Box.createHorizontalStrut(16)); ButtonGroup modeGroup = new ButtonGroup(); voronoiButton = new JRadioButton("voronoi"); modeGroup.add(voronoiButton); voronoiButton.setBackground(Color.WHITE); // VORONOI_MODE is the default mode. voronoiButton.setSelected(true); toolpathsBox.add(voronoiButton); outlineButton = new JRadioButton("outline"); modeGroup.add(outlineButton); outlineButton.setBackground(Color.WHITE); // VORONOI_MODE is the default mode. outlineButton.setSelected(false); toolpathsBox.add(outlineButton); return toolpathsBox; }
From source file:net.rptools.maptool.launcher.MapToolLauncher.java
private JPanel buildTroubleshootingPanel() { final JPanel p = new JPanel(); p.setLayout(new BorderLayout()); ActionListener levelChange = new ActionListener() { @Override//from w w w. j a v a 2s. c om public void actionPerformed(ActionEvent e) { Level x = Level.parse(e.getActionCommand()); if (Level.OFF.equals(x) || Level.INFO.equals(x) || Level.WARNING.equals(x) || Level.SEVERE.equals(x)) log.setLevel(x); } }; JPanel logPanel = new JPanel(); logPanel.setLayout(new GridLayout(0, 1)); logPanel.setBorder(new TitledBorder(new LineBorder(Color.BLACK), CopiedFromOtherJars.getText("msg.logDetailPanel.border"))); //$NON-NLS-1$ logPanel.setAlignmentX(Component.LEFT_ALIGNMENT); ButtonGroup logGroup = new ButtonGroup(); for (Level type : new Level[] { Level.OFF, Level.INFO, Level.WARNING, Level.SEVERE }) { JRadioButton jrb = new JRadioButton(type.toString()); jrb.setActionCommand(type.toString()); jrb.addActionListener(levelChange); jrb.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), jrb.getBorder())); logPanel.add(jrb); logGroup.add(jrb); if (type == Level.WARNING) { jrb.setSelected(true); log.setLevel(type); } } jcbEnableAssertions.setAlignmentX(Component.LEFT_ALIGNMENT); jcbEnableAssertions.setText(CopiedFromOtherJars.getText("msg.info.enableAssertions")); //$NON-NLS-1$ jcbEnableAssertions.setToolTipText(CopiedFromOtherJars.getText("msg.tooltip.enableAssertions")); //$NON-NLS-1$ jcbEnableAssertions.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (!extraArgs.contains(ASSERTIONS_OPTION)) { extraArgs = (ASSERTIONS_OPTION + " " + extraArgs); //$NON-NLS-1$ } } else if (e.getStateChange() == ItemEvent.DESELECTED) { extraArgs = extraArgs.replace(ASSERTIONS_OPTION, ""); //$NON-NLS-1$ } extraArgs = extraArgs.trim(); jtfArgs.setText(extraArgs); updateCommand(); } }); p.add(logPanel, BorderLayout.NORTH); Box other = new Box(BoxLayout.PAGE_AXIS); other.add(jcbEnableAssertions); other.add(Box.createVerticalGlue()); p.add(other, BorderLayout.CENTER); return p; }
From source file:com.diversityarrays.kdxplore.trialmgr.trait.TraitExplorerPanel.java
public TraitExplorerPanel(MessagePrinter mp, OfflineData od, DALClientProvider clientProvider, // KdxUploadHandler uploadHandler, BackgroundRunner backgroundRunner, ImageIcon addBarcodeIcon, Transformer<Trial, Boolean> checkIfEditorActive) { super(new BorderLayout()); this.backgroundRunner = backgroundRunner; this.clientProvider = clientProvider; // this.uploadHandler = uploadHandler; this.messagePrinter = mp; this.offlineData = od; this.checkIfEditorActive = checkIfEditorActive; offlineData.addOfflineDataChangeListener(offlineDataListener); editingLocked.setIcon(KDClientUtils.getIcon(ImageId.LOCKED)); editingLocked.addActionListener(new ActionListener() { @Override/*from ww w . ja v a2s. com*/ public void actionPerformed(ActionEvent e) { changeEditable(editingLocked.isSelected(), DONT_OVERRIDE); } }); changeManager.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { updateUndoRedoActions(); } }); KDClientUtils.initAction(ImageId.TRASH_24, deleteTraitsAction, "Remove Trait"); deleteTraitsAction.setEnabled(false); KDClientUtils.initAction(ImageId.REFRESH_24, refreshAction, "Refresh Data"); KDClientUtils.initAction(ImageId.PLUS_BLUE_24, addNewTraitAction, "Add Trait"); KDClientUtils.initAction(ImageId.UPLOAD_24, uploadTraitsAction, "Upload Traits"); KDClientUtils.initAction(ImageId.ADD_TRIALS_24, importTraitsAction, "Import Traits"); KDClientUtils.initAction(ImageId.EXPORT_24, exportTraitsAction, "Export Traits"); try { Class.forName("com.diversityarrays.kdxplore.upload.TraitUploadTask"); } catch (ClassNotFoundException e1) { uploadTraitsAction.setEnabled(false); if (RunMode.getRunMode().isDeveloper()) { new Toast((JComponent) null, "<HTML>Developer Warning<BR>" + "Trait Upload currently unavailable<BR>", 4000) .showAsError(); } } traitPropertiesTable .setTransferHandler(TableTransferHandler.initialiseForCopySelectAll(traitPropertiesTable, true)); traitPropertiesTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { if (traitPropertiesTableModel.getRowCount() > 0) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { GuiUtil.initialiseTableColumnWidths(traitPropertiesTable); } }); traitPropertiesTableModel.removeTableModelListener(this); } } }); traitTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { showCorrectCard(); } }); TrialManagerPreferences preferences = TrialManagerPreferences.getInstance(); preferences.addChangeListener(TrialManagerPreferences.BAD_FOR_CALC, badForCalcColorChangeListener); badForCalc.setForeground(preferences.getBadForCalcColor()); badForCalc.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e)) { KdxPreference<Color> pref = TrialManagerPreferences.BAD_FOR_CALC; String title = pref.getName(); KdxplorePreferenceEditor.startEditorDialog(TraitExplorerPanel.this, title, pref); } } }); traitsTable.setAutoCreateRowSorter(true); int index = traitTableModel.getTraitNameColumnIndex(); if (index >= 0) { traitsTable.getColumnModel().getColumn(index).setCellRenderer(traitNameCellRenderer); } traitsTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e) && 2 == e.getClickCount()) { e.consume(); int vrow = traitsTable.rowAtPoint(e.getPoint()); if (vrow >= 0) { int mrow = traitsTable.convertRowIndexToModel(vrow); if (mrow >= 0) { Trait trait = traitTableModel.getTraitAtRow(mrow); Integer selectViewRow = null; if (!traitTrialsTableModel.isSelectedTrait(trait)) { selectViewRow = vrow; } if (traitsEditable) { startEditingTraitInternal(trait, selectViewRow, null); } else { warnEditingLocked(); } } } } } }); traitsTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); traitsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { List<Trait> selectedTraits = getSelectedTraits(); traitTrialsTableModel.setSelectedTraits(selectedTraits); if (selectedTraits.size() == 1) { Trait trait = null; int vrow = traitsTable.getSelectedRow(); if (vrow >= 0) { int mrow = traitsTable.convertRowIndexToModel(vrow); if (mrow >= 0) { trait = traitTableModel.getEntityAt(mrow); } } showTraitDetails(trait); } deleteTraitsAction.setEnabled(selectedTraits.size() > 0); showCorrectCard(); } } }); TraitTableModel.initValidationExpressionRenderer(traitsTable); if (RunMode.getRunMode().isDeveloper()) { TraitTableModel.initTableForRawExpression(traitsTable); } cardPanel.add(noTraitsComponent, CARD_NO_TRAITS); cardPanel.add(selectTraitComponent, CARD_SELECT_TO_EDIT); cardPanel.add(new JScrollPane(traitPropertiesTable), CARD_TRAIT_EDITOR); JButton undoButton = initAction(undoAction, ImageId.UNDO_24, "Undo", KeyStroke.getKeyStroke('Z', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); JButton redoButton = initAction(redoAction, ImageId.REDO_24, "Redo", KeyStroke.getKeyStroke('Y', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); Box undoRedoButtons = Box.createHorizontalBox(); undoRedoButtons.add(undoButton); undoRedoButtons.add(redoButton); JPanel detailsPanel = new JPanel(new BorderLayout()); detailsPanel.add(GuiUtil.createLabelSeparator("Details", undoRedoButtons), BorderLayout.NORTH); detailsPanel.add(cardPanel, BorderLayout.CENTER); detailsPanel.add(legendPanel, BorderLayout.SOUTH); PromptScrollPane scrollPane = new PromptScrollPane(traitsTable, "Drag/Drop Traits CSV file or use 'Import Traits'"); TableTransferHandler tth = TableTransferHandler.initialiseForCopySelectAll(traitsTable, true); traitsTable.setTransferHandler(new ChainingTransferHandler(flth, tth)); scrollPane.setTransferHandler(flth); if (addBarcodeIcon == null) { barcodesMenuAction.putValue(Action.NAME, "Barcodes..."); } else { barcodesMenuAction.putValue(Action.SMALL_ICON, addBarcodeIcon); } italicsForProtectedCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { traitNameCellRenderer.setUseItalicsForProtected(italicsForProtectedCheckbox.isSelected()); traitsTable.repaint(); } }); Box leftTopControls = Box.createHorizontalBox(); leftTopControls.add(importTraitsButton); leftTopControls.add(barcodesMenuButton); leftTopControls.add(new JButton(addNewTraitAction)); leftTopControls.add(new JButton(uploadTraitsAction)); leftTopControls.add(new JButton(exportTraitsAction)); leftTopControls.add(Box.createHorizontalGlue()); leftTopControls.add(editingLocked); leftTopControls.add(fixTraitLevelsButton); leftTopControls.add(refreshButton); leftTopControls.add(Box.createHorizontalStrut(8)); leftTopControls.add(new JButton(deleteTraitsAction)); // leftTopControls.add(Box.createHorizontalStrut(4)); Box explanations = Box.createHorizontalBox(); explanations.add(italicsForProtectedCheckbox); explanations.add(badForCalc); explanations.add(Box.createHorizontalGlue()); fixTraitLevelsButton.setToolTipText("Fix Traits with " + TraitLevel.UNDECIDABLE.visible + " 'Level'"); fixTraitLevelsButton.setVisible(false); JPanel leftTop = new JPanel(new BorderLayout()); leftTop.add(leftTopControls, BorderLayout.NORTH); leftTop.add(scrollPane, BorderLayout.CENTER); leftTop.add(explanations, BorderLayout.SOUTH); JPanel leftBot = new JPanel(new BorderLayout()); leftBot.add(GuiUtil.createLabelSeparator("Used by Trials"), BorderLayout.NORTH); leftBot.add(new PromptScrollPane(traitTrialsTable, "Any Trials using selected Traits appear here")); JSplitPane leftSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, leftTop, leftBot); leftSplit.setResizeWeight(0.5); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftSplit, detailsPanel); splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(0.5); add(splitPane, BorderLayout.CENTER); }
From source file:EnvironmentExplorer.java
Box lightPanel() { Box panel = new Box(BoxLayout.Y_AXIS); // add the ambient light checkbox to the panel JCheckBox ambientCheckBox = new JCheckBox("Ambient Light"); ambientCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JCheckBox checkbox = (JCheckBox) e.getSource(); lightAmbient.setEnable(checkbox.isSelected()); }/*from w w w. j av a 2s . c o m*/ }); ambientCheckBox.setSelected(true); panel.add(new LeftAlignComponent(ambientCheckBox)); String[] lightTypeValues = { "None", "Directional", "Positional", "Spot" }; IntChooser lightTypeChooser = new IntChooser("Light Type:", lightTypeValues); lightTypeChooser.addIntListener(new IntListener() { public void intChanged(IntEvent event) { int value = event.getValue(); switch (value) { case 0: lightDirectional.setEnable(false); lightPoint.setEnable(false); lightSpot.setEnable(false); break; case 1: lightDirectional.setEnable(true); lightPoint.setEnable(false); lightSpot.setEnable(false); break; case 2: lightDirectional.setEnable(false); lightPoint.setEnable(true); lightSpot.setEnable(false); break; case 3: lightDirectional.setEnable(false); lightPoint.setEnable(false); lightSpot.setEnable(true); break; } } }); lightTypeChooser.setValueByName("Directional"); panel.add(lightTypeChooser); // Set up the sliders for the attenuation // top row panel.add(new LeftAlignComponent(new JLabel("Light attenuation:"))); FloatLabelJSlider constantSlider = new FloatLabelJSlider("Constant ", 0.1f, 0.0f, 3.0f, attenuation.x); constantSlider.setMajorTickSpacing(1.0f); constantSlider.setPaintTicks(true); constantSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { attenuation.x = e.getValue(); lightPoint.setAttenuation(attenuation); lightSpot.setAttenuation(attenuation); } }); panel.add(constantSlider); FloatLabelJSlider linearSlider = new FloatLabelJSlider("Linear ", 0.1f, 0.0f, 3.0f, attenuation.y); linearSlider.setMajorTickSpacing(1.0f); linearSlider.setPaintTicks(true); linearSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { attenuation.y = e.getValue(); lightPoint.setAttenuation(attenuation); lightSpot.setAttenuation(attenuation); } }); panel.add(linearSlider); FloatLabelJSlider quadradicSlider = new FloatLabelJSlider("Quadradic", 0.1f, 0.0f, 3.0f, attenuation.z); quadradicSlider.setMajorTickSpacing(1.0f); quadradicSlider.setPaintTicks(true); quadradicSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { attenuation.z = e.getValue(); lightPoint.setAttenuation(attenuation); lightSpot.setAttenuation(attenuation); } }); panel.add(quadradicSlider); // Set up the sliders for the attenuation // top row panel.add(new LeftAlignComponent(new JLabel("Spot light:"))); // spread angle is 0-180 degrees, no slider scaling FloatLabelJSlider spotSpreadSlider = new FloatLabelJSlider("Spread Angle ", 1.0f, 0.0f, 180.0f, spotSpreadAngle); spotSpreadSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { spotSpreadAngle = e.getValue(); lightSpot.setSpreadAngle((float) Math.toRadians(spotSpreadAngle)); } }); panel.add(spotSpreadSlider); // concentration angle is 0-128 degrees FloatLabelJSlider spotConcentrationSlider = new FloatLabelJSlider("Concentration", 1.0f, 0.0f, 128.0f, spotConcentration); spotConcentrationSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { spotConcentration = e.getValue(); lightSpot.setConcentration(spotConcentration); } }); panel.add(spotConcentrationSlider); return panel; }