Adding component in a JButton
Hello,
I try to make a dropdown button for toolbars but something is wrong when I pack the main frame :
java.lang.NullPointerException
at com.sun.java.swing.plaf.windows.WindowsButtonUI.getPreferredSize(Unknown Source)
at javax.swing.plaf.basic.BasicButtonUI.getMinimumSize(Unknown Source)
at javax.swing.JComponent.getMinimumSize(Unknown Source)
at javax.swing.BoxLayout.checkRequests(Unknown Source)
at javax.swing.BoxLayout.minimumLayoutSize(Unknown Source)
at java.awt.Container.minimumSize(Unknown Source)
at java.awt.Container.getMinimumSize(Unknown Source)
at javax.swing.JComponent.getMinimumSize(Unknown Source)
at javax.swing.BoxLayout.checkRequests(Unknown Source)
at javax.swing.BoxLayout.minimumLayoutSize(Unknown Source)
at javax.swing.JToolBar$DefaultToolBarLayout.minimumLayoutSize(Unknown Source)
at java.awt.Container.minimumSize(Unknown Source)
at java.awt.Container.getMinimumSize(Unknown Source)
at javax.swing.JComponent.getMinimumSize(Unknown Source)
at javax.swing.BoxLayout.checkRequests(Unknown Source)
at javax.swing.BoxLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.BorderLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at javax.swing.JRootPane$RootLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.BorderLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at java.awt.Window.pack(Unknown Source)
I don't understand this (Unknown Source) because my new class is a sub class from JButton.
An idea ?
JComponents are all containers, but only artifactually since they all extend java.awt.Container. The UI delegate for JButton (and its sibling components) is not going to expect components to be added to JButton. What you are seeing is the UI breaking when trying to calculate preferred size.
Instead of this approach, add two JButtons to a container and manage the interaction through the container. That will accomplish the same thing (largely) and not break L&F.
Mitch Goldstein
Author, Hardcore JFC
[email protected]
Similar Messages
-
Batch Input : Adding component with C002
Hi all
I try to add component on a production ordrer with C0O2 but i have problem with the item category 'R' (Variable-size item). In fact, SAP ask me to fill variable-size item data but i can't run this step with batch input.
For example with the batch input recorder, i obtain :
SAPLCOKO1 0110 X
BDC_OKCODE /00
CAUFVD-AUFNR 10001280
SAPLCOKO1 0115 X
BDC_OKCODE =KPU2
SAPLCOMK 0120 X
BDC_CURSOR RESBD-LGORT(23)
BDC_OKCODE /00
FILTER_BOX NO_FIL
SORT_BOX ST_STA
RESBD-MATNR(23) SAM6506P00055
RESBD-MENGE(23) 2
RESBD-EINHEIT(23) M
RESBD-POSTP(23) R
RESBD-VORNR(23) 0040
RCOLS-APLFL(23) 23
RESBD-WERKS(23) 0200
RESBD-LGORT(23) 0010
BDC_SUBSCR SAPLCOKO1 0800ORD_HEADER
BDC_SUBSCR SAPLCOMK 0050BUTTONS
BDC_SUBSCR SAPLCOMD 0160SUBSCR_0100
BDC_CURSOR RESBD-ROMEI
RESBD-MATNR SAM6506P00055
RESBD-ROMS1 1000
RESBD-ROMEI MM
RESBD-ROKME M
Is there other way to fill variable-size item ? Have you got ideas to simulate this step ?
I don't use FM because i have to fill the field RESBD-VORNR.
Thanks in advance for your response.
Patrick.In fact the choice that i have made was wrong.
Adding component with CO02 is possible with ls_params-nobinpt = ''. -
JTabbedPane switching from within added component
Hey guys,
Anyone know how/if its possible to change between JTabbedPanes
by using a button within a component added to one of the Panes?
Class A has a JtabbedPane in it
and Class B extends JPanel and is added to the TabbedPane
as a Component
Is there anyway to have a buttonclick in class b to switch to
another tab in the parent class?import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class AddingATab
public static void main(String[] args)
BasicGUI gui = new BasicGUI();
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(gui.getUIChanger(), "North");
f.getContentPane().add(gui.getMainUI());
f.setSize(400,400);
f.setVisible(true);
class BasicGUI
JTabbedPane tabbedPane;
public BasicGUI()
tabbedPane = new JTabbedPane();
public JTabbedPane getMainUI()
JPanel
redPanel = new JPanel(),
bluePanel = new JPanel();
redPanel.setBackground(Color.red);
bluePanel.setBackground(Color.blue);
tabbedPane.addTab("red", redPanel);
tabbedPane.addTab("blue", bluePanel);
return tabbedPane;
public JPanel getUIChanger()
JButton add = new JButton("add tab");
add.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
String nextTab = "tab " + String.valueOf(tabbedPane.getTabCount()+1);
tabbedPane.addTab(nextTab, new AddOnPanel(tabbedPane));
JPanel panel = new JPanel();
panel.add(add);
return panel;
class AddOnPanel extends JPanel
JTabbedPane tabbedPane;
public AddOnPanel(JTabbedPane tp)
tabbedPane = tp;
addNavButtons();
private void addNavButtons()
int numberTabs = tabbedPane.getTabCount();
JButton[] buttons = new JButton[numberTabs];
ActionListener l = new ActionListener()
public void actionPerformed(ActionEvent e)
JButton button = (JButton)e.getSource();
int index = tabbedPane.indexOfTab(button.getActionCommand());
tabbedPane.setSelectedIndex(index);
for(int i = 0; i < buttons.length; i++)
String ac = tabbedPane.getTitleAt(i);
buttons[i] = new JButton(ac);
buttons.setActionCommand(ac);
buttons[i].addActionListener(l);
add(buttons[i]); -
Problem with adf table when adding component in table column.
Hi All,
i am using jdev version 11.1.1.5.0.
use case: i have created one adf table which is based on DC VO. now i have added one select one radio group component(which contain 4 radio button approved ,reject,back,None) in adf table.
table have many rows for example in first row i have select approved and to next row i have select reject now when i get value of radio group in backing bean using component binding i got last selected value.(in that case reject).
And second is that when i set radio button value for current row using binding like
rb.setValue("R") then reject option selected for all rows.
so my question is that-
how can i get and set value of select one radio group in row level using component binding.Hi,
I don't see a reason for not using a transient attribute for the radioGroup in your previous reply.
Here is the example i tried.
<af:selectOneRadio label="#{bindings.DeptView1.hints.DeptnoRadio.label}" id="sor1"
value="#{row.bindings.DeptnoRadio.inputValue}">
<af:selectItem label="A" value="A" id="si1"/>
<af:selectItem label="B" value="B" id="si2"/>
<af:selectItem label="C" value="C" id="si3"/>
<af:selectItem label="D" value="D" id="si4"/>
<af:selectItem label="E" value="E" id="si5" disabled="#{row.bindings.EnableDisable.inputValue}"/>
</af:selectOneRadio>Where DeptnoRadio is the transient attribute i've created (which will have some random values between A and E), and EnableDisable is another transient variable of boolean type which would return true or false based on some condition.
Now, for every row, the value is different (and corresponding radio button is selected) and for a row, which matches the condition, the option E is disabled.
-Arun -
Adding Component above all other components
My initial problem is to put the panel (which is created as a result of a click on a button) above all components that have been added to the GBLTablePanel. I've written the following sample that demonstrates my problem
package test;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;
public class GBLTablePanel extends JPanel {
private final GridBagLayout layout;
private final GridBagConstraints gbc;
public GBLTablePanel() {
layout = new GridBagLayout();
gbc = new GridBagConstraints();
setLayout(layout);
JTable table = new JTable();
table.setModel(new DefaultTableModel(new Object[][] {
{ "aaaaaaaaaaaaaaa", 3, "a", null }, { "adasda", 10, "b", null },
{ "aaaaaaaaaaaaaaa", 3, "a", null }, { "adasda", 10, "b", null },
{ "aaaaaaaaaaaaaaa", 3, "a", null }, { "adasda", 10, "b", null },
{ "aaaaaaaaaaaaaaa", 3, "a", null }, { "adasda", 10, "b", null },
{ "assssss", 55, "c", null }, { "asdafasfa", 44, "d", null } },
new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
JScrollPane scrollPane = new JScrollPane(table);
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
layout.setConstraints(scrollPane, gbc);
add(scrollPane);
JButton showPanelBtn = new JButton(new AbstractAction("Show panel") {
@Override
public void actionPerformed(ActionEvent e) {
/* When this button is clicked I want that panel to appear on the top (above all components of the GBLTablePanel ) */
JPanel panel = new JPanel();
panel.add(new JLabel("This must be on the top of JTable"));
panel.setSize(panel.getSize().width, 30);
panel.setPreferredSize(new Dimension(panel.getPreferredSize().width, 30));
layout.setConstraints(panel, gbc);
gbc.gridy = 0;
GBLTablePanel.this.add(panel, 0);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.gridy = 1;
layout.setConstraints(scrollPane, gbc);
add(showPanelBtn);
public static void main(String[] args) {
JFrame f = new JFrame("Test");
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
/* Construct table managed by GridBagLayout */
GBLTablePanel panel = new GBLTablePanel();
f.add(panel);
f.pack();
f.setVisible(true);
}I hope the example is not too confusing, honestly I'm not sure what do I try next to fix my problem. The panel simply does not show up :(Here is an example that might help you with using GridBagLayout:
package table;
* TableInGridbaglayout.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TableInGridbaglayout extends JFrame {
private JButton btShowPanel;
private JPanel panel;
private JTable table;
private boolean show;
public TableInGridbaglayout() {
super("TableInGridbaglayout");
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setSize(400, 300);
setLocationRelativeTo(null);
panel = new JPanel();
table = new JTable(4, 4);
btShowPanel = new JButton("Show Panel");
panel.setBorder(BorderFactory.createTitledBorder("Panel on top of table"));
panel.setVisible(false);
getContentPane().setLayout(new GridBagLayout());
GridBagConstraints gridBagConstraints;
//panel:
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridheight = 3;
gridBagConstraints.fill = GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 0.3;
getContentPane().add(panel, gridBagConstraints);
//table:
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
getContentPane().add(new JScrollPane(table), gridBagConstraints);
//button:
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 4;
gridBagConstraints.anchor = GridBagConstraints.SOUTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 0.1;
getContentPane().add(btShowPanel, gridBagConstraints);
btShowPanel.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent evt) {
show = !show;
btShowPanel.setText(show ? "Hide Panel" : "Show Panel");
panel.setVisible(show);
public static void main(final String args[]) {
EventQueue.invokeLater(new Runnable() {
public void run() {
new TableInGridbaglayout().setVisible(true);
} -
In some design work I was doing I needed to use a vacuum tube type that is not available in Multisim.
After some research on how to add a component I tracked down a spice model of this part and used the component wizard to add it.
After adding it and putting it in a circuit it will simulate fine for a few moments then errors will occur and it will not allow me to restart the simulation there after.
Here is the spice model I'm using, and I've attached a screen cap of the error messages. Any help fixing the errors would be appreciated.
* Filename: SV6AS7.inc V1 25/8/97
* Simulator: PSpice
* Device type: Power triode
* Device model: Svetlana 6AS7
* Author: Duncan Munro
* Date: 25/8/97
* Copyright: (C)1997-2000 Duncan Amplification
* The following parameters are not modelled:
* (1) Heater is not modelled.
* (2) Grid current is not modelled.
* Please note that this model is provided "as is" and
* no warranty is provided in respect of its suitability
* for any application.
* This model is provided for educational and non-profit use.
* Email queries to [email protected]
* Pins A Anode
* G Grid
* K Cathode
.SUBCKT 6AS7 A G K
* Calculate reduction in mu at large negative
* grid voltages
Emu mu 0 VALUE={PWRS(V(G,K),0.88)}
* Emission reduction due to low Va
Eel el 0 VALUE={ATAN(LIMIT(V(A,K),0,1E6)/10)}
* Calculate change in shape with reducing grid voltage
Eshape shape 0 VALUE={(220+V(G,K))/220}
Egs gs 0 VALUE={LIMIT(V(A,K)+V(mu)*2.8,0,1E6)}
Egs2 gs2 0 VALUE={PWRS(V(gs)*V(shape),1.5)*410E-6}
Ecath cc 0 VALUE={V(gs2)*V(el)}
* Calculate anode current
Ga A K VALUE={V(cc)}
* Capacitances
Cgk G K 8p
Cga A G 11p
Cak A K 3p
.ENDSokay I guess the screen cap won't work. Here is the copy pasted error code I'm getting
------ Checking SPICE netlist for Reverse Futterman OTL 1.2 - Saturday, July 20, 2013, 2:36:07 PM ------
SPICE Netlist Error in schematic RefDes 'u2', element 'xu2_b': Invalid subckt definition name '33'
SPICE Netlist Error in schematic RefDes 'u2', element '': Due to errors, the subckt instance 'xu2_b' has been omitted from the simulation
SPICE Netlist Error in schematic RefDes 'u2', element 'xu2_a': Invalid subckt definition name '21'
SPICE Netlist Error in schematic RefDes 'u2', element '': Due to errors, the subckt instance 'xu2_a' has been omitted from the simulation
======= SPICE Netlist check completed, 4 error(s), 0 warning(s) =======
Error message from simulation: doAnalyses: Timestep too small
Error message from simulation: tran simulation(s) canceled -
I was able to download the spice (.MOD file) models for components I want to use from National Semiconductor, but for the life of me can't figure out how to import the models into multisim so I can use them. How do I do this?
The following tutorial should be able to walk you through the process of creating a custom component in Multisim, including adding a model to your component for simulation:
http://zone.ni.com/devzone/cda/tut/p/id/3173
Let me know if you still have questions.
Natasha Baker
R&D Engineer
National Instruments
Join the NI Circuit Design Community
Follow Multisim on Twitter! -
Adding Component to JFileChooser excludes other components
I want to add a JComboBox component to a JFileChooser but when I do, the default components that are supposed to be in that space don't show up.
For example, in the JFileChooser, there are several components (like the accept and cancel buttons) in the SOUTH area of the BorderLayout. When I add a custom combobox like so:
JFileChooser fc = new JFileChooser();
cb = new JComboBox();
fc.add(cb, BorderLayout.SOUTH);
dialogResult = fc.showSaveDialog();the combobox I added is the ONLY component which shows up in the SOUTH area.
I have tried adding the combobox as an accessory, but it always shows up to the right of the file browser window. If I can control where the accessory shows up, that would be fine, but I don't see any way to do that.
I don't understand why the other components wouldn't show up?
Thanks in advance for any help.fc.add(cb, BorderLayout.SOUTH);
This line replaces the components that were
previously in that space - read the tutorial on
BorderLayout. In addition, this code is very brittle
and you can have no guarantee that it will work under
different look-and-feels and in future versions of
JDK, since you're making some far-fetching
assumptions on the internal implementation of the
file chooser dialog.Thanks very much for the help!
Fundamentally, i did not realize that in BorderLayout you may only set ONE component to each area (NORTH, SOUTH, CENTER, etc.).
Once I understood that, I grabbed the component at the bottom of the filechooser and placed it in a JPanel with the components I wanted to Add to the bottom.
This worked perfectly!
I am uncertain, however, about why you say the code is "brittle" and what you mean by making assumptions regarding the internal implementation.
In any case, thanks again for your help!
For anyone else who is interested, here is what the code looks like
JFileChooser fc = new JFileChooser();
JComboBox cb = new JComboBox();
JPanel panel = new JPanel();
BoxLayout box = new BoxLayout(panel,BoxLayout.Y_AXIS);
BorderLayout layout = (BorderLayout) fc.getLayout();
panel.setLayout(box);
Component comp = layout.getLayoutComponent(BorderLayout.SOUTH);
panel.add(comp);
panel.add(cb);
fc.add(panel,BorderLayout.SOUTH); -
Adding component to Navigation Panel -
Hi,
I have developed a JSPDynPage Component. After developing the component I need to add that component to my Navigational panel using an iView. Unfortunately I am not able to achieve this.
Can anybody please suggest me how to add a JSPDynPage component to Navigational panel?
Thanks in advance for your responses!!!!
--VishalVishal,
Unfortunately, this is not an easy task. Have you worked with the Default Framework Page before?
Read the following links;
Default Framework Page
http://help.sap.com/saphelp_nw2004s/helpdata/en/b4/771158e4cb4bf6af9974380948db86/frameset.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/97/d4ee3d6434445ae10000000a11405a/frameset.htm
Regards,
James -
Adding ImageIcon to a JButton going wild
I have my jbutton, and I tried to apply an image to it.
The thing is, for some reason, the button become huge.
buttonJPanel=new JPanel();
this.buttonJPanel.setName("Buttons Panel");
GridLayout glo=new GridLayout(1,4);
glo.setHgap(15);
this.buttons[0] = new JButton();
this.buttons[0].setText("Fold");
//this.buttons[0].setIcon(buttonIcon);
this.buttons[0].setHorizontalTextPosition(SwingConstants.CENTER);
this.buttons[0].setVisible(false);
this.buttons[0].setToolTipText("Click this button to fold the game");
this.buttonJPanel.add(buttons[0]);before
[http://img518.imageshack.us/img518/6132/28150670.jpg]
after
[http://img518.imageshack.us/img518/3057/50479825.jpg]JButton#setContentAreaFilled(false);
JButton#setRolloverEnabled(false);
JButton#setBorder(null); -
Hello everybody,
I'm using JFrame and I want to add component in a specific pixels. How I do that without layouts?
The function setBound() doesn't work... Generally I want add all my component by pixels because the layouts just driving me crazy...
thanks for all helpersHi,
you should do it with a layout manager, the below link is a tutorial to do it without a layout manager ( absolut ) which is NOT recommended
[AbsoluteLayoutManager |http://java.sun.com/docs/books/tutorial/uiswing/layout/none.html]
Please let me know if you have an query around the sample code
Regards,
Alan Mehio
London,UK
Edited by: alan_mehio on 29-Jan-2009 19:30 -
Adding Component, Activity, Changing Activity through BAPI
Hello Everyone,
I have a requirement to develop a FM which will use the standard BAPI's to create an Activity, Change the activity status, and also add a component to the activity.
Am using BAPI_BUS2002_SET_STATUS to set the status of the activity, understand have to use BAPI_PS_INITILIZATION with it.
Using BAPI_NETWORK_MAINTAIN to maintain the activity, BAPI_NETWORK_COMP_ADD to add the component.
But the sequence of the initiailzation that I have developed are not helping me update the all of the required data.
Basic question would be a procedure to update activity, activity status and create component.
If anybody has used the above BAPI's or developed similar applications would be very much helpful.
Regards,
PrashanthHi Koushik,
Thanks for the reply,
But still I need to know what are the specific difference between the two function module.Even in CRM_ORDER MAINTAIN I am able to get all those Structure with which I am working in BAPIACTIVITYCRM_CREATEMULTI. I know all the other CRM Business transaction can be created through CRM_ORDER_MAINTAIN. If you could explain a bit detail in what context one should use CRM_ORDER MAINTAIN and BAPIACTIVITYCRM_CREATEMULTI. -
Need help for adding component
i have 2 class, the first one is Workspace.java, the other one is BannerBox.java,
in my BannerBox.java, the code is look like this:
public class BannerBox extends JPanel{
private JLabel bannerLabel;
public BannerBox(){
setLayout( new GridBagLayout());
bannerLabel = new JLabel();
bannerLabel.setIcon(SparkRes.getImageIcon("TEST_IMAGE"));
bannerLabel.setHorizontalAlignment(JLabel.LEFT);
add(bannerLabel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
setBorder(BorderFactory.createLineBorder(new Color(197, 213, 230), 1));
in my Workspace.java i've tried to add the bannerbox into workspace
and my code is looks like this:
public class Workspace extends JPanel implements PacketListener {
private BannerBox bannerBox;
private Workspace(){
add(bannerBox, new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 4, 4, 4), 0, 0));
There is no error, so i can run it, but the bannerbox is not showed up... hmm, what should i do?
is there some mistake that make this code doesn't work?
(actually this class has a long code, but i can't put it all here, it very long code, and workspace.java is not my code so i barely understand the code but i need to add the label which contain image to this workspace)
need help here.. i'm stuck..
thx before
ralese1) In the future, Swing related questions should be posted in the Swing forum (after searching to make sure it hasn't been asked before)
2) Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.
3) Learn how to use other layout manager before using the GridBagLayout. All the others are much easier to understand
4) Read the Swing tutorial on [How to Use Icons|http://java.sun.com/docs/books/tutorial/uiswing/TOC.html] for a working example.
5) If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour. -
Adding Dynamic JButtons & JLabels on the JTool
On occerance of certain ActionEvent i need to add dynamic JButtons & JLabels on the JToolBar. Initially JToolBar will be empty.
Code below is not working properly...
It is creating buttons dynamiclly but i cant set any property for that one.
class DeviceAction extends AbstractAction
public DeviceAction()
// Add this action to the toolbar resulting
// in a new button getting added to the
// toolbar
JButton jbutton = xmlFilesToolBar.add( this);
xmlFilesToolBar.addSeparator();
jbutton.setActionCommand( "Dynamic" );
I will call " new DeviceAction(); " when ever ActionEvent occurs.
I need to have controle over the dynamically added JButtons & JLables, bcoz each JButtons shld do some Actions when it is clicked.
Plz do the needful.
Reg,
Bha.Multi-post: http://forum.java.sun.com/thread.jspa?threadID=725394&tstart=0
-
Dynamic add component to panel, it does't work
I want to add a label in a panel when you click button.
I used revalidate() and revalidate() method, but it didn't appear in panel.
HELP ME?? WHAT'S WRONG!
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
jPanel1.add(new JLabel("Hello"));
jPanel1.revalidate();
jPanel1.repaint();
}i add Layout manager to panel. It works. Thanks,
So tricky things for dynamic adding component:
1, setup layout manager to container (such as panel),
2, add component to container
3, call revalidate() method to relayout these components in container
You can't miss any one of those.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
jPanel1.setLayout(new FlowLayout());
jPanel1.add(new JButton("Hello"));
jPanel1.revalidate();
}
Maybe you are looking for
-
How to restrict the display of Integrator in Web ADI
Hi, I have developed two Integrators using Web ADI in Oracle application R12.First Integrator is used for download the data and second for Update the data in system. For both integrator separate two function are created and tagged with single menu.Wh
-
My firewall won't let me quit Word
I finally got a broadband connection but I've run into a little snag: I can't quit Word and I have to resort to force quitting. On the macoshints forum I learned that this could be caused by my firewall. According to the writer, "the microsoft databa
-
I have a JEditorPane and aside a DnD JTree. The problem is that I can drag from the tree to the editor and I don't want that. I want the editor to reject the drop ( as I can do in tree).
-
Do I need Toast 7 Titanium?
I mostly use the SuperDrive in my Rev A iMac for burning DVD's of short movies that I make, and for backup copies of those that I buy. I use an external hard drive as a clone/backup for everything on my internal drive. The reason I am asking this que
-
I'm having a problem with the JTable headers, in that I am trying to use a function that sets the initial column sizes for each of the columns, using a AbstractTableModel derivative. But the headers, once rendered, after column 10, seem to have the f