mercredi 4 mars 2015

How to display a webpage in java



I know some already know how to, but I've seen the code and I can't get it to display on the Frame. I tested with lots of different codes but I can't simply get the EditorFrame to show up in the JFrame. (I'm a noob in Java, any help or advices is really appreciated!)


public class MainGui{



private JFrame frame;
/**
* Launch the application.
*/

public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MainGui window = new MainGui();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the application.
* @return
*/
public MainGui() {
initialize();
}

/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 1150, 700);
frame.setTitle("Game Launcher");
Image icono = Toolkit.getDefaultToolkit().getImage("ic.png");
frame.setIconImage(icono);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);

JLabel lblCurrentUserCyberdg = new JLabel("Current User: Cyberdg_");
lblCurrentUserCyberdg.setFont(new Font("Segoe UI", Font.PLAIN, 16));
lblCurrentUserCyberdg.setBounds(10, 11, 172, 22);
frame.getContentPane().add(lblCurrentUserCyberdg);

JLabel lblLauncherVersion = new JLabel("Launcher Version: 0.0.1-pre1");
lblLauncherVersion.setFont(new Font("Segoe UI", Font.PLAIN, 16));
lblLauncherVersion.setBounds(10, 44, 172, 22);
frame.getContentPane().add(lblLauncherVersion);

JLabel lblCurrentlyThereIs = new JLabel("Authentication System: Off");
lblCurrentlyThereIs.setFont(new Font("Segoe UI", Font.PLAIN, 16));
lblCurrentlyThereIs.setBounds(10, 77, 242, 22);
frame.getContentPane().add(lblCurrentlyThereIs);

JLabel lblVersionEditor = new JLabel("Version Editor");
lblVersionEditor.setFont(new Font("Segoe UI", Font.BOLD, 16));
lblVersionEditor.setBounds(10, 167, 126, 22);
frame.getContentPane().add(lblVersionEditor);

JLabel lblSelectedProfileDeafult = new JLabel("Selected profile: Default");
lblSelectedProfileDeafult.setFont(new Font("Segoe UI", Font.PLAIN, 16));
lblSelectedProfileDeafult.setBounds(10, 200, 172, 22);
frame.getContentPane().add(lblSelectedProfileDeafult);

JLabel lblGameVersion = new JLabel("Game Version: 1.8.3");
lblGameVersion.setFont(new Font("Segoe UI", Font.PLAIN, 16));
lblGameVersion.setBounds(10, 219, 143, 22);
frame.getContentPane().add(lblGameVersion);

JLabel lblWelcomeCyberdgReady = new JLabel(" Welcome, Cyberdg_! ");
lblWelcomeCyberdgReady.setFont(new Font("Segoe UI", Font.PLAIN, 16));
lblWelcomeCyberdgReady.setBounds(10, 493, 242, 22);
frame.getContentPane().add(lblWelcomeCyberdgReady);

JLabel lblReadyToPlay = new JLabel("Ready to play {gamename} 1.8.3!");
lblReadyToPlay.setFont(new Font("Segoe UI", Font.PLAIN, 16));
lblReadyToPlay.setBounds(10, 526, 229, 22);
frame.getContentPane().add(lblReadyToPlay);

Scrollbar scrollbar = new Scrollbar();
scrollbar.setBackground(Color.WHITE);
scrollbar.setBounds(1117, 0, 17, 641);
frame.getContentPane().add(scrollbar);

JButton btnNewButton = new JButton("Play");
btnNewButton.setFont(new Font("Segoe UI", Font.PLAIN, 16));
btnNewButton.setBounds(10, 555, 242, 75);
frame.getContentPane().add(btnNewButton);

JMenuBar menuBar = new JMenuBar();
frame.setJMenuBar(menuBar);

JMenu mnAbout = new JMenu("About");
menuBar.add(mnAbout);

JMenuItem mntmLauncherVersion = new JMenuItem("Launcher Version");
mnAbout.add(mntmLauncherVersion);

JMenuItem mntmDevInfo = new JMenuItem("Dev Info");
mnAbout.add(mntmDevInfo);
}


}




Aucun commentaire:

Enregistrer un commentaire