October 2, 1998

Selecting a maximum sum from a group

Question: I need to write a query that selects the maximus sum for a group from a list like the one below. Type ValueA 100B 200C 300A 300B 100C 342 The result should be C, 642. I tried “group by,” but I could only get the sums. Answer: You must

How to capture return value of insert statement

Question: I have a table, called bugs. I have an insert trigger on the bugs table that generates a unique id, called bug_id. When I perform an insert into bugs, it returns the bug_id it just assigned to that record. I am writing a stored procedure called doit that will

Event handling with multiple scrollbars

Question: I’m trying to work on the basics of event handling. I found it easy to set one label and have the scrollbar change the value of the label. I added a few more scrollbars, each with a separate label. When I move any scrollbar, only the first label value

Adding a Component to a JTable

Question: How do I add a JButton to the cells of a JTable? Answer: Using the Swing JTable class can become a sticky business when you want to customize it to your specific needs. First you must become familiar with how the JTable class is organized. Individual cells are rendered


Question: For what uses can the Graphics.create() method be used? Answer: There will be cases where you want to make a copy of a Graphics context and make some alterations to it (for example, change the foreground or background color) without losing the original Graphics context. Also, there will be

Canvas in a ScrollPane

Question: How can you make a canvas nonresizable? The canvas automatically resizes when the frame is resized. Answer: The default layout manager for java.awt.Frame is BorderLayout. BorderLayout will expand the components of its associated container along the regions to which they are attached. For example, a component added to the

SQL Query

Question: I am a beginner in SQL and can’t figure out how to do this: I have two tables with three fields in the row of table1 referencing a master table in an n-1 relation as follows: JobMast ContractorMast======= ==============JobID ContrIDJobDescription —–1> ContrName GenContractorID n ———/ | |ElecContractorID n ———–/

Java Threads and Multiple Processors

Question: On a Windows NT box with multiple processors, will a multithreaded Java application get split between the processors automatically? Answer: This depends on the version and vendor of theJVM you are running. The Microsoft SDK for Javauses native NT threads to implement Java threads.These threads are scheduled by the

Textfield focus

Question: I have a frame with a few textfields on it. How can I set the focus to the first textfield? Is there something like setFocus? Answer: A component can obtain the input focus by invoking requestFocus(), which is defined in java.awt.Component.

No more posts to show