Java Code Examples for javax.swing.JSlider#setMajorTickSpacing()

The following examples show how to use javax.swing.JSlider#setMajorTickSpacing() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimulateControlPanel.java    From VanetSim with GNU General Public License v3.0 7 votes vote down vote up
/**
 * Creates a slider for zooming.
 * 
 * @return a ready-to-use <code>JSlider</code>
 */
private JSlider getZoomSlider() {
	JSlider slider = new JSlider(-75, 212, 1);
	Hashtable<Integer,JLabel> ht = new Hashtable<Integer,JLabel>();
	// the labels correspond to a exponential scale but internally the slider calculates only in a constant scale => need to convert in stateChanged()!
	ht.put(-75, new JLabel("3km"));	//$NON-NLS-1$
	ht.put(-20, new JLabel("1km"));	//$NON-NLS-1$
	ht.put(45, new JLabel("200m"));	//$NON-NLS-1$
	ht.put(96, new JLabel("100m"));	//$NON-NLS-1$
	ht.put(157, new JLabel("30m"));	//$NON-NLS-1$
	ht.put(212, new JLabel("10m"));	//$NON-NLS-1$
	slider.setLabelTable(ht);
	slider.setPaintLabels(true);
	slider.setMinorTickSpacing(10);
	slider.setMajorTickSpacing(40);
	//slider.setPaintTicks(true);
	slider.addChangeListener(this);
	return slider;
}
 
Example 2
Source File: GUIWithSmartClock.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
private JSlider createSlider() {
	slider = new JSlider(SwingConstants.VERTICAL, 0, 30, 0);
	slider.addChangeListener(e -> {
		if (!slider.getValueIsAdjusting()) {
			model.changeTime(slider.getValue());
		}
	});

	slider.setMajorTickSpacing(5);
	slider.setMinorTickSpacing(1);
	slider.createStandardLabels(10);

	slider.setPaintTicks(true);
	slider.setPaintLabels(true);

	return slider;
}
 
Example 3
Source File: TimeSeriesPlayerForm.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
private JSlider createTimeSlider() {
    final JSlider timeSlider = new JSlider(JSlider.HORIZONTAL, 0, 0, 0);
    timeSlider.setMajorTickSpacing(stepsPerTimespan);
    timeSlider.setMinorTickSpacing(1);
    timeSlider.setPaintTrack(true);
    timeSlider.setSnapToTicks(true);
    timeSlider.setPaintTicks(true);
    timeSlider.addChangeListener(e -> {
        final int index = timeSlider.getValue() / stepsPerTimespan;
        final List<Band> bandList = getBandList(currentView.getRaster().getName());
        final String labelText = createSliderLabelText(bandList, index);
        dateLabel.setText("Date: " + labelText);
    });
    timeSlider.setPreferredSize(new Dimension(320, 60));
    return timeSlider;
}
 
Example 4
Source File: SliderField.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Instantiates a new slider field.
 *
 * @param min the min
 * @param max the max
 * @param initialValue the initial value
 */
public SliderField(int min, int max, int initialValue) {
  setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4));

  slider = new JSlider(min, max, initialValue);

  // Try to determine sensible tick spacing:
  int majorTickSpacing = determineMajorTickSpacing(max - min);

  slider.setMajorTickSpacing(majorTickSpacing);
  slider.setPaintTicks(true);

  slider.addChangeListener(this);
  add(slider);

  textField = new IntegerField(min, max, initialValue);
  textField.setColumns(5);
  textField.addPropertyChangeListener(this);

  add(textField);
}
 
Example 5
Source File: ChartPanel.java    From javamelody with Apache License 2.0 6 votes vote down vote up
private JSlider createSlider() {
	final JSlider slider = new JSlider();
	slider.setOpaque(false);
	slider.setMinimum(10);
	slider.setMaximum(200);
	slider.setValue(100);
	slider.setLabelTable(slider.createStandardLabels(50));
	slider.setMajorTickSpacing(100);
	slider.setMinorTickSpacing(10);
	slider.setExtent(20);
	// slider.setPaintLabels(true);
	// slider.setPaintTicks(true);
	// slider.setSnapToTicks(true);
	slider.addChangeListener(new ChangeListener() {
		@Override
		public void stateChanged(ChangeEvent e) {
			final int value = slider.getValue();
			refreshZoom(value);
		}
	});
	return slider;
}
 
