Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,174,159 members, 7,890,924 topics. Date: Tuesday, 16 July 2024 at 01:29 AM

Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? - Programming (2) - Nairaland

Nairaland Forum / Science/Technology / Programming / Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? (6296 Views)

100+ Java, JS & JSP Apps With Their Source Code That You Can Make Money With / How To Make Money From Developing Software Using Vb Or Java / JSP Web Development (2) (3) (4)

(1) (2) (Reply) (Go Down)

Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by sayhi2ay(m): 3:03pm On Jul 12, 2008
sbucareer:


sayhi2ay

Ok, you have learned that yeah, and certain that a variable declared without an identifier is automatically declared private by the JVM. Thank you sayhi2ay for that info.



without an "access specifier",

anyways, its just programming style, nothing to it , you can always put "private" so people would know you really want it private,
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by malone5923(m): 8:49pm On Jul 12, 2008
Just want to share this piece of code with Java enthusiast. It is about Desktop programming. Mind you this code is not compiled or tested. It was typed directly onto the forum message editor. If it doesn't compile when you copy and paste it, you would need to debug it.



package Phone;

import javax.swing.UIManager;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
import javax.swing.text.*;

public class MobilePhoneApplication extends JPanel{

private JPanel mainPanel;
private JPanel display;
private JPanel keyPads;
private JPanel keyControls;

private JTextArea textArea;

private JButton call;
private JButton end;

private ActionListener listener;
private DocumentListener docuListen;
private Document jDocument;


public MobilePhoneApplication (ActionListener listener, DocumentListener docuListen){

try{
UIManager.setLookAndFeel
( UIManager.getSystemLookAndFeelClassName() );
}catch(Exception e ){
}//End try
this.listener = listener;
this.docuListen = docuListen;

mainPanel = new JPanel();
display = new JPanel();
keyPads = keyPads();
keyControls = new JPanel();

keyControls.setLayout ( new FlowLayout( ) );

call = new JButton( "Call"wink;
end = new JButton ( "End" );
keyControls.add ( call );
keyControls.add ( end );

display.setLayout ( new GridLayout (1, 1));
textArea = new JTextArea();
textArea.setEditable ( false );
textArea.getDocument().addDocumentListener (docuListen);
textArea.setForeground ( new Color (255, 50 , 10 ));
textArea.setFont ( new Font ("Dialog", Font.BOLD, 24 ));
display.add ( textArea );

mainPanel.setLayout( new GridLayout(3, 1) );
mainPanel.add ( display );
mainPanel.add ( keyControls );
mainPanel.add ( keyPads );

call.setActionCommand ( "Call" );
end.setActionCommand ("End" );
call.addActionListener (listener);
end.addActionListener ( listener );

this.add( mainPanel );

}//End MobilePhoneApplication Constructor


private JPanel keyPads (){
String values[] = {"1", "ABC2", "DEF3",
"GHI4", "JKL5", "MNO6",
"PQRS7", "TUV8", "WXYZ9",
"*", "0+", "#" };
JPanel toReturn = new JPanel();
toReturn.setLayout (new GridLayout(4, 3));
JButton keys[] = new JButton[values.length];

for ( int index1 = 0; index1 < keys.length; index1++ ){
keys[index1] = new JButton ( values[index1] );
}//End for

for (int index = 0; index < values.length; index++){
//keys[index].setText( values[index] );
keys[index].setActionCommand(values[index]);
keys[index].addActionListener(this.listener);

toReturn.add(keys[index]);
}//End for

return toReturn;

}//End keyPads method

public JTextArea getTextArea (){
return textArea;
}//End getTextArea

public void show(String string ){
textArea.setText( string );
}//End show

public void defaultMenu ( boolean set){

call.setEnabled ( set );
end.setEnabled ( set );
}//End defaultMenu

//Test if the TextArea has any test
public boolean hasChar(){
jDocument = textArea.getDocument();
return ( jDocument.getLength() != 0 );
}//End hasChar

public void clear (){
String text = textArea.getText();
text = null;
textArea.setText (text );
}//End clear
}//End MobilePhoneApplication

Sbucareer or javaprince if is not going to be much of a problem, can you please type the errors you might have received for the first code I just want to know if I can debug it. I should have done it myself but the computer I am currently using doesnt have a compiler.
Well if is going to be a problem I can always wait till I get home and use my own computer(which has a compiler).
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by sbucareer(f): 9:19pm On Jul 12, 2008

malone5923,

Asfar as I know all the current codes above are fully debugged and fully functional. Copy and paste it in a text editor like Notepad or WordPad and save them as .java respectively and run.

Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by malone5923(m): 9:52pm On Jul 12, 2008

malone5923,

Asfar as I know all the current codes above are fully debugged and fully functional. Copy and paste it in a text editor like Notepad or WordPad and save them as .java respectively and run.
As I said earlier I dont have a compiler right now but I will appreciate it if you post the executable file I only have a runtime. Thanks.
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by sbucareer(f): 10:10pm On Jul 12, 2008


Here is the bytecode and a HTML file to run with AppletViwer

Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by malone5923(m): 10:32pm On Jul 12, 2008
I cant run the applet I used IE and Mozzila, am I missing something though I got an exception stating that the runtime could not locate the class file
Note: I have downloaded the class, this are the errors. Please be patient with me.
Java Plug-in 1.6.0_05
Using JRE version 1.6.0_05 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Administrator


----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
p: reload proxy configuration
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

load: class MobilePhoneApplicationGUI.class not found.
java.lang.ClassNotFoundException: MobilePhoneApplicationGUI.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by malone5923(m): 10:44pm On Jul 12, 2008
I do you create a package without a compiler .
If I am getting it all wrong please explain in details.
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by sbucareer(f): 10:52pm On Jul 12, 2008

I have explained it above. How to create a pacakge.
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by malone5923(m): 11:28pm On Jul 12, 2008
Sorry, I just saw the modifications you made to your previous post, It wasnt much help why because as I stated earlier I don't have a Compiler to make changes to the java file. But the link worked well(I guess thats Ok). Thanks
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by sbucareer(f): 9:51am On Jul 13, 2008


This is the MobilePhoneApplicationGUI

package Phone;

import javax.swing.UIManager;
import java.awt.event.*;
import javax.swing.JApplet;
import javax.swing.JFrame;
import javax.swing.event.*;

public class MobilePhoneApplicationGUI extends JApplet
implements ActionListener, DocumentListener{

private MobilePhoneApplication mobile;

public MobilePhoneApplicationGUI(){

mobile = new MobilePhoneApplication(this, this);
mobile.defaultMenu(MobilePhoneApplication.FALSE);
this.init();
}//End MobilePhoneApplicationGUI

public void init(){

this.getContentPane().add(mobile);
}//End init

public void actionPerformed (ActionEvent event ){

String source = event.getActionCommand();

if( source.equals ( "Call" )){
mobile.clear();
mobile.show("connecting, "wink;
mobile.enableCall(MobilePhoneApplication.FALSE);
mobile.setButtons(MobilePhoneApplication.FALSE);
mobile.enableEnd(MobilePhoneApplication.TRUE);
}else if (source.equals ( "End" )){
mobile.clear();
mobile.defaultMenu(MobilePhoneApplication.FALSE);
mobile.setButtons(MobilePhoneApplication.TRUE);
}else if ( source.equals ( "1" )){
mobile.show("1"wink;

}else if ( source.equals ( "ABC2" )){

mobile.show("2"wink;
}else if ( source.equals ( "DEF3" )){
mobile.show("3"wink;

}else if ( source.equals ( "GHI4" ) ){
mobile.show("4"wink;

}else if ( source.equals ( "JKL5" ) ){
mobile.show("5"wink;

}else if ( source.equals ( "MNO6" )){
mobile.show("6"wink;

}else if ( source.equals ( "PQRS7"wink ){
mobile.show("7"wink;

}else if (source.equals ("TUV8"wink){
mobile.show("8"wink;

}else if ( source.equals ( "WXYZ9"wink){
mobile.show("9"wink;

}else if (source.equals ("*" )){
mobile.show("*"wink;

}else if ( source.equals ("0+" )){
mobile.show("0"wink;

}else if (source.equals ( "#"wink){
mobile.show("#"wink;
}else{
mobile.show("You stole this phone!"wink;

}//End if

}//End actionPerformed

public void changedUpdate (DocumentEvent e ){
}//End changedUpdate

public void insertUpdate (DocumentEvent e){
if ( mobile.hasChar() )
mobile.defaultMenu(MobilePhoneApplication.TRUE);
mobile.enableEnd(MobilePhoneApplication.FALSE);

}//End insertUpdate

public void removeUpdate (DocumentEvent e ){
}//End removeUpdate

public static void main (String args[]){

JFrame frame = new JFrame("Mobile Phone"wink;
MobilePhoneApplicationGUI demo = new MobilePhoneApplicationGUI();

frame.getContentPane().add (demo);
frame.setSize(230, 600);
frame.setLocation(550, 100);
frame.setResizable(MobilePhoneApplication.FALSE);
frame.setVisible(MobilePhoneApplication.TRUE);
frame.pack();
frame.show();

/*frame.addActionListener(new ActionListener (){
public void actionPerformed (ActionEvent e ){
System.exit(0);
}});
*/
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
}//End main

}//End MobilePhoneApplicationGUI

Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by javaprince(m): 7:14pm On Jul 13, 2008
sbu Have done has u sent.
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by sayhi2ay(m): 7:24pm On Jul 13, 2008
java genius!


if you keep privatizing all your declarations, then we wont be able to extend your classes and methods,
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by sbucareer(f): 9:17pm On Jul 13, 2008

sayhi2ay

You can always use a callback methods. That is the whole point of it, to stop your code looking like spaghetti.

Remember software cohession. Sorry, I am used to software developing to programming.
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by sayhi2ay(m): 9:30pm On Jul 13, 2008
and if you want to extend classes or methods in the same code ?
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by sayhi2ay(m): 9:37pm On Jul 13, 2008
if you are extending the attributes of a class to another class in the same code ? you are just calling a method in the code you wrote,
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by sbucareer(f): 9:43pm On Jul 13, 2008

You do not extend attributes of any class in Java instead you inherit the public attributes and methods of a super class or protected methods and attributes of the same class package.

private attributes makes your variable immutable by any inquiring accessor, you only expose them by using callbacks.Java calls them setter and getter, i.e let take a variable int qty


//callbacks
int getQty(){return qty;}
void setQty (int qty) {this.qty = qty;}

their first name must start with set for mutable and get immutable
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by sayhi2ay(m): 9:47pm On Jul 13, 2008
exactly, if you keep declaring them as privates, then we will never get to inherit anything right ?
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by sbucareer(f): 10:09pm On Jul 13, 2008
javaprince:
sbu Have done has u sent.


I seriously do not understand that statement
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by candylips(m): 10:22pm On Jul 13, 2008
Oh no i thought we were speaking JSF and JSP here . it will be nice if we stick to the topic

@mydevbox
Majority of the JSF components i see out there are just JSP taglib clones.

I was hoping JSF was going to give us a visual studio style programming model.
Not some Ajax enabled components for things like table rendering, autocompletion and things like this.

I hope the technology keeps improving though. . . . but for now i'm gonna be sticking with good ol jsp and velocity templetes
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by sbucareer(f): 10:30pm On Jul 13, 2008

candylips, we are coming to it, I was trying to demonstrate desktop application development by request. Later we can see how we could use XML with JSF on desktop application development to modify MobilePhoneApplication software above.

Do you stay @ Eltham?

Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by candylips(m): 10:46pm On Jul 13, 2008
alright cool.
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by sayhi2ay(m): 12:43pm On Jul 14, 2008
when you declare a variable as private, it would never be inherited by its children, ok, unless you play some other tricks, not trying to be funny, do u get what am trying to say ?

if you have a daddy class, then variables last name, first name, sex, address, age and so on, dont need to be declared again in the son class right? you can just inherit all the declarations by using son() extends daddy(), disregard the format, which is not complicatedly possible by used 'protected'
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by sayhi2ay(m): 12:46pm On Jul 14, 2008
hey! have you seen the source code of inbuilt methods?
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by logica(m): 4:02pm On Jul 14, 2008
what's all this crap? did somebody miss the intended thread?
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by javaprince(m): 5:59pm On Jul 14, 2008
@sbucareer
Yes, I was talking about ur quote earlier on when u said I should re-MODIFY my code. But never mind.

@logica
I think u are right. May be we should start a new topic on this, and then sbucareer can teach/explain the concepts of Desktop to beginning Java Programmer. Posting it here is actually truly MISLEADING, but really No one is really HURT.!!!

@sayhi2ay
Try and go through the concepts of Scope very very well. Seems u have misunderstood it.
private variables/methods - can only be accessed within the class they are declared.
protected variables - can only be accessed by classes that inherit the class(i.e subclass) and classes in the same package
package acess - this is the default when u don't specify anythin, - can only be accessed by Classes in the same PACKAGE.
public - can be accessed by all.

Hope u Understand better.
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by sbucareer(f): 5:09am On Jul 18, 2008

Nobody has come up with solutions for the delete button and clear button. What a programmers indeed?
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by javaprince(m): 10:09am On Jul 18, 2008
@sbucareer
Promise u i'll look into a solution for it. Internship as been so busy and almost sucking my heads off. The "mail sent stuff', how far "journey"
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by sbucareer(f): 10:59am On Jul 18, 2008

But I have given you a head start here
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by sbucareer(f): 7:39pm On Jul 23, 2008

Look at them, they have all chickened out. Teach me Java, teach me to program. I am this and that simple delete function no one could even try to complete it. I am very disappointed.

Go on; learn needlework, programming is NOT for everybody the sooner you get it the better for you. Chickens!!! Quak! Quak!! Quak!!!
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by javaprince(m): 9:49am On Jul 24, 2008
@sbucareer
LOL.
Never even knew there was a problem that needed soln in the first place. Its hard to follow the topic. Would have tried on it though. Advise, start a new thread for this, and I promise to try and follow and solve questions.
Re: Java Server Pages (jsp) Or Java Server Face(jsf Which Path To Trend? ? ? ? by candylips(m): 2:35pm On Jul 24, 2008
I think we need a moderator for the programming section. I am tired of people hyjacking threads. This thread was supposed to be about jsp and jsf and then unrelated stuff started cropping up.

I am not against posting of code but people should try to stick to what the thread is all about. If you have something different to say why not open a new thread. It doesnt get easier than that

(1) (2) (Reply)

Certified-drugs App: List Of All Drugs Approved For Use In Nigeria By NAFDAC / Vb.net Crystal Report & Dataset / [Help Request ] I Want To Learn Programming, what are the requirements

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 47
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.