jtoolbar

Swing JToolbarButton pressing

荒凉一梦 提交于 2019-12-17 03:45:06
问题 I use JToolbarButton button, I want to make it be "pressed" when I click on it, just like JButton works.How can I do this? Please help!Thanks. 回答1: As mentioned in Costis' reply, you are probably after a JToggleButton. It might also be necessary to suppress the painting of the border, as in the 2nd tool bar in this example. import java.awt.*; import java.awt.image.*; import javax.swing.*; class ToggleBar { public static JToggleButton getButton( Image selected, Image unselected, boolean

JSeperator in JToolBar moves the components to right end

守給你的承諾、 提交于 2019-12-11 03:12:13
问题 I am looking at Oracle's JToolBar code and trying to add JLabels within that toolbar. I have simulated the button-like feel for them by overriding the mouse events. It worked fine until I tried to add a JSeperator as I wanted a vertical line. I have added a separator after 3 JLabels causing the rest of them to get moved to the right end as shown below. I have tried adding the addSeparator() just before and after the JSeparator code , but still no luck. Code import javax.swing.JToolBar; import

Transfer jtoolbar from one jpanel to another

本秂侑毒 提交于 2019-12-11 02:01:44
问题 This is my first question, so bear with me. Let's say that I have 2 JPanel and 1 JToolBar. What I want to do is drag the toolbar from one panel to another and, after mouse release, the toolbar should stick to the second. 回答1: BasicToolbarUI has floatAt method. As you can see from source (below) toolbar uses docing source which is toolbar's parent container. You can try to override the method and replace the source. protected void floatAt(Point position, Point origin) { if(toolBar.isFloatable(

How to add gradient color to Jbuttons placed in jtoolbar

故事扮演 提交于 2019-12-11 01:55:42
问题 I am using netbeans platform module to develop this desktop application. I am using drag and drop facility in netbeans in the developement. I needed to create a toolbar which is having few buttons..I need to create a gradient color for these buttons. I dragged and dropped JToolBar , over it I dragged and placed JButton objects. In the properties of the button I have selected a color for which I want a shaded color. In the custom code I have modified. jbutton = new javax.swing.Jbutton(); as

JTextField in JToolbar - cannot display properly in both Linux and Windows

五迷三道 提交于 2019-12-10 22:45:31
问题 Please see the SSCCE below: import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; import java.awt.EventQueue; import javax.swing.Box; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; import javax.swing.JToolBar; import javax.swing.UIManager; import javax.swing.border.EtchedBorder; @SuppressWarnings("serial") public class GlueTest extends JComponent { private JFrame frame; private JToolBar toolbar;

How can I create a “Drop-Down” menu in a Java Swing toolbar?

断了今生、忘了曾经 提交于 2019-12-08 16:25:02
问题 I've created a drop-down menu on my Swing JToolBar. But it doesn't create behave the way I want. I'm aiming for it to work like Firefox's "Smart Bookmarks" button. It disappears when the user selects a menu item: CORRECT! It disappears when the user presses ESC: CORRECT! It disappears when the user clicks somewhere in the main frame outside of the menu: CORRECT! But it doesn't disappear when the user clicks a second time on the button that shows the drop-down menu: INCORRECT... :-( My

Java Swing JToolBar

落花浮王杯 提交于 2019-12-06 12:53:02
I have created JToolBar (Java Swing). I have set a Background image on frame which contains JToolBar . I want my JToolBar to be transparent so that the image kept on frame should be visible. I am using setOpaque(false) but it is not having any effect on my toolbar.. Has anyone delt with this before? My Code is as follows import javax.swing.ImageIcon; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; public class NewJFrame extends javax.swing.JFrame { static NewJFrame dialog = null; /** Creates new form NewJFrame */ public NewJFrame() { initComponents();

Java Swing JToolbar with panels: look & feel

。_饼干妹妹 提交于 2019-12-04 06:04:05
问题 I have a JToolbar that contains multiple JPanels (needed as I would like to have specific borders for each of them). Unfortunately the Look&Feel manager does not recognize the JPanels as belonging to a toolbar and the JButtons are thus renderer as normal buttons (i.e. without the special mouse-over effect you have on a toolbar). Replacing the JPanels by JToolbars are not an option as the LAF renderer gives it a special background. Any other options / hints? 回答1: As shown below, you can change

JAVA: Ways to fill a Frame. add(), setContentPane(), getContentPane()

半腔热情 提交于 2019-12-03 10:50:49
I found three ways to fill my JFrame frame = new JFrame("...") createContentPanel returns a JPanel and createToolBar returns a ToolBar. frame.add(this.createToolBar(), BorderLayout.PAGE_START); //this works and puts the ToolBar above and the ContentPanel under it<br> frame.add(this.createContentPanel(), BorderLayout.CENTER); frame.setContentPane(this.createContentPanel()); //this lets the JToolBar hover over the ContentPanel frame.getContentPane().add(this.createToolBar()); frame.getContentPane().add(this.createContentPanel()); //this only puts the last one into the JFrame frame.getContentPane

Java Swing JToolbar with panels: look & feel

本秂侑毒 提交于 2019-12-02 11:53:05
I have a JToolbar that contains multiple JPanels (needed as I would like to have specific borders for each of them). Unfortunately the Look&Feel manager does not recognize the JPanels as belonging to a toolbar and the JButtons are thus renderer as normal buttons (i.e. without the special mouse-over effect you have on a toolbar). Replacing the JPanels by JToolbars are not an option as the LAF renderer gives it a special background. Any other options / hints? trashgod As shown below, you can change a toolbar's layout and add components as desired. You can also have an arbitrary number of