W2R2 –Bring up a Dialog Box - finished everything for dialogue box. moving onto actions for dialogue box.
This commit is contained in:
1 parent
d13f8db979
commit
dffe04254f
1 file changed
+27
-11
@@ -42,27 +42,47 @@ public class MainViewer {
|
|||||||
|
|
||||||
System.out.println("Row number: "+ row + " Has been created!");
|
System.out.println("Row number: "+ row + " Has been created!");
|
||||||
|
|
||||||
ActionListener buttonListener = new ActionListener() {
|
ActionListener EditListener = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
System.out.println("Edit Button clicked for Row: " + row + " with Radio Button Text as: " + JR.getText());
|
System.out.println("Edit Button clicked for Row: " + row + " with Radio Button Text as: " + JR.getText());
|
||||||
DialogueBox(JR.getText());
|
DialogueBox(JR.getText(), JR);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
JEdit.addActionListener(EditListener);
|
||||||
JEdit.addActionListener(buttonListener);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void DialogueBox(String JRtext){
|
public void DialogueBox(String JRtext, JRadioButton JR){
|
||||||
JOptionPane pane = new JOptionPane(JRtext); // content of dialogue box
|
|
||||||
JDialog dialog = pane.createDialog("Change Name to what?"); // title of dialogue box
|
|
||||||
|
JTextField JT = new JTextField(JRtext);
|
||||||
|
JLabel JT1 = new JLabel("Enter new text:");
|
||||||
|
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setLayout(new GridLayout(0,1));
|
||||||
|
|
||||||
|
panel.add(JT1);
|
||||||
|
panel.add(JT);
|
||||||
|
|
||||||
|
|
||||||
|
JOptionPane pane = new JOptionPane(panel, 3, 2); // content of dialogue box
|
||||||
|
JDialog dialog = pane.createDialog("Rename Dialogue Box"); // title of dialogue box
|
||||||
dialog.setVisible(true); // changed boiler plate code from .show() to .setVisible(true) because apparently IDE says it's better!!
|
dialog.setVisible(true); // changed boiler plate code from .show() to .setVisible(true) because apparently IDE says it's better!!
|
||||||
|
|
||||||
|
// actions.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void TabMaker(String Pname, JTabbedPane JT)
|
public void TabMaker(String Pname, JTabbedPane JT)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -76,10 +96,6 @@ public class MainViewer {
|
|||||||
{
|
{
|
||||||
CreateRow(i, page);
|
CreateRow(i, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainViewer() // main viewer window
|
public MainViewer() // main viewer window
|
||||||
|
|||||||
Reference in new issue
Block a user