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 8 years ago.
Improve this question
Looking to customise my JTabbedPane to look something like the below:
As you can see it's quite a simple design so shouldn't be too difficult to achieve? I've read a bit on changing Look and Feel but got a bit lost with the wealth of information and options there. Anyone any useful pointers for me?
Changing the look and feel of your complete application is one of the easiest ways to do it. Here is the list (with screen shots, how to use and download links) of different looks and feels for java swing. Use one of them to get some great looks and feels for your swing application.
P.S. Simply put the code into your main method.
As you can see it's quite a simple design so shouldn't be too difficult to achieve?
Creating a custom UI is always a problem. You need to implement the change for all LAF's you intend to support.
You would start by looking at BassicTabbedPaneUI. There you will find the various paintTab...(...) methods. Then you need to look at your LAF, for example the MetalTabbedPaneUI to see if the LAF uses the default implementation or does a custom implementation. Once you know this you override the appropriate class and implement your custom painting code.
Then in your code you have something like:
JTabbedPane tabbedPane = new JTabbedPane(...);
tabbedPane.setUI( new MyCustomTabbedPaneUI() );
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 11 months ago.
Improve this question
I'm trying to create a feature flag in my react project (I believe I have to add a feature flag in the appsettings.json file), the flag is to hide the features that are currently being developed as we don't want users to have those features when those are yet to be tested fully. So the current approach I have is to wrap the newly developed code with a condition like if(flag){new code} I'm sorry if the approach looks silly but that's all I can come up with as a rookie, so can you guys help with some feasible approach if possible?
So I've tried adding the if condition to an existing feature in the code base as the newly developed code is yet to be committed but it didn't work.
Based on your comment from three hours ago I was able to figure out what exactly you wanted to do.
So: already having the flag all there is to do is to use it. There are at least three ways you can do it:
make it hidden - i think MDN docs explain it well enough
make it transparent - this is what you did: setting opacity to 0
not render it at all
not rendering is achieved like this:
return (
<SomeParentComponent>
{EnableDivision &&
<Division/>
}
</SomeParentComponent>
)
It's not like one of them is better than others: they are all situational.
hidden element is rendered, and therefore has state and can be found in the DOM tree, but doesn't take any space
transparent is like hidden, but takes up space
not rendered on the other hand can't be found in the DOM tree, doesn't take any space, the funcion or class creating it is never run and therefore it also can't have any state
Hopefully this should dispel your doubts about how to do it.
Also if you ever needed use some flags in many different components in various places of your component tree take look at what React Context does.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I’m learning Java and have recently started my first project. The idea of this project is to pass one input argument - path to file/folder, which would be analyzed in order to find all files with predefined extension, parse them and create objects based on the results of parsing to store for future.
So far I’ve written all the code and my project structure (simplified) looks like that:
Class defining resulting object
Class that analyzes the input parameter (exists, is file, is folder) and processes it, returning list of all suitable files
Class that parses suitable files and creates objects
The question is - am I following OOP with that structure?
From what I’ve read on the web the last two classes seem to look like polterheists. But I don’t think that it is a good idea to move the logic of the third class to the object class because it consists of lots of methods (define current section of the file, strategy to parse each separate section).
I am learning on my own and don’t want to start my journey by cultivating bad habits.
I am learning on my own and don’t want to start my journey by cultivating bad habits.
You're saying this like you have a choice :)
From what you described it seems reasonable, of course w/o seeing the code we can't say. And even if you show the code - 100 people will have 100 opinions, there's a lot of debates around OOP.
What's important is not to look at your design as something static. Once your app starts to be more complicated you'll have to re-work some of it.
PS: stackoverflow doesn't like this kind of questions since everyone will have an opinion. You'll have to find other resources if you keep having such questions.
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 7 years ago.
Improve this question
Does anyone have any suggestions as to how I can go about creating an Effect for a JavaFX node that can simulate glass shattering and then (potentially) breaking? if the breaking is more difficult, I can skip that part. Basically I want to layer this pane over an image and then make it look like its a picture frame that then shatters. If it can then break into pieces (after some configurable delay).. that would be great as well!
I've looked everywhere but can't seem to find info on simulating the glass shatter effect in JavaFX.
Thanks!
For a simple solution I'd go with a Path that randomly extends and change the style of the path during time.
More sophisticated code could use a Canvas and paint the shattering on it. Daniel Shiffman with his Nature of Code book may be a base for you with the creation of the shatter effect.
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 8 years ago.
Improve this question
my main.java file has a length of about 1000 lines. My code is getting more and more confused, and I would like to "split" it in different parts (e.g. in one file I would have essential stuff like OnCreate, in another file I would have for instance GetHttpRequest).
I already tried to put GetHttpRequest in a different class, but is there no simpler way? (It would take a really long time to adjust the code if I used this method)
You have to use classes and methods, and optionally packages.
This will solve your problem. There's no simpler way than that.
Please do not hard-code your program. There are several patterns on how to code a program, so it is efficient, everybody can easily read and understand it. I think you also have a "GUI", assuming to this, I recommend you to use the MVC pattern. It means Model-View-Controller, so you organize your program in Packages: "model", "view", "controller" and in those packages you put the classes. For instance, you have a simple Calculator. Then you have a class in view thats called "CalculatorView", where your graphical interface is and in controller you have your "CalculatorController" that works out the things like calculations. (You call the controller from the view) and you do not need model at all.
I hope that helps you. But you will have to rewrite all your code...
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I know abstract classes and interfaces in java but I want to know how to bring abstraction in working software/project? how to thing in such way which brings abstraction.
Your question is vague at best, however the usage of interfaces helps abstraction because you are not working with concrete types. For instance:
IPrinter p = PrinterFactory.getPrinter(conditions);
...
p.print(content);
In the below line, you are not aware of exactly what printer you are using. Since you are just using the logic, you do not really care. All that you care about is that the factory will give you the printer you are after and that the print method will print the content to the right stream.
If you want to change the printer being used, you make the amendments in the factory class so that you get a different IPrinter implementation which does what you need (which in this case it would be to print to some other media). This would mean that you have essentially changed the outcome of a piece of code without changing much of it.