Example 6
Source File: FuzzOptionsPanel.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
private static JSlider createDefaultFuzzDelayInMsSlider(
        int defaultDelayInMs, int maxDelayInMs, final JLabel currentValueFeedbackLabel) {
    final JSlider delaySlider = new JSlider();
    delaySlider.setMinimum(0);
    delaySlider.setValue(defaultDelayInMs);
    delaySlider.setMaximum(maxDelayInMs);
    delaySlider.setMinorTickSpacing(25);
    delaySlider.setMajorTickSpacing(100);
    delaySlider.setPaintTicks(true);
    delaySlider.setPaintLabels(true);
    delaySlider.addChangeListener(
            new ChangeListener() {

                @Override
                public void stateChanged(ChangeEvent e) {
                    currentValueFeedbackLabel.setText(Integer.toString(delaySlider.getValue()));
                }
            });
    return delaySlider;
}
 
Example 7
Source File: FuzzerOptionsPanel.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
private static JSlider createDefaultFuzzDelayInMsSlider(
        int delayInMs, int maxDelayInMs, final JLabel currentValueFeedbackLabel) {
    final JSlider delaySlider = new JSlider();
    delaySlider.setMinimum(0);
    delaySlider.setValue(delayInMs);
    delaySlider.setMaximum(maxDelayInMs);
    delaySlider.setMinorTickSpacing(25);
    delaySlider.setMajorTickSpacing(100);
    delaySlider.setPaintTicks(true);
    delaySlider.setPaintLabels(true);
    delaySlider.addChangeListener(
            new ChangeListener() {

                @Override
                public void stateChanged(ChangeEvent e) {
                    currentValueFeedbackLabel.setText(Integer.toString(delaySlider.getValue()));
                }
            });
    return delaySlider;
}
 
Example 8
Source File: JComponentBuilders.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void setupInstance(JSlider instance) {
    super.setupInstance(instance);
    
    instance.setPaintTicks(paintTicks);
    instance.setPaintTrack(paintTrack);
    instance.setPaintLabels(paintLabels);
    instance.setInverted(isInverted);
    if (sliderModel != null) instance.setModel(sliderModel.createInstance());
    instance.setMajorTickSpacing(majorTickSpacing);
    instance.setMinorTickSpacing(minorTickSpacing);
    instance.setSnapToTicks(snapToTicks);
}
 
Example 9
Source File: RotaryStewartPlatformPanel.java    From Robot-Overlord-App with GNU General Public License v2.0 5 votes vote down vote up
protected CollapsiblePanel createSpeedPanel() {
	double speed=robot.getSpeed();
	int speedIndex;
	for(speedIndex=0;speedIndex<speedOptions.length;++speedIndex) {
		if( speedOptions[speedIndex] >= speed )
			break;
	}
	speedNow = new JLabel(Double.toString(speedOptions[speedIndex]),JLabel.CENTER);
	java.awt.Dimension dim = speedNow.getPreferredSize();
	dim.width = 50;
	speedNow.setPreferredSize(dim);

	CollapsiblePanel speedPanel = new CollapsiblePanel("Speed");

	GridBagConstraints con2 = PanelHelper.getDefaultGridBagConstraints();
	con2.weightx=0.25;
	speedPanel.getContentPane().add(speedNow,con2);

	speedControl = new JSlider(0,speedOptions.length-1,speedIndex);
	speedControl.addChangeListener(this);
	speedControl.setMajorTickSpacing(speedOptions.length-1);
	speedControl.setMinorTickSpacing(1);
	speedControl.setPaintTicks(true);
	con2.anchor=GridBagConstraints.NORTHEAST;
	con2.fill=GridBagConstraints.HORIZONTAL;
	con2.weightx=0.75;
	con2.gridx=1;
	speedPanel.getContentPane().add(speedControl,con2);
	
	return speedPanel;
}
 
