473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Gui Help ( toolbar )

Greetings,
Ive came across problems while doing a tutorial work piece.

i've to design a toobar ( yup a JToolBar ) with 5 buttons inside it, that will do certain functions for a JSlider.( set them at certain values )

Its simple enough to go and write 5 buttons into my code, but thats not wot ive to do.

The idea is that you will
develop one button that is customisable at design time to have one of 5 different
appearances. Developing 5 separate buttons is NOT an acceptable solution.
Is this even possible? ( pls note the 5 different appearances are Symbals )

Problem: Placing 5 buttons inside a JToolBar, and positing it under my created JSlider

Expand|Select|Wrap|Line Numbers
  1. // bob smith 
  2.  
  3. import javax.swing.*;
  4. import java.awt.*;
  5. import java.awt.event.*;
  6.  
  7.  
  8. class Testing extends JFrame
  9. {
  10.   int min = 40;
  11.   int max = 180;
  12.   int value = min;
  13.  
  14.   JSlider slider = new JSlider(min,max,value);
  15.   MyUI ui = new MyUI(slider);
  16.   int tw,sw,startGap;
  17.  
  18.   public Testing(){
  19.  
  20.     setSize(250,100);
  21.     setLocation(400,200);
  22.     setDefaultCloseOperation(EXIT_ON_CLOSE);
  23.     slider.setUI(ui);
  24.     slider.addMouseListener(new MouseAdapter(){
  25.       public void mousePressed(MouseEvent me)
  26.       {
  27.         slider.setValue(min+(max-min)*(me.getX()-startGap)/tw);
  28.       }
  29.     });
  30.     slider.setMajorTickSpacing(20);
  31.     slider.setMinorTickSpacing(10);
  32.     slider.setPaintTicks(true);
  33.     slider.setPaintLabels(true);
  34.     getContentPane().add(slider);
  35.     setVisible(true);
  36.     tw = ui.getTrackWidth();
  37.     sw = slider.getWidth();
  38.     startGap = (sw-tw)/2;
  39.   }
  40.   public static void main(String args[]){new Testing();}
  41. }
  42. class MyUI extends javax.swing.plaf.basic.BasicSliderUI
  43. {
  44.   public MyUI(JSlider js)
  45.  {
  46.    super(js);
  47.  }
  48.   public int getTrackWidth()
  49.  {
  50.     return (int)((Rectangle)trackRect).getWidth();
  51.   }
  52.  
  53. }
  54.  
  55.  
Any help or guidance AT all, would be amazing :)

Thanks!
Nov 10 '06 #1
0 1186

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Code Monkee | last post by:
How can the toolbar and menubar be hidden in IE? When opening the window via javascript I can specify 'toolbar=no,menubar=no', which works fine. However if the window already exists how can I...
102
by: me | last post by:
How do I prevent the save/print/email/mypictures toolbar from popping up when IE users place their cursor over photos at my website? Thank you in advance for your help. Signed, me
11
by: N. Graves | last post by:
I have checked the "Alignment and Sizing" toolbar but when I want to use in on aligning several form object the toolbar buttons stay grayed out. What am I missing. Thanks! N. Graves
0
by: Lauren Quantrell | last post by:
I use the following code to create text edit fields and command buttons in my toolbars: Function CreateToolbarObject(myObjectType as integer) Dim newObject Select Case myObjectType Case 1...
4
by: Jason Tabert | last post by:
Is there a way to create a custom IE toolbar with C# (or anything else in ..NET for that matter)? I have been looking all day and have had no luck finding a good place to start. I need to make...
6
by: Juan Pedro Gonzalez | last post by:
I wanted to add a Combobox to a toolbar... Kind of the look you get on VisualStudio's toolbar. I've been able to find some VB 6 samples, but the placeholder option is no longer available for...
1
by: Alfredo Barrientos | last post by:
Hi, I have a little trouble trying to assign a Toolbar control to another toolbar variable control. I am getting my forms controls with this: for (int j = 0; j <= frmChild.Controls.Count -...
4
by: Gerhard | last post by:
I have an MS Access app with multiple forms. One of the forms has a Toolbar (MsComctlLib.Toolbar) and it works as advertised. I handle the buttons in the Toolbar1_ButtonClick event. I would like...
3
by: Undergrid | last post by:
Hi All, I've got a few toolbars in my application hosted in a ToolStripContainer. I have found a problem whereby the location of a toolbar is not restored when doing a LoadSettings if the...
6
by: =?Utf-8?B?L2Rldi9udWxs?= | last post by:
Hello, i am using visual studio 2003 enterprise architect version. I am making apps for the .Net framework 1.1. While testing an interface, i discovered something strange. In this application...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.