Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have a little question.
I have made a java switch in Netbeans. The switch is attached to a label in my Gui. Whenever i click the Label, i want it to be able to change the image it has.
private void LoopLblMouseReleased(java.awt.event.MouseEvent evt) {
switch(looped)
{
case 0:
looped = 1;
LoopLbl.setIcon("path to image");
break;
case 1:
looped = 0;
break;
};
This the code i have for the switch untill now, but it gives an error when i fill in the path to the image. Can someone help me with this?
but it gives an error when i fill in the path to the image.
LoopLbl.setIcon("path to image");
Did you read the API? The setIcon() takes an Icon as a parameter, not a String.
If you want to know how to use Icons, read the section from the Swing tutorial on How to Use Icons for working examples.
I suggest you keep the tutorial link handy for learning the basics of Swing.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
When i start the Jframe "VentanaPrincipal" this one looks like this:
but when I open the Jframe from another Jframe, it changes the format of the components:
My code is:
VentanaPrincipal vp = new VentanaPrincipal();
vp.setVisible(true);
Can you please help me?
The Look and Feel (LAF) is changing.
Swing components use the LAF at the time the component is created.
It would seem that one frame uses a different LAF so the second frame inherits that LAF when it is created.
Fix your code to use the same LAF.
Read the section from the Swing tutorial on Modifying the Look and Feel for more information.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am currently in Gr 12 and recently we received a assessment task. The task asks us to create GUI screens and then code everything behind it. Problem is that our teacher never explained to us how to code GUI screens and since exams are approaching, she won't really help us. I created the GUI screens in Netbeans using JFrame forms. From there on out, I am lost. I am using a text file to read from and I know how to code an array, display and basic class. I need help though because I don't even know where to start. If someone can help me, it would be greatly appreciated. Even if we need to talk about it more somewhere. Thank you
Create a new project in NetBeans
and then create JForm by
then select design from toolbar
now drag and drop elements from palette
click on button properties then choose ActionPerformed
this code will generates in source code write code there
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I want to display Vo for initial velocity, and it displays fine in MOST places, but on all of my circle buttons, it displays in all caps, so it looks like "VO" instead of "Vo".
Is there a way to fix this? Is it a weird button interaction?
Thanks!
Buttons are all-caps by default since Android 5.0. If you want to disable this, you may have to specify android:textAllCaps="false" on your Buttons.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I'm using this android studio project, but I didn't know how to change content there.For example, I want to have a text "Hello World" in the first tab, the text "Goodbye..." in the second tab and so on... Can you help me?
Did you try anything? There is a sample folder where you can find an example. In the first file I opened, which is MainActivity.java, there is a class called MyPagerAdapter, with the following line:
private final String[] TITLES = { "Categories", "Home", "Top Paid", "Top Free", "Top Grossing", "Top New Paid", "Top New Free", "Trending" };
Seems to me you can change that to
private final String[] TITLES = {"Hello world", "Goodbye..."};
If that doesn't work you do have a valid question, but in this case you should have checked the sample first. Literraly took me less than a minute to find.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am attempting to create an Android UI similar to the one shown above.
This type of layout is fairly common in websites and I want to recreate this for my Android app.
It is a list of names and when you click on a name it expands and displays some customized UI.
Can someone please guide me on how this can be achieved ?
To be specific, the expansion when clicking a name so that a new View is displayed.
Have a look at the ExpandableListItemAdapter class in the ListViewAnimations library.
You can seperately specify a header View and a content View. The content view smoothly animates in to sight when clicked.
I have done something very similar, you can use the code provided here (check src/com/udinic/expand_animation_example/ExpandAnimation.java) to achieve exactly what you are looking for.
Sample code:
final int animationTime=250;
ExpandAnimation expandAni = new ExpandAnimation(expandingView, animationTime);
expandingView.startAnimation(expandAni);
Note that the code would call requestLayout() to perform the animation which is computationally expensive. So if you are trying to apply this animation to a complex LinearLayout encapsulated in a ScrollView, the result would be choppy. In this case try to use ListView to populate the screen instead.