Example 10
Source File: DeltaRobot3Panel.java    From Robot-Overlord-App with GNU General Public License v2.0 5 votes vote down vote up
protected CollapsiblePanel createSpeedPanel() {
	double speed=robot.getSpeed();
	int speedIndex;
	for(speedIndex=0;speedIndex<speedOptions.length;++speedIndex) {
		if( speedOptions[speedIndex] >= speed )
			break;
	}
	speedNow = new JLabel(Double.toString(speedOptions[speedIndex]),JLabel.CENTER);
	java.awt.Dimension dim = speedNow.getPreferredSize();
	dim.width = 50;
	speedNow.setPreferredSize(dim);

	CollapsiblePanel speedPanel = new CollapsiblePanel("Speed");

	GridBagConstraints con2 = PanelHelper.getDefaultGridBagConstraints();
	con2.weightx=0.25;
	speedPanel.getContentPane().add(speedNow,con2);

	speedControl = new JSlider(0,speedOptions.length-1,speedIndex);
	speedControl.addChangeListener(this);
	speedControl.setMajorTickSpacing(speedOptions.length-1);
	speedControl.setMinorTickSpacing(1);
	speedControl.setPaintTicks(true);
	con2.anchor=GridBagConstraints.NORTHEAST;
	con2.fill=GridBagConstraints.HORIZONTAL;
	con2.weightx=0.75;
	con2.gridx=1;
	speedPanel.getContentPane().add(speedControl,con2);
	
	return speedPanel;
}
 
Example 11
Source File: FilterPanel.java    From FoxTelem with GNU General Public License v3.0 5 votes vote down vote up
private JSlider createSlider(int min, int max, int tick) {
	JSlider slideFilterLength = new JSlider(JSlider.HORIZONTAL, min, max, tick); 
	slideFilterLength.addChangeListener(this);
	//Turn on labels at major tick marks.
	slideFilterLength.setMajorTickSpacing(tick);
	//slideFilterLength.setMinorTickSpacing(64);
	slideFilterLength.setPaintTicks(true);
	slideFilterLength.setPaintLabels(true);
	//slideFilterLength.createStandardLabels(tick);
	slideFilterLength.setSnapToTicks(true);
	
	return slideFilterLength;
}
 
Example 12
Source File: ZoomSliderPanel.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
private JSlider getControl() {
    JSlider slider = new JSlider(JSlider.HORIZONTAL, 50, 200, 100);
    slider.setMajorTickSpacing(50);
    slider.setMinorTickSpacing(10);
    slider.setPaintTicks(true);
    slider.setPaintLabels(true);
    slider.addChangeListener(this);
    return slider;        
}
 
Example 13
Source File: JComponentBuilders.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
protected void setupInstance(JSlider instance) {
    super.setupInstance(instance);
    
    instance.setPaintTicks(paintTicks);
    instance.setPaintTrack(paintTrack);
    instance.setPaintLabels(paintLabels);
    instance.setInverted(isInverted);
    if (sliderModel != null) instance.setModel(sliderModel.createInstance());
    instance.setMajorTickSpacing(majorTickSpacing);
    instance.setMinorTickSpacing(minorTickSpacing);
    instance.setSnapToTicks(snapToTicks);
}
 
Example 14
Source File: Slider.java    From dctb-utfpr-2018-1 with Apache License 2.0 5 votes vote down vote up
Slider() {
    // Cria componentes
    titulo = new JLabel("Desenvolvimento Aberto - JSlider");
    valor = new JLabel(mostraValor);
    slider = new JSlider(JSlider.HORIZONTAL, sMin, sMax, sPos);
    botao = new JButton("Ok");

    // Adiciona propriedades ao componentes
    slider.setMajorTickSpacing(10);
    slider.setMinorTickSpacing(1);
    slider.setPaintTicks(true);
    slider.setPaintLabels(true);

    botao.addActionListener(this);

    // Cria layout
    GridLayout layout = new GridLayout(0, 1, 5, 10);

    setLayout(layout);

    // Adiciona componentes no painel
    add(valor);
    add(slider);
    add(botao);

    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

}
 
