Results 1 to 11 of 11
Thread: Extend Jscroll
- 12-13-2009, 04:59 PM #1
Member
- Join Date
- Oct 2009
- Posts
- 48
- Rep Power
- 0
Extend Jscroll
I tried to inherit the Jcroll
Java Code:package IV_FORM; import javax.swing.JScrollBar; public class Extended_scroll extends JScrollBar{ public Extended_scroll(){ } }
-
I don't think that there's enough information here to know how to help you. Please tell the details, including why you even want to extend JScrollBar.
- 12-13-2009, 05:21 PM #3
Member
- Join Date
- Oct 2009
- Posts
- 48
- Rep Power
- 0
I just want to reach 2 things...
1.Get some experience with inheriting classes such Jscroll :)
2.And at all i want using the buttons on a scroll for increase or reduce (differ from the button) the values in Jspinner.
-
So you want to use inheritance to change a scrollbar into doing something that it was never intended to do? Good luck with that one as it will be very difficult to do, and not a wise thing to do either. But if you still feel a strong desire to tilt at this windmill, then I suggest you study the API for JScrollBar and its model the BoundedRangeModel, and then I suggest you delve a bit into the source code for both of these classes as well as the DefaultBoundedRangeModel class (you have already downloaded this zip file with the JDK. I think it's called src.zip).
If I were your teacher though, I would suggest abandoning this quixotic quest and instead learn inheritance by doing something a bit more reasonable, such as playing with JTables and extending the different TableModels that are out there, but YMMV.
Much luck.
- 12-13-2009, 05:35 PM #5
Member
- Join Date
- Oct 2009
- Posts
- 48
- Rep Power
- 0
Thanks for your answer :) . I will tru to reach this aim just to pu only 2 jButtons on my From :) ..Anyway, thanks for your help! i will drop this stupid idea ..But i do not understand why it is so difficult to add a possible to increase values in some other components like textbox?
-
Last edited by Fubarable; 12-13-2009 at 05:46 PM.
- 12-13-2009, 05:55 PM #7
Member
- Join Date
- Oct 2009
- Posts
- 48
- Rep Power
- 0
Yes! I just want to change values in some exist component on my form(JSpinner date model). But i do not know how to rewrite or add method that edit the jSpinners buttons behavior. Tell what method i should to rewrite for this ?
Nevertheless,From Russia with Love :) ?
-
- 12-13-2009, 07:01 PM #9
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,236
- Rep Power
- 13
"JScroll" is not a component. (Are you talking about a JScrollPane or JScrollBar?)
"textbox" is not a component. (Are you talking about a JTextField, JTextArea or JTextPane?)
English may not be your first language buy there is no reason for NOT using the proper Java terms when talking about components so we can better understand your question.
But i do not understand why it is so difficult to add a possible to increase values in some other components like textbox?
Please give a better example for better help.
- 12-13-2009, 08:28 PM #10
Member
- Join Date
- Oct 2009
- Posts
- 48
- Rep Power
- 0
This is a prinscreen of my project
Then i press the button number 3 - values(date) in jSpinner1 changing one day more or one day less. And i want to use a Extended jScroll bar for change a hour!! values in jSpinner1. One touch on rigth button(2)-the hour on jSppiner became more.One touch on left button(1) of ScrollBar- the hour became less.
-
A JSpinner can scroll on the year, day, month, or hour, or whatever, depending on where the cursor is. For instance, in this code here, you can advance the year, month, day, hour, or minute if the cursor is in that portion of the text:
Java Code:import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import javax.swing.*; public class DateSpinner { private static void createAndShowUI() { final Calendar calendar = new GregorianCalendar(); // code below from Sun tutorial: // http://java.sun.com/docs/books/tutorial/uiswing/components/spinner.html Date initDate = calendar.getTime(); calendar.add(Calendar.YEAR, -100); Date earliestDate = calendar.getTime(); calendar.add(Calendar.YEAR, 200); Date latestDate = calendar.getTime(); final SpinnerDateModel model = new SpinnerDateModel(initDate, earliestDate, latestDate, Calendar.YEAR); JSpinner spinner = new JSpinner(model); spinner.setEditor(new JSpinner.DateEditor(spinner, "yyyy.MMMMM.dd hh:mm aa")); JPanel panel = new JPanel(); panel.add(spinner); JFrame frame = new JFrame("DateSpinner"); frame.getContentPane().add(panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } public static void main(String[] args) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { createAndShowUI(); } }); } }
Similar Threads
-
Trying to extend class
By ribbs2521 in forum New To JavaReplies: 4Last Post: 10-29-2009, 07:28 PM -
How can I extend java.net.URI - why is it final?
By johann_p in forum Advanced JavaReplies: 1Last Post: 08-21-2009, 06:31 AM -
extend a button
By Omarero in forum New To JavaReplies: 0Last Post: 03-25-2009, 07:57 PM -
using J-classes or extend them ?
By itaipee in forum AWT / SwingReplies: 1Last Post: 01-01-2009, 08:58 PM -
How to extend Messages Component
By Jothi in forum JavaServer Faces (JSF)Replies: 0Last Post: 05-20-2008, 09:50 AM
Bookmarks