Problemas con los frames

Hola! Me han pasado el código para hacer un menú dinámico en java y mi página tiene frames. El menu está colocado en uno de ellos. En el menu hay referencias a otras páginas y el problema es que cuando se abren esas páginas se abren en ese frame del menu y quiero se se abra un ventana nueva. Espero que me hayáis entendido y me podáis ayudar. No tengo mucha idea de java.

2 Respuestas

Respuesta
1
No preocupes, en java recuerda que todos son objetos.
Se pueden crear dependiendo de que clase extiendan.
Tal vez lo que tu quieres es algo como esto.
Checalo y me dices si te sirvió.
//Programa 1. Principal
import java.awt.*;
import java.awt.event.*;
public class TestWindows extends Frame{
Button btn = new Button("Aceptar");
Label lbl = new Label("Crea ventana");
public TestWindows(){
setLayout(new BorderLayout());
btn.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
createDialog();
}
}
);
add("North",btn);
add("South",lbl);
}
public void createDialog(){
new TestDialog(this);
}
public static void main(String args[]){
TestWindows temp = new TestWindows();
temp.addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent ev){
System.exit(0);
}
}
);
temp.setSize(100,75);
temp.show();
}
}
//Programa 2
import java.awt.*;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;
import java.util.Vector;
public class TestDialog extends Dialog{
Vector vct, vct2 = new Vector();
Label label = new Label ("Hola como estas");
public TestDialog(Frame frame){
super(frame,"Test Dialog",false);
setLayout(new BorderLayout());
add("Center",label);
addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent ev){
dispose();
}
}
);
show();
}
}
Compilalos y ejecucalos y revisa si el funcionalidad que tu quieres son que con menús.
Saludos y me dices si te sirvió o era otra cosa.
P.D. Perdona la tardanza
Respuesta
El problema es que el menu de java esta hecho para que actue por si solo en un frame, por lo que habra que retocar el codigo del mismo...
Si tienes los .java tienes que buscar el sitio donde se dice que se abran las paginas en la propia pagina y cambiarlo por el nombre del frame donde quieres que se abra.
Si no tienes los .java, no importa, ya que hay "decompiladores" que te dan los .java a partir de los .class
Con los .java modificados, tienes que volver a compilarlos y listo.
Intentalo y si no puedes, mandame el .jar o lo que tengas y el nombre del frame en el que quieres que se abran las paginas.
te envio el codigo, a ver si puedes ayudarme porque no encuentro el problema. quien me lo ha pasado me ha dicho que lo ha copiado de www.ferpol.com/dynamicsubmenu.htm
GRACIAS
<style type="text/css">
<!--
a.bi{
background-color:darkcyan;
color:#ffffff;
display:block;
font-family: MS Sans Serif,sans-serif;
font-size:8pt;
font-weight:bold;
padding:3px 3px 3px 3px;
text-decoration:none;
border-color: #225555 #000000 #000000 #225555;
border-style:solid;
border-width:2px;
}
a.bi:hover{
background-color:#f8f8f8;
color:darkred;
}
a.mi{
background-color:darkred;
color:#ffffff;
display:block;
font-family:MS Sans Serif,sans-serif;
font-size:8pt;
font-weight:bold;
padding: 2px 2px 2px 4px;
text-decoration:none;
}
a.mi:hover{
background-color:#f8f8f8;
color:darkred;
}
.mn{
background-color:darkred;
border-color: #225555 #000000 #000000 #225555;
border-style:solid;
border-width:2px;
z-index:100;
}
.sp{
BORDER-TOP:#000000 1px solid;
MARGIN:2px;
BORDER-BOTTOM:#225555 1px solid
}
//-->
</style>
<!--paste above inbetween your head tags-->
<!--Past below inbetween your body tags-->
<script language="JavaScript">
<!--//
var D6=window,Y7=document;
function
B8(){this.ver=navigator.appVersion;this.agent=navigator.userAgent;this.dom=Y7.getElementById?1:0;th
is.opera5=this.agent.indexOf("Opera 5")>-1;this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom &&
!this.opera5)?1:0;this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom &&
!this.opera5)?1:0;this.ie4=(Y7.all && !this.dom &&
!this.opera5)?1:0;this.ie=this.ie4||this.ie5||this.ie6;this.mac=this.agent.indexOf("Mac")>-1;this.n
s6=(this.dom && parseInt(this.ver)>=5)?1:0;this.ns4=(Y7.layers &&
!this.dom)?1:0;this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5);return
this}bw=new B8();z=0;b=0;g="";if(bw.opera5||bw.ns6){b=2};if(bw.ie){g=" style='width:
100%'"}else{z=6}mt=70;ml=10;w=129;mh=23;mw=ml-w;k=0;mt=mt-z;p="<a class='mi'"+g+" href='";q="'
title='";r="\"; return true' onmouseout='window.status=\"\"; return true'>";t="</a>";a="'
onmouseover='window.status=\"";v="<div class=sp></div>";
m=new Array();n=new Array();s=new Array();sw=new Array();su=new Array();st=new Array()
m[0]='Mi familia';n[0]='#';sw[0]=120;su[0]='Mi familia';st[0]="";s[0]=""
+p+"lucia.html"+q+"eva"+a+"mi sobrina"+r+"mi sobrina"+t
+p+"practica1.html"+q+a+"mi novio"+r+"mi novio"+t
m[1]='fotos';n[1]='#';sw[1]=140;su[1]='fotos';st[1]="";s[1]=""
+p+"http://www.pozoseco.com"+q+a+"pueblo"+r+"pueblo"+t
+p+"practica2.html"+q+a+"familia"+r+"familia"+t
m[2]='';n[2]='#';sw[2]=130;su[2]='';st[2]="";s[2]=""
+p+"page.html"+q+a+""+r+""+t
+p+"page.html"+q+a+""+r+""+t
+p+"page.html"+q+a+""+r+""+t
+p+"page.html"+q+a+""+r+""+t
m[3]='';n[3]='#';sw[3]=130;su[3]='';st[3]="";s[3]=""
+p+"page.html"+q+a+""+r+""+t
ma=m.length
if (k==1) {mw2=ml-w;
for (i=0; i < ma; i++){document.write("<div id='sb"+i+"' class='mn' style='position: absolute;
top:"+(mt+mh)+";left:"+(mw+=w+2)+";width:"+(sw-b)+"' onmouseover='o["+i+"].showIt()'
onmouseout='o["+i+"].hideIt()'>"+s+"</div>")}
for (i=0; i < ma; i++){document.write("<div style='position: absolute;
top:"+mt+";left:"+(mw2+=w+2)+";width:"+w+"' onmouseover='o["+i+"].showIt()'
onmouseout='o["+i+"].hideIt()'><a class='bi'"+g+" href='"+n+q+st+a+su+r+m+t+"</div>")}}
else {mw2=mt-mh;mt2=mt-mh+2
for (i=0; i < ma; i++){document.write("<div id='sb"+i+"' class='mn' style='position: absolute;
top:"+(mt2+=(mh+1))+";left:"+(ml+w-10)+";width:"+sw+"' onmouseover='o["+i+"].showIt()'
onmouseout='o["+i+"].hideIt()'>"+s+"</div>")}
for (i=0; i < ma; i++){document.write("<div style='position: absolute;
top:"+(mw2+=(mh+1))+";left:"+ml+";width:"+w+"' onmouseover='o["+i+"].showIt()'
onmouseout='o["+i+"].hideIt()'><a class='bi'"+g+"
href='"+n+q+st+a+su+r+m+t+"</div>")}}
function lib_obj(obj,nest){nest=(!nest) ? "":'document.'+nest+'.';this.evnt=bw.dom?
document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document.layers."
+obj):0;this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt;this.ref=bw.dom||bw.ie4?document:this.css
.document;this.x=parseInt(this.css.left)||this.css.pixelLeft||this.evnt.offsetLeft||0;this.y=parseI
nt(this.css.top)||this.css.pixelTop||this.evnt.offsetTop||0;return this}
function lib_doc_size(){this.x=0;this.x2=bw.ie &&
document.body.offsetWidth-20||innerWidth||0;this.y=0;this.y2=bw.ie &&
document.body.offsetHeight-5||innerHeight||0;this.x50=this.x2/2;this.y50=this.y2/2;return this;}
lib_obj.prototype.showIt = function(){this.css.visibility="visible"}
lib_obj.prototype.hideIt = function(){this.css.visibility="hidden"}
function libinit(){page=new lib_doc_size();o=new Array();for (i=0; i < ma; i++){o=new
lib_obj('sb'+i);o.hideIt()}}
libinit();
//-->
</script>
Esto que me pasas es un menu en javascript, no en java, cosa que es muy diferente.
Pero bueno, la solucion pasa por ser la misma:
Si te fijas, se crean dinamicamente los links que se usan para ir a diferentes partes: los tags <a>
Estos tags tienen las direcciones de las paginas que se cargaran, pero no se les dice donde deben cargarse, por lo que toman la pagina en la que estan por defecto.
Esto se puede cambiar con la propiedad "target"
Si el frameset se llama frames.htm y los dos frames menu y main, para cargar en main los links de menu debes poner en todos los <a> target="main".
Si tienes dudas acerca de esta propiedad busca en google, que hay muchas cosas al respecto.
Si aun te quedan dudas, te arrglare uno a modo de ejemplo, ¿ok?

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas