SRL Archive - Help and Support

Java help...


NKN

2013-04-21 13:53:04

So… I have a lightweight component(JMenuBar), and a heavyweight(Runescape applet.)

I added the Runescape Applet to a JPanel, and the JPanel to the JFrame, and I set the JFrame's Menu bar to my JMenuBar.


When I open it, this happens:

Note how the menu opens UNDER the applet.


On the Oracle page, they said this was fixed.. but it's like, not?

How does one fix this.


Here's my code, I wrote it fast so like, don't worry about the quality. ;)
    public frame() throws Exception{
JFrame i = new JFrame("NKN's OldSchool Loader");
JLabel label = new JLabel();
JMenuBar menuBar= new JMenuBar();
JMenuItem items;
JPanel p = new JPanel();
LayoutManager ovr = new OverlayLayout(p);
p.setLayout(ovr);
JMenu menu = new JMenu("View");
menu.setMnemonic(KeyEvent.VK_V);
menuBar.add(menu);
ImageIcon icon = new ImageIcon(new URL(
"http://www.runescape.com/img/rsp777/oldschool_ani.gif"));
icon.setImageObserver(null);

items = new JCheckBoxMenuItem("Yaw");
items.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(!Vars.Yaw)
Vars.Yaw = true;
else
Vars.Yaw = false;
}
});
menu.add(items, 0);
menuBar.add(menu,0);
menuBar.setPreferredSize(new Dimension(763,20));
menuBar.setBounds(0, 0, 763, 20);


i.setJMenuBar(menuBar);
i.setResizable(false);
i.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
label.setIcon(icon);
p.add(label, 0);
p.setSize(new Dimension(763,650));
i.add(p,-1);
i.setPreferredSize(new Dimension(763,650));
i.setSize(i.getPreferredSize());
i.setVisible(true);
String str = getPageSource(new URL("http://oldschool38.runescape.com"));
Pattern pattern = Pattern.compile("gamep\\w+");
Matcher match = pattern.matcher(str);
if(match.find()){
frame stub = new frame(Pattern.compile("<param name=\"([^\\s]+)\"\\s+value=\"([^>]*)\">"), str);
Download("http://oldschool38.runescape.com/", match.group(0) + ".jar");
stub.setCodeBase(new URL("http://oldschool38.runescape.com/" + match.group(0) + ".jar"));
stub.setDocumentBase(new URL("http://oldschool38.runescape.com/" + match.group(0) + ".jar"));
stub.getParameter(parameters.get("java_arguments"));

CLASSES = parseJar(new JarFile("gamepack.jar"));
System.out.println(CLASSES.values().size() + " Classes parsed");
this.loadAnalysters();
this.runAnalysters();
updateJar(CLASSES, new JarFile("gamepack.jar"));
URLClassLoader classLoader = new URLClassLoader(new URL[] { new URL("file:injected.jar") });
Main.applet = (Applet) classLoader.loadClass("client").newInstance();
Main.applet.setStub(stub);
Main.applet.setPreferredSize(new Dimension(763, 504));
Main.applet.init();
Main.applet.start();

p.add(Main.applet);

i.add(p,-1);

label.setVisible(false);
}
}

@Brandon

JPHamlett

2013-04-22 01:23:58

Ummm, like maybe i.pack();


Haven't like worked with JFrame for a while.

NKN

2013-04-22 10:42:50

From: JPHamlett
Ummm, like maybe i.pack();


Haven't like worked with JFrame for a while.


Pyroryan helped me.

menu.getModel().isDefaultLightWeightEnabled(false);