Example 15
Source File: ResearchTechPanel.java    From Open-Realms-of-Stars with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create Research Tech panel with - and + buttons and up arrow to
 * upgrade tech level.
 * @param actionMinus ActionCommand for minus button
 * @param actionPlus ActionCommand for plus button
 * @param iconName Icon name to show
 * @param text Text for tech focus label
 * @param text2 Text for tech level label
 * @param actionUpgrade ActionCommand for upgrade button
 * @param sliderValue slider value
 * @param actionSlider slider action command
 * @param listener Action Listener
 */
public ResearchTechPanel(final String actionMinus,
    final String actionPlus, final String iconName, final String text,
    final String text2, final String actionUpgrade, final int sliderValue,
    final String actionSlider, final ActionListener listener) {
  super();
  this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
  btnMinus = new IconButton(Icons.getIconByName(Icons.ICON_MINUS),
      Icons.getIconByName(Icons.ICON_MINUS_PRESSED), false, actionMinus,
      this);
  btnMinus.addActionListener(listener);
  this.add(Box.createRigidArea(new Dimension(5, 5)));
  this.add(btnMinus);
  SpaceGreyPanel panel = new SpaceGreyPanel();
  panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

  label = new IconLabel(null, Icons.getIconByName(iconName), text);
  panel.add(label);
  slider = new JSlider(0, 100, sliderValue);
  slider.setMinorTickSpacing(4);
  slider.setMajorTickSpacing(20);
  slider.setPaintTicks(true);
  slider.setSnapToTicks(true);
  slider.setBackground(GuiStatics.COLOR_GREYBLUE);
  slider.setForeground(GuiStatics.COLOR_COOL_SPACE_BLUE);
  slider.addKeyListener(null);
  slider.addChangeListener(new ChangeListener() {

    @Override
    public void stateChanged(final ChangeEvent e) {
      if (e.getSource() instanceof JSlider) {
        JSlider slide = (JSlider) e.getSource();
        if (slide.getValue() % 4 == 0) {
          listener.actionPerformed(new ActionEvent(e, 0, actionSlider));
        }
      }
    }
  });
  panel.add(slider);
  lvlLabel = new IconLabel(null, Icons.getIconByName(Icons.ICON_EMPTY),
      text2);
  panel.add(lvlLabel);

  this.add(panel);

  btnUpgrade = new IconButton(Icons.getIconByName(Icons.ICON_ARROWUP),
      Icons.getIconByName(Icons.ICON_ARROWUP_PRESSED), false, actionUpgrade,
      this);
  btnUpgrade.setDisabledImage(
      Icons.getIconByName(Icons.ICON_ARROWUP_DISABLED).getIcon());
  btnUpgrade.addActionListener(listener);
  btnUpgrade.setEnabled(false);

  this.add(btnUpgrade);

  btnPlus = new IconButton(Icons.getIconByName(Icons.ICON_PLUS),
      Icons.getIconByName(Icons.ICON_PLUS_PRESSED), false, actionPlus, this);
  btnPlus.addActionListener(listener);
  this.add(btnPlus);
  this.add(Box.createRigidArea(new Dimension(5, 5)));
}
 
Example 16
Source File: AmountPanel.java    From testing-cin with MIT License 4 votes vote down vote up
/**
 * Constructor.
 */
