Home Answers Viewqa Swing-AWT SplitButton of dropdownbutton invisible when mouse clicking

 
 


prasad
SplitButton of dropdownbutton invisible when mouse clicking
0 Answer(s)      2 years and 9 months ago
Posted in : Swing AWT

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 Pages:
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
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
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
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
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
invisible watermarking
invisible watermarking  can anyone help with code for invisible watermarking in java
4D Mouse
mouse has other many advantages like when user put the cursor on the vertical... 4D Mouse       Here... mouse is an advanced species of traditional 2D mouse that can move only horizontal
Mouse Buttons, Modifier Keys
when the event occurred. Mouse scroll controls were first supported in Java 2... Java NotesMouse Buttons, Modifier Keys Mouse Buttons. Java supports up to three mouse buttons. Even if your mouse doesn't have three separate
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
How to make elements invisible ?
How to make elements invisible ?   How to make elements invisible
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     
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
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 "
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
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
'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
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
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
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
Mouse Listener
Mouse Listener  how to move any object with help of mouse but not drag it in an applet
The Mouse
Java NotesThe Mouse The mouse is handled automatically by most components... (and shouldn't care) whether this was from a mouse click on the button, or from..., in a JPanel) and need to know where the user clicks, then you need to know about mouse
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
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
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
BoxLayout spacing
, and custom Fillers Invisible components can be added to a BoxLayout to produce empty... to increase when a window is resized. Box.Filler is a class... of horizontal space. When you want to specify space between components use a strut
Change paragraph by clicking button(Toggle effect)
Change paragraph by clicking button(Toggle effect) In this tutorial, we will discuss about how to change paragraph by clicking button using jQuery. In the above example, a button & paragraph is displaying initially .When we click
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
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
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
Autopopulate values into textbox from database on pressing tab or on clicking
corresponding producttype,productprice into textboxes when we press tab or click
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
Mouse Listeners
the mouse listeners.   They are usually added to a graphics panel... implement the mouse listener interfaces in your non-panel class and write all.... For example, to listen for mouse clicks, p.addMouseListener(new
MouseListener
Java NotesMouseListener This type of mouse listener is for events which typically don't happen very often -- a mouse button is pressed, released, or the mouse enters or leaves the area of the component with a listener. Here
Mouse Drag and Drop
Mouse Drag and Drop       This section illustrates you how to drag and move mouse to draw... a rectangle. This rectangle has been shown on the frame. When you drag
How can I open my Java desktop app by clicking on its file?
How can I open my Java desktop app by clicking on its file?  How can I open my Java desktop app by clicking on the file it creates? This app creates files when selecting its "Save as" option with an extension specificaly defined
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
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
After Clicking Image I need Popup Window - Design concepts & design patterns
After Clicking Image I need Popup Window  Hi Friends. when i click any image button , i need to display popup window in javascript.can u give code for this New Document EMPLOYEE DETAILS
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
'key down' mouse event of the jQuery
'key down' mouse event of the jQuery In this tutorial ,we will display... , a text box is given. When you type something or press any key it shows ASCII...;/body> </html> OUTPUT When we enter 'a' : When we enter
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
create text box by clicking button and submittong text in text box using submit
create text box by clicking button and submittong text in text box using submit  Hi, I created a button when i click on button new textbox is created. and i want to do that when i enter the text input in text box and when i
Tomahawk popup tag
when user takes the mouse on the element. This popup is created on the mouse... : This is a boolean attribute that if set to true then it closes the popup when mouse... : This is a boolean attribute that if set to true then it closes the popup when mouse exits
How to show multiple identicle rows from database on clicking search button to jtable
How to show multiple identicle rows from database on clicking search button... .when i enter search value in the search field only one row is displayed... and show multiple identical rows from database on clicking search button

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.