joptionpane

Need Help adding a difficulty option for User functionality

二次信任 提交于 2019-12-02 07:27:58
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 might work. (I'm just not sure how to do one for the A.I selection) Current A.I's ai1 ai2 ai3 package

Close showOptionDialog after 5 seconds if not button is pressed in java

为君一笑 提交于 2019-12-02 07:04:51
问题 I have a showOptionDialog that ask if the user wants to delete something. I want to close the frame and not delete if nothing is press after 5 seconds. How can I achive this? Here is my code: JFrame frame = new JFrame(); frame.setAlwaysOnTop(true); Object[] options = {"OK"}; int n = JOptionPane.showOptionDialog(frame,"Do you want to delete?","Title",JOptionPane.PLAIN_MESSAGE,JOptionPane.QUESTION_MESSAGE,null,options,options[0]); if (JOptionPane.OK_OPTION == n) { System.out.println("Delete");

JoptionPane multi select and srollable option

家住魔仙堡 提交于 2019-12-02 04:34:54
I'm new to JoptionPane is there any method that i can have multi select and scrollable feature. Please find my code below. String bigList[] = new String[100]; for (int i = 0; i < bigList.length; i++) { bigList[i] = Integer.toString(i); } for scrolling i'm using JOptionPane.showInputDialog(new JFrame(), "Pick a printer", "Input", JOptionPane.QUESTION_MESSAGE,null, bigList, "Titan"); for multi select im using JList list = new JList(bigList); JOptionPane.showMessageDialog(null, list, "Select Test Case (For Multiple Selections Press 'Ctrl') ", JOptionPane.PLAIN_MESSAGE); problem is i need to

how to change font size of JOptionPane

若如初见. 提交于 2019-12-02 03:59:58
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, "MINES AND GEOSCIENCES BUREAU - REGION XI, DAVAO CITY\n" + " LIST OF REGISTERED EMPLOYEES", "Please

JOptionPane in Java

ⅰ亾dé卋堺 提交于 2019-12-02 01:15:17
Does anyone know why tab (\t) does not work with JOptionPane.showMessageDialog? My code is as follows: String addText = "NAME\t\tADDRESS\t\tTEL.No\tEMAIL\n"; for (int i = 0; i < addressBookSize; i++) { addText = addText+entry[i].viewAllInfo(); } System.out.print(addText); JOptionPane.showMessageDialog(null, addText); Are there other ways to align text in JOptionPane? Put your tabbed text into JTextArea String addText = "NAME\t\tADDRESS\t\tTEL.No\tEMAIL\n"; for (int i = 0; i < addressBookSize; i++) { addText = addText+entry[i].viewAllInfo(); } System.out.print(addText); JOptionPane

Java full screen exclusive mode

旧城冷巷雨未停 提交于 2019-12-02 01:14:23
I made my application to be full screen in exclusive mode but when I show an input dialog the application is minimized. I want the application to stay full screen and the input dialog to be show over it. This is how I render my application full screen: setUndecorated(true); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); gs.setFullScreenWindow(this); validate(); Edit: This is how I open the dialog: JOptionPane.showMessageDialog(StartingPoint.this,txt, "You are on: " + planet, JOptionPane.INFORMATION_MESSAGE, icon);

How to Delay MessageDialogBox in Java?

天涯浪子 提交于 2019-12-02 00:04:34
问题 So in this chunk of code: //Actions performed when an event occurs. public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); //If btnConvertDocuments is clicked, the FileConverter method is called and the button is then disabled [so as to prevent duplicates]. if (command.equals("w")) { new Thread(new Runnable() { public void run() { FileConverter fc = new FileConverter(); } }).start(); btnConvertDocuments.setEnabled(false); //Validation message ensuring

How to Delay MessageDialogBox in Java?

╄→гoц情女王★ 提交于 2019-12-01 22:42:57
So in this chunk of code: //Actions performed when an event occurs. public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); //If btnConvertDocuments is clicked, the FileConverter method is called and the button is then disabled [so as to prevent duplicates]. if (command.equals("w")) { new Thread(new Runnable() { public void run() { FileConverter fc = new FileConverter(); } }).start(); btnConvertDocuments.setEnabled(false); //Validation message ensuring completion of the step. JOptionPane.showMessageDialog(this, "Step 1 Complete!", "Validation", JOptionPane

JOptionPane title bar icon

不羁的心 提交于 2019-12-01 21:53:39
I'd like to replace the icon in a JOptionPane title bar (as it currently shows the default Java coffee logo). I tried the following: JOptionPane.showMessageDialog(null, "Some Text", "Login", JOptionPane.INFORMATION_MESSAGE, ImageCacheProvider .instance.getImageIcon("img/an image.png")); It replaces the icon in the window but not the one in the title bar: Is there any approach to change the icon in the title bar or alternatively to hide the default Java icon without having to implement a JDialog class? Thanks a bunch! Thomas Sainath S.R Use it like this: Icon icon = new ImageIcon("d:/temp

java.util.IllegalFormatConversionException: f != java.lang.String Error

折月煮酒 提交于 2019-12-01 21:25:05
问题 import javax.swing.JOptionPane; public class Minutes { public static void main(String[] args) { double BasePlanCost = 20; final double BaseCostPerMinute=0.15; double MinutesUsed = Double.parseDouble(JOptionPane.showInputDialog("Please enter the amount of minutes Used: ")); double CostForMinutes = BaseCostPerMinute * MinutesUsed; double GrandTotal = BasePlanCost + CostForMinutes; JOptionPane.showMessageDialog(null, String.format("$%.2f","**IST Wireless Receipt**","\n","Base Plan Cost:"