What is "hash code"?
hashCode() is available in most of the classes in Java API.
What is "hash code"?
Thanks!
From the page
http://java.sun.com/docs/books/tutorial/java/javaOO/objectclass.html
"The value returned by hashCode is an int that maps an object into a bucket in a hash table. An object must always produce the same hash code. However, objects can share hash codes (they aren't necessarily unique)."
Similar Messages
-
What is hash code in Java and how it is related to equals method
Can any body give me the detailed information about hashcode and the relationship between equals method and hash code.
Objects in Java have hash codes associated with them. An object's hash code is a signed number that identifies the object (for example, an instance of the parent class). An object's hash code may be obtained by using the object's hashCode() method as follows:
int hashCode = SomeObject.hashCode();
The method hashCode() is defined in the Object class and is inherited by all Java objects. The following code snippet shows how the hash codes of two objects relate to the corresponding equals() method:
1. // Compare objects and then compare their hash codes
2. if (object1.equals(object2)
3. System.out.println("hash code 1 = " + object1.hashCode() +
4. ", hashcode 2 = " + object2.hashCode());
5.
6. // Compare hash codes and then compare objects
7. if (object1.hashCode() == object2.hashCode())
8. {
9. if (object1.equals(object2))
10. System.out.println"object1 equals object2");
11. else
12. System.out.println"object1 does not equal object2");
13. }
In lines 3-4, the value of the two hash codes will always be the same. However, the program may go through line 10 or line 12 in the code. Just because an object's reference equals another object's reference (remember that the equals() method compares object references by default), it does not necessarily mean that the hash codes also match.
The hashCode() method may be overridden by subclasses. Overriding the hash code will allow you to associate your own hash key with the object. -
What is the hash code of an object? What does hash code mean?
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Obje
ct.html#hashCode()also http://en.wikipedia.org/wiki/Hash_code
what the hashcode isn't, though, is an identifier for an object, unique or otherwise. don't make that mistake!
"Database Systems" by Connolly-Begg has a good section on hash codes and their uses, if memory serves me well -
Urgent: please help - Object Hash Code of RMI stubs in a cluster
Hello all,
I'm trying to find out for a week now if members of a cluster can get out of synch
regarding "Object Hash Code" of RMI stubs in the JNDI.
After binding an RMI object to one server (no rmic performed since the object
is in the classpath of both servers and the service is pinned), the JNDI mapping
looked identical on both servers.
However, while one server went down for a few hours, the other server has changed
the "Object Hash Code" to a new one (the binding name stayed constant). When the
server went up again it tried to lookup the object under the same binding, then
found it but failed to execute remote methods on it. An error message says that
the object was garbage collected:
java.rmi.NoSuchObjectException: Unable to dispatch request to Remote object with
id: '347'. The object has been garbage collected. at weblogic.rjvm.RJVMImpl.dispatchRequest(RJVMImpl.java:766)
at weblogic.rjvm.RJVMImpl.dispatch(RJVMImpl.java:738) at weblogic.rjvm.ConnectionManagerServer.handleRJVM(ConnectionManagerServer.java:207)
at weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:777) at weblogic.rjvm.t3.T3JVMConnection.dispatch(T3JVMConnection.java:508)
at weblogic.socket.NTSocketMuxer.processSockets(NTSocketMuxer.java:664) at weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:23)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)
Why isn't the new JNDI mapping replicated to the new booting server? Should I
use specific rmic flags? How can I maintain the JNDI trees identical on all clustered
servers?
I'm using two managed WLS 7.02 servers running on win2000 servers.
DaniHi Andy,
Thank you for responding.
The binding code looks like that:
m_ctx = new InitialContext();
int index = getNextAvailableRepositoryJNDIIndex();
m_ctx.bind(
NODE_PREFIX+index,
this
where this is the Remote implementation.
How will I make the object hash code constant or have all views remain constant
when the GC changes its reference?
Dani
Andy Piper <[email protected]> wrote:
"Daniel Gordon" <[email protected]> writes:
I'm trying to find out for a week now if members of a cluster can getout of synch
regarding "Object Hash Code" of RMI stubs in the JNDI.The hash code can probably change since the stub represents an
aggregate view of the cluster. But this may be a red-herring. What
does your code look like that binds the rmi object? It may be that DGC
is biting you.
andy -
Hi all!
I found myself implementing hashCode and equals methods for a class, and googled a little bit looking for a good implementation.
I found that the most used is this one:
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((Int1 == null) ? 0 : Int1.hashCode());
result = prime * result + ((Int2 == null) ? 0 : Int2.hashCode());
result = prime * result + ((Int3 == null) ? 0 : Int3.hashCode());
result = prime * result + ((Int4 == null) ? 0 : Int4.hashCode());
result = prime * result + ((Int5 == null) ? 0 : Int5.hashCode());
result = prime * result + ((Int6 == null) ? 0 : Int6.hashCode());
result = prime * result + ((Int7 == null) ? 0 : Int7.hashCode());
return result;
}Actually, this exact code was generated automatically by Eclipse tools for a test class I made.
What I found alarming, is that, in such an implementation, that prime variable, is multiplied by itself in every row!
This is what result equation would look like:
result = prime^7 + prime^6*Int7.hashCode() + prime^5*Int6.hashCode() + ... (where prime^n means a power).
And, translating it into numbers, we have that:
result > prime^7 = 31^7 = 27,512,614,111 > 2,147,483,647 = MAX VALUE OF JAVA PRIMITIVE INT!!!!
I dont want to think about classes with 10 or 20 fields!!
Im not sure about how java faces a value over its maximum, but, anyway I think that, over 6 fields, this implementation is a bit HEAVY for an int hashCode
Obviously, you can change the 31 for a lower prime, but dont think there would be much difference in that.
These would be the maximum valid number of fields for the corresponding primes:
31 6
29 6
23 6
19 7
17 7
13 8
A part from that, although it covers pretty fast the whole int range, there's no consistency about collisions, so it's far form being a "perfect" hash code ( an utopic hash code implementation that returns a unique value for each different instance of a class ).
So, thinking about a better implementation I came into this:
public int hashCode() {
double result = Math.pow(2,((Int1 == null) ? 0 : Int1.hashCode()));
result *= Math.pow(3,((Int1 == null) ? 0 : Int1.hashCode()));
result *= Math.pow(5,((Int1 == null) ? 0 : Int1.hashCode()));
result *= Math.pow(7,((Int1 == null) ? 0 : Int1.hashCode()));
result *= Math.pow(11,((Int1 == null) ? 0 : Int1.hashCode()));
result *= Math.pow(13,((Int1 == null) ? 0 : Int1.hashCode()));
result *= Math.pow(17,((Int1 == null) ? 0 : Int1.hashCode()));
return (int) result;
}but I guess that, although there would be absolutely no collision its cost would be too much for optimizing hash tables searches.
So, what do you think about it?
Or better...Does anyone thought of it before? and Did you get into a better implementation?
Thanx, and good programming!Well, let me explain...
And I don't know what exactly you mean by "HEAVY".I meant in terms of size of the value. Obviously, what I suggested is really a lot more expensive ( in temps of computation costs ), but it was only an example that guarantees unicity.
The algorithm you describe is widely used and usually considered to be the best general-purpose algorithm that can be applied to pretty much all classes.Chapter 3 of Effective Java (= the go-to-place for information on equals() and hashCode()) also describes that algorithm. >
Well, that's what I've seen, that this is the most commonly accepted algoritm, but what I wonder is why it is so common, and which is its Mathmatical consitency.
If you have a look at the expression I wrote, there's absolutelly no control over the unicity of that algoritm. Off course this is not a problem, as it fits the hash code contract, returning different values for different elements, but, I question why to make such a "big" product when there's plenty of collisions anyway!
Look at what you refered:
>
"The multiplication in step 2.b makes the hash value depend on the order of the
fields, which results in a much better hash function if the class contains multiple
similar fields. For example, if the multiplication were omitted from a String hash
function built according to this recipe, all anagrams would have identical hash
codes. The multiplier 37 was chosen because it is an odd prime. If it was even and
the multiplication overflowed, information would be lost because multiplication
by two is equivalent to shifting. The advantages of using a prime number are less
clear, but it is traditional to use primes for this purpose.""The multiplication in step 2.b makes the hash value depend on the order of the
fields, which results in a much better hash function if the class contains multiple
similar fields. For example, if the multiplication were omitted from a String hash
function built according to this recipe, all anagrams would have identical hash
codes. The multiplier 37 was chosen because it is an odd prime. If it was even and
the multiplication overflowed, information would be lost because multiplication
by two is equivalent to shifting. The advantages of using a prime number are less
clear, but it is traditional to use primes for this purpose.">
Even here it is said that there's absolutely no consistent reason for taking such an approach! (or, at least, I don't see it).
For example, in case of the class I was talking about, take a look at this:
public int hashCode() {
int result = 2 * ((Int1 == null) ? 0 : Int1.hashCode());
result += 3 * ((Int2 == null) ? 0 : Int2.hashCode());
result += 5 * ((Int3 == null) ? 0 : Int3.hashCode());
result += 7 * ((Int4 == null) ? 0 : Int4.hashCode());
result += 11 * ((Int5 == null) ? 0 : Int5.hashCode());
result += 13 * ((Int6 == null) ? 0 : Int6.hashCode());
result += 17 * ((Int7 == null) ? 0 : Int7.hashCode());
return result;
}I really haven't calculated it, but I suspect that number of collisions would be equivalent to the given by the other algoritm, and its values would remain smaller than in the other case.
In fact, you could even change the prime numbers for the Integers succession: 2,3,4,5,6,7....
So, my question is...Why that algoritm? Which are the advatages of an algoritm that works with such a Big values?
thanks! -
Hi all,
Can anyone explain me what is HASH table?
Thanks in Advance.......An internal table of type HASHED can be used to improve performance. Hashed tables have no linear index. You can only access hashed tables by specifying
the key. The system has its own hash algorithm for managing the table.The response time for key access remains constant, regardless of the number of table entries. Like database tables, hashed tables always have a unique key. Hashed tables are useful if you want to construct and use an internal table
which resembles a database table or for processing large amounts of data.A restriction for hashed tables is that they may not contain more than 2 million entries.
You can also chk the links
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb2fcc358411d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_47x200/helpdata/en/90/8d7328b1af11d194f600a0c929b3c3/frameset.htm
If you have an internal table in your program which is used solely for lookup, it is good programming practice to use a hash table. The example below shows this, in combination with a method for buffering SELECT SINGLE results.
Code
*& Form select_dispo
Get MRP controller and in-house production time from material
and plant
--> MATNR Material
--> RESWK Plant
<-- DISPO MRP controller
<-- DZEIT In-house production time
form select_from_marc using matnr werks dispo dzeit.
types: begin of mrp_lookup_type,
matnr like marc-matnr,
werks like marc-werks,
dispo like marc-dispo,
dzeit like marc-dzeit,
end of mrp_lookup_type.
Define static hashed table to hold results
statics: st_mrp type hashed table of mrp_lookup_type
with unique key matnr werks.
data: l_wa_mrp type mrp_lookup_type.
clear dzeit.
See if data is in the table
read table st_mrp into l_wa_mrp with table key matnr = matnr
werks = werks.
If not in table, get it from the database
if not sy-subrc is initial.
select single dispo dzeit from marc
into corresponding fields of l_wa_mrp-dispo
where matnr eq matnr
and werks eq werks.
Insert into table
l_wa_mrp-matnr = matnr.
l_wa_mrp-werks = werks.
insert l_wa_mrp into table st_mrp.
endif.
dispo = l_wa_mrp-dispo. " MRP Controller
dzeit = l_wa_mrp-dzeit. " Inhouse production time
endform. " select_from_marc
reward points if helpful -
Hi everyone,
I am building dynamic web pages using Oracle's plsql web
toolkit. I am building a page that will pass information to a
credit card authorizer. I need to create a MD5 hash string to
pass to the credit card company. Is there an Oracle built in
procedure/function/package to generate a MD5 hash string? If
not, can anyone recommend a good reference source for generating
a MD5 hash code in a plsql environment.
Thanks.
Dave W.This is from the Object API; I think it has the information that explains what's happening (but doesn't resolve your apparent problem)
public int hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.
The general contract of hashCode is:
Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results.
However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables.
As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.) -
What does (error code -600) mean?
What does (error code -600) mean?
I received this code in a pop up window while trying to open iTunes from my Apps folder.procNotFound
= -600, /*no eligible process with specified descriptor*/
Could be many things, we should start with this...
"Try Disk Utility
1. Insert the Mac OS X Install disc, then restart the computer while holding the C key.
2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu at top of the screen. (In Mac OS X 10.4 or later, you must select your language first.)
*Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.*
3. Click the First Aid tab.
4. Select your Mac OS X volume.
5. Click Repair Disk, (not Repair Permissions). Disk Utility checks and repairs the disk."
http://docs.info.apple.com/article.html?artnum=106214
Then try a Safe Boot, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, reboot when it completes.
(Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive.)
If perchance you can't find your install Disc, at least try it from the Safe Boot part onward.
Any change? -
Does anyone know what this error code means?My itunes will not even open, no matter how many times i downlaod and restore it??? "The procedure entry point xmlITexTextReaderName could not be located in the dynamic link library libxml2.dlll." Please let me know if your know anything! It is greatly apprecitated!
Taken at face value, you're having trouble with an Apple Application Support program file there. (Apple Application Support is where single copies of program files used by multiple different Apple programs are kept.)
Let's try something relatively simple first. Restart the PC. Head into your Add or Remove Programs control panel, select "Apple Application Support", click "Change" and then click "Repair".
If no joy after that, try the more rigorous uninstall/reinstall procedure from the following post. (Although the procedure is for Vista and 7 and you've got XP, just read "Computer" as "My Computer", read "Uninstall a program control panel" as "Add or Remove programs control panel" and assume the system is 32-bit, and you'll be doing the right things.)
Re: I recently updated to vista service pack 2 and I updated to itunes 10.2.1 and ever since I did that my itunes won't open any more. Itunes starts but before anything loads a -
In BSP-HTMLB what is the code for auto refresh.?
Hi friends,
In BSP-HTMLB what is the code for auto refresh.?
Means i gave the input every 2 minutes once my output should get refresh.
So what is the code in bsp-htmpb?
MoosaHi Moosa,
Many threads on this topic...
[Auto Refresh - I|Auto refresh]
[Auto Refresh - II|Auto-Refresh for BSP page]
[Auto Refresh - III|Page refresh.....]
Search the forum for more information.
Regards,
Anubhav -
What is error code 603 and how does one fix it?
What is error code 603, please, regarding add-on installation? (The error codes page says for "error 6xx" to contact the Exchange online forum for assistance..) It is a "failed online license check" for an add-on that is a free add-on listed on the Adobe Add-ons page as compatible with PS CS6, CC, and CC 2014, as well as all three versions of a bunch of other apps. It is a Flypaper app, which looks to have been reworked to be compatible with the new 2014 apps. Since Flypaper apps come from reliable source, I'm not sure what the error means, and I'm certainly not sure how to remedy this. (The original Russell Brown Paper Textures Pro works fine on PS CC but isn't compatible with 2014.)
I am running Win 7 64-bit.
Thanks.
Gail
p.s. numbers of other extensions still don't download to PS 2014, so maybe this is also waiting for an Adobe fix??The add-on in question is called "Flypaper Select" (by Flypaper Textures).
This morning, when I sent the question, it was on last page of the free PS
add-on list and showed the add-on as compatible with all three latest PS
versions. Tonight, when I click on the add-on in "my add-ons" list, it now
shows compatibility only with PS6 and CC, and I can no longer even find it
in the big add-ons list. I will try to send screen shot of "my add-ons" to
the address you listed. It is also below.
Thanks for your help. I have been finding many add-ons change from day to
day, and many won't show up in Extensions window even though the desktop CC
app says they have been installed. I assume I am not the only person with
these problems.
Gail -
what is error code (1)? it is not listed but this is the error i get trying to restore
Take a look here for Apple's suggestions on that error:
http://support.apple.com/kb/TS3694#error1
Regards. -
What is the code to get the Label of radio button item at runtime?
Hi All
I am working on forms 10g(version 10.1.2.0.2 ) with Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 on windows 2000 platform.
My requirement is to dynamically get the label of the radio button item in a radio group.I am able to get the label of the radio group as shown below
Item :Radio group
Label : Gender
IF m_type = 'RADIO GROUP' THEN
m_label:=Get_Item_Property(m_Item ,label);
END IF;
There two Radio buttons inside this radio group which are
item : Radio button
Label : Male
item :Radio button
Label :female
What is the code to get the label of radio button(i.e) male and female ?
How will I get the count of radio buttons in a radio group at runtime?
Regards
MohanBut you have to provide the button name which cannot be get at runtime.
This is a lack of information that the Dev team would correct !
Francois -
What is ok-code for page down in bdc (reward)
hiiii
What is ok-code for page down in bdc...HI..
here is the list..
P- : Back
P-- : Scroll to previous page
P+ : Scroll to next page
P++ Scroll to last page
PL- : Scroll to first line in page
PL-n : Scroll back n lines
PL+ : Scroll to last line in page
PL+n Scroll forward n lines
PP- : Scroll back one page
PP-n Scroll back n pages
PP+ scroll forward one page
PP+n : scroll forward n page
PPn : Scroll to start of page n
Ps- : Scroll to first column
PS++ Scroll to last column
Reward if useful
Regards
Prax -
What event handling code do I need to access a web site ?
Hello
I am doing a GUI program that would go to a program or a web site when a button is clicked. What event handling code do I need to add to access a web site ?
for instance: if (e.getSource() == myJButtonBible)
// go to www.nccbuscc.org/nab/index.htm ? ? ? ? ? ? ?
} below is the drive class.
Thank you in advance
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import java.awt.event.*;
import javax.swing.JEditorPane.*;
public class TryGridLayout
public TryGridLayout() {
JFrame myJFrame = new JFrame("Choose your program");
Toolkit myToolkit = myJFrame.getToolkit();
Dimension myScreenSize = myToolkit.getDefaultToolkit().getScreenSize();
//Center of screen and set size to half the screen size
myJFrame.setBounds(myScreenSize.width / 4, myScreenSize.height / 4,
myScreenSize.width / 2, myScreenSize.height / 2);
//change the background color
myJFrame.getContentPane().setBackground(Color.yellow);
//create the layout manager
GridLayout myGridLayout = new GridLayout(2, 2);
//get the content pane
Container myContentPane = myJFrame.getContentPane();
//set the container layout manager
myContentPane.setLayout(myGridLayout);
//create an object to hold the button's style
Border myEdge = BorderFactory.createRaisedBevelBorder();
//create the button size
Dimension buttonSize = new Dimension(190, 100);
//create the button's font object
Font myFont = new Font("Arial", Font.BOLD, 18);
//create the 1st button's object
JButton myJButtonCalculator = new JButton("Calculator");
myJButtonCalculator.setBackground(Color.red);
myJButtonCalculator.setForeground(Color.black);
// set the button's border, size, and font
myJButtonCalculator.setBorder(myEdge);
myJButtonCalculator.setPreferredSize(buttonSize);
myJButtonCalculator.setFont(myFont);
//create the 2nd button's object
JButton myJButtonSketcher = new JButton("Sketcher");
myJButtonSketcher.setBackground(Color.pink);
myJButtonSketcher.setForeground(Color.black);
// set the button's border, size, and font
myJButtonSketcher.setBorder(myEdge);
myJButtonSketcher.setPreferredSize(buttonSize);
myJButtonSketcher.setFont(myFont);
//create the 3rd button's object
JButton myJButtonVideo = new JButton("Airplane-Blimp Video");
myJButtonVideo.setBackground(Color.pink);
myJButtonVideo.setForeground(Color.black);
// set the button's border, size, and font
myJButtonVideo.setBorder(myEdge);
myJButtonVideo.setPreferredSize(buttonSize);
myJButtonVideo.setFont(myFont);
//create the 4th button's object
JButton myJButtonBible = new JButton("The HolyBible");
myJButtonBible.setBackground(Color.white);
myJButtonBible.setForeground(Color.white);
// set the button's border, size, and font
myJButtonBible.setBorder(myEdge);
myJButtonBible.setPreferredSize(buttonSize);
myJButtonBible.setFont(myFont);
//add the buttons to the content pane
myContentPane.add(myJButtonCalculator);
myContentPane.add(myJButtonSketcher);
myContentPane.add(myJButtonVideo);
myContentPane.add(myJButtonBible);
JEditorPane myJEditorPane = new JEditorPane();
//add behaviors
ActionListener myActionListener = new ActionListener() {
public void actionPerformed(ActionEvent e) throws Exception
/*if (e.getSource() == myJButtonCalculator)
new Calculator();
else
if (e.getSource() == myJButtonSketcher)
new Sketcher();
else
if (e.getSource() == myJButtonVideo)
new Grass();
else*/
if (e.getSource() == myJButtonBible)
// Go to http://www.nccbuscc.org/nab/index.htm
}; // end of actionPerformed method
//add the object listener to listen for the click event on the buttons
myJButtonCalculator.addActionListener(myActionListener);
myJButtonSketcher.addActionListener(myActionListener);
myJButtonVideo.addActionListener(myActionListener);
myJButtonBible.addActionListener(myActionListener);
myJFrame.setVisible(true);
} // end of TryGridLayout constructor
public static void main (String[] args)
new TryGridLayout();
} // end of TryGridLayout classHello
I am doing a GUI program that would go to a program or a web site when a button is clicked. What event handling code do I need to add to access a web site ?
for instance: if (e.getSource() == myJButtonBible)
// go to www.nccbuscc.org/nab/index.htm ? ? ? ? ? ? ?
} below is the drive class.
Thank you in advance
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import java.awt.event.*;
import javax.swing.JEditorPane.*;
public class TryGridLayout
public TryGridLayout() {
JFrame myJFrame = new JFrame("Choose your program");
Toolkit myToolkit = myJFrame.getToolkit();
Dimension myScreenSize = myToolkit.getDefaultToolkit().getScreenSize();
//Center of screen and set size to half the screen size
myJFrame.setBounds(myScreenSize.width / 4, myScreenSize.height / 4,
myScreenSize.width / 2, myScreenSize.height / 2);
//change the background color
myJFrame.getContentPane().setBackground(Color.yellow);
//create the layout manager
GridLayout myGridLayout = new GridLayout(2, 2);
//get the content pane
Container myContentPane = myJFrame.getContentPane();
//set the container layout manager
myContentPane.setLayout(myGridLayout);
//create an object to hold the button's style
Border myEdge = BorderFactory.createRaisedBevelBorder();
//create the button size
Dimension buttonSize = new Dimension(190, 100);
//create the button's font object
Font myFont = new Font("Arial", Font.BOLD, 18);
//create the 1st button's object
JButton myJButtonCalculator = new JButton("Calculator");
myJButtonCalculator.setBackground(Color.red);
myJButtonCalculator.setForeground(Color.black);
// set the button's border, size, and font
myJButtonCalculator.setBorder(myEdge);
myJButtonCalculator.setPreferredSize(buttonSize);
myJButtonCalculator.setFont(myFont);
//create the 2nd button's object
JButton myJButtonSketcher = new JButton("Sketcher");
myJButtonSketcher.setBackground(Color.pink);
myJButtonSketcher.setForeground(Color.black);
// set the button's border, size, and font
myJButtonSketcher.setBorder(myEdge);
myJButtonSketcher.setPreferredSize(buttonSize);
myJButtonSketcher.setFont(myFont);
//create the 3rd button's object
JButton myJButtonVideo = new JButton("Airplane-Blimp Video");
myJButtonVideo.setBackground(Color.pink);
myJButtonVideo.setForeground(Color.black);
// set the button's border, size, and font
myJButtonVideo.setBorder(myEdge);
myJButtonVideo.setPreferredSize(buttonSize);
myJButtonVideo.setFont(myFont);
//create the 4th button's object
JButton myJButtonBible = new JButton("The HolyBible");
myJButtonBible.setBackground(Color.white);
myJButtonBible.setForeground(Color.white);
// set the button's border, size, and font
myJButtonBible.setBorder(myEdge);
myJButtonBible.setPreferredSize(buttonSize);
myJButtonBible.setFont(myFont);
//add the buttons to the content pane
myContentPane.add(myJButtonCalculator);
myContentPane.add(myJButtonSketcher);
myContentPane.add(myJButtonVideo);
myContentPane.add(myJButtonBible);
JEditorPane myJEditorPane = new JEditorPane();
//add behaviors
ActionListener myActionListener = new ActionListener() {
public void actionPerformed(ActionEvent e) throws Exception
/*if (e.getSource() == myJButtonCalculator)
new Calculator();
else
if (e.getSource() == myJButtonSketcher)
new Sketcher();
else
if (e.getSource() == myJButtonVideo)
new Grass();
else*/
if (e.getSource() == myJButtonBible)
// Go to http://www.nccbuscc.org/nab/index.htm
}; // end of actionPerformed method
//add the object listener to listen for the click event on the buttons
myJButtonCalculator.addActionListener(myActionListener);
myJButtonSketcher.addActionListener(myActionListener);
myJButtonVideo.addActionListener(myActionListener);
myJButtonBible.addActionListener(myActionListener);
myJFrame.setVisible(true);
} // end of TryGridLayout constructor
public static void main (String[] args)
new TryGridLayout();
} // end of TryGridLayout class
Maybe you are looking for
-
IPad mini retina screen protector
I need to get a screen protector for the new iPad mini retina and, after some googling, can't locate anything confirming whether the layout of the screen exactly matches that of the predecesor, iPad mini. Is the footprint of the two devices exactly
-
New update adds third-party remote support. I could use mine already!
I am a little confused. Appletell states- "The update also allows users to use third party remotes with their Apple TV, which has been a long standing request from many users" This is saying, to me, that you can use a third-party remote to control T
-
Auto determination of Service Organization and Org.Unit
Hello I've created an Org.Model with Org.Units. I've also configured a rule to derive the service organization and the responsible Org Unit based on the activity reason. When i manually specify the activity reason in the transaction, both service org
-
SMB makes life unbearable for AFP network directory users
We have a an XServe/XServe RAID combo running 10.4.11 acting as a home directory server for around 20-30 simultaneous users. Most use network home directory accounts served by AFP to desktop Macs. A handful use PCs (SMB access) or Linux boxen (NFS ac
-
Hi all, I have 2 V880 server with Solaris 9 with Sun cluster 3.1 with 2 nodes. I am getting the "Cluster.CCR: [ID 544775 daemon.error] libpnm system error: read error" error in one cluster node and the same tine i am getting "Jun 11 11:13:56 server1