Re: Help with Swing
What I am trying to achieve here is say is a GUI application designed
with Swing- The first of the tasks will be when I click the Add1st
Button it disappears and in its place three buttons appears namely Up
Arrow icon,Down Arrow and delete button. Also in addition to this
three textfields used by the SetBounds(I am new to setBounds as I am
used to limited simple GUI creation such as BorderLayout,GridLayout
for look and feel appearance) property appears.Say I enter a string in
each of the textfields and then press the Up Arrow (ToolTipText Add
One Row Above) Button , the textfield flips over(like the version of
"Spinner Control") and the textfields appears empty,prompting the user
to enter another row of entry(the previous entry should be stored
dynamically and should show up when the Down Arrow Button is pressed).
Till date after trying many controls I have been unable to show the
textfields and the three buttons on clicking the Add 1st button
A small version of code
//Declarations somewhere
public class T1Panel implements IEEventListener{
private static final String AddActions="RC_ADDFIRST";
private IEButton AddFirstButton;
private IEButton rowControlButton;
private static final String[] ROW_CONTROL_ACTIONS =
{"RC_UP","RC_DOWN","RC_DELETE"};
public void go() {
// Add UpDownDEL Buttons
AddFirstButton=new IEButton("");
AddFirstButton.setBounds(setHeaderRowX_Pixels
+45,row*IEFrame.ROW_HEIGHT+15,40,IEFrame.ROW_HEIGHT+4);
AddFirstButton.setIcon(new javax.swing.ImageIcon("images/
T1DriverAdd1st.jpg"));
AddFirstButton.setToolTipText("Add 1st row");
AddFirstButton.setActionCommand(AddActions);
panelStats.checkMaxX_bounds(AddFirstButton.getBounds());
AddFirstButton.addActionListener(this.t1Frame);
aContainer.add(AddFirstButton);
row++;
// Get the actioncommand of button AddFirstButton so that row
fields are displayed and row control button shows up
buttonClickV2("AddActions","");
if ("RC_ADDFIRST" .equals(AddFirstButton.getName())) // Not sure If
I am doing right here
{
int numFields = tfs.getNumFieldsInSet();
// Getting the number of fields row fields so
that makeTextField method can be used to display the textfields....
//numFields = -1;
int xOffset = fieldXOffset;
for(int i=0;i<numFields;i++) {
T1Field fldInSet = tfs.getNthField(i);
int fldInSetType = fldInSet.getFieldType();
if(fldInSetType != T1Field.FLD_TYPE_SLCT2) {
IETextField e2 =
makeTextField(fldInSet.getInputLength(),fldInSet,xOffset,row); // new
IETextField(flen);
paramData.addNthObject(0,i,e2);
aContainer.add(e2);
xOffset += (fldInSet.getInputLength() +
T1FieldSet.X_STR_BETWEEN_SET_FIELDS.length()) *
IEFrame.COL_WIDTH_PER_CHAR;
} else {
JComboBox cb1 = makeComboBox(fldInSet,xOffset,row);
paramData.addNthObject(0,i,cb1);
xOffset += ( cb1.getBounds().width + cb1.getBounds().x) +
(T1FieldSet.X_STR_BETWEEN_SET_FIELDS.length()) *
IEFrame.COL_WIDTH_PER_CHAR;
aContainer.add(cb1);
}
}
}
//Checks if fieldset rows is complete
for(int b=0;b<3;b++) {
rowControlButton = new IEButton("");
rowControlButton.setActionCommand(ROW_CONTROL_ACTIONS[b]);
rowControlButton.setVisible(false);
if(b == 0) {
rowControlButton.setIcon(new javax.swing.ImageIcon("images/
T1DriverUp.jpg"));
rowControlButton.setToolTipText("Add 1st Row Above");
}
else if(b == 1) {
rowControlButton.setIcon(new javax.swing.ImageIcon("images/
T1DriverDown.jpg"));
rowControlButton.setToolTipText("Add One Row below");
}
else if(b == 2) {
rowControlButton.setIcon(new javax.swing.ImageIcon("images/
T1DriverX.jpg"));
rowControlButton.setToolTipText("Delete row");
}
rowControlButton.setBounds(setHeaderRowX_Pixels + (45*(b
+2)),row * IEFrame.ROW_HEIGHT,40,IEFrame.ROW_HEIGHT);
panelStats.checkMaxX_bounds(rowControlButton.getBounds());
rowControlButton.addActionListener(this.t1Frame);
aContainer.add(rowControlButton);
}
}
}
// Button Clicks - events
public void buttonClickV2(java.lang.String buttonLabel,String msg) {
if(true)
System.err.println("buttonClickV2 - label->" + buttonLabel + " Msg-
" + msg);
if(IEFrame.BUTTON_CLICK_DEBUG)
System.err.println("T1Panel.buttonClickV2 - CLICKS= " +
T1Panel.BUTTON_CLICKS++ + " buttonClick Method In T1Panel ->" +
buttonLabel + " Msg->" + msg);
if (buttonLabel.equals("Cancel")) {
fieldsValidA(this.paramData, false);
// call to set values so Part/Oper updated on mod select
this.drvr.T1PanelCancel(false);
return;
}
else if(buttonLabel.equals(VIEW_MODEL) ||
buttonLabel.equals(VIEW_FLAT)) {
T1Field tf = (T1Field) this.paramData.getFieldVector().get(0);
String p = tf.getUserInputStr();
boolean flat = false;
if(buttonLabel.equals(VIEW_FLAT))
flat = true;
this.drvr.startModelViewer(p,flat);
return;
}
else if(buttonLabel.equals(AddActions)){
System.err.println("Add 1st row to fieldset");
AddFirstButton.setVisible(false); // disables the button
this.t1Frame.repaint();
//Incomplete here
How do I call rowControlButton to setEnabled(true) because
setEnabled True of rowControlButton doesn't work ...Returns the last
row RoWControlActions[2] the Delete Icon button that is all....
Hope this helps
Thanks in advance ...WOuld like help .....in this....
On Sep 2, 2:58 pm, RedGrittyBrick <RedGrittyBr...@spamweary.invalid>
wrote:
GG Sriram wrote:
Hi
I am trying to "flip" over a JTextField(three) say for example I
have 4 buttons Add 1st, Add one row above , Add one row below and
Delete icon buttons. WHen I click on the Add 1st I must be able to
fill the JTextField(must be stored as string in dynamic
memory?...How ?? I dont know if anyone can help me here!!... When I
click Add One row above the JTextField shuffles and flip one row
previous which of course is empty... and I must be able to entter
another string....
I am confused as there is no mapping to JTable or usage of JTable to
store the text field strings... user inputs... Can anyone here help me
From your description I find it impossible to visualise what you are
trying to achieve and what your problem is.
* Is it an Application an Applet, JSF or something else?
* What is your GUI intended to look like?
* How is the GUI intended to change when the "Add 1st" button is clicked?
I suggest you post a small example after reading the guidelines athttp://=
sscce.org
--
RGB