LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-06-2005, 02:16 PM   #1
Diederick
LQ Newbie
 
Registered: Apr 2005
Posts: 25

Rep: Reputation: 15
Unhappy Help with Panels in Java please.


What i want to do is move from one frame to another like when you install a new software and you click on the next button. I am currently using an abstract class and override my drawPanel in each class that follows. The code that i have now is:

import javax.swing.*;

public abstract class Abs{
public abstract JPanel drawPanel();
}

AND


private JFrame frame;

SecondPage sp = new SecondPage(frame);

public FirstPage(JFrame f){
frame = f;
panel = new JPanel();
next = new JButton("Next");
pre = new JButton("Pre");
ActionListener nextL = new NextListener();
next.addActionListener(nextL);
}

public JPanel drawPanel(){

panel.add(pre);
panel.add(next);
return panel;
}

public class NextListener implements ActionListener{
public void actionPerformed(ActionEvent event){
frame.add(sp.drawPanel());
System.out.println("First Page Listener Next");
}
}
}


So can someone plaese help me or provide me with some source code to do this?

Thank You
Diederick
 
Old 07-07-2005, 03:44 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

This might be of interest:
http://java.sun.com/developer/techni.../swing/wizard/

Before you go that far, I'd definitely make sure you're comfortable programming a basic JFrame, first. Specifically:

1. Create a JFrame with a panel (for example, a scrollable text area) and a couple of buttons (for example, "Do Something" and "Quit")

2. Successfully lay out the controls on the JFrame (for example, change the default JFrame layout manager to a vertical BoxLayout, position the panel on the top, and center the buttons horizontall on the bottom).

3. Successfully display the JFrame (and the attached controls).

4. Successfully field events from the controls (for example, detect button clicks; handle "X" exit)

If you're unclear about any of these "basics", trying working through the Swing tutorials on http://java.sun.com.

You might also want to check out JavaRanch as another resource (in addition to LQ.org):

http://www.javaranch.com

'Hope that helps .. PSM
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
panels in enlightenment? echo_max Linux - Software 1 08-22-2005 01:52 AM
deleted panels bharatp Linux - Newbie 4 07-28-2005 10:21 AM
Java menus (radio buttons) and panels titanium_geek Programming 6 01-07-2004 11:13 AM
my panels are gone ... s9722 Linux - Software 10 05-29-2003 04:33 PM
panels s9722 Linux - Newbie 0 05-23-2003 01:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration