#Jframes
Explore tagged Tumblr posts
sunnystared · 1 month ago
Text
Hi!!!
it’s been a while, I wanted to hop on with some updates! So I’ve only been able to work of the project for one hour each week and most of that time has been research on trying to learn JFrame. Two weeks ago I was recommended to consider javaFX and I am under the impression that this is a better option for me but I literally know nothing about it so it’s going mean no progress for quite a while. Currently my coding club at school is the only time I can really work on it due to the crappy pc I have at home. So I’m also limited by that sadly. I believe that’s all I have to say and I really appreciate everyone who engages with my silly project.
0 notes
jojotier · 1 year ago
Text
WE HAVE MOVEMENT. THE BLOCK IS LIVE
1 note · View note
16naughts · 3 months ago
Text
Dev Log Feb 7 2025 - The Stack
Ahoy. This is JFrame of 16Naughts in the first of what I hope will turn out to be a weekly series of developer logs surrounding some of our activities here in the office. Not quite so focused on individual games most of the time, but more on some of the more interesting parts of development as a whole. Or really, just an excuse for me to geek out a little into the void. With introductions out of the way, the first public version of our game Crescent Roll (https://store.steampowered.com/app/3325680/Crescent_Roll juuuust as a quick plug) is due out here at the end of the month, and has a very interesting/unorthodox tech stack that might be of interest to certain devs wanting to cut down on their application install size. The game itself is actually written in Javascript - you know, the scripting language used by your web browser for the interactive stuff everywhere, including here. If you've been on Newgrounds or any other site, they might call games that use it "HTML5" games like they used to call "Flash" games (RIP in peace). Unfortunately, Javascript still has a bit of a sour reputation in most developer circles, and "web game" doesn't really instill much confidence in the gamer either. However, it's turning more and more into the de-facto standard for like, everything. And I do mean everything. 99% of applications on your phone are just websites wrapped in the system view (including, if you're currently using it, the Tumblr app), and it's bleeding more and more into the desktop and other device spaces. Both Android and iOS have calls available to utilize their native web browsers in applications. Windows and Mac support the same thing with WebView2 and WebKit respectively. Heck, even Xbox and Nintendo have a web framework available too (even goes back as far as Flash support for the Wii). So, if you're not using an existing game engine like we aren't and you want to go multi-platform, your choices are either A) Do it in something C/C++ -ish, or now B) Write it in JS. So great - JS runs everywhere. Except, it's not exactly a first-class citizen in any of these scenarios. Every platform has a different SDK for a different low-level language, and none of them have a one-click "bundle this website into an exe" option. So there is some additional work that needs to be done to get it into that nice little executable package.
Enter C#. Everyone calls it Microsoft Java, but their support for it has been absolutely spectacular that it has surpassed Java in pretty much every single possible way. And that includes the number and types of machines that it runs on. The DotNet Core initiative has Mac, Windows, and Linux covered (plus Xbox), Xamarin has Android, and the new stuff for Maui brought iOS into the fold. Write once, run everywhere. Very nice. Except those itty bitty little application lifetime quirks completely change how you do the initialization on each platform, and the system calls are different for getting the different web views set up, and Microsoft is pushing Maui so hard that actually finding the calls and libraries to do the stuff instead of using their own (very strange) UI toolkit is a jungle, but I mean, I only had to write our stream decompression stuff once and everything works with the same compilation options. So yeah - good enough. And fortunately, only getting better. Just recently, they added Web Views directly into Maui itself so we can now skip a lot of the bootstrapping we had to do (I'm not re-writing it until we have to, but you know- it's there for everyone else). So, there you have it. Crescent Roll is a Javascript HTML5 Web Game that uses the platform native Web View through C#. It's a super tiny 50-100MB (depending on the platform) from not having to bundle the JS engine with it, compiles in seconds, and is fast and lean when running and only getting faster and leaner as it benefits from any performance improvements made anywhere in any of those pipeline. And that's it for today's log. Once this thing is actually, you know, released, I can hopefully start doing some more recent forward-looking progress things rather than a kind of vague abstract retrospective ramblings. Maybe some shader stuff next week, who knows.
Lemme know if you have any questions on anything. I know it's kind of dry, but I can grab some links for stuff to get started with, or point to some additional reading if you want it.
3 notes · View notes
nel-world · 7 days ago
Text
j
Swing is not thread-safe. Updating UI components from background threads (not the Event Dispatch Thread) causes race conditions, freezes, or crashes.
Use SwingUtilities.invokeLater() or SwingWorker to handle background tasks safely.
Component Overlap or Z-order Issues Components might overlap or not render correctly if layout and repainting aren’t managed properly.
revalidate() and repaint() are often needed after dynamic UI changes.
Scaling and DPI Conflicts On high-DPI displays, Swing apps can look blurry or improperly scaled if not configured.
Java 9+ supports HiDPI better, but older setups require workarounds.
Architecture Conflicts Mixing UI logic with business logic leads to spaghetti code and maintenance problems.
Not following patterns like MVC or separating concerns can make the design fragile.
Event Handling Conflicts Multiple listeners acting on the same component or event can cause logic errors.
Improper handling of key bindings or focus can result in unresponsive controls. // Updating a JTable in Java Swing can be done in a few different ways Using a DefaultTableModel (most common way)
Access the model:DefaultTableModel model = (DefaultTableModel) table.getModel(); Refreshing the UI If you're updating the model directly, the JTable usually updates automatically. But if needed:
java model.fireTableDataChanged();
// If you update the JTable (or any Swing component) from a non-EDT thread, you risk:
UI glitches
Random exceptions
Unpredictable behavior
The Fix: Use SwingUtilities.invokeLater() // Always wrap the JTable in a JScrollPane to handle large datasets.
Use BorderLayout.CENTER to make it fill the frame.
This design makes JTable the main UI element—perfect for apps like:
Inventory systems
Admin dashboards
// Custom Cell Rendering (How Data is Displayed) To change how a cell looks, implement a custom TableCellRenderer.
// Make Only Certain Columns Editable Override isCellEditable() in your model:
java Copy Edit DefaultTableModel model = new DefaultTableModel(data, columnNames) { @Override public boolean isCellEditable(int row, int column) {
//
Custom Cell Editors (How Data is Edited) To control how a user edits a cell, use a TableCellEditor.
Example: Use a combo box editor for a column java
String[] roles = {"Developer", "Designer", "Manager"}; JComboBox comboBox = new JComboBox<>(roles);
table.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor // Format Displayed Values You can convert raw data (like timestamps, enums, booleans) into human-readable text using renderers or by overriding getValueAt() in a custom TableModel.
//
GridLayout Divides space into equal-sized rows and columns.
java
BoxLayout Aligns components vertically or horizontally.
GridBagLayout Most flexible, but also the most complex.
Allows fine-grained control over row/column span, alignment, padding. //
Optimized event-driven programming for efficient user interactions and system performance.
Implemented MVC architecture to ensure scalability and maintainability of Java Swing applications.
Enhanced multithreading in Swing applications to improve responsiveness using SwingWorker.
Debugged and resolved UI rendering issues, ensuring cross-platform compatibility.
Worked with Look and Feel (LAF) customization for a modern and branded UI experience.
//
ava Swing Application Works JFrame (Main Window) – The base container that holds all UI components.
JPanel (Layout Container) – Used to organize components inside the frame.
Swing Components – Buttons (JButton), labels (JLabel), text fields (JTextField), tables (JTable), etc.
Event Handling – Listeners (like ActionListener) handle user interactions.
Threading (SwingWorker) – Ensures UI remains responsive during background tasks.
Example Use Cases Point of Sale (POS) Systems – Cashier interfaces for processing transactions.
Inventory Management – Applications for tracking stock levels.
Data Entry Forms – GUI forms for database input and management.
Media Players – Applications for playing audio/video with Swing UI.\
JFrame Main application window JPanel Container for organizing UI elements JButton Clickable button JLabel Display text or images JTextField Single-line input field JTextArea Multi-line text input JTable Displays tabular data JMenuBar Menu bar with dropdown menus JList List of selectable items
.. //
Use of Modern Look and Feel (LAF) FlatLaf – A modern, flat UI theme for Swing that provides a better-looking UI.
Improved Concurrency with CompletableFuture Handles long-running tasks without freezing the UI.
Example:
java
CompletableFuture.supplyAsync(() -> fetchData()) .thenAccept(data -> SwingUtilities.invokeLater(() -> label.setText(data)));
// Use a Layout Manager Java Swing provides various layout managers like:
BorderLayout – Divides the window into 5 regions (North, South, East, West, Center).
GridBagLayout – Flexible and customizable grid-based layout.
BoxLayout – Arranges components in a single row or column.
GroupLayout – Best for complex resizable designs (used in NetBeans GUI Builder).
Use JScrollPane to make JTable scrollable ✔ Use DefaultTableModel for editing rows ✔ Add event listeners to detect row selection ✔ Integrate with a database using JDBC
Performance Issues in JTable & How to Optimize When dealing with large datasets in JTable, performance can degrade due to factors like slow rendering, inefficient data models, excessive event handling, Large Dataset Causes UI Lag Issue: If the table has thousands of rows, JTable may slow down because it loads all rows at once.
Solution: Use pagination or lazy loading instead of loading everything upfront.
✅ Example: Paginated JTable (Loading 100 Rows at a Time)
java Copy Edit int pageSize = 100; // Load 100 rows at a time int currentPage = 0; List data = fetchDataFromDatabase(currentPage * pageSize, pageSize); // Load only a subset
DefaultTableModel model = (DefaultTableModel) table.getModel(); for (Object[] row : data) {
//
Slow Rendering Due to Default Renderer Issue: The default cell renderer calls Component.setOpaque(false), causing unnecessary painting.
Solution: Use a custom renderer with setOpaque(true).
✅ Example: Custom Fast Renderer
java Copy Edit class FastRenderer extends DefaultTableCellRenderer { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); label.setOpaque(true); // Prevents repainting issues
;;
Frequent Repainting & Event Listeners Cause Overhead Issue: JTable repaints everything after every update, even when unnecessary.
Solution: Temporarily disable auto updates, batch updates, then re-enable.
✅ Example: Batch Update with Table Locking
java Copy Edit DefaultTableModel model = (DefaultTableModel) table.getModel(); model.setRowCount(0); // Clear table without repainting table.setAutoCreateColumnsFromModel(false); // Avoid unnecessary updates
// Batch insert rows for (int i = 0; i < 1000; i++) { model.addRow(new Object[]{"ID " + i, "Name " + i, i + 20}); }
table.setAutoCreateColumnsFromModel(true); //
Using DefaultTableModel for Large Data Handling Issue: DefaultTableModel is inefficient for large datasets because it stores all data in memory.
Solution: Use a custom TableModel that fetches data dynamically.
✅ Example: Custom Lazy Loading Table Model
java Copy Edit class CustomTableModel extends AbstractTableModel { private final int rowCount = 1000000; // Simulating large dataset@Override public int getRowCount() { return rowCount;
Slow Sorting & Filtering Issue: Default sorting can be slow for large datasets.
Solution: Use RowSorter with custom sorting instead of sorting all rows at once.
✅ Example: Optimized Sorting
java Copy Edit TableRowSorter sorter = new TableRowSorter<>(table.getModel()); table.setRowSorter(sorter);
Use pagination or lazy loading for large datasets. ✅ Optimize cell rendering with setOpaque(true). ✅ Batch updates & disable auto updates temporarily. ✅ Use a custom TableModel instead of DefaultTableModel. ✅ Implement RowSorter for efficient sorting.
0 notes
mintie-chip · 16 days ago
Text
my lungs r on fire & i am full of ire
today there is much to do, such as arrange ten functions into a menu using jframes on netbeans,,, i feel like eclipse or intellij would be better but i have very little time to explore because of how much i have to do. also being ill these past few days has been less than ideal.
i have very limited spoons and breathing is very hard. fuck my yaoi life. i'll be working on C problems because i need to understand data structures better, but my minors are also creeping up on meeeee
will reblog w a progress update by EOD.
0 notes
bleghablah · 9 months ago
Text
I know Oracle claims that a gazillion devices run Java, but truly I think it missed its golden age.
for decades everyone lamented how inefficient the JVM was, and then as soon as computers were powerful enough and embraced the benefits of sandboxing, suddenly Java was kind of antiquated and cringey.
I'll always love you Java, you and your JFrames will live in my heart for ever... but God forbid I ever use you for an enterprise application and get fucked by Oracle every six months.
0 notes
3riverblades · 1 year ago
Text
0 notes
codetru · 3 years ago
Photo
Tumblr media
All GUIs in Java are built using Frames or JFrames. While Frames are a part of the Java AWT toolkit, JFrames are Java Swing containers.
To understand the difference between Frames and JFrames, and to see if they are still relevant today, check out our blog here https://codetru.com/Java.
Contact our CodeTru marketing team for Java-based projects. Ping us for more information and price quotes.
1 note · View note
worleyguy · 3 years ago
Photo
Tumblr media
Wheelgunning Wednesday 👍 ///////////////////////////////////////////////////////////////// LINKS in Bio PLEASE LIKE, COMMENT, & FOLLOW 🙏 #triggertherapy #2a #secondamendment #freedom #everydaycarry #edc #pewpew #airsoft #gunsofinstagram #2022 #model36 #jframe #38special #revolver #wheelgun #blued #vzgrips #g10 #steel (at Indiana) https://www.instagram.com/p/CcTB-YlLdUN/?igshid=NGJjMDIxMWI=
9 notes · View notes
shootersfaync · 5 years ago
Photo
Tumblr media
Looking for a pocket blaster? #shootersfaync #braggblvd #sigsauer #smithandwesson #p365 #p365xl #38special #jframe #fay #fayettenam #fayettevillenc #edc #pocketblaster #ftbragg #fortbragg #2a #2a #shinny (at Bragg Blvd) https://www.instagram.com/p/CC3yKEapCc2/?igshid=1uv8lh4dl55gs
7 notes · View notes
jojotier · 1 year ago
Text
update: i can now code a single orange block in a black void in jframe!
17 notes · View notes
kaya-butsu · 6 years ago
Text
So I was programming and didn’t realize I misspelled gigabytes as
Tumblr media
I forgot to type b
7 notes · View notes
nel-world · 7 days ago
Text
hi
Scrollbar ScrollPane Type Component (a widget) Container (a container that can hold components)Scrollbar: Just the scroll bar, standalone.
ScrollPane: A container that can show scrollbars when needed for its content.
Java Swing, a Container is a component that can hold and organize other components (like buttons, text fields, etc.). It is part of the AWT hierarchy but is also used in Swing through classes like JPanel, JFrame, and JDialog, which are all containers.
Here's a simple Swing layout design using a JFrame with a combination of BorderLayout and FlowLayout. It includes a header, footer, center area, and side panel.
FlowLayout Default for: JPanel
Arranges: Left to right, wraps to next line.
BorderLayout Default for: JFrame
Divides into 5 regions: North, South, East, West, Center
GridLayout Arranges: Components in a rectangular grid.
All cells are equal in size.
BoxLayout Arranges: Components either vertically (Y_AXIS) or horizontally (X_AXIS).
Usage:
GridBagLayout Most flexible, but complex.
Allows components to span multiple rows/columns and align precisely.
FlowLayout Simple row layout Low Low BorderLayout App-like UI with sections Medium Low GridLayout Equal-sized grid Medium Low BoxLayout List-like vertical/horizontal stack Medium Medium GridBagLayout Complex form-like layout High High CardLayout Switching panels (tabs/wizards)
Using layout managers provides flexibility, portability, and maintainability when building GUIs. Here's a breakdown of their key advantages:
Platform Independence Layout managers adapt to different screen sizes and resolutions automatically.
You don't need to manually set pixel positions for components.
Without Layout Manager (using null layout): You're responsible for absolute positioning and sizing (setBounds()).
Not responsive or portable.
Breaks with different screen DPI or user settings.
Scrollbar vs ScrollPane Scrollbar:
A standalone component (widget).
Just the scroll bar itself; does not contain other components.
ScrollPane:
A container that can hold another component and adds scrollbars as needed.
Manages content overflow automatically.
Container in Java Swing A Container can hold and organize other components like buttons, text fields, panels, etc.
Examples of Containers in Swing:
JPanel
JFrame
JDialog
Containers come from the AWT hierarchy, but are heavily used in Swing as well.
Why Use Layout Managers? Platform Independence:
Layout managers automatically adjust to different screen sizes and resolutions.
Avoids Manual Positioning:
No need to manually set x, y, width, height via setBounds().
Responsiveness:
UIs adapt to font changes, screen DPI settings, window resizing, etc.
Maintainability:
Easier to modify layouts without breaking the UI across different devices.
Drawback of NOT Using Layout Managers Using null layout (no layout manager):
You must manually set component positions and sizes.
Non-responsive: Breaks on different screen sizes and settings.
Not portable: UI may look fine on one machine, but terrible on another.
FlowLayout
Arranges: Left to right, wraps to next line.
Notes: Default for JPanel.
BorderLayout
Arranges: Divides into 5 regions — North, South, East, West, Center.
Notes: Default for JFrame.
GridLayout
Arranges: Components in a rectangular grid with equal-sized cells.
Notes: Simple and uniform layout.
BoxLayout
Arranges: Components stacked vertically (Y_AXIS) or horizontally (X_AXIS).
Notes: Good for list-like or linear layouts.
GridBagLayout
Arranges: Highly flexible, components can span multiple rows/columns.
Notes: Complex but powerful for fine-tuned layouts.
CardLayout
Arranges: Allows switching between multiple panels (like cards).
Notes: Useful for building tabbed panels, step-by-step wizards.
Quick Comparison of Layout Managers FlowLayout
Use Case: Simple row layout.
Flexibility: Low.
Complexity: Low.
BorderLayout
Use Case: Application-like UI with structured sections.
Flexibility: Medium.
Complexity: Low.
GridLayout
Use Case: Uniform grid with equal-sized components.
Flexibility: Medium.
Complexity: Low.
BoxLayout
Use Case: Vertical or horizontal stacking of components.
Flexibility: Medium.
Complexity: Medium.
GridBagLayout
Use Case: Complex, form-like layouts with precise control.
Flexibility: High.
Complexity: High.
CardLayout
Use Case: Switching between multiple panels (like tabs).
Flexibility: Medium.
Complexity: Medium.
Event Dispatch Thread (EDT) in Java Swing is the special thread responsible for handling all GUI events — like button clicks, screen repaints, key presses, and mouse movements. Swing is not thread-safe — meaning you should only update the UI from one thread, and that thread is the EDT.
Key Rules: Create and update GUI components on the EDT.
Never do long-running tasks (like file or network access) on the EDT — it freezes the UI.
Creating GUI on EDT (best practice): java Copy Edit SwingUtilities.invokeLater(() -> { // Safe to create GUI components here JFrame frame = new JFrame("EDT Example"); frame.setSize(300, 200); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); });
EDT handles all UI updates and events.
Always use invokeLater() or SwingWorker to interact with the UI safely.
Never block the EDT — it makes your GUI unresponsive.
Using SwingWorker The built-in SwingWorker handles threading and result-passing for you.
// 1) Define a SwingWorker that returns your data type SwingWorker, Void> worker = new SwingWorker<>() { @Override protected List doInBackground() throws Exception {
Using ExecutorService + invokeLater If you need a pool of threads or more control:
ExecutorService dbPool = Executors.newFixedThreadPool(2);
Use background threads (SwingWorker, ExecutorService, CompletableFuture).
Update Swing components only on the EDT (invokeLater(), done(), or thenAcceptAsync).
Java Swing, a component's preferred size determines how much space it wants to occupy, and layout managers usually respect this when arranging components.
MVC (Model-View-Controller) – Primary Swing Pattern Swing uses a lightweight version of MVC.
Model – Holds data (e.g., TableModel, ListModel)
View – The UI component (e.g., JTable, JList)
Controller – Often combined into the View via event listeners
Observer Pattern Used in event handling — listeners observe changes and respond.
Example: ActionListener, ChangeListener, PropertyChangeListener
Composite Pattern UI components and containers follow this pattern.
JPanel can contain JButton, JLabel, etc., and be treated as a single component.
Singleton Pattern Often used for a central app window or config manager.
develop a JTable in Java Swing, you can either use:
Simple data + column arrays (quick setup), or
Custom TableModel (for more control, e.g., editable cells, dynamic data).
JTable with DefaultTableModel (editable & dynamic)
. Custom TableModel (for full control) If you want non-editable columns or custom data source (like a database), extend AbstractTableModel. Use a Custom TableModel (AbstractTableModel) This gives you full control over:
Data source (could be a list, database, etc.)
Column behavior (e.g., types, editable columns) if your table data changes frequently (like from a database, real-time updates, or user interaction), you should use a custom AbstractTableModel with a List-based backend. This approach gives you:
Clean separation of data and UI
Easy updates (add, remove, modify rows)
Fine control over column behavior (e.g., editable or read-only)
create a JTable with dynamic columns at runtime — meaning the columns can change while the application is running (e.g., based on user action or data changes).
Custom TableModel for Dynamic Columns
You can call setColumns(…) at any time to dynamically change column headers and structure.
Rows can be added using addRow(…) with values matching the new column layout.
The table refreshes itself with fireTableStructureChanged().
Cell Click / Selection Event Use a ListSelectionListener to detect row selection:
To handle mouse clicks in a JTable, such as detecting double-clicks, right-clicks, or clicks on specific cells, use a MouseListener or MouseAdapter.
display different cells in different colors based on data, you can override the prepareRenderer() method in JTable. This lets you customize cell background and foreground colors dynamically depending on the cell's content or row/column inde
What You Can Customize: c.setBackground(Color.X) – change background
c.setForeground(Color.Y) – change text color
You can also change font, borders, tooltips, etc.
Steps to Update Cell Background Based on Data and Repaint Assuming you're customizing cell colors with prepareRenderer():
Change the underlying data in your TableModel
model.setValueAt("Failed", rowIndex, colIndex);
Then trigger a repaint of the table
table.repaint();
Ensure the TableModel supports editing If you're using DefaultTableModel, editing is enabled by default.
If you're using a custom AbstractTableModel, override: Implement setValueAt() in Custom TableModel If you're using a custom model, this method must actually update the data:
sort data in a JTable, you can use the built-in TableRowSorter, which works with any TableModel (like DefaultTableModel or AbstractTableModel).
Features of TableRowSorter Click on a column header to sort ascending/descending
Can sort numerically or alphabetically
You can programmatically control sorting:
Sorting for Custom TableModel Works the same way as long as your getValueAt() returns proper data types (Integer, String, etc.) — not Strings for everything.
To implement flushing (auto-refresh) every 3 seconds in a JTable, you can use a javax.swing.Timer. This is Swing-safe and fires events on the Event Dispatch Thread (EDT).
Flush from a database query
Flush based on web API call
Conditional flushing (if flag is dirty)
0 notes
iamdotzero · 6 years ago
Link
[Niveau Débutant][Pour les étudiants (ou personnes) qui prennent leurs premiers pas en Java]. La première chose que nous constatons après...
1 note · View note
maurijhn · 8 years ago
Photo
Tumblr media
I have finally made the matrix windows display on the screen properly. It wasn't as easy as I thought it would be to create the code for it, but when I finished I found out it was a pretty simple idea
2 notes · View notes
rutseneagle · 4 years ago
Photo
Tumblr media
Just another Magnum Monday… @smithandwessoninc #jframe ___________________________ @crimsontrace @recom_actual ___________________________ #triggerheads #2a #lifestyle #gear #photographer #rutseneagle #recomactual #gunlifemedia #smithandwesson #crimsontrace #357magnumrevolver #wheelgun (at Magnum Mondays) https://www.instagram.com/p/CSErLHkrZnw/?utm_medium=tumblr
0 notes