How can I get this textfield and dropdown menu working to do what I want?How can I concatenate two arrays in Java?How does the Java 'for each' loop work?How can I generate an MD5 hash?How can I initialise a static Map?How can I create an executable JAR with dependencies using Maven?How to get an enum value from a string value in Java?How can I convert a stack trace to a string?Getting the Current Working Directory in JavaHow to make Twitter Bootstrap menu dropdown on hover rather than clickCan I get a JTextField above an JEditorPane but below a JTabbedPane?

Did depressed people far more accurately estimate how many monsters they killed in a video game?

Why is the Cauchy Distribution is so useful?

Classical Greek for 'You came home to our hearts with your shield'?

I make billions (#6)

Is it ok for parents to kiss and romance with each other while their 2- to 8-year-old child watches?

What are the effects of abstaining from eating a certain flavor?

Object's height not a multiple of layer height

How to convert diagonal matrix to rectangular matrix

What happens to unproductive professors?

Is it okay to roll multiple attacks that all have advantage in one cluster?

A horrible Stockfish chess engine evaluation

Compressed gas thruster for an orbital launch vehicle?

Can a landlord force all residents to use the landlord's in-house debit card accounts?

Is there a strong legal guarantee that the U.S. can give to another country that it won't attack them?

Found and corrected a mistake on someone's else paper -- praxis?

Four ships at the ocean with the same distance

How should I ask for a "pint" in countries that use metric?

How do I explain that I don't want to maintain old projects?

Do we know SL(2,C) subgroups (not only finite ones)?

How many tone holes are there actually in different orchestral woodwind instruments?

Hail hit my roof. Do I need to replace it?

What's it called when the bad guy gets eaten?

Conditions for Roots of a quadratic equation at infinity

Bold and Colored Image Caption



How can I get this textfield and dropdown menu working to do what I want?


How can I concatenate two arrays in Java?How does the Java 'for each' loop work?How can I generate an MD5 hash?How can I initialise a static Map?How can I create an executable JAR with dependencies using Maven?How to get an enum value from a string value in Java?How can I convert a stack trace to a string?Getting the Current Working Directory in JavaHow to make Twitter Bootstrap menu dropdown on hover rather than clickCan I get a JTextField above an JEditorPane but below a JTabbedPane?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I don't expect anyone to do the work for me, but I'm having trouble finding the exact answers to my questions researching on my own. I'm trying to have a text field where the user must input an integer between 1 and 3 and then a drop down menu to pick a flavor (would like the drop down selection to either work as the way to submit or just get the menu itself to stay selected). After submission I want a window to pop up with a painted ice cream cone that changes color based on the flavor and the number of scoops to also be accurate to the user's input.



I have been trying to work with JOptionPanel as I thought maybe that in combination with some sort of ActionListener set up would do the trick for me, but I can't seem to find the how-to or advice I need to get the job done that way.



public void createGUI()

setDefaultCloseOperation(EXIT_ON_CLOSE);

Container window = getContentPane();
window.setLayout(new BorderLayout());

GridLayout mainLayout = new GridLayout(2,1);
GridLayout topLayout = new GridLayout(1,2);
GridLayout menuLayout = new GridLayout(6,2);

JLabel storeFront = new JLabel("Ice Cream Shop");
JLabel orderHere = new JLabel("Order Here");

ImageIcon storeImage = new ImageIcon("storefront.jpeg");
JLabel store = new JLabel(storeImage);

ImageIcon flavorsImage = new ImageIcon("flavors.jpeg");
JLabel flavors = new JLabel(flavorsImage);

JTextField numberScoops = new JTextField(5);


JMenuBar flavorMenu = new JMenuBar();
JMenu flavorIceCream = new JMenu();

JMenuItem chocolate = new JMenuItem("Chocolate");
JMenuItem vanilla = new JMenuItem("Vanilla");
JMenuItem strawberry = new JMenuItem("Strawberry");
flavorIceCream.add(chocolate);
flavorIceCream.add(vanilla);
flavorIceCream.add(strawberry);

flavorMenu.add(flavorIceCream);

JPanel iceCreamShop = new JPanel();
iceCreamShop.setBackground(Color.gray);
iceCreamShop.add(store, BorderLayout.CENTER);

JPanel iceCreamMenu = new JPanel();
iceCreamMenu.setBackground(Color.gray);
JPanel menuPanel = new JPanel();
menuPanel.setBackground(Color.gray);
menuPanel.setLayout(menuLayout);

menuPanel.add(new JLabel("Chocolate"));
menuPanel.add(new JLabel("$2.00/scoop"));
menuPanel.add(new JLabel("Vanilla"));
menuPanel.add(new JLabel("$2.00/scoop"));
menuPanel.add(new JLabel("Strawberry"));
menuPanel.add(new JLabel("$2.25/scoop"));
menuPanel.add(new JLabel("How Many Scoops?"));
menuPanel.add(numberScoops);
menuPanel.add(new JLabel("what flavor?"));
menuPanel.add(flavorMenu);
menuPanel.add(new JButton("clear"));
menuPanel.add(new JButton("submit"));
iceCreamMenu.add(menuPanel);

JPanel iceCreamOrder = new JPanel();
iceCreamOrder.setLayout(topLayout);
iceCreamOrder.add(iceCreamShop);
iceCreamOrder.add(iceCreamMenu);

JPanel mainPanel = new JPanel();
mainPanel.setLayout (mainLayout);
mainPanel.setBackground(Color.gray);
mainPanel.add(iceCreamOrder);
mainPanel.add(flavors, BorderLayout.CENTER);

window.add(mainPanel, BorderLayout.CENTER);











share|improve this question






















  • How to Use Combo Boxes, Performing Custom Painting; Painting in AWT and Swing

    – MadProgrammer
    Mar 25 at 23:20











  • @MadProgrammer thank you so much for pointing me toward combo boxes, that was the thing I needed to stumble upon and just wasn't getting to on my own!

    – Patrick Alan Sean Fadden
    Mar 30 at 12:45

















1















I don't expect anyone to do the work for me, but I'm having trouble finding the exact answers to my questions researching on my own. I'm trying to have a text field where the user must input an integer between 1 and 3 and then a drop down menu to pick a flavor (would like the drop down selection to either work as the way to submit or just get the menu itself to stay selected). After submission I want a window to pop up with a painted ice cream cone that changes color based on the flavor and the number of scoops to also be accurate to the user's input.



I have been trying to work with JOptionPanel as I thought maybe that in combination with some sort of ActionListener set up would do the trick for me, but I can't seem to find the how-to or advice I need to get the job done that way.



public void createGUI()

setDefaultCloseOperation(EXIT_ON_CLOSE);

Container window = getContentPane();
window.setLayout(new BorderLayout());

GridLayout mainLayout = new GridLayout(2,1);
GridLayout topLayout = new GridLayout(1,2);
GridLayout menuLayout = new GridLayout(6,2);

JLabel storeFront = new JLabel("Ice Cream Shop");
JLabel orderHere = new JLabel("Order Here");

ImageIcon storeImage = new ImageIcon("storefront.jpeg");
JLabel store = new JLabel(storeImage);

ImageIcon flavorsImage = new ImageIcon("flavors.jpeg");
JLabel flavors = new JLabel(flavorsImage);

JTextField numberScoops = new JTextField(5);


JMenuBar flavorMenu = new JMenuBar();
JMenu flavorIceCream = new JMenu();

JMenuItem chocolate = new JMenuItem("Chocolate");
JMenuItem vanilla = new JMenuItem("Vanilla");
JMenuItem strawberry = new JMenuItem("Strawberry");
flavorIceCream.add(chocolate);
flavorIceCream.add(vanilla);
flavorIceCream.add(strawberry);

flavorMenu.add(flavorIceCream);

JPanel iceCreamShop = new JPanel();
iceCreamShop.setBackground(Color.gray);
iceCreamShop.add(store, BorderLayout.CENTER);

JPanel iceCreamMenu = new JPanel();
iceCreamMenu.setBackground(Color.gray);
JPanel menuPanel = new JPanel();
menuPanel.setBackground(Color.gray);
menuPanel.setLayout(menuLayout);

menuPanel.add(new JLabel("Chocolate"));
menuPanel.add(new JLabel("$2.00/scoop"));
menuPanel.add(new JLabel("Vanilla"));
menuPanel.add(new JLabel("$2.00/scoop"));
menuPanel.add(new JLabel("Strawberry"));
menuPanel.add(new JLabel("$2.25/scoop"));
menuPanel.add(new JLabel("How Many Scoops?"));
menuPanel.add(numberScoops);
menuPanel.add(new JLabel("what flavor?"));
menuPanel.add(flavorMenu);
menuPanel.add(new JButton("clear"));
menuPanel.add(new JButton("submit"));
iceCreamMenu.add(menuPanel);

JPanel iceCreamOrder = new JPanel();
iceCreamOrder.setLayout(topLayout);
iceCreamOrder.add(iceCreamShop);
iceCreamOrder.add(iceCreamMenu);

JPanel mainPanel = new JPanel();
mainPanel.setLayout (mainLayout);
mainPanel.setBackground(Color.gray);
mainPanel.add(iceCreamOrder);
mainPanel.add(flavors, BorderLayout.CENTER);

window.add(mainPanel, BorderLayout.CENTER);











share|improve this question






















  • How to Use Combo Boxes, Performing Custom Painting; Painting in AWT and Swing

    – MadProgrammer
    Mar 25 at 23:20











  • @MadProgrammer thank you so much for pointing me toward combo boxes, that was the thing I needed to stumble upon and just wasn't getting to on my own!

    – Patrick Alan Sean Fadden
    Mar 30 at 12:45













1












1








1








I don't expect anyone to do the work for me, but I'm having trouble finding the exact answers to my questions researching on my own. I'm trying to have a text field where the user must input an integer between 1 and 3 and then a drop down menu to pick a flavor (would like the drop down selection to either work as the way to submit or just get the menu itself to stay selected). After submission I want a window to pop up with a painted ice cream cone that changes color based on the flavor and the number of scoops to also be accurate to the user's input.



I have been trying to work with JOptionPanel as I thought maybe that in combination with some sort of ActionListener set up would do the trick for me, but I can't seem to find the how-to or advice I need to get the job done that way.



public void createGUI()

setDefaultCloseOperation(EXIT_ON_CLOSE);

Container window = getContentPane();
window.setLayout(new BorderLayout());

GridLayout mainLayout = new GridLayout(2,1);
GridLayout topLayout = new GridLayout(1,2);
GridLayout menuLayout = new GridLayout(6,2);

JLabel storeFront = new JLabel("Ice Cream Shop");
JLabel orderHere = new JLabel("Order Here");

ImageIcon storeImage = new ImageIcon("storefront.jpeg");
JLabel store = new JLabel(storeImage);

ImageIcon flavorsImage = new ImageIcon("flavors.jpeg");
JLabel flavors = new JLabel(flavorsImage);

JTextField numberScoops = new JTextField(5);


JMenuBar flavorMenu = new JMenuBar();
JMenu flavorIceCream = new JMenu();

JMenuItem chocolate = new JMenuItem("Chocolate");
JMenuItem vanilla = new JMenuItem("Vanilla");
JMenuItem strawberry = new JMenuItem("Strawberry");
flavorIceCream.add(chocolate);
flavorIceCream.add(vanilla);
flavorIceCream.add(strawberry);

flavorMenu.add(flavorIceCream);

JPanel iceCreamShop = new JPanel();
iceCreamShop.setBackground(Color.gray);
iceCreamShop.add(store, BorderLayout.CENTER);

JPanel iceCreamMenu = new JPanel();
iceCreamMenu.setBackground(Color.gray);
JPanel menuPanel = new JPanel();
menuPanel.setBackground(Color.gray);
menuPanel.setLayout(menuLayout);

menuPanel.add(new JLabel("Chocolate"));
menuPanel.add(new JLabel("$2.00/scoop"));
menuPanel.add(new JLabel("Vanilla"));
menuPanel.add(new JLabel("$2.00/scoop"));
menuPanel.add(new JLabel("Strawberry"));
menuPanel.add(new JLabel("$2.25/scoop"));
menuPanel.add(new JLabel("How Many Scoops?"));
menuPanel.add(numberScoops);
menuPanel.add(new JLabel("what flavor?"));
menuPanel.add(flavorMenu);
menuPanel.add(new JButton("clear"));
menuPanel.add(new JButton("submit"));
iceCreamMenu.add(menuPanel);

JPanel iceCreamOrder = new JPanel();
iceCreamOrder.setLayout(topLayout);
iceCreamOrder.add(iceCreamShop);
iceCreamOrder.add(iceCreamMenu);

JPanel mainPanel = new JPanel();
mainPanel.setLayout (mainLayout);
mainPanel.setBackground(Color.gray);
mainPanel.add(iceCreamOrder);
mainPanel.add(flavors, BorderLayout.CENTER);

window.add(mainPanel, BorderLayout.CENTER);











share|improve this question














I don't expect anyone to do the work for me, but I'm having trouble finding the exact answers to my questions researching on my own. I'm trying to have a text field where the user must input an integer between 1 and 3 and then a drop down menu to pick a flavor (would like the drop down selection to either work as the way to submit or just get the menu itself to stay selected). After submission I want a window to pop up with a painted ice cream cone that changes color based on the flavor and the number of scoops to also be accurate to the user's input.



I have been trying to work with JOptionPanel as I thought maybe that in combination with some sort of ActionListener set up would do the trick for me, but I can't seem to find the how-to or advice I need to get the job done that way.



public void createGUI()

setDefaultCloseOperation(EXIT_ON_CLOSE);

Container window = getContentPane();
window.setLayout(new BorderLayout());

GridLayout mainLayout = new GridLayout(2,1);
GridLayout topLayout = new GridLayout(1,2);
GridLayout menuLayout = new GridLayout(6,2);

JLabel storeFront = new JLabel("Ice Cream Shop");
JLabel orderHere = new JLabel("Order Here");

ImageIcon storeImage = new ImageIcon("storefront.jpeg");
JLabel store = new JLabel(storeImage);

ImageIcon flavorsImage = new ImageIcon("flavors.jpeg");
JLabel flavors = new JLabel(flavorsImage);

JTextField numberScoops = new JTextField(5);


JMenuBar flavorMenu = new JMenuBar();
JMenu flavorIceCream = new JMenu();

JMenuItem chocolate = new JMenuItem("Chocolate");
JMenuItem vanilla = new JMenuItem("Vanilla");
JMenuItem strawberry = new JMenuItem("Strawberry");
flavorIceCream.add(chocolate);
flavorIceCream.add(vanilla);
flavorIceCream.add(strawberry);

flavorMenu.add(flavorIceCream);

JPanel iceCreamShop = new JPanel();
iceCreamShop.setBackground(Color.gray);
iceCreamShop.add(store, BorderLayout.CENTER);

JPanel iceCreamMenu = new JPanel();
iceCreamMenu.setBackground(Color.gray);
JPanel menuPanel = new JPanel();
menuPanel.setBackground(Color.gray);
menuPanel.setLayout(menuLayout);

menuPanel.add(new JLabel("Chocolate"));
menuPanel.add(new JLabel("$2.00/scoop"));
menuPanel.add(new JLabel("Vanilla"));
menuPanel.add(new JLabel("$2.00/scoop"));
menuPanel.add(new JLabel("Strawberry"));
menuPanel.add(new JLabel("$2.25/scoop"));
menuPanel.add(new JLabel("How Many Scoops?"));
menuPanel.add(numberScoops);
menuPanel.add(new JLabel("what flavor?"));
menuPanel.add(flavorMenu);
menuPanel.add(new JButton("clear"));
menuPanel.add(new JButton("submit"));
iceCreamMenu.add(menuPanel);

JPanel iceCreamOrder = new JPanel();
iceCreamOrder.setLayout(topLayout);
iceCreamOrder.add(iceCreamShop);
iceCreamOrder.add(iceCreamMenu);

JPanel mainPanel = new JPanel();
mainPanel.setLayout (mainLayout);
mainPanel.setBackground(Color.gray);
mainPanel.add(iceCreamOrder);
mainPanel.add(flavors, BorderLayout.CENTER);

window.add(mainPanel, BorderLayout.CENTER);








java swing drop-down-menu textinput






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 25 at 23:09









Patrick Alan Sean FaddenPatrick Alan Sean Fadden

43 bronze badges




43 bronze badges












  • How to Use Combo Boxes, Performing Custom Painting; Painting in AWT and Swing

    – MadProgrammer
    Mar 25 at 23:20











  • @MadProgrammer thank you so much for pointing me toward combo boxes, that was the thing I needed to stumble upon and just wasn't getting to on my own!

    – Patrick Alan Sean Fadden
    Mar 30 at 12:45

















  • How to Use Combo Boxes, Performing Custom Painting; Painting in AWT and Swing

    – MadProgrammer
    Mar 25 at 23:20











  • @MadProgrammer thank you so much for pointing me toward combo boxes, that was the thing I needed to stumble upon and just wasn't getting to on my own!

    – Patrick Alan Sean Fadden
    Mar 30 at 12:45
















How to Use Combo Boxes, Performing Custom Painting; Painting in AWT and Swing

– MadProgrammer
Mar 25 at 23:20





How to Use Combo Boxes, Performing Custom Painting; Painting in AWT and Swing

– MadProgrammer
Mar 25 at 23:20













@MadProgrammer thank you so much for pointing me toward combo boxes, that was the thing I needed to stumble upon and just wasn't getting to on my own!

– Patrick Alan Sean Fadden
Mar 30 at 12:45





@MadProgrammer thank you so much for pointing me toward combo boxes, that was the thing I needed to stumble upon and just wasn't getting to on my own!

– Patrick Alan Sean Fadden
Mar 30 at 12:45












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347676%2fhow-can-i-get-this-textfield-and-dropdown-menu-working-to-do-what-i-want%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid …


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347676%2fhow-can-i-get-this-textfield-and-dropdown-menu-working-to-do-what-i-want%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?