1

When user press on Harris(Green) button as shown in GreenButton Image the OP1 button will get Green color with any icon upon it with a timer underneath it....first image is showing harris button

enter image description here

when we will click on harris button other button with any background color will get shape like this as shown in down image

enter image description here

this button will contain any icons..(one on left one on right) and two timers and divided color.

EDIT:1 Question is that I don't have idea how to customize my second(OP1) button like this one

Cœur
  • 37,241
  • 25
  • 195
  • 267
Haseeb Wali
  • 1,181
  • 3
  • 14
  • 34
  • 1
    *"it will be great if any one can help me..."* It will also be great if you can: 1) Use your shift key at the start of sentences to make the text easier to read. 2) Fix that stuck '.' key. 3) Ask a question. What is your question? – Andrew Thompson Jan 09 '13 at 06:36

3 Answers3

2

make it a JPanel with a MouseListener. That way you can "play" inside the Component.

THarms
  • 311
  • 1
  • 4
2

basic view

  • use JToggleButton with CardLayout (switch betweens two cards by determine JToggleButton.isSelected())

  • only JFrames ContentPane (BorderLayout) and JPanel(FlowLayout) has implemented LayoutManager in API, for rest of JComponents to have to add proper one

2nd. view

  • put opaque JPanels (or JLabel) to the JToggleButton, use GridLayout

  • put proper LayoutManager to JPanels, then to add the rest JComponent / Icons

Community
  • 1
  • 1
mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • Gread idea to use cardLayout with JToggleButton...but i have 1 problem there are three states of button..1-is not pressed,, 2 is pressed after 1 button(in this situation button will only have green color like harris button) , and 3rd is pressed after 2 buttons in this state it will have 2 colors as shown in picture.. – Haseeb Wali Jan 09 '13 at 11:11
  • 1
    `isPressed`, `isArmed` e.i. [are implemented in ButtonModel](http://stackoverflow.com/a/5755124/714968) – mKorbel Jan 09 '13 at 11:14
  • `isPresses` is internal status of `JToggleButton`, you can to determine from `ItemListener`, `ActionListener` or `Property(Change)Listener` – mKorbel Jan 09 '13 at 11:36
2

As shown here, you can implement the Icon interface to render any desired appearance and update the time remaining dynamically.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045