public AmountPanel() {
    setBackground(UIConstants.TABLE_COLOR);
    
    sliderAmounts = new HashMap<Integer, Integer>();
    
    setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    
    amountSlider = new JSlider();
    amountSlider.setBackground(UIConstants.TABLE_COLOR);
    amountSlider.setMajorTickSpacing(1);
    amountSlider.setMinorTickSpacing(1);
    amountSlider.setPaintTicks(true);
    amountSlider.setSnapToTicks(true);
    amountSlider.addChangeListener(this);
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 2;
    gbc.gridheight = 1;
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets = new Insets(0, 0, 0, 5);
    add(amountSlider, gbc);

    amountLabel = new JLabel(" ");
    amountLabel.setForeground(UIConstants.TEXT_COLOR);
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.gridwidth = 2;
    gbc.gridheight = 1;
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets = new Insets(5, 0, 5, 0);
    add(amountLabel, gbc);
    
    betRaiseButton = new JButton("Bet");
    betRaiseButton.addActionListener(this);
    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets = new Insets(0, 0, 0, 0);
    add(betRaiseButton, gbc);
    
    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(this);
    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets = new Insets(0, 0, 0, 0);
    add(cancelButton, gbc);
}
 
Example 17
Source File: SpaceSliderPanel.java    From Open-Realms-of-Stars with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create space slider panel with - and + buttons and label
 * @param actionMinus ActionCommand for minus button
 * @param actionPlus ActionCommand for plus button
 * @param iconName Icon name to show
 * @param text Text for label
 * @param minValue Minimum value in slider
 * @param maxValue Maximum value in slider
 * @param sliderValue slider value
 * @param actionSlider slider action command
 * @param listener Action Listener
 */
public SpaceSliderPanel(final String actionMinus,
    final String actionPlus, final String iconName, final String text,
    final int minValue, final int maxValue, final int sliderValue,
    final String actionSlider, final ActionListener listener) {
  super();
  this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
  btnMinus = new IconButton(Icons.getIconByName(Icons.ICON_MINUS),
      Icons.getIconByName(Icons.ICON_MINUS_PRESSED), false, actionMinus,
      this);
  btnMinus.addActionListener(listener);
  this.add(Box.createRigidArea(new Dimension(5, 5)));
  this.add(btnMinus);
  SpaceGreyPanel panel = new SpaceGreyPanel();
  panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

  label = new IconLabel(null, Icons.getIconByName(iconName), text);
  panel.add(label);
  slider = new JSlider(minValue, maxValue, sliderValue);
  slider.setMinorTickSpacing(1);
  slider.setMajorTickSpacing(10);
  slider.setPaintTicks(true);
  slider.setSnapToTicks(true);
  slider.setBackground(GuiStatics.COLOR_GREYBLUE);
  slider.setForeground(GuiStatics.COLOR_COOL_SPACE_BLUE);
  slider.addKeyListener(null);
  slider.addChangeListener(new ChangeListener() {

    @Override
    public void stateChanged(final ChangeEvent e) {
      if (e.getSource() instanceof JSlider) {
        JSlider slide = (JSlider) e.getSource();
        if (slide.getValue() % slide.getMinorTickSpacing() == 0) {
          listener.actionPerformed(new ActionEvent(e, 0, actionSlider));
        }
      }
    }
  });
  panel.add(slider);

  this.add(panel);
  btnPlus = new IconButton(Icons.getIconByName(Icons.ICON_PLUS),
      Icons.getIconByName(Icons.ICON_PLUS_PRESSED), false, actionPlus, this);
  btnPlus.addActionListener(listener);
  this.add(btnPlus);
  this.add(Box.createRigidArea(new Dimension(5, 5)));
}
 
