Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › Java - Making tabbed frames and splitting each of them
New Posts  All Forums:Forum Nav:

Java - Making tabbed frames and splitting each of them

post #1 of 2
Thread Starter 
I'm working on a Java program that is basically a metric and imperial unit converter, but I'm stumped on how to even get the UI going. I'm wanting to make 3 tabs: weight, length, and temperature. Then in each of those tabs, I want to split the frame so that one side is for entering/displaying the imperial units and measurements, and the other side is for metric.

I can make the tabs, and I can make the split panes, but I can't seem to get them to go together. I don't suppose anyone knows how to do that and provide code so I can understand it better? Thanks!
Thing 3
(15 items)
 
  
CPUMotherboardGraphicsRAM
AMD Phemon II X4 955 ASUS M4A785TD-V EVO ASUS 6870 1GB 256-bit GDDR5 G.Skill "Ripjaw" 6GB PC3 12800 
Hard DriveOptical DriveOSMonitor
WD 500GB + WD 80GB DVD-RW Windows 7 Ultimate x64 x2 ASUS VH242 24" Monitors 
KeyboardPowerCaseMouse
Microsoft Ergonomic 4000 700W DangerDen Torture Rack Logitech MX 518 
Mouse PadAudioAudio
Black with wrist pad JVC HA-RX700 Headphones Hercules 2.0 Speakers 
  hide details  
Reply
Thing 3
(15 items)
 
  
CPUMotherboardGraphicsRAM
AMD Phemon II X4 955 ASUS M4A785TD-V EVO ASUS 6870 1GB 256-bit GDDR5 G.Skill "Ripjaw" 6GB PC3 12800 
Hard DriveOptical DriveOSMonitor
WD 500GB + WD 80GB DVD-RW Windows 7 Ultimate x64 x2 ASUS VH242 24" Monitors 
KeyboardPowerCaseMouse
Microsoft Ergonomic 4000 700W DangerDen Torture Rack Logitech MX 518 
Mouse PadAudioAudio
Black with wrist pad JVC HA-RX700 Headphones Hercules 2.0 Speakers 
  hide details  
Reply
post #2 of 2
i think what you want is an event driven unit converter. you need to wait for changes in one panel and display the conversion in the other. so you have a way to display 2 separate panels. you also need code that does the conversion.

Code:
public int impToMetric(int imp){
  int metric;
  //do some calculations here
  return metric;
}
Code:
public int metricToImp(int metric){
  int imp;
  //do some calculations here
  return imp;
}
say the user enters a value in the imperial text field and hits a convert button. the action for the button takes the value of the text field and calls the impToMetric method above. it takes the returned metric value and passes it to a display method in the metric panel. the use case for metric to imperial will be very similar. it should be the same concept for all 3 tabs.

i assume you're using swing so you may want to read up on action listeners. as the name suggests, this is what listens for changes in a component and performs an action. if the component is a button, it would be triggered for a click.
http://download.oracle.com/javase/tu...nlistener.html

ideally you should use the model, view, controller pattern for this to separate the code. hope that helps
Fractal Design
(15 items)
 
775 4 life
(15 items)
 
 
CPUMotherboardGraphicsRAM
Intel i7 2600K Biostar TP67XE NVidia GTX 570 Crucial Ballistix 
Hard DriveHard DriveCoolingOS
Crucial C300 RealSSD SDD Samsung F4 2TB Noctua NH-D14 Windows 7 Professional x64 
MonitorMonitorKeyboardPower
Asus VH202T 20'' 1600x900 Acer P244W 24" 1920 x 1080 Apple Keyboard with Numeric Keypad SeaSonic M12II 620W 
CaseMouseAudio
Fractal Design Define XL Titanium Grey Razor Abyssus Creative Sound Blaster X-FI Xtreme Gamer 
CPUMotherboardGraphicsRAM
Intel X3350 3.2Ghz @ 1.25v Gigabyte-GA-P35-DS3L (rev 2) XFX 4870 1GB 4GB OCZ Reaper PC2-6400 
RAMHard DriveHard DriveOptical Drive
2GB Corsair XMS2 PC2-6400 Crucial C300 64GB SSD 2TB Samsung Spinpoint F4 Sony Super Multi 
OSMonitorPowerCase
Windows 7 Professional x64 SP1 Asus VH202T 20'' 1600x900 SeaSonic M12II 620W Cooler Master Centurion 5 
Mouse
Razor Abyssus 
CPUMotherboardGraphicsRAM
Core i5-520M Lenovo 2522BF3 NVIDIA® Quadro® NVS3100M  Ramaxel Technology 4Gb DDR3 
Hard DriveOptical DriveOSMonitor
Samsung SSD 128GB 1.8" Micro SATA  hl-dt-st dvdram gu10n Windows 7 Enterprise (64-bit) 14.1" WXGA (1280x800) display, anti-glare, LED ... 
Power
9-cell plus Slice battery 
  hide details  
Reply
Fractal Design
(15 items)
 
775 4 life
(15 items)
 
 
CPUMotherboardGraphicsRAM
Intel i7 2600K Biostar TP67XE NVidia GTX 570 Crucial Ballistix 
Hard DriveHard DriveCoolingOS
Crucial C300 RealSSD SDD Samsung F4 2TB Noctua NH-D14 Windows 7 Professional x64 
MonitorMonitorKeyboardPower
Asus VH202T 20'' 1600x900 Acer P244W 24" 1920 x 1080 Apple Keyboard with Numeric Keypad SeaSonic M12II 620W 
CaseMouseAudio
Fractal Design Define XL Titanium Grey Razor Abyssus Creative Sound Blaster X-FI Xtreme Gamer 
CPUMotherboardGraphicsRAM
Intel X3350 3.2Ghz @ 1.25v Gigabyte-GA-P35-DS3L (rev 2) XFX 4870 1GB 4GB OCZ Reaper PC2-6400 
RAMHard DriveHard DriveOptical Drive
2GB Corsair XMS2 PC2-6400 Crucial C300 64GB SSD 2TB Samsung Spinpoint F4 Sony Super Multi 
OSMonitorPowerCase
Windows 7 Professional x64 SP1 Asus VH202T 20'' 1600x900 SeaSonic M12II 620W Cooler Master Centurion 5 
Mouse
Razor Abyssus 
CPUMotherboardGraphicsRAM
Core i5-520M Lenovo 2522BF3 NVIDIA® Quadro® NVS3100M  Ramaxel Technology 4Gb DDR3 
Hard DriveOptical DriveOSMonitor
Samsung SSD 128GB 1.8" Micro SATA  hl-dt-st dvdram gu10n Windows 7 Enterprise (64-bit) 14.1" WXGA (1280x800) display, anti-glare, LED ... 
Power
9-cell plus Slice battery 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › Java - Making tabbed frames and splitting each of them