Results 1 to 5 of 5
  1. #1
    mr.suchy is offline Member
    Join Date
    Feb 2013
    Posts
    17
    Rep Power
    0

    Default Example application with standard option

    Hi,

    Maybe the title don't say what I want to but I try explain it. I'm learning java and I did a few tutorial with SWING but nowhere I can't find tutorial where is describe simple application with two option and when I choose one of them I see new window inside this frame. Did I express clear ? Another words, I dont know how write app and open new option, section in the same windows as main. Thanks for help.

    Best regards.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Example application with standard option

    There will be no tutorial for this specific problem. Instead you need to find tutorials for individual components of your problem and then synthesize it all together yourself. I'd look at using a CardLayout, and the tutorial on that (Google can help you find it), should help.

  3. #3
    mr.suchy is offline Member
    Join Date
    Feb 2013
    Posts
    17
    Rep Power
    0

    Default Re: Example application with standard option

    This is what I need. Thanks for help.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Example application with standard option

    Quote Originally Posted by mr.suchy View Post
    This is what I need. Thanks for help.
    You're welcome! Please come on back if you have a problem with your code or project.

  5. #5
    mr.suchy is offline Member
    Join Date
    Feb 2013
    Posts
    17
    Rep Power
    0

    Default Re: Example application with standard option

    Hi,

    Right now I have a simple code whic generate a window with with two card. I dont know how can I do include another class ex. NewPanel.java in one of this card.

    Aplikacja.java
    Java Code:
    import java.awt.CardLayout;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JPanel;
    
    public class Aplikacja extends JFrame {
    
    	private static final long serialVersionUID = -4575271483481196192L;
    
    	Container pane;
    	CardLayout layout;
    
    	public Aplikacja() {
    
    		layout = new CardLayout();
    		setLayout(layout);
    
    		pane = this.getContentPane();
    
    		JPanel newPanel = new JPanel();
    		pane.add("New", newPanel);
    		JButton przycisk = new JButton("Przycisk");
    		newPanel.add(przycisk);
    
    		JPanel loadPanel = new JPanel();
    		pane.add("Load", loadPanel);
    
    		JPanel savePanel = new JPanel();
    		pane.add("Save", savePanel);
    
    		JMenuBar menuBar = new JMenuBar();
    		JMenu menuPlik = new JMenu();
    		JMenu menuPomoc = new JMenu();
    		JMenuItem menuPomocOProgramie = new JMenuItem();
    		JMenuItem menuPlikNew = new JMenuItem();
    		JMenuItem menuPlikLoad = new JMenuItem();
    		JMenuItem menuPlikExit = new JMenuItem();
    
    		menuPlik.setText("Plik");
    		menuPlikNew.setText("Opcja 1");
    		menuPlikLoad.setText("Opcja 2");
    		menuPlikExit.setText("Wyjdź");
    
    		menuPomoc.setText("Pomoc");
    		menuPomocOProgramie.setText("O programie");
    
    		menuPlikExit.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent e) {
    				Aplikacja.this.windowClosed();
    			}
    		});
    
    		menuPlikNew.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent e) {
    				layout.show(pane, "New");
    			}
    		});
    		menuPlikLoad.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent e) {
    				layout.show(pane, "Load");
    			}
    		});
    		menuPlik.add(menuPlikNew);
    		menuPlik.add(menuPlikLoad);
    		menuPlik.add(menuPlikExit);
    		menuBar.add(menuPlik);
    		menuBar.add(menuPomoc);
    		menuPomoc.add(menuPomocOProgramie);
    
    		setTitle("Aplikacja v0.1");
    		setJMenuBar(menuBar);
    		setSize(new Dimension(640, 480));
    
    		this.addWindowListener(new WindowAdapter() {
    			public void windowClosing(WindowEvent e) {
    				Aplikacja.this.windowClosed();
    			}
    		});
    	}
    
    	protected void windowClosed() {
    		System.exit(0);
    	}
    
    	public static void main(String[] arg) {
    		Aplikacja f = new Aplikacja();
    		f.setVisible(true);
    	}
    }
    When I write:

    Java Code:
    NewPanel zakladka = new NewPanel();
    I dont know how can I display everything from NewPanel.java into Aplikacja.java (in one of the car ex. "New").

    Thanks for help.

Similar Threads

  1. [Y/N] Option
    By OOO in forum New To Java
    Replies: 3
    Last Post: 03-24-2011, 10:49 PM
  2. Replies: 0
    Last Post: 03-15-2011, 03:48 AM
  3. JAX-WS\METRO - apt with option option key="r"
    By Talkinjive in forum Web Frameworks
    Replies: 0
    Last Post: 01-31-2010, 04:15 PM
  4. How to enable save as option in menu after the application has been launched
    By plenitude in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 12-26-2008, 09:31 AM
  5. Is JSP the right option?
    By Naga in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 08-20-2008, 06:48 AM

Tags for this Thread

Posting Permissions

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