Example 18
Source File: ExportImage.java    From Logisim with GNU General Public License v3.0 4 votes vote down vote up
OptionsPanel(JList<?> list) {
	// set up components
	formatPng = new JRadioButton("PNG");
	formatGif = new JRadioButton("GIF");
	formatJpg = new JRadioButton("JPEG");
	ButtonGroup bgroup = new ButtonGroup();
	bgroup.add(formatPng);
	bgroup.add(formatGif);
	bgroup.add(formatJpg);
	formatPng.setSelected(true);

	slider = new JSlider(SwingConstants.HORIZONTAL, -3 * SLIDER_DIVISIONS, 3 * SLIDER_DIVISIONS, 0);
	slider.setMajorTickSpacing(10);
	slider.addChangeListener(this);
	curScale = new JLabel("222%");
	curScale.setHorizontalAlignment(SwingConstants.RIGHT);
	curScale.setVerticalAlignment(SwingConstants.CENTER);
	curScaleDim = new Dimension(curScale.getPreferredSize());
	curScaleDim.height = Math.max(curScaleDim.height, slider.getPreferredSize().height);
	stateChanged(null);

	printerView = new JCheckBox();
	printerView.setSelected(true);

	// set up panel
	gridbag = new GridBagLayout();
	gbc = new GridBagConstraints();
	setLayout(gridbag);

	// now add components into panel
	gbc.gridy = 0;
	gbc.gridx = GridBagConstraints.RELATIVE;
	gbc.anchor = GridBagConstraints.NORTHWEST;
	gbc.insets = new Insets(5, 0, 5, 0);
	gbc.fill = GridBagConstraints.NONE;
	addGb(new JLabel(Strings.get("labelCircuits") + " "));
	gbc.fill = GridBagConstraints.HORIZONTAL;
	addGb(new JScrollPane(list));
	gbc.fill = GridBagConstraints.NONE;

	gbc.gridy++;
	addGb(new JLabel(Strings.get("labelImageFormat") + " "));
	Box formatsPanel = new Box(BoxLayout.Y_AXIS);
	formatsPanel.add(formatPng);
	formatsPanel.add(formatGif);
	formatsPanel.add(formatJpg);
	addGb(formatsPanel);

	gbc.gridy++;
	addGb(new JLabel(Strings.get("labelScale") + " "));
	addGb(slider);
	addGb(curScale);

	gbc.gridy++;
	addGb(new JLabel(Strings.get("labelPrinterView") + " "));
	addGb(printerView);
}
 
Example 19
Source File: MainWindow.java    From Creatures with GNU General Public License v2.0 4 votes vote down vote up
private void initUI(WorldView view) {
	JPanel rightContainer = new JPanel();
	rightContainer.setLayout(new BoxLayout(rightContainer, BoxLayout.PAGE_AXIS));

	textLabel = new JLabel("Creatures");
	textLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
	
	speedLabel = new JLabel("Speed");
	speedLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
	
	speedSlider = new JSlider(0, 15, 1);
	speedSlider.setAlignmentX(Component.LEFT_ALIGNMENT);
	speedSlider.setMajorTickSpacing(5);
	speedSlider.setMinorTickSpacing(1);
	speedSlider.setSnapToTicks(true);
	speedSlider.setPaintLabels(true);
	speedSlider.setPaintTicks(true);
	speedSlider.addChangeListener(this);
	
	JPanel maxFoodContainer = new JPanel();
	maxFoodContainer.setLayout(new FlowLayout(FlowLayout.LEFT));
	maxFoodContainer.setAlignmentX(Component.LEFT_ALIGNMENT);
	
	maxFoodLabel = new JLabel("Max Food");
	SpinnerModel maxFoodSpinnerModel = new SpinnerNumberModel(WorldModel.maxFoodAmount, 0, 100000, 1);
	maxFoodSpinner = new JSpinner(maxFoodSpinnerModel);
	maxFoodSpinner.setEditor(new JSpinner.NumberEditor(maxFoodSpinner, "#"));
	maxFoodSpinner.addChangeListener(this);
	
	maxFoodContainer.add(maxFoodLabel);
	maxFoodContainer.add(maxFoodSpinner);
	
	rightContainer.add(textLabel);
	rightContainer.add(Box.createVerticalStrut(10));
	rightContainer.add(speedLabel);
	rightContainer.add(speedSlider);
	rightContainer.add(maxFoodContainer);

	splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, view, rightContainer);
	splitPane.setResizeWeight(0.8);

	add(splitPane);
	
	menuBar = new JMenuBar();
	
	fileMenu = new JMenu("File");
	exportStatisticsItem = new JMenuItem("Export Statistics");
	exportStatisticsItem.addActionListener(this);
	closeItem = new JMenuItem("Close");
	closeItem.addActionListener(this);
	fileMenu.add(exportStatisticsItem);
	fileMenu.addSeparator();
	fileMenu.add(closeItem);
	
	worldMenu = new JMenu("Creation");
	createWorldItem = new JMenuItem("Create World");
	createWorldItem.addActionListener(this);
	worldMenu.add(createWorldItem);
	worldMenu.addSeparator();
	createCreatureItem = new JMenuItem("Create Creature");
	createCreatureItem.addActionListener(this);
	worldMenu.add(createCreatureItem);
	createCreaturesItem = new JMenuItem("Create Creatures");
	createCreaturesItem.addActionListener(this);
	worldMenu.add(createCreaturesItem);
	
	statisticsMenu = new JMenu("Statistics");
	showStatisticsItem = new JMenuItem("Show Statistics");
	showStatisticsItem.addActionListener(this);
	statisticsMenu.add(showStatisticsItem);
	
	menuBar.add(fileMenu);
	menuBar.add(worldMenu);
	menuBar.add(statisticsMenu);
	
	setJMenuBar(menuBar);
}
 
