joptionpane

I get only null from: Object selectedValue = jPane.getValue(); (jPane = new JOptionPane(…)

时光怂恿深爱的人放手 提交于 2019-12-02 16:57:03
问题 private void cancelButtonPressed() { jPane = new JOptionPane("quit?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, buttons, buttons[1]); jPane.setName("WPane"); dialog = jPane.createDialog(jPane.getParent(), "Confirm Dialog"); dialog.setVisible(true); dialog.dispose(); Object selectedValue = jPane.getValue(); System.out.println("selectedValue:" + selectedValue); if(selectedValue == null) System.out.println("selectedValue:" + selectedValue); //return CLOSED_OPTION; if(buttons

I would like to change this code to display only “OK” and delete the cancel button

删除回忆录丶 提交于 2019-12-02 13:08:53
I would like to change this code to display only "OK" and delete the cancel button. Object contestacion5 = JOptionPane.showInputDialog(null, "#5 Que describe mejor a la Norteña?", "Examen Tijuanas PR", //3 JOptionPane.DEFAULT_OPTION, null, new Object[] {"Ensalada de espinacas, tomates, zetas, cebolla, tocineta, aguacate, queso de hoja y tiras de maiz crujientes en vinagreta de la casa.", "Lechuga romana servida con tomate, cebolla, maiz, aguacate, queso de hoja y tiritas de maiz crujientes acompañado de su seleccion de filetes de pollo de res.", "Ensalada vegetariana de nopales, tomates,

White bars in the right and bottom sides of a canvas after a JOptionPane confirmDialog?

半腔热情 提交于 2019-12-02 12:51:59
So guys, using a JOptionPane to ask the user if the app should update or not, and after which I get these white bars in the bottom and right sides of my canvas. Tried removing the autoupdate thing and works fine. Here's my code GameUtils.init(); String version = AutoUpdate.checkForUpdates(); if (Double.parseDouble(version) > AutoUpdate.VERSION) { AutoUpdate.update(version); JFrame frame = null; try { frame = new JFrame(GameUtils.data.getString("title")); } catch (JSONException e) { e.printStackTrace(); } frame.getContentPane().setPreferredSize(new Dimension(1000, 500)); frame

Alternative to calling a static method via an instance

自古美人都是妖i 提交于 2019-12-02 12:30:29
JOptionPane jop = new JOptionPane( ); jop.showMessageDialog(“This is never done”); I'm told that this is done in poor taste. I mean it works, but apparently a "pro" would not do it thus as showMessageDialog is static. Is there a better way to write this? A static method can be invoked without a reference to an instance: JOptionPane.showMessageDialog("This is never done"); Actually, these line: JOptionPane jop = new JOptionPane(); jop.showMessageDialog("This is never done"); will be converted at compile time to: JOptionPane jop = new JOptionPane(); JOptionPane.showMessageDialog("This is never

I get only null from: Object selectedValue = jPane.getValue(); (jPane = new JOptionPane(…)

ⅰ亾dé卋堺 提交于 2019-12-02 11:29:01
private void cancelButtonPressed() { jPane = new JOptionPane("quit?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, buttons, buttons[1]); jPane.setName("WPane"); dialog = jPane.createDialog(jPane.getParent(), "Confirm Dialog"); dialog.setVisible(true); dialog.dispose(); Object selectedValue = jPane.getValue(); System.out.println("selectedValue:" + selectedValue); if(selectedValue == null) System.out.println("selectedValue:" + selectedValue); //return CLOSED_OPTION; if(buttons == null) { if(selectedValue instanceof Integer) { //return ((Integer)selectedValue).intValue(); System

JOptionPane Multidimensional Array output

时光总嘲笑我的痴心妄想 提交于 2019-12-02 10:25:00
Ok say I have Multidimensional array that I want to display in JOptionPane.showMessageDialog . I know that when using System.out.println , you use a for loop. However the array size is determined by the user input, therefore I have to use a incrementor. For example: userinput[k] next to usernumber[k] then the next row would be userinput[k+1] next to usernumber[k+1] The trouble I am having is that by using my loop, it does each set one at a time in separate windows and not all together in a table in one window. for (int k = 0; k < userinput.length; k++){ JOptionPane.showMessageDialog(null,

how to change font size of JOptionPane

余生颓废 提交于 2019-12-02 09:07:56
问题 import java.awt.ComponentOrientation; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JScrollPane; public class trial2 { public static void main(String[] args) { String[] option = {"Chorita M. Adlawan", "Noel B. Angeles", "Julie P. Benenoso", "Percival P.Bermas", "Beverly Mae M. Brebante","Adela N. Cabaylo", "Carol G. Cainglet", "Oscar U. Cainglet", String selected = (String)JOptionPane.showInputDialog(null,

How to select an index value from a String Array in a JOptionPane

北战南征 提交于 2019-12-02 09:01:19
I've created a JOptionPane as a selection method. I want the int value for selection 1,2 or 3 of the String Array so I can use it as a counter. How do I get the index of the array and set it equal to my int variable loanChoice? public class SelectLoanChoices { int loanChoice = 0; String[] choices = {"7 years at 5.35%", "15 years at 5.5%", "30 years at 5.75%"}; String input = (String) javax.swing.JOptionPane.showInputDialog(null, "Select a Loan" ,"Mortgage Options",JOptionPane.QUESTION_MESSAGE, null, choices, choices[0] **loanChoice =**); } You can use JOptionPane.showOptionDialog() if you want

get JSlider's input and changes

岁酱吖の 提交于 2019-12-02 07:40:39
I need to use JSlider with getting input live, meaning that it will return an input without pressing any button. I have this piece of code for the slider: JPanel panel = new JPanel(); JSlider js = new JSlider(JSlider.VERTICAL, 0, 20, 10); js.setMajorTickSpacing(2); js.setPaintTicks(true); Hashtable labelTable = new Hashtable(); labelTable.put(new Integer(js.getMinimum()), new JLabel("x0")); labelTable.put(new Integer((js.getMinimum() + js.getMaximum()) / 2), new JLabel("x1")); labelTable.put(new Integer(js.getMaximum()), new JLabel("x2")); js.setLabelTable(labelTable); js.setPaintLabels(true);

Need Help adding a difficulty option for User functionality

最后都变了- 提交于 2019-12-02 07:36:03
问题 Quick question, I have developed 3 A.I's each with a different depth. Currently to choose what A.I you want to play against you have to go into the java file called Main.java and change it to whichever one you want. The line to change is: chessGame.setPlayer(Piece.COLOR_BLACK, ai3);//Here A.I is assigned I want to allow the user to have an option at the start of the game to choose the A.I. I was hoping for some help with the interface, I was thinking something something like a JOptionpane