|
Hello Friends
I created a viewer in applet and embed into html.This viewer having differnt button that controls zooming,panning,moving.Now,I want to know that Is it possible to have all these buttons on same HTML page on which I embed the viewer to control the viewer zooming all things?
Thanks & Regards
Yogesh
|
|
|
|
|
Yogesh!
Honestly - you have worked a lot on this, I noticed quit some posts of you.
As much as you have been working with JAVA, you should have noticed at least some GUI-examples. And as you did so, you should have taken notice of the existens of the JPanel.
Java Tutorials[^]
Example with multible JPanels
Please check the JPanel which is mounted in the south-position of the BorderLayout:
public class DynamicTreePanel extends JPanel implements ActionListener {
private int newNodeSuffix = 1;
private static String ADD_COMMAND = "add";
private static String REMOVE_COMMAND = "remove";
private static String CLEAR_COMMAND = "clear";
private DynamicTree treePanel;
public DynamicTreePanel() {
super(new BorderLayout());
treePanel = new DynamicTree();
populateTree(treePanel);
JButton addButton = new JButton("Add");
addButton.setActionCommand(ADD_COMMAND);
addButton.addActionListener(this);
JButton removeButton = new JButton("Remove");
....
JButton clearButton = new JButton("Clear");
...
treePanel.setPreferredSize(new Dimension(300, 150));
add(treePanel, BorderLayout.CENTER);
JPanel panel = new JPanel(new GridLayout(0,3));
panel.add(addButton);
panel.add(removeButton);
panel.add(clearButton);
add(panel, BorderLayout.SOUTH);
}
....
}
I never finish anyth...
|
|
|
|
|
Hello Torsten
Thx a Lot.Its my pleasure that somebody is noticing My work and get reward like this.Basically,I worked on C++ project but as sudden as per requiremnt I have to work with java3d and obviously we need core java too.And I learned from u guys only.
Now,the code u suggested will create a button in jpanel that will b part of Applet.And I also looked at setActionCommand tht just records the string.
Suppose a button in applet zooms the object.but after embeding tht applet into browser,I want now the same button as html button tht will zoom the object of applet inspite of that button in the applet.
I want to control the Jbutton thru html button.
Any other Ideas.
Thanks Again
Regards
Yogesh
|
|
|
|
|
Hello Guys
I got one link in which we can call java public method from javascript but I want to know that how can i call same method if I m specifying jar file thru jnlp file in html code.
this is the link,u will find tht how can u create an object and call public method of java file.
but i need ideas with jar file.
Regards
yogesh
|
|
|
|
|
Hello guys
I got it .
To control java methods with javaScript code when u have jar file then just define ur applet tag in html like this
<applet code = 'packageName.MainClassName'
archive = 'test.jar',
id='viewer',
width = 200,
height = 200 />
</applet>
<input type="button" value="Animate" onClick="pass();">
function pass()
{
var tViewer = document.getElementById('viewer');
tViewer.methodName();
}
Like this,u can call whatever method u want to call.
|
|
|
|
|
I want a Javascript code for my webpage, which performs following action:
resize window to (100, 100)
disable any further Resizing,
disable toolbars,
disable scrolling....
Actually a code which forces the user to close the window.....
It become difficult for him to proceed further...
Please help me..please
|
|
|
|
|
sangeeta2009 wrote: I want a Javascript code for my webpage
This is the Java forum; try elsewhere.
It's time for a new signature.
|
|
|
|
|
|
Hello,
I am trying to do a Shorst Remaning Time First Algorithm in java. I need help on how i can start implemnting.
Thank you
|
|
|
|
|
Blackberry89 wrote: I need help on how i can start
Start with a better question; this one is not very clear.
It's time for a new signature.
|
|
|
|
|
i have got 5 randomly generated numbers in a queue. I want the smallest number in the queue to be displayed. After this another random number will be generated and i want it to be compared against the queue and from that the smallest number be displayed. The code so far is below:
import java.util.ArrayList;
import java.util.Iterator;
public class Assign1 {
private final int MAX_QUEUE_SIZE = 5;
private final int NO_SIMULATIONS_TO_RUN = 7;
private int maxSize;
private double[] queArray;
private int nItems;
public static void main( String args[] ) {
new Assign1().runSimulation();
}
public void runSimulation() {
PriorityQueue queue = new PriorityQueue();
initQueue(queue);
for (int i = 0; i < NO_SIMULATIONS_TO_RUN; i++) {
System.out.println( "The numbers in the queue are: " + queue.toString());
System.out.println( "The current dispatched number is " + queue.poll());
queue.remove();
int item = getRandomNumber();
System.out.println( "The new coming number is " + item );
queue.add(item);
System.out.print( "\n\n" );
}
}
private void initQueue(PriorityQueue queue){
for (int i = 0; i < MAX_QUEUE_SIZE; i++)
queue.add(getRandomNumber());
}
public static int getRandomNumber(){
return 1 + ( int ) ( Math.random() * 100 );
}
private class PriorityQueue extends ArrayList {
public void add(int val){
super.add(new Integer(val));
}
public int poll(){
return ((Integer) iterator().next()).intValue();
}
public String toString(){
StringBuffer buff = new StringBuffer();
Iterator it = iterator();
buff.append("[");
while (it.hasNext()) {
buff.append(it.next());
if (it.hasNext())
buff.append(", ");
}
buff.append("]");
return buff.toString();
}
public void remove(){
if (!isEmpty())
remove(0);
}
}
}
|
|
|
|
|
so your method poll() should give the smallest number in the Array. OKOK.
You need to compare the numbers in your Array, start with first number and compareTo the other numbers - as long as you do not find a smaller number. IF so, use this number as comparsion and continue. When you reach the end of the Array the comparsion should be the number searched for.
shouldn*t be that hard to figure out
Remember to modify the mechanism for the exchange of the found number.
greets
Torsten
I never finish anyth...
|
|
|
|
|
yes, try to define your question. An programm needs more explanation.
Try to make a plan:
- what is your goal?
- which parameter is able to give to an decision on my goal?
- How can i get this parameter?
- which other points must I consider (GUI, special framework, ...) ?
I never finish anyth...
|
|
|
|
|
hi all ! i'm in need of source code (working)in java for encrypting and decrypting an image(be it any format).gif,jpeg,png etc......
or any link directing to the download of the same is also appreciated..
or members can directly mail to my id glinseynew@gmail.com (its preferrable to post it on to group so that others like me are also benifitted )
many thanks for ur help ...
plz do reply @ earliest
thanking u inanticipation..
glinsey
|
|
|
|
|
See here[^], tutorials on all aspects of Java. Also try a Google search.
It's time for a new signature.
|
|
|
|
|
Hello,
I have got two arrays one called NB(number of memory blocks) and the other called NJ(number of Jobs). I want the NB arrays to search through the jobs and find a job that is <= to the block. So for example if i had:
Blocks
800
300
750
200
Jobs
200
720
900
500
The 200 jobs should look the the blocks list and fit memory that best fits it, in this case that would be block 200. And job 720 should look through the list and instead of going to block 800 it should go to memory 750 as it best fits it.
Here is my code below so far:
import java.util.*;
public class BestFit
{
public static final int NJ = 5;
public static final int NB = 5;
public static void main(String[] args) {
int [][] Jobs = new int [NJ][2];
int [][] block = new int [NB][2];
Random random = new Random();
for(int i=0; i<NJ; i++){
Jobs[i][0] = -1;
Jobs[i][1] = 100 + random.nextInt(900);
}
for(int i=0; i<NB; i++){
block[i][0] = -1;
block[i][1] = 100 + random.nextInt(900);
}
for(int i=0; i<NJ;i++){
for(int j=0; j<NB; j++){
if(Jobs[i][1] <= block [j][1] && block[j][0] == -1 && Jobs[i][0] == -1){
block[j][0] = i;
Jobs[i][0] = j;
System.out.println("Job" + Jobs[i][1] + " in memory" + block[j][1]);
}
}
}
for(int i=0; i<NJ; i++){
System.out.println("Job [" + i +"][0] = " + Jobs[i][0]);
System.out.println("Job [" + i +"][1] = " + Jobs[i][1]);
}
for(int i=0; i<NB; i++){
System.out.println("block [" + i +"][0] = " + block[i][0]);
System.out.println("block [" + i +"][1] = " + block[i][1]);
}
}
}
thanks for all help
|
|
|
|
|
You only hit the first possible block. Not ideal but a simple solution is to check each hit if it is smaller than a previous one:
for(int i=0; i<NJ;i++){
int smallest = -1;
for(int j=0; j<NB; j++){
if(Jobs[i][1] <= block [j][1] && block[j][0] == -1 &&
(smallest == -1 || block[j][1] < block[smallest][1]))
{
smallest=j;
}
}
if (smallest >-1) {
block[smallest][0] = i;
Jobs[i][0] = smallest;
System.out.println("Job" + Jobs[i][1] + " in memory" + block[smallest][1]);
}
}
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
Thanks a lot..it works perfectly
|
|
|
|
|
hello guys..need ur help yet again..lolzz.....how can i resize buttons in java. Further more how can i make sizes of buttons B1, B2 and B3 according to the size of button B4??...thanx
|
|
|
|
|
|
Hello Friends
I created a Applet viewer in java using java3d sdk.Now I embed it into my site.I have questions:
1)If any user opens the viewer on his browser then how can I find that jre is installed on his machine or not?so that I can provide him link to install.
Regards
Yogesh
|
|
|
|
|
|
Hi,
Can I resize an image of shape diamond using swing?
Can I place a label inside the diamond image?
Label should be editable dynamically.
If it is possible, can you tell how to do this?
Thanks,
Janaki
|
|
|
|
|
Images are always square. You can resize them.
you can put an layer upon the image and place a textfield in there - yes - that's possible:
http://www.java2s.com/Code/Java/Swing-JFC/Panelwithbackgroundimage.htm
http://www.javalobby.org/articles/ultimate-image/
greets
Torsten
I never finish anyth...
|
|
|
|
|
Hi,
Thnx for ur reply.
Dynamically system has to allow to resize the image of shape Diamond.
If I try to resize it from left, it will increase the size of image only in left side and its has to do that side only.
But the shape will be changed right?
What to do in this situation?
Placing a Label inside an image:
Here the diamond shape image has background where the label doesn't.
In this case also is it possible?
Thanks
Janaki
|
|
|
|