Results 1 to 3 of 3
Thread: Trying to input Draggable boxes
- 12-26-2012, 12:28 PM #1
Member
- Join Date
- Nov 2012
- Posts
- 8
- Rep Power
- 0
Trying to input Draggable boxes
Hi.
I'm working on a project for school, the requirements are that we must have at least 10 classes and implement the usual stuff like inheritence, overriding, ...
I wanted to do something special, so I'm working on a visual drag'n drop program for sounds. So you can specify the frequency and duration of a tone, and add the specific block to a channel. A channel is something I created so blocks don't have to overlap. A channel is actually just an additional of blocks beneath the other one. The amount of channels is unlimited, so is the length of a Channel. Channels will be played simultaneously. Now comes the problem..
I have a class named 'SynthesizedPanel', which contains the starting time, duration and frequency of this tone. It is a part of my Channel class. (= arraylist)
I wanted to represent a synthblock visually, so I made another class: SynthBlock. This is the actual block, who calculates his own position etc.
I programmed quite a lot of it now, but I can't get the draggable SynthBoxes working..
If someone could take a look at my project, that would be great!
http://rapidshare.com/files/169532825/simsynth.zip
Greetings
- 12-26-2012, 06:23 PM #2
AN21XX
- Join Date
- Mar 2012
- Location
- Munich
- Posts
- 297
- Rep Power
- 2
Re: Trying to input Draggable boxes
You probably won't get an answer as your problem decription is too inaccurate and your code is in an external link. Describe your problem and post only the code of the concerned section please.
I like likes!.gif)
- 12-27-2012, 01:16 PM #3
Member
- Join Date
- Nov 2012
- Posts
- 8
- Rep Power
- 0
Re: Trying to input Draggable boxes
Excuse me, let me explain it: I have a JPanel child where I draw some stuff onto. This custom JPanel has a NULL layout and contains so called 'boxes'; smaller JPanels. The position of these JPanels is automatically calculated by the method updateInfo() in those boxes. Now, I would like to make these boxes draggable. But I can't get it to work tough..
Java Code:@Override protected void updateInfo(){ //GetDurationRelation etc are constant values. setPanelText(getFrequency() + "MHz", (getDuration() / 1000) + "s"); //Set text updateColor(); setBackground(getColor()); setToolTipText(getFrequency() + "Hz, " + getDuration()/1000 + "s"); //onMouseHover int yPos = (getChannel().getChannelNumber() + 2) * (getChannel().getChannelHeight()) - (getChannel().getChannelHeight()*2) + 20; //20 offset for headers int width = (int) ((getDuration() * getChannel().getDurationRelation() / 1000)); //A little precision loss. setBounds((getStart() * getChannel().getDurationRelation()/ 1000) + 1, yPos, width, getChannel().getChannelHeight() ); //Stupid 1 pixel offset. }Java Code:public void drawSynthGrid(){ panel.removeAll(); //Remove all blocks. int height = (channels.size() * getChannelHeight()) + 20; //Calculate the height. if (height < TimeLinePanel.minHeight) { height = TimeLinePanel.minHeight; } int width = getMaxDistance(); // Estimate how much space we'll need. if (width < TimeLinePanel.minWidth) { width = TimeLinePanel.minWidth; } setDimensions(width, height); for (Channel channel : channels){ for (SynthBlock block : channel.getBlocks()){ panel.add(block); // Add our Blocks } } panel.revalidate(); panel.repaint(); System.out.println("Redrawn"); }
Similar Threads
-
Getting input from 3 input text boxes and store into 1 values
By niksipandit in forum New To JavaReplies: 1Last Post: 11-14-2011, 01:03 PM -
JToolBar make it non-draggable
By nathic in forum New To JavaReplies: 1Last Post: 03-22-2011, 08:52 AM -
How to create a Draggable environment inside JFrame
By chyrl in forum AWT / SwingReplies: 3Last Post: 07-14-2010, 10:34 PM -
Duplicate Input Boxes
By habester in forum New To JavaReplies: 3Last Post: 11-09-2009, 06:13 PM -
Canvas with draggable window
By shravan28 in forum SWT / JFaceReplies: 1Last Post: 03-24-2009, 07:11 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks