SplitButton of dropdownbutton invisible when mouse clicking

SplitButton of dropdownbutton invisible when mouse clicking

click the SplitButton of dropdownbutton, when dropdownmenu willbe displayed. but this is not disabled when mouevent performed on the jpanel
how to disabled or hide the dropdownmenu when we click the dropdown button?
//the code is below

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.plaf.basic.BasicArrowButton;
public class SplitButton1 extends JButton
{
private JButton mainButton, dropDownButton;
private JMenu dropDownMenu;
public SplitButton1()
{
this(" ");
}
public SplitButton1(String text)
{
this(new JButton(text), SwingConstants.SOUTH);
}
public SplitButton1(String text, int orientation)
{
this(new JButton(text), orientation);
}
public SplitButton1(JButton mainButton, int orientation)
{
//super();
this.mainButton = mainButton;
this.dropDownButton = new BasicArrowButton(orientation);
//dropDownButton.addActionListener(this);
this.setBorderPainted(false);
this.dropDownButton.setBorderPainted(false);
this.mainButton.setBorderPainted(false);
this.setPreferredSize(new Dimension(75, 34));
this.setMaximumSize(new Dimension(75, 34));
this.setMinimumSize(new Dimension(200, 34));
this.setLayout(new BorderLayout());
this.setMargin(new Insets(-3, -3,-3,-3));
this.add(mainButton, BorderLayout.CENTER);
this.add(dropDownButton, BorderLayout.EAST);
}
public void setMenu(JMenu menu)
{
this.dropDownMenu = menu;
}
public JButton getMainButton()
{
return mainButton;
}
public JButton getDropDownButton()
{
return dropDownButton;
}
public JMenu getMenu()
{
return dropDownMenu;
}


public static void test()
{
JFrame frame = new JFrame("Simple Split Button Test");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.getContentPane().setLayout(new BorderLayout());
JPanel p = new JPanel();
p.setLayout(new BorderLayout());
JToolBar toolBar = new JToolBar("tb");
JButton sbButton = new JButton(new ImageIcon("D:\\min.png"));
sbButton.setBackground(Color.BLACK);
sbButton.setContentAreaFilled(false);
SplitButton sb = new SplitButton(sbButton, SwingConstants.SOUTH);
//toolBar.add(new JButton("test button"));
toolBar.add(sb);
//p.add(new JLabel("SplitButton test"), BorderLayout.CENTER);
final JPopupMenu testMenu = new JPopupMenu("test menu");
testMenu.add("file");
testMenu.add("new");
sb.setMenu(testMenu);
testMenu.addSeparator();
frame.getContentPane().add(toolBar, BorderLayout.NORTH);
frame.getContentPane().add(p, BorderLayout.CENTER);
frame.setSize(200, 100);
frame.show();
frame.addMouseListener( new MouseAdapter()
{
public void mousePressed(MouseEvent evt)
{


}
} );


}
public static void main(String[] args)
{
test();
}
}
View Answers









Related Tutorials/Questions & Answers:
SplitButton of dropdownbutton invisible when mouse clicking - Swing AWT
SplitButton of dropdownbutton invisible when mouse clicking  click the SplitButton of dropdownbutton, when dropdownmenu willbe displayed. but this is not disabled when mouevent performed on the jpanel how to disabled or hide
jcheckbox in jtable does nothing when clicking on it
jcheckbox in jtable does nothing when clicking on it  my table model is as follows public class MyTableModel implements TableModel { ArrayList<PersonDTO> list=new ArrayList<PersonDTO>(); String headerName
Advertisements
invisible watermarking
invisible watermarking  can anyone help with code for invisible watermarking in java
How to make elements invisible ?
How to make elements invisible ?   How to make elements invisible
mouse events
mouse events  When i click a button i want to retrieve image and audio from database and play it. how can i do dis. I m using Netbeans IDE and mysql for database. pls do hel[p me
Mouse Listener
Mouse Listener  how to move any object with help of mouse but not drag it in an applet
Mouse Motion
Mouse Motion  Could you please send me the code of finding the (x,y) co-ordinates in a JFrame Compoenent..?? I need it urgently for my project
ModuleNotFoundError: No module named 'invisible-ink'
ModuleNotFoundError: No module named 'invisible-ink'  Hi, My... 'invisible-ink' How to remove the ModuleNotFoundError: No module named 'invisible-ink' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'invisible-ui'
ModuleNotFoundError: No module named 'invisible-ui'  Hi, My Python... 'invisible-ui' How to remove the ModuleNotFoundError: No module named 'invisible-ui' error? Thanks   Hi, In your python
how to use mouse pressed
how to use mouse pressed   to action mouse clicked
Image swap on mouse over and mouse move
Image swap on mouse over and mouse move  i tried the code , sent form u...But if there are 50 images and..i want swap images on mousse over and mouse out, then the code becomes very lengthy...so please give the code for multiple
Image swap on mouse over and mouse move
Image swap on mouse over and mouse move  i tried the code , sent form u...But if there are 50 images and..i want swap images on mousse over and mouse out, then the code becomes very lengthy...so please give the code for multiple
ModuleNotFoundError: No module named 'mouse'
ModuleNotFoundError: No module named 'mouse'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'mouse' How to remove the ModuleNotFoundError: No module named 'mouse'
4D Mouse
. Besides these, 4D mouse has other many advantages like when user put the cursor... 4D Mouse       Here... mouse is an advanced species of traditional 2D mouse that can move only horizontal
ModuleNotFoundError: No module named 'django-invisible-recaptcha-admin'
ModuleNotFoundError: No module named 'django-invisible-recaptcha-admin' ...: ModuleNotFoundError: No module named 'django-invisible-recaptcha-admin' How to remove the ModuleNotFoundError: No module named 'django-invisible-recaptcha-admin'
ModuleNotFoundError: No module named 'django-invisible-recaptcha-admin'
ModuleNotFoundError: No module named 'django-invisible-recaptcha-admin' ...: ModuleNotFoundError: No module named 'django-invisible-recaptcha-admin' How to remove the ModuleNotFoundError: No module named 'django-invisible-recaptcha-admin'
mouse over effects in css
mouse over effects in css  I have written a mouse over effect in CSS. But it is not working in HTML. Can any one suggest me? Thanks
Swap images oon mouse over and mouse out
Swap images oon mouse over and mouse out  I have multiple images...i want to swap each image on mouse out and mouse over..   <html> <script language="javascript" type="text/javascript"> if(document.images
Java Swing: Draw rectangle on mouse click
has provide an interface MouseListener. When the user clicks a mouse.... In the given example, we are going to draw a rectangle by clicking the mouse...Java Swing: Draw rectangle on mouse click In this tutorial, you will learn how
Display alert box on clicking link
Display alert box on clicking link In this tutorial, we will display alert box... a "a href" link. On clicking this link ,a alert box prompt message "redirecting...." and when we click "Ok" button
ModuleNotFoundError: No module named 'clicking'
ModuleNotFoundError: No module named 'clicking'  Hi, My Python... 'clicking' How to remove the ModuleNotFoundError: No module named 'clicking... to install padas library. You can install clicking python with following
mouse event - Java Beginners
mouse event  import javax.swing.*; import java.awr.*; import...=getContentPane(); setLayout(new FlowLayout()); setTitle("Mouse Event..."); public MouseEventt() { f.setLayout(new FlowLayout()); f.setTitle("Mouse
ModuleNotFoundError: No module named 'mouse_droid'
ModuleNotFoundError: No module named 'mouse_droid'  Hi, My Python... 'mouse_droid' How to remove the ModuleNotFoundError: No module named 'mouse_droid' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'mouse_record'
ModuleNotFoundError: No module named 'mouse_record'  Hi, My Python... 'mouse_record' How to remove the ModuleNotFoundError: No module named 'mouse_record' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'remarkable-mouse'
ModuleNotFoundError: No module named 'remarkable-mouse'  Hi, My... named 'remarkable-mouse' How to remove the ModuleNotFoundError: No module named 'remarkable-mouse' error? Thanks   Hi, In your
Dynamically added Row is Invisible in another javascript function..?
Dynamically added Row is Invisible in another javascript function..?  I have table as below, I need to create 5 default rows, ( this is fine with below code)..but when add row its creating row in a table, but the created row
Retrieve data by clicking a link
Retrieve data by clicking a link  In a page there are 5 links.Every link has a hidden value. According to that hidden value data should be retrieved from the database and data should be displayed in a new page.How to do it?Please
Compose mail by clicking on send mail button
Compose mail by clicking on send mail button  How i get microsof out look page opend for composing mail by just clicking on send mail button and when outlook page open then in to:my email id is written on my jsp page
adding mouse listeners to drop target
with adding mouse listeners to "table" which is drop target, to accept drop component wherever it drops from the mouse. in this code when component drops...adding mouse listeners to drop target  import java.awt.*; import
Auto select cell on mouse hover using 'hover' mouse event
, when we hover mouse on it , it will highlight the cell by changing background...Auto select cell on mouse hover using 'hover' mouse event In this tutorial, we will discuss about how to highlight Table's cell on mouse hover
Handling Mouse Clicks in Java
the mouse click event in the awt application. This program simply implements the left click event of the mouse. When you click "Click Me" button... Handling Mouse Clicks in Java     
How to design a mouse
How to design a mouse Follow this example to learn how to design a mouse. New File: First take a new file (Ctrl + N). Use Pen Tool (P..., point your mouse pointer then select Direct selection tool (A key) and adjust
Browser Back Button Disable/Hide/Invisible using Java Script
Browser Back Button Disable/Hide/Invisible using Java Script  Dear Sir, Please Help..., Q: How to Write Code For Browser Back Button Disable/Hide/Invisible using Java Script without Page Reload/Refreshing. anyone
ModuleNotFoundError: No module named 'mouse_joystick_interface'
ModuleNotFoundError: No module named 'mouse_joystick_interface'  Hi...: No module named 'mouse_joystick_interface' How to remove the ModuleNotFoundError: No module named 'mouse_joystick_interface' error? Thanks  
jQuery '.live' & '.die' Mouse events
jQuery '.live'  & '.die' Mouse events...; mouse event of jQuery. In this Example, we removes the 'click' event of a button by clicking on other button. First button is for enabling event , Second
hybrid digital image embedding process using invisible watermarking - Swing AWT
hybrid digital image embedding process using invisible watermarking   sir/madam, I am subramanian from chennai.i did not create this project using rsa algorithm and i did not understand.please help me with source
'append' & 'fade out/in' on mouse hover
'append' & 'fade out/in' on mouse hover In this tutorial...; on mouse hover using jQuery. In this Example, a list is given , if we hover on first two element, "<<<" is appended on it, to show mouse
Hide text by clicking button
Hide text by clicking button In this tutorial, we will discuss about hide/show text by clicking on button. In the below example, there are two buttons... button " is used to show text. These actions are fired when "
Should not logout after clicking the back/forward button
Should not logout after clicking the back/forward button  Hi all I have wrote a code for login now. User is able to login but after logging in when he clicks on the back button user automatically gets logged out. very next
How to read and retrieve jtable row values into jtextfield on clicking at particular row ...
How to read and retrieve jtable row values into jtextfield on clicking at particular row ...  Hello Sir, I am developing a desktop... to read all the values of particular row at which mouse is clicked. and display
Hide boxes by clicking on it using jQuery
Hide boxes by clicking on it using jQuery In this tutorial , we will discuss about how to hide boxes by clicking on it using jQuery. In the given below example , 30 boxes inside web page are displayed. When we click on any box (among
Program to draw rectangle on each mouse click and erase priviouse rectangles
Program to draw rectangle on each mouse click and erase priviouse rectangles  Program to draw rectangle on each mouse click and erase previous rectangle on next mouse click
Image swap on MouseOver ann Mouse out
Image swap on MouseOver ann Mouse out  I tried ur code for multiple images but didnt get the right answer...i dont want the hardcodded code...a code which is flexible with multiple images <html> <script language
Explore key & mouse with Flex
Explore key & mouse with Flex   ... to determine for a key is pressed or not when an event occurs. In the example... created. Also two MouseEvent class events click and mouse over are used
Display two alert box alternately by clicking on text
Display two alert box alternately by clicking on text In this tutorial , we will discuss about how to display two alert box alternately by clicking on text line. In this example, a text line is given ,when we click
Clicking F5 and reentering value throws Null pointer exception
Clicking F5 and reentering value throws Null pointer exception  Hi, My page performs search operation.Normally when i enter a value and click on search it fetches a list corresponding to the search value entered by me.But when i
start tomcat automatically by double clicking on exe
start tomcat automatically by double clicking on exe  Hi I wanted to start tomcat automatically by double clicking on exe. i made project in jsp and use tomcat 6 as a server. but now i wanted to do some challenging in that. i
show folder on server by clicking a row in table using jsp and ajax
show folder on server by clicking a row in table using jsp and ajax  Hi, i want a jsp page which has one dropdown and one textfield. when i click on serach button after selecting the dropdown and a value in textfield it should
show folder on server by clicking a row in table using jsp and ajax
show folder on server by clicking a row in table using jsp and ajax  Hi, i want a jsp page which has one dropdown and one textfield. when i click on serach button after selecting the dropdown and a value in textfield it should
autogeneration of a random number and displaying it as a alert message to the user on clicking submit
to the user on clicking submit  Hi, In my project order purchase system under... automatically.But i want this number to be displayed when user click... is generated it should be inserted into database along with the details of addform when

Ads