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



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

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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

 

 

DMCA.com