Example 20
Source File: DeobfuscationDialog.java    From jpexs-decompiler with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public DeobfuscationDialog() {
    setDefaultCloseOperation(HIDE_ON_CLOSE);
    setSize(new Dimension(330, 270));
    setTitle(translate("dialog.title"));
    Container cp = getContentPane();
    cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS));
    codeProcessingLevel = new JSlider(JSlider.VERTICAL, 1, 3, 3);
    codeProcessingLevel.setMajorTickSpacing(1);
    codeProcessingLevel.setPaintTicks(true);
    codeProcessingLevel.setMinorTickSpacing(1);
    codeProcessingLevel.setSnapToTicks(true);
    JLabel lab1 = new JLabel(translate("deobfuscation.level"));
    //lab1.setBounds(30, 0, getWidth() - 60, 25);
    lab1.setAlignmentX(0.5f);
    cp.add(lab1);
    Hashtable<Integer, JLabel> labelTable = new Hashtable<>();
    //labelTable.put(LEVEL_NONE, new JLabel("None"));

    labelTable.put(DeobfuscationLevel.LEVEL_REMOVE_DEAD_CODE.getLevel(), new JLabel(translate("deobfuscation.removedeadcode")));
    labelTable.put(DeobfuscationLevel.LEVEL_REMOVE_TRAPS.getLevel(), new JLabel(translate("deobfuscation.removetraps")));
    labelTable.put(DeobfuscationLevel.LEVEL_RESTORE_CONTROL_FLOW.getLevel(), new JLabel(translate("deobfuscation.restorecontrolflow")));
    codeProcessingLevel.setLabelTable(labelTable);

    codeProcessingLevel.setPaintLabels(true);
    codeProcessingLevel.setAlignmentX(Component.CENTER_ALIGNMENT);
    //codeProcessingLevel.setSize(300, 200);

    //codeProcessingLevel.setBounds(30, 25, getWidth() - 60, 125);
    codeProcessingLevel.setAlignmentX(0.5f);
    add(codeProcessingLevel);
    //processAllCheckbox.setBounds(50, 150, getWidth() - 100, 25);
    processAllCheckbox.setAlignmentX(0.5f);
    add(processAllCheckbox);

    processAllCheckbox.setSelected(true);

    JButton cancelButton = new JButton(translate("button.cancel"));
    cancelButton.addActionListener(this::cancelButtonActionPerformed);
    JButton okButton = new JButton(translate("button.ok"));
    okButton.addActionListener(this::okButtonActionPerformed);

    JPanel buttonsPanel = new JPanel(new FlowLayout());
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);
    buttonsPanel.setAlignmentX(0.5f);
    cp.add(buttonsPanel);

    setModal(true);
    View.centerScreen(this);
    setIconImage(View.loadImage("deobfuscate16"));
}