Basit56
August 12th, 2009, 05:48 AM
Hi to all,
Hope you all will be fine.I have a recorder for record sound, now i want to add slider to the recorder so i know for how much time i record a voice but the problem is after adding Jslider to the panel the panel sizes are disturbed and i don't know how i change the panel size. First i try to see whether something like panel.setsize() method is exist then i try to adjust by using Layouts but i was unable to fix this problem.
when you'll open the attachment you'll see four panels with four different colors.It is for easiness that for which panel i am talking about.The panel in green i want that green panel increase its height and the panel in red which include two sub panel one in blue contain Jslider and the other in yellow contain Done button shrink their heights accordingly and the buttonPanel which includes three buttons remain as it is.
Also i want slider shows 0, 1, 2 and 3.I want it also shows 1 and 2 between 0 and 3 on their respective ticks and want to add seconds ticks between 0 and 1 and so on. How can i do this
Thanks in advance.
Here is the code
public CapturePlayback1() {
setLayout(new BorderLayout());
EmptyBorder eb = new EmptyBorder(5,5,5,5);
SoftBevelBorder sbb = new SoftBevelBorder(SoftBevelBorder.LOWERED);
JPanel p1 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
JPanel p2 = new JPanel();
p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));
JPanel buttonsPanel = new JPanel();
playButton = addButton("Play", buttonsPanel, false);
recordButton = addButton("Record", buttonsPanel, true);
pauseButton = addButton("Pause", buttonsPanel, false);
p2.add(buttonsPanel);
JPanel samplingPanel = new JPanel(new BorderLayout());
samplingPanel.setBorder(new LineBorder(Color.GREEN, 2, true));
eb = new EmptyBorder(10, 20, 25, 20);
samplingPanel.add(samplingGraph = new SamplingGraph());
p2.add(samplingPanel);
JPanel savePanel = new JPanel();
savePanel.setBorder(new LineBorder(Color.RED, 2, true));
savePanel.setLayout(new BoxLayout(savePanel, BoxLayout.Y_AXIS));
JPanel saveTFpanel = new JPanel();
saveTFpanel.setBorder(new LineBorder(Color.BLUE, 2, true));
saveTFpanel.setLayout(new BorderLayout());
progressSlider = new JSlider(SwingConstants.HORIZONTAL, 0, 3, 0);
progressSlider.setMajorTickSpacing(3);
progressSlider.setMinorTickSpacing(1);
progressSlider.setPaintTicks(true);
progressSlider.setPaintLabels(true);
saveTFpanel.add(progressSlider);
savePanel.add(saveTFpanel);
JPanel saveBpanel = new JPanel();
saveBpanel.setBorder(new LineBorder(Color.yellow, 2, true));
doneButton = addButton("Done", saveBpanel, false);
savePanel.add(saveBpanel);
p2.add(savePanel);
p1.add(p2);
add(p1);
}
Hope you all will be fine.I have a recorder for record sound, now i want to add slider to the recorder so i know for how much time i record a voice but the problem is after adding Jslider to the panel the panel sizes are disturbed and i don't know how i change the panel size. First i try to see whether something like panel.setsize() method is exist then i try to adjust by using Layouts but i was unable to fix this problem.
when you'll open the attachment you'll see four panels with four different colors.It is for easiness that for which panel i am talking about.The panel in green i want that green panel increase its height and the panel in red which include two sub panel one in blue contain Jslider and the other in yellow contain Done button shrink their heights accordingly and the buttonPanel which includes three buttons remain as it is.
Also i want slider shows 0, 1, 2 and 3.I want it also shows 1 and 2 between 0 and 3 on their respective ticks and want to add seconds ticks between 0 and 1 and so on. How can i do this
Thanks in advance.
Here is the code
public CapturePlayback1() {
setLayout(new BorderLayout());
EmptyBorder eb = new EmptyBorder(5,5,5,5);
SoftBevelBorder sbb = new SoftBevelBorder(SoftBevelBorder.LOWERED);
JPanel p1 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
JPanel p2 = new JPanel();
p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));
JPanel buttonsPanel = new JPanel();
playButton = addButton("Play", buttonsPanel, false);
recordButton = addButton("Record", buttonsPanel, true);
pauseButton = addButton("Pause", buttonsPanel, false);
p2.add(buttonsPanel);
JPanel samplingPanel = new JPanel(new BorderLayout());
samplingPanel.setBorder(new LineBorder(Color.GREEN, 2, true));
eb = new EmptyBorder(10, 20, 25, 20);
samplingPanel.add(samplingGraph = new SamplingGraph());
p2.add(samplingPanel);
JPanel savePanel = new JPanel();
savePanel.setBorder(new LineBorder(Color.RED, 2, true));
savePanel.setLayout(new BoxLayout(savePanel, BoxLayout.Y_AXIS));
JPanel saveTFpanel = new JPanel();
saveTFpanel.setBorder(new LineBorder(Color.BLUE, 2, true));
saveTFpanel.setLayout(new BorderLayout());
progressSlider = new JSlider(SwingConstants.HORIZONTAL, 0, 3, 0);
progressSlider.setMajorTickSpacing(3);
progressSlider.setMinorTickSpacing(1);
progressSlider.setPaintTicks(true);
progressSlider.setPaintLabels(true);
saveTFpanel.add(progressSlider);
savePanel.add(saveTFpanel);
JPanel saveBpanel = new JPanel();
saveBpanel.setBorder(new LineBorder(Color.yellow, 2, true));
doneButton = addButton("Done", saveBpanel, false);
savePanel.add(saveBpanel);
p2.add(savePanel);
p1.add(p2);
add(p1);
}