Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

Have Programming Question? Ask it here!
 
 
 


prasad
SplitButton of dropdownbutton invisible when mouse clicking
0 Answer(s)      3 years and 11 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();
}
}

Advertisement
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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... mouse pointer then select Direct selection tool (A key) and adjust the points
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     
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
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
'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 "
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
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
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
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
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
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
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
Change Mouse sensitivity in Chart in Flex4
Change Mouse Sensitivity in Chart in Flex4: You can change the mouse... a slider for changing the value of mouse sensitivity. Example: <...;/fx:Script> <s:Panel title="Change mouse sensitivity
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
Get specific item details by clicking on hyperlink
Get specific item details by clicking on hyperlink  sir, I am developing a shopping site, following is my problem definition: I have a search item button, if I click on that button it lists all items with item name
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
Toggle hide/show by clicking same button
Toggle hide/show by clicking same button In this tutorial, we will discuss about how to toggle hide/show by clicking button. In the given below 2 example, there is button ,by clicking on it, the paragraph will hide/show . In first
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
Write an applet program to transfer the content of the text field into the component on clicking a button
Write an applet program to transfer the content of the text field into the component on clicking a button  Write an applet program to transfer the content of the text field into the component on clicking a button
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
retrieve the data to text fields from database on clicking the value of combo box
retrieve the data to text fields from database on clicking the value of combo box   retrieve the data to text fields from database on clicking... getting data into textarea from database table by clicking on the button
Advertisements
 

 

 

DMCA.com