Results 1 to 14 of 14
  1. #1
    spero33 is offline Member
    Join Date
    Feb 2014
    Posts
    4
    Rep Power
    0

    Post how to add website?

    Hello, im working on a program, but i have question and its. How can i add a website into one of my "JFrame" i have made?

    exampel i want to add google.com website into the fram called V2.
    HERE IS MY CODE:

    Java Code:
    package mittprogram;
    
    
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    
    //1. Create the frame.
    public class MittProgram {
    	
    
    
    public static void main(String[] args) {
    JFrame vindu = new JFrame("MittProgram");
    vindu.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    vindu.pack();
    vindu.setResizable(false);
    vindu.setSize(280, 360);
    vindu.setVisible(true);
    
    JLabel label = new JLabel();
    JPanel panel = new JPanel();
    vindu.add(panel);
    panel.add(label);
    
    
    panel.setBackground(Color.BLACK);
    
    JButton b1 = new JButton("FRONTER");
    b1.setBounds(12, 10, 250, 100);
    b1.setFont(b1.getFont().deriveFont(Font.BOLD | Font.ITALIC));
    b1.setFont(b1.getFont().deriveFont(18.0f));
    b1.setForeground(Color.RED);
    b1.setBackground(Color.GRAY);
    b1.addActionListener(new Action1());
    panel.add(b1);
    
    
    JButton b2 = new JButton("NDLA");
    b2.setBounds(12, 115, 250, 100);
    b2.setFont(b2.getFont().deriveFont(Font.BOLD | Font.ITALIC));
    b2.setFont(b2.getFont().deriveFont(18.0f));
    b2.setForeground(Color.RED);
    b2.setBackground(Color.GRAY);
    b2.addActionListener(new Action2());
    panel.add(b2);
    
    JButton b3 = new JButton("ARSENAL");
    b3.setBounds(12, 220, 250, 100);
    b3.setFont(b3.getFont().deriveFont(Font.BOLD | Font.ITALIC));
    b3.setFont(b3.getFont().deriveFont(18.0f));
    b3.setForeground(Color.RED);
    b3.setBackground(Color.GRAY);
    b3.addActionListener(new Action3());
    panel.add(b3);
    }
    
    //VINDU TIL FRONTER
    static class Action1 implements ActionListener {
    	public void actionPerformed (ActionEvent e){
    	
                try{		
                
                            JFrame v2 = new JFrame("fronter2");
                            v2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                            v2.pack();
    			v2.setSize(800, 800);
    			v2.setVisible(true);
                
             
                }
                catch(Exception ex){
                    
                }
                            
                            
                            
    		}
    	}
    //VINDU TIL NDLA
    static class Action2 implements ActionListener {
    	public void actionPerformed (ActionEvent e){
    			JFrame v3 = new JFrame("NDLA2");
    			v3.setSize(800, 800);
    			v3.setVisible(true);
    		}
    	}
    //VINDU TIL ARSENAL
    static class Action3 implements ActionListener {
    	public void actionPerformed (ActionEvent e){
    		JFrame v4 = new JFrame("Arsenal2");
    		v4.setSize(800, 800);
    		v4.setVisible(true);
    	}
    }
    }
    Last edited by spero33; 02-03-2014 at 01:33 PM.

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,277
    Rep Power
    6

    Default Re: how to add website?

    JFrame is not a browser.

    edit: JavaFX 2 does have certain webpage rendering capabilities in the form of javafx.scene.web.WebView, and it is possible to embed JavaFX 2 components in a Swing application. So if you would be inclined to research JavaFX 2, how to embed JavaFX 2 in Swing and how to specifically use the WebView component and embed it, maybe you might pull it off. But then you're restricted to Java 7 update 17 and up due to JavaFX 2 needing to be available.
    Last edited by gimbal2; 02-03-2014 at 05:45 PM.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: how to add website?

    A JEditorPane can display simple HTML. If that would meet your needs, here's an example that displays HTML from a local file: https://github.com/kjkrum/DarkMatter...itsWindow.java
    Get in the habit of using standard Java naming conventions!

  4. #4
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: how to add website?

    If you want to, you can parse the HTML yourself and display graphics on a JPanel.
    1000011 1100001 1101110 100000 1111001 1101111 1110101 100000 1110010 1100101 1100001 1100100 100000 1000010 1101001 1101110 1100001 1110010 1111001 111111

  5. #5
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,029
    Rep Power
    4

    Default Re: how to add website?

    Quote Originally Posted by zFollette View Post
    If you want to, you can parse the HTML yourself and display graphics on a JPanel.
    Basically you tell the guy to re-write Firefox, Chrome or IE? Well, that escalated quickly... [insert meme picture here]
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  6. #6
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: how to add website?

    Quote Originally Posted by SurfMan View Post
    Basically you tell the guy to re-write Firefox, Chrome or IE? Well, that escalated quickly... [insert meme picture here]
    Its been done. It's not out of the realm of possibilities. If you want something done right, do it yourself.
    1000011 1100001 1101110 100000 1111001 1101111 1110101 100000 1110010 1100101 1100001 1100100 100000 1000010 1101001 1101110 1100001 1110010 1111001 111111

  7. #7
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: how to add website?

    Reinventing the wheel is a sure way to never finish a project.
    Get in the habit of using standard Java naming conventions!

  8. #8
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: how to add website?

    Quote Originally Posted by kjkrum View Post
    Reinventing the wheel is a sure way to never finish a project.
    Re inventing the wheel is what makes it a 'project'. I agree that making a browser from scratch just to display a webpage is an awful idea. But if you want to make a modern browser for practical use, I say re invent the wheel. It would be a good learning experience.
    1000011 1100001 1101110 100000 1111001 1101111 1110101 100000 1110010 1100101 1100001 1100100 100000 1000010 1101001 1101110 1100001 1110010 1111001 111111

  9. #9
    Daryn is offline Senior Member
    Join Date
    Oct 2012
    Posts
    176
    Rep Power
    3

    Default Re: how to add website?

    If no one tried to reinvent the wheel they would still be made of stone
    With the right know how, anything is possible

  10. #10
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,277
    Rep Power
    6

    Default Re: how to add website?

    Yes that's true and a highly amusing statement, but the wheel is still not a highly complex monster that takes a whole team of people to not only design and build (possibly multiple times to match specific operating system designs) but then also maintain to keep it constantly up to date with modern and often changing requirements.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  11. #11
    Daryn is offline Senior Member
    Join Date
    Oct 2012
    Posts
    176
    Rep Power
    3

    Default Re: how to add website?

    not a highly complex monster? have you seen wheels today. a bycicle wheel has spokes to adjust, a car tire needs to be dynamically balancing and then whether there steel or aluminum depends varies were the waits are placed. casters must be greased. and three words ... monster truck tires
    With the right know how, anything is possible

  12. #12
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,029
    Rep Power
    4

    Default Re: how to add website?

    Quote Originally Posted by Daryn View Post
    not a highly complex monster? have you seen wheels today. a bycicle wheel has spokes to adjust, a car tire needs to be dynamically balancing and then whether there steel or aluminum depends varies were the waits are placed. casters must be greased. and three words ... monster truck tires
    That's where you are wrong. Those are all improvements and/or variations, not reinvented.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  13. #13
    Daryn is offline Senior Member
    Join Date
    Oct 2012
    Posts
    176
    Rep Power
    3

    Default Re: how to add website?

    Well then nothing is actually "reinvented" just improved and better advertised like when the ipad came out. Tablets have been around for years. Ipads did less than my tablet. But somehow they were revolutionary
    With the right know how, anything is possible

  14. #14
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,277
    Rep Power
    6

    Default Re: how to add website?

    Quote Originally Posted by Daryn View Post
    not a highly complex monster? have you seen wheels today. a bycicle wheel has spokes to adjust, a car tire needs to be dynamically balancing and then whether there steel or aluminum depends varies were the waits are placed. casters must be greased. and three words ... monster truck tires
    You make your point, yet I stick with mine regardless ;)
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 4
    Last Post: 07-02-2011, 04:28 AM
  2. Want to use OOP on my website
    By DoubleDee in forum New To Java
    Replies: 23
    Last Post: 09-11-2010, 01:55 AM
  3. What do I need to use this website?
    By ZachVK in forum Java Applets
    Replies: 27
    Last Post: 06-24-2010, 09:15 PM
  4. How to download website (Get all link in website)
    By finalmem in forum Advanced Java
    Replies: 0
    Last Post: 11-12-2008, 09:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •