Results 1 to 5 of 5
- 02-19-2013, 08:40 AM #1
Member
- Join Date
- Feb 2013
- Posts
- 15
- Rep Power
- 0
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.
-
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.
- 02-20-2013, 09:35 AM #3
Member
- Join Date
- Feb 2013
- Posts
- 15
- Rep Power
- 0
Re: Example application with standard option
This is what I need. Thanks for help.
-
- 03-11-2013, 10:17 AM #5
Member
- Join Date
- Feb 2013
- Posts
- 15
- Rep Power
- 0
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
When I write: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); } }
I dont know how can I display everything from NewPanel.java into Aplikacja.java (in one of the car ex. "New").Java Code:NewPanel zakladka = new NewPanel();
Thanks for help.
Similar Threads
-
[Y/N] Option
By OOO in forum New To JavaReplies: 3Last Post: 03-24-2011, 10:49 PM -
ResourceBundle not working for applet, only for standard application
By DerekRaimann in forum New To JavaReplies: 0Last Post: 03-15-2011, 03:48 AM -
JAX-WS\METRO - apt with option option key="r"
By Talkinjive in forum Web FrameworksReplies: 0Last Post: 01-31-2010, 04:15 PM -
How to enable save as option in menu after the application has been launched
By plenitude in forum Enterprise JavaBeans (EJB)Replies: 1Last Post: 12-26-2008, 09:31 AM -
Is JSP the right option?
By Naga in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 08-20-2008, 06:48 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks